[postgis-users] Geocoding cross streets?

Stephen Woodbridge woodbri at swoodbridge.com
Mon Nov 28 21:15:02 PST 2011


Aren,

You do not even need C++. While I have not done this yet myself, you can 
look at the source for postGIS or pgRouting and there is good 
documentation in the postgreSQL docs for how to do this. The basic 
follow of control is something like this:

plpgsql stored procedure the references a shared library and entry point.

The library and entry point are typically C code and call the API as 
defined in the docs. You would pass an text string into the C function 
that would deal with converting from postgresql internal formats into a 
standard C string. Then you call my code (it might need to be tweaked a 
little to deal with memory allocation and error handling in this 
environment to work through the postgresql API). My code return an array 
of strings that is the parsed data. You then convert these back to 
postgresql strings an return them as a record. Clean up memory and 
whatnot's and your done.

This is probably a fairly clean and only little more complex than hello 
world, but not majorly so, if you want to try your hand at it.

Thanks,
   -Steve


On 11/28/2011 10:41 PM, Aren Cambre wrote:
> Is there anything I can to do help this happen? I admit I haven't done
> much intensively with C++ since my undergrad in the late '90s. I'm in
> the coddled world of IT now and use stuff like C#. :-)
>
> Aren
>
> On Mon, Nov 28, 2011 at 5:30 PM, Stephen Woodbridge
> <woodbri at swoodbridge.com <mailto:woodbri at swoodbridge.com>> wrote:
>
>     Yes, this makes sense. Regardless you can always add a higher level
>     parser to deal with parsing a single field of input and splitting it
>     into fields and then deciding which appropriate API to call to get
>     results.
>
>     I have written and contributed to PAGC a single line address parser
>     that works for US addresses. It is a standalone C module that can be
>     reused and is licensed under MIT-X style license, so it could be
>     picked up and easily wrapped with a plpgsql wrapper to pass text on
>     input and get a fielded record of parsed results.
>
>     -Steve
>
>
>     On 11/28/2011 5:53 PM, Paragon Corporation wrote:
>
>         Steve,
>
>         Yap that's what we were thinking.  That's why we have it as a
>         separate
>         function specifically for cross intersection which will take the
>         form:
>
>         geocode_intersection(roadway1, roadway2, city, state, zip)
>
>         So we at least for the first pass, are not going to assume any
>         symbol etc.
>         to break (we have enough issues with our normalize logic that we are
>         cleaning up).
>         We'll force people to type the streets in as separate arguments.
>
>
>         For our case we already have it coded that way so the easiest to
>         port since
>         ours (the use case we have it coded for) is fed from a user
>         interface
>         that looks somethng like
>
>         where people have
>
>         Address: ______________________________ __ (goes regular route)
>
>         or
>
>         Cross Street of ______________ and _____________  (goes thru our
>         geocode
>         intersection route)
>
>         option.
>
>
>
>
>             -----Original Message-----
>             From: postgis-users-bounces at postgis. refractions.net
>             <mailto:postgis-users-bounces at postgis.refractions.net>
>             [mailto:postgis-users-bounces@ postgis.refractions.net
>             <mailto:postgis-users-bounces at postgis.refractions.net>] On
>             Behalf Of Stephen Woodbridge
>             Sent: Monday, November 28, 2011 5:39 PM
>             To: postgis-users at postgis. refractions.net
>             <mailto:postgis-users at postgis.refractions.net>
>             Subject: Re: [postgis-users] Geocoding cross streets?
>
>             On 11/28/2011 5:28 PM, Aren Cambre wrote:
>
>                 I think that *geocode_intersection* function would be
>                 perfect!
>
>                 I just entered an enhancement request at
>                 http://trac.osgeo.org/postgis/ ticket/1333
>                 <http://trac.osgeo.org/postgis/ticket/1333>.
>
>                 I totally understand about merging into the existing
>
>             *geocode* function.
>
>                 A counter-strategy might be to require the *&* symbol?
>                 But if you're
>
>
>             This is actually not a good idea from the point of view that
>             the Tiger data does have street names the contain an&
>             character like "B&  O", "Tom&  Ann" or something like that,
>
>             and others. I already did this analysis when looking at PAGC
>             geocoder and Tiger data. You will also fine the word "and" in
>             some street names so that is not good as a separator. In PAGC
>             I arbitrarily pick the '@' character as it is not used in the
>             Tiger data and it reads as "street a (at) street b" which
>             seems as good as any definition for an intersection.
>
>             Thanks,
>                 -Steve W
>
>                 requiring that, then seems like it wouldn't be much more
>
>             work for the
>
>                 developer to split into cross streets rather than having
>                 postgis
>                 figure that out upon every geocode.
>
>                 Aren
>
>                 On Mon, Nov 28, 2011 at 4:08 PM, Paragon
>                 Corporation<lr at pcorp.us <mailto:lr at pcorp.us>
>                 <mailto:lr at pcorp.us <mailto:lr at pcorp.us>>>  wrote:
>
>                      It doesn't geocode cross streets or if it is its share
>
>             accident.  I
>
>                      think what it's doing is just picking the first one
>
>             most likely so
>
>                      you are getting at the beginning of a street with that
>
>             name and it's
>
>                      ignoring the second street at best.
>                      The cross streets feature takes a different algorithm.
>
>             We do have
>
>                      that coded as a sub process in one of our projects,
>                 but it's not
>                      committed in tiger geocoder.  Feel free to post a
>                 ticket under
>                      tiger_geocoder
>                      if you are interested  in seeing it incorporated into
>
>             tiger geocoder.
>
>                 http://trac.osgeo.org/postgis/
>                      Right now what we have can be relatively easily
>                 incorporated in
>                      tiger geocoder to be a function of the form:
>                      geocode_intersection(roadway1, roadway2, city,
>                 state, zip)
>                      Would that work for you?  I would hesitate to try to
>
>             merge into the
>
>                      existing geocode function since I'm not sure how much
>
>             unnecessary
>
>                      processing that would add if people know they aren't
>
>             dealing with
>
>                      cross street addresses.
>                      Thanks,
>                      Leo and Regina
>                 http://www.postgis.us
>
>                          *From:* postgis-users-bounces at postgis.
>                 refractions.net
>                 <mailto:postgis-users-bounces at postgis.refractions.net>
>                 <mailto:postgis-users-bounces@ postgis.refractions.net
>                 <mailto:postgis-users-bounces at postgis.refractions.net>>
>                          [mailto:postgis-users-bounces@
>                 postgis.refractions.net
>                 <mailto:postgis-users-bounces at postgis.refractions.net>
>                 <mailto:postgis-users-bounces@ postgis.refractions.net
>                 <mailto:postgis-users-bounces at postgis.refractions.net>>] *On
>                          Behalf Of *Aren Cambre
>                          *Sent:* Monday, November 28, 2011 3:14 PM
>                          *To:* PostGIS Users Discussion
>                          *Subject:* Re: [postgis-users] Geocoding cross
>                 streets?
>
>                          Hey, thanks!
>
>                          I used this query:
>
>                          *SELECT g.rating, ST_X(geomout) AS lon,
>
>             ST_Y(geomout) AS lat,
>
>                          (addy).* FROM geocode('XXXX') as g;*
>                          *
>                          *
>                          where *XXXX* is replaced with strings like:
>
>                            * *erin and tralee, dallas, tx*
>                            * *erin&  tralee, dallas, tx*
>                            * *sagecanyon&  sagegreen, houston, tx*
>
>
>                          Those produce lat/longs that are a few miles from
>
>             the correct
>
>                          locations.
>                          *
>                          *
>                          Aren
>
>                          On Mon, Nov 28, 2011 at 1:33 PM, Johnathan Leppert
>                 <johnathan.leppert at gmail.com
>                 <mailto:johnathan.leppert at gmail.com>
>                 <mailto:johnathan.leppert@ gmail.com
>                 <mailto:johnathan.leppert at gmail.com>>>  wrote:
>
>                              Cross-streets should be supported. Can you
>
>             supply your exact
>
>                              query and what versions of PostGIS and geocoder
>
>             you are using?
>
>
>                              Johnathan
>
>                              On Mon, Nov 28, 2011 at 9:26 AM, Aren Cambre
>                 <aren at arencambre.com <mailto:aren at arencambre.com>
>
>             <mailto:aren at arencambre.com <mailto:aren at arencambre.com>>>
>               wrote:
>
>
>                                  I have the TIGER geocoder running with
>
>             PostGIS 2.0 as
>
>                                  per
>
>             http://www.letseehere.com/ postgis-geocoder-using-tiger-
>             2010-data
>             <http://www.letseehere.com/postgis-geocoder-using-tiger-2010-data>.
>
>
>
>                                  It seems to do well finding street
>                 addresses, but it
>                                  can't seem to find cross streets. For
>                 example, if I
>                                  geocode *sagecanyon and sagegreen, houston,
>
>             tx*, I get a
>
>                                  location on the other side of town. Here's
>
>             a Google Map
>
>                                  showing both: http://g.co/maps/nphp9
>
>                                  Can I even use the TIGER geocoder for
>                 cross streets?
>
>                                  Aren
>
>                                  ______________________________
>                 _________________
>                                  postgis-users mailing list
>                 postgis-users at postgis. refractions.net
>                 <mailto:postgis-users at postgis.refractions.net>
>                 <mailto:postgis-users at postgis. refractions.net
>                 <mailto:postgis-users at postgis.refractions.net>>
>
>                 http://postgis.refractions.
>                 net/mailman/listinfo/postgis- users
>                 <http://postgis.refractions.net/mailman/listinfo/postgis-users>
>
>
>
>
>                              --
>                              /Johnathan /
>                              Software Engineer
>                              San Francisco,  California
>                              /Follow me on Twitter: @iamleppert
>                 <http://twitter.com/#!/ iamleppert
>                 <http://twitter.com/#!/iamleppert>>  /
>
>
>                              ______________________________
>                 _________________
>                              postgis-users mailing list
>                 postgis-users at postgis. refractions.net
>                 <mailto:postgis-users at postgis.refractions.net>
>                 <mailto:postgis-users at postgis. refractions.net
>                 <mailto:postgis-users at postgis.refractions.net>>
>
>                 http://postgis.refractions.
>                 net/mailman/listinfo/postgis- users
>                 <http://postgis.refractions.net/mailman/listinfo/postgis-users>
>
>
>
>                      ______________________________ _________________
>                      postgis-users mailing list
>                 postgis-users at postgis. refractions.net
>                 <mailto:postgis-users at postgis.refractions.net>
>                 <mailto:postgis-users at postgis. refractions.net
>                 <mailto:postgis-users at postgis.refractions.net>>
>                 http://postgis.refractions.
>                 net/mailman/listinfo/postgis- users
>                 <http://postgis.refractions.net/mailman/listinfo/postgis-users>
>
>
>
>
>                 ______________________________ _________________
>                 postgis-users mailing list
>                 postgis-users at postgis. refractions.net
>                 <mailto:postgis-users at postgis.refractions.net>
>                 http://postgis.refractions.
>                 net/mailman/listinfo/postgis- users
>                 <http://postgis.refractions.net/mailman/listinfo/postgis-users>
>
>
>             ______________________________ _________________
>             postgis-users mailing list
>             postgis-users at postgis. refractions.net
>             <mailto:postgis-users at postgis.refractions.net>
>             http://postgis.refractions. net/mailman/listinfo/postgis-
>             users
>             <http://postgis.refractions.net/mailman/listinfo/postgis-users>
>
>
>
>         ______________________________ _________________
>         postgis-users mailing list
>         postgis-users at postgis. refractions.net
>         <mailto:postgis-users at postgis.refractions.net>
>         http://postgis.refractions. net/mailman/listinfo/postgis- users
>         <http://postgis.refractions.net/mailman/listinfo/postgis-users>
>
>
>     ______________________________ _________________
>     postgis-users mailing list
>     postgis-users at postgis. refractions.net
>     <mailto:postgis-users at postgis.refractions.net>
>     http://postgis.refractions. net/mailman/listinfo/postgis- users
>     <http://postgis.refractions.net/mailman/listinfo/postgis-users>
>
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list