Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #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.

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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2021-01-26 18:35 GMT
    Find Nodes?
      Voting Booth?