Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Howdy :)

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.

Enjoy,
Darren :)

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.

1 For those that are not yet on the Big Monk Map, but would like to be - simply follow the instructions here


In reply to Google Earth Monks by McDarren

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-25 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found