Open Source Geocoding Engine

David Bitner osgis.lists at GMAIL.COM
Mon Mar 7 08:33:45 EST 2005


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