From: Regina Obe Date: Sat, 18 Jun 2011 22:16:54 +0000 (+0000) Subject: Fix for #1025 -- Geocoder Failing with NORTH EAST is street name X-Git-Tag: 2.0.0alpha1~1400 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fdc48741c1fafb9361eed76470e4bca31c7a750;p=postgis Fix for #1025 -- Geocoder Failing with NORTH EAST is street name git-svn-id: http://svn.osgeo.org/postgis/trunk@7426 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql b/extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql index 43bf38043..4e027103e 100644 --- a/extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql +++ b/extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql @@ -336,12 +336,12 @@ BEGIN tempString := substring(reducedStreet, '(?i)(^' || name || ')' || ws) FROM direction_lookup WHERE reducedStreet ILIKE '%' || name || '%' AND texticregexeq(reducedStreet, '(?i)(^' || name || ')' || ws) - ORDER BY length(name) DESC; + ORDER BY length(name) DESC LIMIT 1; IF tempString IS NOT NULL THEN preDir := tempString; result.preDirAbbrev := abbrev FROM direction_lookup where reducedStreet ILIKE '%' || name '%' AND texticregexeq(reducedStreet, '(?i)(^' || name || ')' || ws) - ORDER BY length(name) DESC; + ORDER BY length(name) DESC LIMIT 1; result.streetName := substring(reducedStreet, '^' || preDir || ws || '(.*)'); ELSE result.streetName := reducedStreet; @@ -354,7 +354,7 @@ BEGIN substring(result.location, '(?i)^(' || name || ')' || ws) as value FROM direction_lookup WHERE result.location ILIKE '%' || name || '%' AND texticregexeq(result.location, '(?i)^' - || name || ws) ORDER BY length(name) desc; + || name || ws) ORDER BY length(name) desc LIMIT 1; IF rec.value IS NOT NULL THEN postDir := rec.value; result.postDirAbbrev := rec.abbrev; @@ -374,11 +374,11 @@ BEGIN SELECT INTO tempString substring(result.location, '(?i)(^' || name || ')' || ws) FROM direction_lookup WHERE result.location ILIKE '%' || name || '%' AND texticregexeq(result.location, '(?i)(^' || name || ')' || ws) - ORDER BY length(name) desc; + ORDER BY length(name) desc LIMIT 1; IF tempString IS NOT NULL THEN postDir := tempString; SELECT INTO result.postDirAbbrev abbrev FROM direction_lookup - WHERE result.location ILIKE '%' || name || '%' AND texticregexeq(result.location, '(?i)(^' || name || ')' || ws); + WHERE result.location ILIKE '%' || name || '%' AND texticregexeq(result.location, '(?i)(^' || name || ')' || ws) ORDER BY length(name) DESC LIMIT 1; result.location := substring(result.location, '^' || postDir || ws || '+(.*)'); END IF; END IF; @@ -389,7 +389,7 @@ BEGIN || ws || '+(' || name || ')' || ws || '+' || result.internal) FROM direction_lookup WHERE fullStreet ILIKE '%' || name || '%' AND texticregexeq(fullStreet, '(?i)' - || ws || name || ws || '+' || result.internal) ORDER BY length(name) desc; + || ws || name || ws || '+' || result.internal) ORDER BY length(name) desc LIMIT 1; IF tempString IS NOT NULL THEN postDir := tempString; SELECT INTO result.postDirAbbrev abbrev FROM direction_lookup