]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 11 Apr 2014 20:30:15 +0000 (22:30 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 11 Apr 2014 20:30:15 +0000 (22:30 +0200)
1  2 
sql/functions.sql

diff --combined sql/functions.sql
index f6b221f9f76a9f8fb4adc18c1fb439cb68e179a3,96e4d6983230aaf4c8d7a60a441af5ee6ed546a8..21d037170744bd59289066a4bc5a8b9a13f5fba6
@@@ -922,11 -922,6 +922,11 @@@ DECLAR
  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;
      ELSEIF NEW.class = 'waterway' AND NEW.name is NULL THEN
        RETURN NULL;
      ELSEIF NEW.class = 'waterway' THEN
-       NEW.rank_address := 17;
+       NEW.rank_search := 17;
+       NEW.rank_address := 0;
      ELSEIF NEW.class = 'highway' AND NEW.osm_type != 'N' AND NEW.type in ('service','cycleway','path','footway','steps','bridleway','motorway_link','primary_link','trunk_link','secondary_link','tertiary_link') THEN
        NEW.rank_search := 27;
        NEW.rank_address := NEW.rank_search;
@@@ -1991,15 -1987,18 +1992,18 @@@ LANGUAGE plpgsql
  CREATE OR REPLACE FUNCTION place_delete() RETURNS TRIGGER
    AS $$
  DECLARE
-   placeid BIGINT;
+   has_rank BOOLEAN;
  BEGIN
  
    --DEBUG: RAISE WARNING 'delete: % % % %',OLD.osm_type,OLD.osm_id,OLD.class,OLD.type;
  
    -- deleting large polygons can have a massive effect on the system - require manual intervention to let them through
    IF st_area(OLD.geometry) > 2 and st_isvalid(OLD.geometry) THEN
-     insert into import_polygon_delete values (OLD.osm_type,OLD.osm_id,OLD.class,OLD.type);
-     RETURN NULL;
+     SELECT bool_or(not (rank_address = 0 or rank_address > 26)) as ranked FROM placex WHERE osm_type = OLD.osm_type and osm_id = OLD.osm_id and class = OLD.class and type = OLD.type INTO has_rank;
+     IF has_rank THEN
+       insert into import_polygon_delete values (OLD.osm_type,OLD.osm_id,OLD.class,OLD.type);
+       RETURN NULL;
+     END IF;
    END IF;
  
    -- mark for delete
@@@ -2031,11 -2030,6 +2035,11 @@@ BEGI
      --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
      END IF;
  
    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, '')