]> granicus.if.org Git - postgis/commitdiff
#1068 partial fix -- trimmed leading/trailing spaces in normalize_address fields...
authorRegina Obe <lr@pcorp.us>
Tue, 28 Jun 2011 01:27:03 +0000 (01:27 +0000)
committerRegina Obe <lr@pcorp.us>
Tue, 28 Jun 2011 01:27:03 +0000 (01:27 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7507 b70326c6-7e19-0410-871a-916f4a2858ee

extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql

index 35eb7d656cca5aa16e5df7b1fc6ff03de4567b8d..c8582e5da360047ae7c0c55d8622f3136df62d16 100644 (file)
@@ -259,7 +259,7 @@ BEGIN
 
   IF result.location IS NULL THEN
     -- If the internal address is given, the location is everything after it.
-    result.location := substring(fullStreet, result.internal || ws || '+(.*)$');
+    result.location := trim(substring(fullStreet, result.internal || ws || '+(.*)$'));
   END IF;
 
   IF debug_flag THEN
@@ -291,13 +291,13 @@ BEGIN
         IF position(rec.given IN fullStreet) < position(result.internal IN fullStreet) THEN
           IF tempInt < position(rec.given IN fullStreet) THEN
             streetType := rec.given;
-            result.streetTypeAbbrev := rec.abbrev;
+            result.streetTypeAbbrev := trim(rec.abbrev);
             tempInt := position(rec.given IN fullStreet);
           END IF;
         END IF;
       ELSIF tempInt < position(rec.given IN fullStreet) THEN
         streetType := rec.given;
-        result.streetTypeAbbrev := rec.abbrev;
+        result.streetTypeAbbrev := trim(rec.abbrev);
         tempInt := position(rec.given IN fullStreet);
       END IF;
     END LOOP;
@@ -337,7 +337,7 @@ BEGIN
              tempString ILIKE '%' || name || '%'  
             ORDER BY length(name) DESC LIMIT 1;
           IF tempString IS NOT NULL THEN
-            result.postDirAbbrev = tempString;
+            result.postDirAbbrev = trim(tempString);
           END IF;
       END IF;
     END IF;
@@ -358,9 +358,9 @@ BEGIN
       result.preDirAbbrev := abbrev FROM direction_lookup
           where reducedStreet ILIKE '%' || name '%' AND texticregexeq(reducedStreet, '(?i)(^' || name || ')' || ws)
           ORDER BY length(name) DESC LIMIT 1;
-      result.streetName := substring(reducedStreet, '^' || preDir || ws || '(.*)');
+      result.streetName := trim(substring(reducedStreet, '^' || preDir || ws || '(.*)'));
     ELSE
-      result.streetName := reducedStreet;
+      result.streetName := trim(reducedStreet);
     END IF;
 
     IF texticregexeq(result.location, '(?i)' || result.internal || '$') THEN
@@ -492,10 +492,10 @@ BEGIN
           result.preDirAbbrev := abbrev FROM direction_lookup WHERE
               reducedStreet ILIKE '%' || name || '%' AND texticregexeq(reducedStreet, '(?i)(^' || name || ')' || ws)
               ORDER BY length(name) DESC;
-          result.streetName := substring(reducedStreet, '^' || preDir || ws
-                     || '+(.*)');
+          result.streetName := trim(substring(reducedStreet, '^' || preDir || ws
+                     || '+(.*)'));
         ELSE
-          result.streetName := reducedStreet;
+          result.streetName := trim(reducedStreet);
         END IF;
       ELSIF tempInt > 1 THEN
         -- Multiple postDir candidates were found.  We need to find the last