Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Friday January 26, 2007
01:50 AM

Take a Google Earth tour using Mac::Glue

[ #32257 ]

Get a bird's eye view of all the Perl Mongers by using Mac::Glue to drive Google Earth:

#!/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;
    }

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.