Perl World Map Marker
This is a Perl script that, when provided with a list of airports, will look them up in a text database and place red markers on a world map, such as this one, which marks every place I have been to. Feel free to modify and redistribute.
You also need to download the following supporting files and place them in the same directory:
map-blank.gif
map-airports.txt
#!/usr/bin/perl
use Math::Trig;
use Image::Magick;
$locations="(LAX|SFO|ANC|FAI|MUC)";
$image = new Image::Magick;
$image->Read('map-blank.gif');
$width=679;
$height=724;
open(infile,"<map-airports.txt");
while(chomp($line=)) {
($icao,$iata,$name,$city,$country,$latd,$latm,$lats,
$latx,$lond,$lonm,$lons,$lonx,$alt)=split(/:/,$line);
if($iata=~/$locations/) {
print "$iata $name $city $country\n";
$lat=$latd+$latx/60+$lats/3600;
$lon=$lond+$lonx/60+$lons/3600;
if($lonx eq "E") { $lonz=$lon; }
if($lonx eq "U") { $lonz=-$lon; }
if($latx eq "N") { $latz=$lat; }
if($latx eq "S") { $latz=-$lat; }
$x=$lonz;
$px=$x/180*$width/2+$width/2;
$y=atanh(sin($latz/180*3.14159));
$py=-.94*$y/3.14159*$height/2+$height/2*.99;
$image->Draw(stroke=>'red',primitive=>'rectangle',
points=>"$px,$py,".($px+2).",".($py+2));
}
}
close(infile);
$image->Write('map.gif');
undef $image;
Copyright (C) 2007 Dheera Venkatraman. For usage of photos, please see the Photo usage policy. Please contact me for any use of other content from this website.
