]> git.openstreetmap.org Git - nominatim.git/blobdiff - sql/functions.sql
update osm2pgsql to latest version
[nominatim.git] / sql / functions.sql
index 236f5b9c2b338f7fdb2064b039a67ebcbc6fdfc3..035eaf901f2478d20d0ef395a3b7b0bd2461b966 100644 (file)
@@ -1068,6 +1068,9 @@ BEGIN
     ELSEIF NEW.class = 'landuse' AND ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') THEN
       NEW.rank_search := 22;
       NEW.rank_address := NEW.rank_search;
     ELSEIF NEW.class = 'landuse' AND ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') THEN
       NEW.rank_search := 22;
       NEW.rank_address := NEW.rank_search;
+    ELSEIF NEW.class = 'natural' and NEW.type in ('peak','volcano','mountain_range') THEN
+      NEW.rank_search := 18;
+      NEW.rank_address := 0;
     -- any feature more than 5 square miles is probably worth indexing
     ELSEIF ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_Area(NEW.geometry) > 0.1 THEN
       NEW.rank_search := 22;
     -- any feature more than 5 square miles is probably worth indexing
     ELSEIF ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_Area(NEW.geometry) > 0.1 THEN
       NEW.rank_search := 22;
@@ -1093,9 +1096,6 @@ BEGIN
       NEW.rank_address := NEW.rank_search;
     ELSEIF NEW.class = 'natural' and NEW.type in ('coastline') THEN
       RETURN NULL;
       NEW.rank_address := NEW.rank_search;
     ELSEIF NEW.class = 'natural' and NEW.type in ('coastline') THEN
       RETURN NULL;
-    ELSEIF NEW.class = 'natural' and NEW.type in ('peak','volcano') THEN
-      NEW.rank_search := 18;
-      NEW.rank_address := 0;
     END IF;
 
   END IF;
     END IF;
 
   END IF;
@@ -1699,21 +1699,24 @@ BEGIN
     IF array_upper(isin_tokens, 1) IS NOT NULL THEN
       FOR i IN 1..array_upper(isin_tokens, 1) LOOP
 --RAISE WARNING '  getNearestNamedFeature: % % % %',NEW.partition, place_centroid, search_maxrank, isin_tokens[i];
     IF array_upper(isin_tokens, 1) IS NOT NULL THEN
       FOR i IN 1..array_upper(isin_tokens, 1) LOOP
 --RAISE WARNING '  getNearestNamedFeature: % % % %',NEW.partition, place_centroid, search_maxrank, isin_tokens[i];
+        IF NOT ARRAY[isin_tokens[i]] <@ nameaddress_vector THEN
 
 
-        FOR location IN SELECT * from getNearestNamedFeature(NEW.partition, place_centroid, search_maxrank, isin_tokens[i]) LOOP
+          FOR location IN SELECT * from getNearestNamedFeature(NEW.partition, place_centroid, search_maxrank, isin_tokens[i]) LOOP
 
 
---RAISE WARNING '  ISIN: %',location;
+  --RAISE WARNING '  ISIN: %',location;
 
 
-          nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
-          INSERT INTO place_addressline VALUES (NEW.place_id, location.place_id, false, NOT address_havelevel[location.rank_address], location.distance, location.rank_address);
-          address_havelevel[location.rank_address] := true;
+            nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
+            INSERT INTO place_addressline VALUES (NEW.place_id, location.place_id, false, NOT address_havelevel[location.rank_address], location.distance, location.rank_address);
+            address_havelevel[location.rank_address] := true;
 
 
-          IF location.rank_address > parent_place_id_rank THEN
-            NEW.parent_place_id = location.place_id;
-            parent_place_id_rank = location.rank_address;
-          END IF;
+            IF location.rank_address > parent_place_id_rank THEN
+              NEW.parent_place_id = location.place_id;
+              parent_place_id_rank = location.rank_address;
+            END IF;
 
 
-        END LOOP;
+          END LOOP;
+
+        END IF;
 
       END LOOP;
     END IF;
 
       END LOOP;
     END IF;