From 5e6a9638a8f92449b8aa24e054f8e33f3136481a Mon Sep 17 00:00:00 2001 From: Datendelphin Date: Sun, 15 Apr 2012 23:05:31 +0200 Subject: [PATCH] only calculate country for search ranks country and below --- sql/functions.sql | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sql/functions.sql b/sql/functions.sql index 5c4e9f2d..7a68718e 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -909,7 +909,12 @@ BEGIN NEW.place_id := nextval('seq_place'); NEW.indexed_status := 1; --STATUS_NEW - NEW.country_code := lower(get_country_code(NEW.geometry, NEW.country_code)); + IF NEW.rank_search >= 4 THEN + NEW.country_code := lower(get_country_code(NEW.geometry, NEW.country_code)); + ELSE + NEW.country_code := NULL; + END IF; + NEW.partition := get_partition(NEW.geometry, NEW.country_code); NEW.geometry_sector := geometry_sector(NEW.partition, NEW.geometry); @@ -1252,8 +1257,12 @@ BEGIN END IF; -- reclaculate country and partition (should probably have a country_code and calculated_country_code as seperate fields) - SELECT country_code from place where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type INTO NEW.country_code; - NEW.country_code := lower(get_country_code(NEW.geometry, NEW.country_code)); + IF NEW.rank_search >= 4 THEN + SELECT country_code from place where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type INTO NEW.country_code; + NEW.country_code := lower(get_country_code(NEW.geometry, NEW.country_code)); + ELSE + NEW.country_code := NULL; + END IF; NEW.partition := get_partition(NEW.geometry, NEW.country_code); NEW.geometry_sector := geometry_sector(NEW.partition, NEW.geometry); -- 2.39.5