From: Regina Obe Date: Tue, 15 Feb 2011 07:19:10 +0000 (+0000) Subject: document reverse_geocode X-Git-Tag: 2.0.0alpha1~1979 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9b86f6185a15a7908436e7e39ece3a9aa65f588;p=postgis document reverse_geocode git-svn-id: http://svn.osgeo.org/postgis/trunk@6821 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/extras_tigergeocoder.xml b/doc/extras_tigergeocoder.xml index 3269bc67f..2dd738860 100644 --- a/doc/extras_tigergeocoder.xml +++ b/doc/extras_tigergeocoder.xml @@ -360,5 +360,92 @@ UNZIPTOOL=unzip + + + + Reverse_Geocode + + Takes a geometry point in a known spatial ref sys and returns a record containing an array of possible addresses and an array of cross streets. If include_strnum_range = true, includes the street range in the cross streets. + + + + + + record Reverse_Gecode + geometry pt + geometry[] OUT intpt + norm_addy[] OUT addy + varchar[] OUT street + + + + + record Reverse_Gecode + geometry pt + boolean include_strnum_range + geometry[] OUT intpt + norm_addy[] OUT addy + varchar[] OUT street + + + + + + Description + + Takes a geometry point in a known spatial ref and returns a record containing an array of possible addresses and an array of cross streets. If include_strnum_range = true, includes the street range in the cross streets. + include_strnum_range defaults to false if not passed in. Addresses are sorted according to which road a point is closest to so first address is most likely the right one. + + + + Availability: 2.0.0 + + + + + Examples + Example of a point at the corner of two streets, but closest to one. This is approximate location of MIT: 77 Massachusetts Ave, Cambridge, MA 02139 + Note that although we don't have 3 streets, PostgreSQL will just return null for entries above our upper bound so safe to use. This includes street ranges + SELECT pprint_addy(r.addy[1]) As st1, pprint_addy(r.addy[2]) As st2, pprint_addy(r.addy[3]) As st3, array_to_string(r.street, ',') As cross_streets + FROM reverse_geocode(ST_GeomFromText('POINT(-71.093902 42.359446)',4269),true) As r; + + result + ------ + st1 | st2 | st3 | cross_streets +-------------------------------------------+-----+-----+---------------------------------------------- + 67 Massachusetts Ave, Cambridge, MA 02139 | | | 67 - 127 Massachusetts Ave,32 - 88 Vassar St + + Here we choose not to include the address ranges for the cross streets and picked a location +really really close to a corner of 2 streets thus could be known by two different addresses. +SELECT pprint_addy(r.addy[1]) As st1, pprint_addy(r.addy[2]) As st2, pprint_addy(r.addy[3]) As st3, +array_to_string(r.street, ',') As cross_str +FROM reverse_geocode(ST_GeomFromText('POINT(-71.06941 42.34225)',4269)) As r; + +result +-------- + st1 | st2 | st3 | cross_str +---------------------------------+---------------------------------+-----+------------------------ + 4 Bradford St, Boston, MA 02118 | 48 Waltham St, Boston, MA 02118 | | Bradford St,Waltham St + - +For this one we reuse our geocoded example from and we only want the primary address and at most 2 cross streets. +SELECT actual_addr, lon, lat, pprint_addy((rg).addy[1]) As int_addr1, (rg).street[1] As cross1, (rg).street[2] As cross2 +FROM (SELECT address As actual_addr, + reverse_geocode( ST_SetSRID(ST_Point(lon,lat),4326) ) As rg + FROM addresses_to_geocode WHERE rating IS NOT NULL) As foo; + + actual_addr | int_addr1 | cross1 | cross2 +----------------------------------------------+-------------------------------------------+-------------------+-------------- + 529 Main Street, Boston MA, 02129 | 538 Main St, Boston, MA 02129 | Main St | + 77 Massachusetts Avenue, Cambridge, MA 02139 | 59 Massachusetts Ave, Cambridge, MA 02139 | Massachusetts Ave | Wellesley St + + + + + See Also + + , + + + + \ No newline at end of file