]> granicus.if.org Git - postgis/commitdiff
#2958 reverse_geocode erroring ERROR: invalid input syntax for type numeric: " "
authorRegina Obe <lr@pcorp.us>
Tue, 7 Oct 2014 13:38:49 +0000 (13:38 +0000)
committerRegina Obe <lr@pcorp.us>
Tue, 7 Oct 2014 13:38:49 +0000 (13:38 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13039 b70326c6-7e19-0410-871a-916f4a2858ee

extras/tiger_geocoder/tiger_2011/geocode/reverse_geocode.sql

index 53dcb68a939fc133e89ba5858cadc286b09eab27..158a0a4c49e84e59dcf655091c565947ec235de8 100644 (file)
@@ -1,7 +1,7 @@
 --$Id$
  /*** 
  * 
- * Copyright (C) 2011-2012 Regina Obe and Leo Hsu (Paragon Corporation)
+ * Copyright (C) 2011-2014 Regina Obe and Leo Hsu (Paragon Corporation)
  **/
 -- This function given a point try to determine the approximate street address (norm_addy form)
 -- and array of cross streets, as well as interpolated points along the streets
@@ -124,8 +124,8 @@ BEGIN
                                )
                SELECT * 
                FROM (SELECT DISTINCT ON(tlid,side)  foo.fullname, foo.predirabrv, foo.streetname, foo.streettypeabbrev, foo.zip,  foo.center_pt,
-                         side, to_number(fromhn, ''999999'') As fromhn, to_number(tohn, ''999999'') As tohn, ST_GeometryN(ST_Multi(line),1) As line
-                          dist
+                         side, to_number(CASE WHEN trim(fromhn) ~ ''^[0-9]+$'' THEN fromhn ELSE ''0'' END,''99999999'')  As fromhn, to_number(CASE WHEN trim(tohn) ~ ''^[0-9]+$'' THEN tohn ELSE ''0'' END,''99999999'') As tohn
+                         ST_GeometryN(ST_Multi(line),1) As line, dist
                FROM 
                  (SELECT e.tlid, e.the_geom As line, n.fullname, COALESCE(n.prequalabr || '' '','''')  || n.name AS streetname, n.predirabrv, COALESCE(suftypabrv, pretypabrv) As streettypeabbrev,
                      n.sufdirabrv, e.zip, e.side, e.fromhn, e.tohn , e.center_pt,