[mapserver-users] Online Geocoding?

klehr1 at tampabay.rr.com klehr1 at tampabay.rr.com
Thu Apr 25 10:38:45 PDT 2002


Does anyone know of an online geo-coding service.

i.e. they have an address form press submit and back comes the geo-code.

I may process 10-1000 GeoCodes a day and need it in realtime.  I've scene some sites that allow you to do 100 free geo-codes, but would like to use a subscription type service.

I am planning to write a script that connects to their web page, posts the data to a form, captures the returned geo-code and then update my database record.  Another wonderful job for PERL.

Thanks
Steve Lehr

For those of you have not done such a thing-- here a nifty script that POSTS/GETS data from a web form.

#!/usr/bin/perl -w
use Socket;
use strict;
# these are the only pertinent variables
my $ip ="www.wherver.com";
my $path = "geocode.pl";
my $content = "CMD=geoCode&Address=123+Seaseme+St&";

my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(tim
e);
my $timestr = sprintf("%4d%02d%02d%02d%02d", $year+1900, $mon+1, $mday, $hour, $
min); 
my $host = $ip;
my $port = 80;
my $socketaddr;

print HTML "\nRetrieving page $path with $content";

print "\nRetrieving page $path with $content";
openSock();
post ($content);
@wholePage = <SOCK>;
close SOCK;
print HTML @wholePage;

exit;

###########
# subroutine: open a socket at SOCK
###########

sub openSock {
$socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";  
#print "Connecting to $socketaddr $host, $port";
socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or die "Bad socket\n";
connect SOCK, $socketaddr or die "Bad connection\n";
select((select(SOCK), $| = 1)[0]);
}


###########
# subroutine: send post request to target web site
###########

sub post {
my $content = shift @_;
print SOCK "POST http://$host/$path HTTP/1.0\n";
print SOCK "Content-type: application/x-www-form-urlencoded\n";
my $contentLength = length $content;
print SOCK "Content-length: $contentLength\n";
print SOCK "\n";
print SOCK "$content";
}

sub get {
my $content = shift @_;
print SOCK "GET http://$host/$path HTTP/1.0\n";
print SOCK "Content-type: text/html\n\n";
#my $contentLength = length $content;
#print SOCK "Content-length: $contentLength\n";
#print SOCK "\n";
#print SOCK "$content";
}      


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020425/88ad1855/attachment.htm>


More information about the MapServer-users mailing list