streetType := rec.given;
result.streetTypeAbbrev := rec.abbrev;
isHighway := rec.is_hw;
+ IF debug_flag THEN
+ RAISE NOTICE 'street Type: %, street Type abbrev: %', rec.given, rec.abbrev;
+ END IF;
ELSIF tempInt > 1 THEN
tempInt := 0;
FOR rec IN SELECT abbrev, substring(fullStreet, '(?i)' || ws || '?('
result.streetTypeAbbrev := rec.abbrev;
isHighway := rec.is_hw;
tempInt := position(rec.given IN fullStreet);
+ IF debug_flag THEN
+ RAISE NOTICE 'street Type: %, street Type abbrev: %', rec.given, rec.abbrev;
+ END IF;
END IF;
END LOOP;
END IF;
END IF;
IF tempString > '' AND result.location IS NOT NULL THEN
reducedStreet := tempString;
- result.streetName := trim(reducedStreet);
+ result.streetName := reducedStreet;
+ IF debug_flag THEN
+ RAISE NOTICE 'reduced Street: %', result.streetName;
+ END IF;
+ -- the post direction might be portion of fullStreet after reducedStreet
+ -- reducedStreet: 24 fullStreet: Country Road 24, N or fullStreet: Country Road 24 N
+ tempString := regexp_replace(fullStreet, streetType || ws || '+' || reducedStreet,'');
+ IF tempString > '' THEN
+ IF debug_flag THEN
+ RAISE NOTICE 'remove reduced street: % + streetType: % from fullstreet: %', reducedStreet, streetType, fullStreet;
+ END IF;
+ tempString := abbrev FROM direction_lookup WHERE
+ tempString ILIKE '%' || name || '%' AND texticregexeq(reducedStreet || ws || '+' || streetType, '(?i)(' || name || ')' || ws || '+|$')
+ ORDER BY length(name) DESC LIMIT 1;
+ IF tempString IS NOT NULL THEN
+ result.postDirAbbrev = trim(tempString);
+ IF debug_flag THEN
+ RAISE NOTICE 'postDirAbbre of highway: %', result.postDirAbbrev;
+ END IF;
+ END IF;
+ END IF;
ELSE
tempString := substring(fullStreet, streetType || ws ||
E'+([0-9][^ ,.\t\r\n\f]*?)' || ws);
reducedStreet := substring(fullStreet, '^(.*)' || ws || '+'
|| streetType);
END IF;
- -- the post direction might be portion of fullStreet after reducedStreet
- -- reducedStreet: Main fullStreet: Main St, N or fullStreet: Main St N
- tempString := trim(regexp_replace(fullStreet, reducedStreet || ws || '+' || streetType,''));
- IF tempString > '' THEN
- tempString := abbrev FROM direction_lookup WHERE
- tempString ILIKE '%' || name || '%' AND texticregexeq(reducedStreet || ws || '+' || streetType, '(?i)(' || name || ')' || ws || '+|$')
- ORDER BY length(name) DESC LIMIT 1;
- IF tempString IS NOT NULL THEN
- result.postDirAbbrev = trim(tempString);
- END IF;
- END IF;
-
-
- IF debug_flag THEN
- raise notice '% reduced street: %', clock_timestamp(), reducedStreet;
- END IF;
-
- -- The pre direction should be at the beginning of the fullStreet string.
- -- The post direction should be at the beginning of the location string
- -- if there is no internal address
- reducedStreet := trim(reducedStreet);
- tempString := trim(regexp_replace(fullStreet, ws || '+' || reducedStreet || ws || '+',''));
- IF tempString > '' THEN
- tempString := substring(reducedStreet, '(?i)(^' || name
- || ')' || ws) FROM direction_lookup WHERE
- reducedStreet ILIKE '%' || name || '%' AND texticregexeq(reducedStreet, '(?i)(^' || name || ')' || ws)
- ORDER BY length(name) DESC LIMIT 1;
- END IF;
- IF tempString > '' THEN
- preDir := tempString;
- 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 := trim(substring(reducedStreet, '^' || preDir || ws || '(.*)'));
- ELSE
- result.streetName := trim(reducedStreet);
- END IF;
+ -- the post direction might be portion of fullStreet after reducedStreet
+ -- reducedStreet: Main fullStreet: Main St, N or fullStreet: Main St N
+ tempString := trim(regexp_replace(fullStreet, reducedStreet || ws || '+' || streetType,''));
+ IF tempString > '' THEN
+ tempString := abbrev FROM direction_lookup WHERE
+ tempString ILIKE '%' || name || '%' AND texticregexeq(reducedStreet || ws || '+' || streetType, '(?i)(' || name || ')' || ws || '+|$')
+ ORDER BY length(name) DESC LIMIT 1;
+ IF tempString IS NOT NULL THEN
+ result.postDirAbbrev = trim(tempString);
+ END IF;
+ END IF;
+
+
+ IF debug_flag THEN
+ raise notice '% reduced street: %', clock_timestamp(), reducedStreet;
+ END IF;
+
+ -- The pre direction should be at the beginning of the fullStreet string.
+ -- The post direction should be at the beginning of the location string
+ -- if there is no internal address
+ reducedStreet := trim(reducedStreet);
+ tempString := trim(regexp_replace(fullStreet, ws || '+' || reducedStreet || ws || '+',''));
+ IF tempString > '' THEN
+ tempString := substring(reducedStreet, '(?i)(^' || name
+ || ')' || ws) FROM direction_lookup WHERE
+ reducedStreet ILIKE '%' || name || '%' AND texticregexeq(reducedStreet, '(?i)(^' || name || ')' || ws)
+ ORDER BY length(name) DESC LIMIT 1;
+ END IF;
+ IF tempString > '' THEN
+ preDir := tempString;
+ 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 := trim(substring(reducedStreet, '^' || preDir || ws || '(.*)'));
+ ELSE
+ result.streetName := trim(reducedStreet);
+ END IF;
END IF;
IF texticregexeq(result.location, '(?i)' || result.internal || '$') THEN
-- If the internal address is at the end of the location, then no
END IF;
END IF;
+ --get rid of extraneous spaces before we return
result.address := to_number(addressString, '99999999999');
- result.zip := zipString;
-
+ result.zip := trim(zipString);
+ result.streetName := trim(result.streetName);
+ result.location := trim(result.location);
+ result.postDirAbbrev := trim(result.postDirAbbrev);
result.parsed := TRUE;
RETURN result;
END
#1076b|16725 24, Plymouth, MN 55447|16725 County Road 24, Plymouth, MN 55447|POINT(-93.49326 45.02186)|25
#1076b|16725 24th Ave N, Plymouth, MN 55447|16725 County Road 24, Plymouth, MN 55447|POINT(-93.4927 45.00457)|27
#1076c|13800 9, Andover, MN 55304|13800 County Hwy 9, Andover, MN 55304|POINT(-93.35733 45.22052)|30
-#1076d|13800 9, Andover, MN 55304|13800 9, Andover, MN 55304|POINT(-93.35733 45.22052)|10
+#1076d|13800 9, Andover, MN 55304|13800 9, Andover, MN 55304|POINT(-93.35733 45.22052)|0
#1076e|3900 6, North Eastham, MA 02642|3900 Route 6, Eastham, Massachusetts 02642|POINT(-69.98743 41.85543)|15
-#1076f|1940 W C, Roseville, MN 55113|1940 County Road C W, Roseville, MN 55113|POINT(-93.18492 45.02058)|27
-#1076f|1940 C W, Roseville, MN 55113|1940 County Road C W, Roseville, MN 55113|POINT(-93.18492 45.02058)|27
+#1076f|1940 C W, Roseville, MN 55113|1940 County Road C W, Roseville, MN 55113|POINT(-93.18492 45.02058)|25
+#1076f|1940 W C, Roseville, MN 55113|1940 County Road C W, Roseville, MN 55113|POINT(-93.18492 45.02058)|29
#1076g|15709 Rockford Rd, Plymouth, MN 55447|15709 Rockford Road, Plymouth, MN 55447|POINT(-93.47898 45.02726)|0