]> git.openstreetmap.org Git - nominatim.git/blobdiff - sql/functions.sql
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / sql / functions.sql
index 057906fe3f2caee8d0be181ae063dd4d53e6f896..980528aecfec7becea0ff01b273c6216bf359cff 100644 (file)
@@ -922,6 +922,11 @@ DECLARE
 BEGIN
   --DEBUG: RAISE WARNING '% %',NEW.osm_type,NEW.osm_id;
 
+  -- remove operator tag for most places, messes too much with search_name indexes
+  IF NEW.class not in ('amenity', 'shop') THEN
+    NEW.name := delete(NEW.name, 'operator');
+  END IF;
+
   -- just block these
   IF NEW.class in ('landuse','natural') and NEW.name is null THEN
 --    RAISE WARNING 'empty landuse %',NEW.osm_id;
@@ -1600,17 +1605,13 @@ BEGIN
             END IF;
 
             -- merge in extra tags
-            IF NOT linkedPlacex.extratags IS NULL THEN
-              NEW.extratags := linkedPlacex.extratags || NEW.extratags;
-            END IF;
-
-            IF NOT NEW.extratags ? linkedPlacex.class THEN
-              NEW.extratags := NEW.extratags || hstore(linkedPlacex.class, linkedPlacex.type);
-            END IF;
+            NEW.extratags := hstore(linkedPlacex.class, linkedPlacex.type) || coalesce(linkedPlacex.extratags, ''::hstore) || coalesce(NEW.extratags, ''::hstore);
 
             -- mark the linked place (excludes from search results)
             UPDATE placex set linked_place_id = NEW.place_id where place_id = linkedPlacex.place_id;
 
+            -- keep a note of the node id in case we need it for wikipedia in a bit
+            linked_node_id := linkedPlacex.osm_id;
           END LOOP;
 
         END LOOP;
@@ -1639,13 +1640,7 @@ BEGIN
                 END IF;
 
                 -- merge in extra tags
-                IF NOT linkedPlacex.extratags IS NULL THEN
-                  NEW.extratags := linkedPlacex.extratags || NEW.extratags;
-                END IF;
-
-                IF NOT NEW.extratags ? linkedPlacex.class THEN
-                  NEW.extratags := NEW.extratags || hstore(linkedPlacex.class, linkedPlacex.type);
-                END IF;
+                NEW.extratags := hstore(linkedPlacex.class, linkedPlacex.type) || coalesce(linkedPlacex.extratags, ''::hstore) || coalesce(NEW.extratags, ''::hstore);
 
                 -- mark the linked place (excludes from search results)
                 UPDATE placex set linked_place_id = NEW.place_id where place_id = linkedPlacex.place_id;
@@ -1687,11 +1682,7 @@ BEGIN
           name_vector := make_keywords(NEW.name);
 
           -- merge in extra tags
-          NEW.extratags := linkedPlacex.extratags || NEW.extratags;
-
-          IF NOT NEW.extratags ? linkedPlacex.class THEN
-            NEW.extratags := NEW.extratags || hstore(linkedPlacex.class, linkedPlacex.type);
-          END IF;
+          NEW.extratags := hstore(linkedPlacex.class, linkedPlacex.type) || coalesce(linkedPlacex.extratags, ''::hstore) || coalesce(NEW.extratags, ''::hstore);
 
           -- mark the linked place (excludes from search results)
           UPDATE placex set linked_place_id = NEW.place_id where place_id = linkedPlacex.place_id;
@@ -2031,6 +2022,11 @@ BEGIN
     --DEBUG: RAISE WARNING '%', existingplacex;
   END IF;
 
+  -- remove operator tag for most places, messes too much with search_name indexes
+  IF NEW.class not in ('amenity', 'shop') THEN
+    NEW.name := delete(NEW.name, 'operator');
+  END IF;
+
   -- Just block these - lots and pointless
   IF NEW.class in ('landuse','natural') and NEW.name is null THEN
     -- if the name tag was removed, older versions might still be lurking in the place table
@@ -2221,6 +2217,12 @@ BEGIN
 
   END IF;
 
+  -- refuse to update multiplpoygons with too many objects, too much of a performance hit
+  IF ST_NumGeometries(NEW.geometry) > 2000 THEN
+    RAISE WARNING 'Dropping update of % % because of geometry complexity.', NEW.osm_type, NEW.osm_id;
+    RETURN NULL;
+  END IF;
+
   IF coalesce(existing.name::text, '') != coalesce(NEW.name::text, '')
      OR coalesce(existing.extratags::text, '') != coalesce(NEW.extratags::text, '')
      OR coalesce(existing.housenumber, '') != coalesce(NEW.housenumber, '')