--$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
)
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,