</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
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
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
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