Over the past week or so, I've been playing around with Google Earth. Very very cool stuff.
Anyway, I thought it would be kinda neat to put Perlmonks on Google Earth, in a similar way that jcwren did with the Big Monk Map, and theorbtwo did with pmplanet. So I hacked together a script to pull the monk location data from tinymicros, and then pull in the other basic Monk data (such as XP level, date joined, number of writeups) from Perlmonks.
The end result is a
KML KMZ (see update 2 below) placemark file which can be directly imported into Google Earth. For those that have Google Earth installed, or are sufficiently motivated to install it - the placemark file is available here.
At the moment it's fairly rudimentary, with Monks ascii-betically grouped into folders. Clicking on any single monk name brings up some basic info about that monk, and double-clicking zooms to their location (all standard Google Earth behaviour). I did manage to find a rather cute little "monk" to use as an icon for the placemarks :)
I'm a little bit hesitant to post the code I used, mainly because when run it will hit Perlmonks about 800 times, to gather the monk stats. And I don't think we'd suddenly want to have dozens of people doing that ;)
But basically, the code does the following:
- Uses LWP::UserAgent to successively pull the Monk location data (Lat/Long) from tinymicros. Because there are around 800 monks that have supplied location data1, and I can only get 50 records at a time, this takes about 16 hits.
- From the returned pages, it pulls the node ID, username, Lat and Long for each Monk.
- It stuffs this data into a hash, keyed by Monk homenode ID, and uses Storable to save it to disk.
- It then iterates through the list of Monks, and using a combination LWP::UserAgent and HTML::TokeParser pulls in the date joined, XP level, and number of writeups for each monk, from their homenode.
- Finally, it writes the KML file.
I used Storable to save the data to disk, so that I could re-use the data on subsequent runs (whilst tweaking the script), and not have to continually scrape the data over and over again. This means that the data is already out of date - but shrug, at this stage it's just an exercise for a bit of fun and learning :)
The other thing that occurred to me is that something like this would probably be better integrated into jcwren's existing pmstats at tinymicros - especially as he is already pulling the required data on a daily basis.
It's also possible that somebody has already done this, and so I may have just re-invented another wheel. Although if they have - I couldn't find it.
So for now I just thought I'd throw this out there, and see what the reaction is.
Update 1. (2006-07-04): - I've discussed this with jcwren this morning, and he has supplied me with an XML feed directly from tinymicros for all this data (on a single page). So once I have the time (over the next few days), I'll provide a link to a daily updated KML file. Stay tuned! :)
Update 2. (2006-07-06): - Made a few changes over the past few days as follows:
- - I'm using KMZ (compressed) format instead of KML for the monkfile. This has reduced the filesize from 701K to 47K.
- - there are now coloured icons to represent each different monk level, and monks are grouped by level and ordered alphabetically within the levels (in the "places" menu)
Update 3. (2006-07-10): - This now has a "permanent" home. Two files are generated each day, and there are also a few screenshots.
Update 4. (2006-07-11): - The code.