Thursday, June 19, 2008

KML Extension, Julian Time

Creating a virtual globe that can view KML files as well as creating numerous datasets that have to use KML has given me what I feel is a unique perspective on the strengths and weaknesses of the language. It also gives me a really unique opportunity to enact some features in the language that I feel are needed. Hopefully at some point the OGC and Google will consider some of my suggestions once they are more formalized.

I've just come up with a *really* nice extension to KML that can drastically reduce the size of some datasets (e.g.: a 1.2 MB dataset is reduced to 60K) and at the same time enable functionality that is sorely missing. I'm not going to spill the beans on it quite yet since I've got another couple of enhancements that will enable even more great functionality. I'll present this extension and others when I give my talk at Google on the 15th of July. I'll post a video of that talk on this blog once its available.

Julian Time:
One of the less fortunate aspects of KML, in my opinion, is it's use of the ISO 8601 Date and Time Format. I understand why they did it; because it is human readable and a standard to hang their hat on. The processing overhead on parsing the date is significant, but not a deal breaker so why do I care?

Clearly the ISO time format should be left in, but there should be another option for specifying it as Julian Time. There are so many nice properties of julian time that I would be very surprised if Google Earth, Virtual Earth, ESRI and any other virtual globes don't all use it for their internal representation of time. It is a floating point number (usually a 64 bit double) that can be manipulated with standard mathematical functions. Anyone who has ever written a date library the naive way (as I have) has come to dislike all of the little details like days in a month, leap years and worst of all... time zones. Why not standardize on a time format that does away with all of that dreck and can be operated on like a regular number? You can add 3.5 days, subtract an hour and do simple comparison operations like greater than, less than and equal. I can't imagine ever using another internal representation.

Here's a conversion routine in Python:

# gdate is (year, month [1-12], day, hour, minute, second)
def julian_date(gdate):
if gdate[1] < 3:
M = gdate[1] + 12
Y = gdate[0] - 1
M = gdate[1]
Y = gdate[0]
D = gdate[2] + (gdate[3] / 24.0) + (gdate[4] / 1440.0) + (gdate[5] / 86400.0)
A = math.floor(Y/100.0)
RV = math.floor(365.25*(Y+4716.0)) + math.floor(30.6001*(M+1.0))
return RV + D + (2.0-A+math.floor(A/4.0)) - 1524.5

Friday, June 13, 2008

Google open sources Gears

Google has open sourced it's web plugin Gears under a modified BSD license. Normally I wouldn't comment on something like this because it seems unrelated to what I'm doing with EarthBrowser. However I believe that it could be very important to the future direction of EarthBrowser. A web plugin that supports all major browsers on all major platforms is a *very* large project, one I would never attempt myself. I am kind of in shock that Google would make it so easy for others to make web plugins by giving this away under such a permissive license.

A really long time ago, way back when in the days of Netscape before Internet Explorer even came around, I had a version of EarthBrowser working as a web plugin. It had too many problems with memory limits on the old MacOS 7 and 8 so I canned the project and went with a desktop app. So now there is an open source web plugin code base that I can use to port my OpenGL version of EarthBrowser right into a website. I probably won't tackle that particular project until next year, but it is good to know that it is now possible.

I am very impressed with the release of this code, this is such a different way of doing business. I don't see any benefit for them in doing this, but there isn't any harm either. Way to share knowledge Google!

Thursday, June 12, 2008

KML to JSKML translator now available

It's now available at the JSKML Site run though the Google App Engine.

I've created a KML parser that will transform a KML document into the JSKML format, or alternately a JSON formatted JSKML document if that is what you require. It's a simple copy and paste translator similar to Dean Edwards excellent Javascript Packer.

It currently works on the KML 2.2 standard and could use a little optimization but it is functional and easy to use. If you give it a try and find an error, please let me know.

Monday, June 09, 2008

jskml: Javascript KML Dialect

KML data structures need to be represented in other formats than just XML. With virtual globes moving into the web browser, the need for an alternate representation that does not require parsing to go from XML text into Javascript objects is an important step, in my opinion, in simplifying web based scripting of online mapping.

I have created a simple static website describing the new dialect at:

I used Google App Engine and the Django framework to create this site. I've got another exciting app or two planned for deployment using this platform and this website was a good way for me to orient myself as well as put out a format that I feel should be supported.

Friday, June 06, 2008

Thoughts on the Google earth plugin API

Good job Google earth/maps team.

While it feels like they rushed the introduction of the earth plugin a bit, leaving pretty spotty documentation of the API and only a Windows version, it is indeed a great first step. Putting javascript tendrils deep into the control structure of the plugin was inspired and will be transformative.

However, the programmer in me can't help but be a little offended by the size and verbosity of the interface. Am I to understand that the very first example of creating a placemark is what will be needed for such a simple task?

var placemark = ge.createPlacemark('');
placemark.setName("You are at Google");

// Create style map for placemark
var normal = ge.createIcon('');
var iconNormal = ge.createStyle('');
var highlight = ge.createIcon('');
var iconHighlight = ge.createStyle('');
var styleMap = ge.createStyleMap('');

// Create point
var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
var point = ge.createPoint('');

Admittedly it uses the super-annoying StyleMap which I feel should be abolished. Don't you think it is too much to ask to perform this kind of operation for every placemark? I suppose someone could create a wrapper library for this to simplify common tasks.

How about implementing this in your API instead:
name:'You are at Google',

Could the maps/earth team create the nicer interface wrapper?

Wednesday, June 04, 2008

EarthBrowser is Adobe site of the day, Google talk

I don't have the marketing megaphone that a Google has but EarthBrowser is starting to get a little attention in the Flash world. I was just notified today that was selected as the Flash site of the day. There was also a nice article recently on titled EarthBrowser - 3D AIR App in Flash.

Google, via Michael Weiss-Malik, has invited me to come down and deliver a presentation about EarthBrowser, KML and whatever else I want to talk about. I guess it will be something like the Google Tech Talks where they make a YouTube video of the presentation. I've been consolidating things on version 3 for the past month so I haven't set a date yet but I'm pretty sure it will be mid July if that is available for them. Hopefully those guys aren't too miffed about my KML criticisms, or my out of date Google Earth criticisms. Perhaps I should bring a rotten tomato shield.

I've got a little project I'm hoping to unveil at or before the talk, but I'll leave everyone in suspense about what that could be...