More Mashup Fun…

I wasn’t completely happy with the my last Google Maps/Weather Radar mashup. Two things I discovered; that Google Maps doesn’t update a KML loaded from the search function, and that the radar locations weren’t clear enough.

The later, radar visibility, was fairly east to correct. I added the transmitter points to the KML, and added a 10% magenta overprint to show the 200km range of the radar.

The first, I discovered that the Google Maps API is not completely in line with the KML reference, as that it doesn’t update images or dynamic content except with very specific controls. Google Earth KML’s have a <refreshMode> tag that allows users to declare expiration of data base on user behavior, a time delay, or expiration date and time. As far as I can tell, only the latter, onExpire, is supported by Google Maps. The options for using onExpire are based on either HTTP header settings, or setting an expiry time in the kml. The HTTP header settings are beyond my control with the hosting I use, and this left me with calculating a date/time stamp to be embedded in the KML.

At the suggestion of Coverfire, I calculated a proper date/time stamp during the web image grab, and just stuffed it into the KML, which in now assembled each time the script runs. The kit and kaboodle is uploaded to the server, which should allow users to get recent images when following the link.

Environment Canada Weather Radar on Google Maps

Or if you prefer Google Earth:

Environment Canada Weather Radar KMZ

A few things that came out of this clean up and finalization: Google Maps support of the KML is still really in beta, and is changing rapidly. And, Bash shell parameter expansion can drive you mad.

It’ll be interesting to see how long this mashup still works. I don’t see Google removing functionality, but they may streamline the KML import, and possible clean up some fuzzier aspects of refreshing dynamic content.

I spent two hours trying to get my shell scripts to crunch the date command to give me a nice ISO standard date 10 minutes in the future. Figuring that adding 600 seconds to the epoch time was the easiest, I just had date spit out epoch seconds and add 600. The most fun was getting all the variables to expand correctly while feeding it back to date.

Handy things to know about date:

To get the seconds since epoch:

date +%s

To get the date back from epoch time:

date –date=@EPOCHSECONDS

This option is incredibly handy for future dating as it makes the date command take care of what day/hour/minute is is when you add time. The only problem I found is nobody knows about it. Neither the wikipedia entry, nor the unixhelp page listed this option. I found it reading in the GNU manual. In fact, I don’t think I could have sorted out my difficulties with out this reference. Good one to know!

At this point, I think I’m happy with the look and operation of the Weather Radar KML. If you find any problems, or have suggestions, please leave me a note here, and I’ll look into it.

kgs

Advertisements

One Response to “More Mashup Fun…”

  1. Jonathan Says:

    Hi there

    I am interested in creating a Weather Radar in Google Earth for Alberta. I have been looking at your codes and the help files on google, so I believe I can create the correct KMZ files which I have already done. However, I am not sure how to develop the script to take the weather radar images and remove the backgrounds and save them to a server? Can you help me with this portion of the code?

    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: