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
else:
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