Open Source Geocoding Engine

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Mon Mar 7 09:45:18 EST 2005


Hannah,

You need to have the zipcode centroids. For the US, you can get them
from the Census website. Build a table in SQL of
    ZIPCODE, LAT, LONG
and load your zipcode centroids. The when the use enters the zipcode
look it up and display the map. You can get an image from mapserver
using a url like:

http://yoursite.com/cgi-bin/mapserv?mode=map&layers=all&scale=500000&map=/path/to/mapfile.map&mapxy=456579.116+4029578.248&map_size=300+200

Adjust the parameters to suite your needs, or do something similar in
mapscript.

-Steve W.

David Bitner wrote:
> Hannah,
>
> There is probably an easier way that this could be done in PHP
> Mapscript that perhaps someone else on the list could comment on.
>
> Basically, what you need to do is to be able to get an extent from the
> selected zipcode (minx,miny,maxx,maxy).  Your query is simple because
> it is always an exact query.  Using basic MYSQL without any spatial
> extension, you would want to pre-calculate the minx,miny,maxx, and
> maxy of each zipcode and populate fields with them in your mysql
> database.  Then all you would do is use PHP to execute a query (select
> minx,miny,maxx,maxy from zipcodes where zip = $_REQUEST['zipcode']).
> You could then either take those results and use them for the extent
> in your mapserver request.
>
> David
> On Mon, 7 Mar 2005 12:53:42 +0000 (GMT), Hannah Brown
> <hannahbrown_21 at yahoo.co.uk> wrote:
>
>>Hi
>>I wonder if you can help...
>>I am implementing a fault reporting system;
>>
>>A user has to enter a postcode following pressing submit the appropriate
>>region of the map will load, I am using PHP and MySQL to do this.  I have
>>the maps and required postcodes.  I am having trouble with the code needed
>>to find the area on the map once the postcode is submitted.
>>
>>Hannah*
>>
>>*User in the UK
>>
>>
>>David Bitner <osgis.lists at GMAIL.COM> wrote:
>>PostgreSQL/PostGIS combined with PL/PGSQL can create a very good
>>localized geocoder. I have created a geocoder using PostgreSQL that
>>is very specific to a particular local streets dataset without much
>>difficulty.
>>
>>The previously mentioned OS geocoders will not do anything for
>>Southern Ontario out of the box since they are specific to the US
>>Census Tiger Data.
>>
>>The first thing that you will need regardless of how you are planning
>>on creating your geocoder is good address matchable street data. This
>>streets data must have separated fields for the different component
>>address parts as well as from and to address ranges for each street
>>segment (often a group of fields l_f_add,l_t_add,r_f_add,r_t_add).
>>
>>If you do not have address matchable street data, you are dead in the
>>water regardless of whether you have geocoding software.
>>
>>I do know that Refractions has been working on some geocoding pl/pgsql as
>>well.
>>
>>A rough outline of a plpgsql geocoder follows (assuming you can split
>>the address into the appropriate parts):
>>
>>create a type to hold the results of your geocode query -- this should
>>include all fields that you'll want in your result and a field to hold
>>a rank.
>>
>>create a function that returns your geocode result type:
>>set up a loop with the pieces of the address that you want to force an
>>exact match --
>>
>>for i in select * from roads where streetname=inputstreetname and
>>inputstreetnumber between minimum_address_number and maximum address
>>number LOOP
>>if i.prefix_direction=inputprefixdirection then rank=rank+1; end if;
>>if i.street_type=inputstreettype then rank=rank+1;end if;
>>...
>>result.prefix_direction:=i.prefix_direction;
>>result.street_type:=i.street_type;
>>...
>>percent:=(street_number-i.minimum_address)/(i.maximum_address-i.minimum_address);
>>result.geometry:=line_interpolate_point(geometryn(i.geometry,1),percent);
>>result.rank=rank;
>>return next result;
>>end LOOP;
>>
>>
>>The to get your result, you could use a query like:
>>select * from geocode_function(inputstreetnumber,inputprefixdirection,...)
>>order by rank limit 1;
>>
>>
>>
>>
>>On Fri, 4 Mar 2005 11:50:31 -0600, Poopalasingham Elankeswaran
>>wrote:
>>
>>>Hi there,
>>>
>>>I am doing research on Address gecoding with Mapserver and
>>>PostgreSQL/PostGIS. Does anyone have any idea in this area? It is not like
>>>Goole Map or Mapquest. This has to be specifically for Southern Ontario,
>>>Canada. I need to search list of addresses and displaying them together on
>>
>>a
>>
>>>Map or save all the corresponding points to a shape file.
>>>
>>>Is there any Open Source Geocoding Engine?
>>>
>>>Thanks,
>>>
>>>P.Elankes
>>>Computer System Engineering
>>>Carleton University
>>>Ottawa,Canada
>>>
>>
>>
>>Send instant messages to your online friends http://uk.messenger.yahoo.com
>
>



More information about the mapserver-users mailing list