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

diff --combined sql/functions.sql
index 21d037170744bd59289066a4bc5a8b9a13f5fba6,7b3a39cda9bee02b4d7ccaecaec4c9b40b9678f9..092aa8acdc5931efc1d14a37464579690299eed4
@@@ -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;
    END IF;
  
    -- a country code make no sense below rank 4 (country)
-   IF NEW.rank_address < 4 THEN
+   IF NEW.rank_search < 4 THEN
      NEW.calculated_country_code := NULL;
    END IF;
  
  
    RETURN NEW; -- @DIFFUPDATES@ The following is not needed until doing diff updates, and slows the main index process down
  
-   IF (ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_IsValid(NEW.geometry)) THEN
-     -- Performance: We just can't handle re-indexing for country level changes
-     IF st_area(NEW.geometry) < 1 THEN
-       -- mark items within the geometry for re-indexing
- --    RAISE WARNING 'placex poly insert: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;
-       -- work around bug in postgis, this may have been fixed in 2.0.0 (see http://trac.osgeo.org/postgis/ticket/547)
-       update placex set indexed_status = 2 where (st_covers(NEW.geometry, placex.geometry) OR ST_Intersects(NEW.geometry, placex.geometry)) 
-        AND rank_search > NEW.rank_search and indexed_status = 0 and ST_geometrytype(placex.geometry) = 'ST_Point' and (rank_search < 28 or name is not null or (NEW.rank_search >= 16 and addr_place is not null));
-       update placex set indexed_status = 2 where (st_covers(NEW.geometry, placex.geometry) OR ST_Intersects(NEW.geometry, placex.geometry)) 
-        AND rank_search > NEW.rank_search and indexed_status = 0 and ST_geometrytype(placex.geometry) != 'ST_Point' and (rank_search < 28 or name is not null or (NEW.rank_search >= 16 and addr_place is not null));
-     END IF;
-   ELSE
-     -- mark nearby items for re-indexing, where 'nearby' depends on the features rank_search and is a complete guess :(
-     diameter := 0;
-     -- 16 = city, anything higher than city is effectively ignored (polygon required!)
-     IF NEW.type='postcode' THEN
-       diameter := 0.05;
-     ELSEIF NEW.rank_search < 16 THEN
+   IF NEW.rank_address > 0 THEN
+     IF (ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_IsValid(NEW.geometry)) THEN
+       -- Performance: We just can't handle re-indexing for country level changes
+       IF st_area(NEW.geometry) < 1 THEN
+         -- mark items within the geometry for re-indexing
+   --    RAISE WARNING 'placex poly insert: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;
+         -- work around bug in postgis, this may have been fixed in 2.0.0 (see http://trac.osgeo.org/postgis/ticket/547)
+         update placex set indexed_status = 2 where (st_covers(NEW.geometry, placex.geometry) OR ST_Intersects(NEW.geometry, placex.geometry)) 
+          AND rank_search > NEW.rank_search and indexed_status = 0 and ST_geometrytype(placex.geometry) = 'ST_Point' and (rank_search < 28 or name is not null or (NEW.rank_search >= 16 and addr_place is not null));
+         update placex set indexed_status = 2 where (st_covers(NEW.geometry, placex.geometry) OR ST_Intersects(NEW.geometry, placex.geometry)) 
+          AND rank_search > NEW.rank_search and indexed_status = 0 and ST_geometrytype(placex.geometry) != 'ST_Point' and (rank_search < 28 or name is not null or (NEW.rank_search >= 16 and addr_place is not null));
+       END IF;
+     ELSE
+       -- mark nearby items for re-indexing, where 'nearby' depends on the features rank_search and is a complete guess :(
        diameter := 0;
-     ELSEIF NEW.rank_search < 18 THEN
-       diameter := 0.1;
-     ELSEIF NEW.rank_search < 20 THEN
-       diameter := 0.05;
-     ELSEIF NEW.rank_search = 21 THEN
-       diameter := 0.001;
-     ELSEIF NEW.rank_search < 24 THEN
-       diameter := 0.02;
-     ELSEIF NEW.rank_search < 26 THEN
-       diameter := 0.002; -- 100 to 200 meters
-     ELSEIF NEW.rank_search < 28 THEN
-       diameter := 0.001; -- 50 to 100 meters
-     END IF;
-     IF diameter > 0 THEN
- --      RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter;
-       IF NEW.rank_search >= 26 THEN
-         -- roads may cause reparenting for >27 rank places
-         update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter);
-       ELSEIF NEW.rank_search >= 16 THEN
-         -- up to rank 16, street-less addresses may need reparenting
-         update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter) and (rank_search < 28 or name is not null or addr_place is not null);
-       ELSE
-         -- for all other places the search terms may change as well
-         update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter) and (rank_search < 28 or name is not null);
+       -- 16 = city, anything higher than city is effectively ignored (polygon required!)
+       IF NEW.type='postcode' THEN
+         diameter := 0.05;
+       ELSEIF NEW.rank_search < 16 THEN
+         diameter := 0;
+       ELSEIF NEW.rank_search < 18 THEN
+         diameter := 0.1;
+       ELSEIF NEW.rank_search < 20 THEN
+         diameter := 0.05;
+       ELSEIF NEW.rank_search = 21 THEN
+         diameter := 0.001;
+       ELSEIF NEW.rank_search < 24 THEN
+         diameter := 0.02;
+       ELSEIF NEW.rank_search < 26 THEN
+         diameter := 0.002; -- 100 to 200 meters
+       ELSEIF NEW.rank_search < 28 THEN
+         diameter := 0.001; -- 50 to 100 meters
+       END IF;
+       IF diameter > 0 THEN
+   --      RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter;
+         IF NEW.rank_search >= 26 THEN
+           -- roads may cause reparenting for >27 rank places
+           update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter);
+         ELSEIF NEW.rank_search >= 16 THEN
+           -- up to rank 16, street-less addresses may need reparenting
+           update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter) and (rank_search < 28 or name is not null or addr_place is not null);
+         ELSE
+           -- for all other places the search terms may change as well
+           update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter) and (rank_search < 28 or name is not null);
+         END IF;
        END IF;
      END IF;
    END IF;
  
     -- add to tables for special search
@@@ -2035,11 -2031,6 +2036,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, '')