#!/usr/bin/perl -w # Create a test for the ProjectedOverlay... # Author. John D. Coryat 01/2008... # Copyright 1997-2008 USNaviguide LLC, all rights reservered. use CGI qw/:standard *table/ ; use USNaviguide_Google_RelPix ; use strict ; use GD ; use GD::Polyline; my $sw = param('SW') ; my $ne = param('NE') ; my $zoom = param('ZOOM') ; my @d1 = ( ) ; my @d2 = ( ) ; my $ht = 0 ; my $wd = 0 ; my $lat = 0 ; my $lng = 0 ; my $north = 0 ; my $west = 0 ; my $top = 0 ; my $left = 0 ; my $line = '' ; my $i = 0 ; my $ix = 0 ; my $iy = 0 ; my $im = '' ; my $grey = '' ; my $black = '' ; my $red = '' ; my $input = <<_POINTS ; 35.108675,-90.038452 35.137879,-90.107117 35.189522,-90.027466 35.178298,-89.901123 35.088451,-89.862671 34.991754,-89.892883 34.989504,-90.09613 35.104181,-90.178528 35.205233,-90.164795 35.281501,-90.00824 35.236646,-89.763794 35.07946,-89.697876 34.957995,-89.717102 34.879172,-89.986267 34.982753,-90.307617 35.303919,-90.343323 35.496456,-89.906616 35.404722,-89.568787 35.016501,-89.296875 34.75741,-89.612732 34.957995,-90.615234 35.527756,-90.6427 35.699686,-90.159302 35.715298,-89.505615 35.272532,-88.879395 34.556335,-89.02771 34.352507,-90.269165 34.998504,-91.664429 36.275279,-91.153564 36.870832,-90.043945 36.4036,-87.945557 34.642247,-87.132568 33.155948,-91.933594 35.182788,-93.208008 36.993778,-92.69165 38.048091,-90.703125 38.013476,-85.605469 35.675147,-85.253906 31.933517,-87.736816 31.578535,-93.911133 34.669359,-97.294922 39.334297,-97.558594 42.163403,-91.362305 41.112469,-80.947266 35.639441,-80.771484 28.536275,-83.71582 26.273714,-90.834961 27.722436,-99.448242 36.774092,-104.941406 43.484812,-101.030273 47.279229,-92.285156 46.377254,-73.740234 37.857507,-71.367187 27.527758,-71.982422 16.720385,-94.833984 28.921631,-112.675781 42.747012,-116.015625 51.124213,-107.226562 52.696361,-87.539062 _POINTS my @points = split( /\n/,$input ) ; if( $sw =~ /(.*),(.*)/ ) { $lat = $1 ; $lng = $2 ; $west = $2 ; @d1 = &Google_RelPix($lat, $lng, $zoom); } if( $ne =~ /(.*),(.*)/ ) { $lat = $1 ; $lng = $2 ; $north = $1 ; @d2 = &Google_RelPix($lat, $lng, $zoom); } ($top,$left) = &Google_RelPix($north, $west, $zoom); $ht = abs( $d1[0] - $d2[0] ) ; $wd = abs( $d1[1] - $d2[1] ) ; # create a new image $im = new GD::Image($wd,$ht,0) ; $grey = $im->colorAllocate(220,220,220) ; $im->interlaced('true') ; $im->transparent($grey) ; $im->setThickness(3) ; $black = $im->colorAllocate(0,0,0) ; $red = $im->colorAllocate(255,0,0) ; $im->stringFT($black,'/www/VERDANA.TTF',10,0,10,20,"$wd,$ht") ; $im->stringFT($black,'/www/VERDANA.TTF',10,0,250,20,"$left,$top") ; # Plot Points... $line = new GD::Polyline ; for ( $i=0; $i <= $#points; $i++ ) { ($lat,$lng) = split( /,/, $points[$i] ) ; ($iy,$ix) = &Google_RelPix($lat, $lng, $zoom) ; $ix = $ix - $left ; $iy = $iy - $top ; $line->addPt($ix,$iy); } $im->polydraw($line,$red) ; print header(-type=> 'image/png', -expires=> '+1d') ; print $im->png ;