#!/usr/local/bin/perl # # Include LWP::Simple to call the URL for the points # use LWP::Simple; # # Include the SOAP::Lite package to make SOAP calls # use SOAP::Lite; # # Not sure how this works but this is supposed to be an error handler # on_fault => sub { my($soap, $res) = @_; die ref $res ? $res->faultstring : $soap->transport->status, "\n"; }; # # This is a routine I found that parses CGI input parameters # ############################################################## sub read_input { local ($a,$b, $lvalue, $buffer, @pairs, $pair, $name, $value, %FORM); $a=0; # Read in text $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } # Split information into name/value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { $lvalue = "$value"; ($name, $value) = split(/=/, $pair); ++$found{"$name"}; $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; if ($found{"$name"} > 1) { $a++; $FORM{"$name$a"} = $value; } else { $a=0; $FORM{$name} = $value; } } %FORM; } ################################################################# ################################## MAIN ######################### # # Read the input CGI parameters # %cgiparams = &read_input; $fileurl = 'http://www.rossoworld.com/arcweb/points.txt'; if (!$cgiparams{loc} eq "") { $fileurl = $cgiparams{loc}; } # # # Call the Authentication Service to get a token # my $auth = SOAP::Lite -> uri('http://arcweb.esri.com/v2') -> proxy('https://arcweb.esri.com/services/v2/Authentication'); eval { $token = $auth ->getToken( SOAP::Data->name('username' => 'your username'), SOAP::Data->name('password' => 'your password') ) ->result; 1 } or die; # # Read in the GPS Points and descriptions from the given URL # my $file = get($fileurl); # # Parse the data and grab the x,y,index and description # while ($file =~ m{(.*?)\n}gs) { @entries = split(/,/, $1); if ($#entries >= 3) { my $x = $entries[0]; my $y = $entries[1]; my $idx = $entries[2]; $desc[$idx-1] = $entries[3]; # # Create a marker using the SOAP::Data object # $markerarray[$idx-1] = \SOAP::Data->value( SOAP::Data->name('iconDataSource' => 'ESRI.Raster.Icons'), SOAP::Data->name('name' => 'blue_' .$idx. '.gif'), SOAP::Data->name('location' => \SOAP::Data->value( SOAP::Data->name('x' => $x), SOAP::Data->name('y' => $y) ) ) ); } } # # For each marker found create an array with SOAP::Data # my @markers; $idx = 0; foreach $m (@markerarray) { @markers = (@markers, SOAP::Data->name('marker' .$idx => $m)); $idx++; } # # Call MapImage to plot the points on the map # my $map = SOAP::Lite -> uri('http://arcweb.esri.com/v2') -> proxy('http://arcweb.esri.com/services/v2/MapImage'); eval { $mapImageInfo = $map ->getBestMap( SOAP::Data->name('mapImageOptions' => \SOAP::Data->value( SOAP::Data->name('dataSource' => 'GDT.Streets.US'), SOAP::Data->name('markers' => \SOAP::Data->value(@markers)) ) ), SOAP::Data->name('token' => $token), ); } or die; # # Create the output page # print "Content-type: text/html\n\n"; print "\n"; print "
"; print "

ArcWeb Locations Map

"; print "

Locations from $fileurl

result->{mapUrl}; print "\">"; $idx = 1; foreach $d (@desc) { print ""; $idx++; } print "
$idx. $d
\n";