]> git.openstreetmap.org Git - nominatim.git/commitdiff
skip is_in items already in address vector
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 29 Sep 2012 16:02:32 +0000 (18:02 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 29 Sep 2012 16:02:32 +0000 (18:02 +0200)
sql/functions.sql

index 236f5b9c2b338f7fdb2064b039a67ebcbc6fdfc3..2ba1b6fa6091d1fe2edf41f8a94350744951c1e8 100644 (file)
@@ -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 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;