]> granicus.if.org Git - postgis/commitdiff
Fix for #1086 Issue with parsing out location. also added to regression tests
authorRegina Obe <lr@pcorp.us>
Fri, 1 Jul 2011 02:22:27 +0000 (02:22 +0000)
committerRegina Obe <lr@pcorp.us>
Fri, 1 Jul 2011 02:22:27 +0000 (02:22 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7531 b70326c6-7e19-0410-871a-916f4a2858ee

extras/tiger_geocoder/tiger_2010/normalize/location_extract.sql
extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql
extras/tiger_geocoder/tiger_2010/normalize/state_extract.sql
extras/tiger_geocoder/tiger_2010/regress/normalize_address_regress
extras/tiger_geocoder/tiger_2010/regress/normalize_address_regress.sql

index b855303a835b3eaeba6b69d424e11065d4192f14..dc62f6c44a5a014eb58aa6abbb10c6faa53aa5b3 100644 (file)
@@ -31,7 +31,7 @@ BEGIN
   ws := E'[ ,.\n\f\t]';
 
   IF stateAbbrev IS NOT NULL THEN
-    lstate := statefp FROM state WHERE state.stusps = stateAbbrev;
+    lstate := statefp FROM state_lookup WHERE abbrev = stateAbbrev;
   END IF;
   lstate := COALESCE(lstate,'');
 
index 8b3185563d92542e6a64a10fe4aafdcadb9dee05..f07459fe27e015f1db1c751ecd38efaaf6fc5281 100644 (file)
@@ -128,6 +128,9 @@ BEGIN
   IF zipString IS NOT NULL THEN
     fullStreet := substring(rawInput from '(.*)'
         || ws || '+' || cull_null(zipString) || '[- ]?([0-9]{4})?$');
+    /** strip off any trailing  spaces or ,**/
+    fullStreet :=  btrim(fullStreet, ',');
+    
   ELSE
     fullStreet := rawInput;
   END IF;
index a599f9f6a4b9994e2eb58030e1346685c31b0442..d616a5f55e6bbf4e82a7fa05ff6e420a10c95a66 100644 (file)
@@ -26,7 +26,8 @@ BEGIN
   -- this is to handle case where people use , instead of space to separate state and zip
   -- such as '2450 N COLORADO ST, PHILADELPHIA, PA, 19132' instead of '2450 N COLORADO ST, PHILADELPHIA, PA 19132'
   
-  tempString := regexp_replace(rawInput, E'(.*)' || ws || '+', E'\\1');
+  --tempString := regexp_replace(rawInput, E'(.*)' || ws || '+', E'\\1');
+  tempString := btrim(rawInput, ', ');
   -- Separate out the last word of the state, and use it to compare to
   -- the state lookup table to determine the entire name, as well as the
   -- abbreviation associated with it.  The zip code may or may not have
index 9b406a8c388f2f64cff4a403d243e297c753ba9d..4ab88ffe2bb714bb85ad846ce3cc79b910916e43 100644 (file)
@@ -2,7 +2,7 @@
 
      529 |              | Main       | St               |               |          | Boston   | MA          | 02129 | t
 
-     529 |              | Main       | St               |               |          | Boston,MA |             | 02129 | t
+     529 |              | Main       | St               |               |          | Boston   | MA          | 02129 | t
 
      529 |              | Main       | St               |               |          | Boston   | MA          |     | t
 
@@ -12,3 +12,7 @@
 
      212 |              | 3rd        | Ave              | N             |          | MINNEAPOLIS | MN          | 55401 | t
 
+     949 | N            | 3rd        | St               |               |          | New Hyde Park | NY          | 11040 | t
+
+     949 | N            | 3rd        | St               |               |          | New Hyde Park | NY          | 11040 | t
+
index 8381090c2e29b143a5f08342c591e911f90fcd33..9c805315febd80a2a68b01e9a1ab17c4c130a9c6 100644 (file)
@@ -12,4 +12,10 @@ SELECT * FROM normalize_address('529 Main Street, Boston, MA 021');
 -- Mangled zipcodes
 SELECT * FROM normalize_address('212 3rd Ave N, MINNEAPOLIS, MN 553404');
 SELECT * FROM normalize_address('212 3rd Ave N, MINNEAPOLIS, MN 55401-');
+
+-- comma in wrong position
+SELECT * FROM normalize_address('949 N 3rd St, New Hyde Park, NY, 11040');
+
+-- comma in right position --
+SELECT * FROM normalize_address('949 N 3rd St, New Hyde Park, NY 11040');
 \timing
\ No newline at end of file