[mapserver-users] Online Geocoding?
klehr1@tampabay.rr.com
klehr1@tampabay.rr.com
Thu, 25 Apr 2002 13:38:45 -0400
This is a multi-part message in MIME format.
------=_NextPart_000_0156_01C1EC5E.85C5D3A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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 =3D"www.wherver.com";
my $path =3D "geocode.pl";
my $content =3D "CMD=3DgeoCode&Address=3D123+Seaseme+St&";
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =3D =
localtime(tim
e);
my $timestr =3D sprintf("%4d%02d%02d%02d%02d", $year+1900, $mon+1, =
$mday, $hour, $
min);=20
my $host =3D $ip;
my $port =3D 80;
my $socketaddr;
print HTML "\nRetrieving page $path with $content";
print "\nRetrieving page $path with $content";
openSock();
post ($content);
@wholePage =3D <SOCK>;
close SOCK;
print HTML @wholePage;
exit;
###########
# subroutine: open a socket at SOCK
###########
sub openSock {
$socketaddr=3D sockaddr_in $port, inet_aton $host or die "Bad =
hostname\n"; =20
#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), $| =3D 1)[0]);
}
###########
# subroutine: send post request to target web site
###########
sub post {
my $content =3D shift @_;
print SOCK "POST http://$host/$path HTTP/1.0\n";
print SOCK "Content-type: application/x-www-form-urlencoded\n";
my $contentLength =3D length $content;
print SOCK "Content-length: $contentLength\n";
print SOCK "\n";
print SOCK "$content";
}
sub get {
my $content =3D shift @_;
print SOCK "GET http://$host/$path HTTP/1.0\n";
print SOCK "Content-type: text/html\n\n";
#my $contentLength =3D length $content;
#print SOCK "Content-length: $contentLength\n";
#print SOCK "\n";
#print SOCK "$content";
} =20
------=_NextPart_000_0156_01C1EC5E.85C5D3A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Does anyone know of an online =
geo-coding=20
service.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>i.e. they have an address form press =
submit and=20
back comes the geo-code.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I may process 10-1000 GeoCodes a day =
and need it in=20
realtime. I've scene some sites that allow you to do 100 free =
geo-codes,=20
but would like to use a subscription type service.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I am planning to write a script that =
connects to=20
their web page, posts the data to a form, captures the =
returned=20
geo-code and then update my database record. Another =
wonderful job=20
for PERL.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Steve Lehr</FONT></DIV></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>For those of you have not done such a =
thing-- here=20
a nifty script that POSTS/GETS data from a web form.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>#!/usr/bin/perl -w<BR>use =
Socket;<BR>use=20
strict;<BR># these are the only pertinent variables<BR>my $ip=20
=3D"www.wherver.com";<BR>my $path =3D "geocode.pl";<BR>my $content =3D=20
"CMD=3DgeoCode&Address=3D123+Seaseme+St&";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>my ($sec, $min, $hour, $mday, $mon, =
$year, $wday,=20
$yday, $isdst) =3D localtime(tim<BR>e);<BR>my $timestr =3D=20
sprintf("%4d%02d%02d%02d%02d", $year+1900, $mon+1, $mday, $hour, =
$<BR>min);=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>my $host =3D $ip;<BR>my $port =3D =
80;<BR>my=20
$socketaddr;<BR></FONT><FONT face=3DArial size=3D2><BR>print HTML =
"\nRetrieving page=20
$path with $content";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>print "\nRetrieving page $path with=20
$content";<BR>openSock();<BR>post ($content);<BR>@wholePage =3D=20
<SOCK>;<BR>close SOCK;<BR>print HTML @wholePage;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>exit;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>###########<BR># subroutine: open a =
socket at=20
SOCK<BR>###########</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>sub openSock {<BR>$socketaddr=3D =
sockaddr_in $port,=20
inet_aton $host or die "Bad hostname\n"; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>#print "Connecting to $socketaddr =
$host,=20
$port";<BR>socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or =
die "Bad=20
socket\n";<BR>connect SOCK, $socketaddr or die "Bad=20
connection\n";<BR>select((select(SOCK), $| =3D 1)[0]);<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><BR>###########<BR># subroutine: send =
post request=20
to target web site<BR>###########</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>sub post {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>my $content =3D shift @_;<BR>print SOCK =
"POST <A=20
href=3D"http://$host/$path">http://$host/$path</A> HTTP/1.0\n";<BR>print =
SOCK=20
"Content-type: application/x-www-form-urlencoded\n";<BR>my =
$contentLength =3D=20
length $content;<BR>print SOCK "Content-length: =
$contentLength\n";<BR>print SOCK=20
"\n";<BR>print SOCK "$content";<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>sub get {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>my $content =3D shift @_;<BR>print SOCK =
"GET <A=20
href=3D"http://$host/$path">http://$host/$path</A> HTTP/1.0\n";<BR>print =
SOCK=20
"Content-type: text/html\n\n";<BR>#my $contentLength =3D length=20
$content;<BR>#print SOCK "Content-length: $contentLength\n";<BR>#print =
SOCK=20
"\n";<BR>#print SOCK "$content";<BR>} =20
</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>
------=_NextPart_000_0156_01C1EC5E.85C5D3A0--