From 8bc9ec02913a4f3b770f76a05b0b179e951db03c Mon Sep 17 00:00:00 2001 From: Schuyler Erle Date: Tue, 21 Jun 2011 21:46:58 +0000 Subject: [PATCH] Fix "San Francisco, CA" by not geocoding place names to unique-type ZIPs. --- lib/geocoder/us/database.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/geocoder/us/database.rb b/lib/geocoder/us/database.rb index cb2c026..82a9e58 100644 --- a/lib/geocoder/us/database.rb +++ b/lib/geocoder/us/database.rb @@ -178,8 +178,16 @@ def places_by_city (city, tokens, state) args = [city] + tokens.clone + [state] end metaphones = metaphone_placeholders_for tokens + # Addendum: Don't include unique or business ZIP codes when searching for + # addresses by place name, because weird things happen, like the point winding + # up out in the Pacific Ocean (thanks to the Farallons). Unlike unique ZIP codes, + # general ZIP codes have all been checked to ensure that they're actually within + # their ZCTA. + # execute("SELECT *, levenshtein(?, city) AS city_score - FROM place WHERE city_phone IN (#{metaphones}) #{and_state} order by priority desc;", *args) + FROM place WHERE city_phone IN (#{metaphones}) #{and_state} + AND status NOT IN ('U','B') + ORDER BY PRIORITY DESC;", *args) end # Generate an SQL query and set of parameters against the feature and range