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\ Earth.app
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( 'http://www.pm.org/groups/perl_mongers.xml' ); $data ? ( print "done\n" ) : ( die "Could not get file!" ); # See Mac::Glue for details on creating the glue, probably: # gluemac /Applications/Google\ Earth.app 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 :)
In reply to Perl Mongers Google Earth Tour by brian_d_foy
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |