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

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Randal has been playing around with Aperture to organize his photos on his MacBook then upload them to Flickr. It has a nifty feature to geotag images based on the current view in Google Earth.

I figured that must be using AppleScript, so I tried creating a Mac::Glue glue for it:

% sudo gluemac /Applications/Google\

That worked. The glue isn't that interesting. I can get the data for the current view, which is what Aperture does:

my $gEarth = Mac::Glue->new('Google_Earth'); my $reco = $gEarth->getviewinfo;

That gives me a hash:

{ 'azimuth' => '1.19852752792094e-14', 'longitude' => '-96.4999988896226', 'distance' => '25484000', 'latitude' => '40.4999984526947', 'tilt' => '-1.26725225589562e-15' }

I want to set the view though. But what to set it too? How about flying through all of the Perl Mongers locations? I can get those from the Perl Mongers XML file. Once I extract the latitude and longitude I pass it back to setviewinfo. If I wanted to get really fancy I could then use savescreenshot to save the view.

#!/usr/bin/perl use LWP::Simple; use Mac::Glue; print "Downloading Perl Mongers XML file..."; my $data = get( '' ); $data ? ( print "done\n" ) : ( die "Could not get file!" ); # See Mac::Glue for details on creating the glue, probably: # gluemac /Applications/Google\ print "Starting Google Earth..."; my $gEarth = Mac::Glue->new( 'Google_Earth' ); $gEarth ? ( print "done\n" ) : ( die "Could not start Google Earth!" ) +; while( $data =~ m|<group.*?>(.*?)</group>|gs ) { # I could use an XML parser, but it's too easy to do it myself my( $name, $long, $lat ) = $1 =~ m| <name>(.*?)</name> .*? <longitude>(.*?)</longitude> .*? <latitude>(.*?)</latitude> |xs; print "Flying to $name\n"; $gEarth->setviewinfo( { 'azimuth' => '0', 'longitude' => $long, 'distance' => '4000', 'latitude' => $lat, 'tilt' => '0' } ); sleep 15; }

You might have to make that sleep a little longer if you have a slower network connection, and maybe you want to loop around the setviewinfo to start farther up (that number is in meters) and zoom in.

Have fun :)

brian d foy <>
Subscribe to The Perl Review

In reply to Perl Mongers Google Earth Tour by brian_d_foy

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
    [Discipulus]: damn I missed a possible employer for seconds..

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (8)
    As of 2018-04-20 18:57 GMT
    Find Nodes?
      Voting Booth?