Version 0 of geocoder

Updated 2005-12-04 06:53:24

Geocoder


http://geocoder.us is a service that translates street addresses to long/lat coords. Such coords are a necessity for some services such as Google's map API.


** Professional Approach

(to come)


** Simple Approach

Here is the simplest solution with no error checking and no extensive use of packages. (A more professional version - to come - would use an XML package and provide error checking and a million options.

 set args "100 Bureau Dr, Gaithersburg, MD  20899"
 regsub -all " " $args "+" encodedURL

 set geocoder "http://rpc.geocoder.us/service/rest/geocode?address=$encodedURL"
 set data [http::data [http::geturl $geocoder]]

 regexp "<geo:long>(.*)</geo:long>" $data X long
 regexp "<geo:lat>(.*)</geo:lat>"   $data X lat

 puts "long: $long"
 puts "lat : $lat"