]> granicus.if.org Git - postgis/commitdiff
Fix typo in tiger manual and fix for #887 -- it was really the issue of using ,...
authorRegina Obe <lr@pcorp.us>
Mon, 4 Apr 2011 16:25:48 +0000 (16:25 +0000)
committerRegina Obe <lr@pcorp.us>
Mon, 4 Apr 2011 16:25:48 +0000 (16:25 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7005 b70326c6-7e19-0410-871a-916f4a2858ee

doc/extras_tigergeocoder.xml
extras/tiger_geocoder/tiger_2010/normalize/location_extract.sql
extras/tiger_geocoder/tiger_2010/normalize/state_extract.sql

index 11f00bc98fbb17e706337ca4fa3e31ebc057a649..5a4ff2ca2dddc87f0a79a47f36174a04948c1f5e 100644 (file)
@@ -366,7 +366,7 @@ wget http://www2.census.gov/geo/pvs/tiger2010st/44_Rhode_Island/ --no-parent --r
                </programlisting>
                
                <para>Pretty print address a table of addresses</para>
-               <programlisting>SELECT address As orig, pprint_addy(normalize_address(address)) As pretty_address;
+               <programlisting>SELECT address As orig, pprint_addy(normalize_address(address)) As pretty_address
         FROM addresses_to_geocode;
         
                         orig                         |              pretty_address
index 1e1e3f8b4d86a4fac62ad939a736db88781bba37..b42028eee5d2eafd0d636fb0544a6a703ef6ab91 100644 (file)
@@ -33,6 +33,7 @@ BEGIN
   IF stateAbbrev IS NOT NULL THEN\r
     lstate := statefp FROM state WHERE state.stusps = stateAbbrev;\r
   END IF;\r
+  lstate := COALESCE(lstate,'');\r
 \r
   street_array := regexp_split_to_array(fullStreet,ws);\r
   word_count := array_upper(street_array,1);\r
@@ -41,7 +42,7 @@ BEGIN
   FOR i IN 1..word_count LOOP\r
     CONTINUE WHEN street_array[word_count-i+1] IS NULL OR street_array[word_count-i+1] = '';\r
 \r
-    tempString := street_array[word_count-i+1] || tempString;\r
+    tempString := COALESCE(street_array[word_count-i+1],'') || tempString;\r
 \r
     stmt := ' SELECT'\r
          || '   1,'\r
index fb1da58dbcf36b51f78a1b7b3c6d7e05b38643d1..0a481a35d36051c226e107c6d648922106b94c9f 100644 (file)
@@ -18,14 +18,21 @@ DECLARE
   rec RECORD;\r
   test BOOLEAN;\r
   ws VARCHAR;\r
+  var_verbose boolean := false;\r
 BEGIN\r
   ws := E'[ ,.\t\n\f\r]';\r
 \r
+  -- If there is a trailing space or , get rid of it\r
+  -- this is to handle case where people use , instead of space to separate state and zip\r
+  -- such as '2450 N COLORADO ST, PHILADELPHIA, PA, 19132' instead of '2450 N COLORADO ST, PHILADELPHIA, PA 19132'\r
+  \r
+  tempString := regexp_replace(rawInput, E'(.*)' || ws || '+', E'\\1');\r
   -- Separate out the last word of the state, and use it to compare to\r
   -- the state lookup table to determine the entire name, as well as the\r
   -- abbreviation associated with it.  The zip code may or may not have\r
   -- been found.\r
-  tempString := substring(rawInput from ws || E'+([^ ,.\t\n\f\r0-9]*?)$');\r
+  tempString := substring(tempString from ws || E'+([^ ,.\t\n\f\r0-9]*?)$');\r
+  IF var_verbose THEN RAISE NOTICE 'state_extract rawInput: % tempString: %', rawInput, tempString; END IF;\r
   SELECT INTO tempInt count(*) FROM (select distinct abbrev from state_lookup\r
       WHERE upper(abbrev) = upper(tempString)) as blah;\r
   IF tempInt = 1 THEN\r