suppress recursive updates for places that cannot appear in addresses

This commit is contained in:
Sarah Hoffmann
2014-04-11 22:57:00 +02:00
parent 496e1b0616
commit 488cd726ed

View File

@@ -1150,7 +1150,7 @@ BEGIN
END IF; END IF;
-- a country code make no sense below rank 4 (country) -- 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; NEW.calculated_country_code := NULL;
END IF; END IF;
@@ -1163,11 +1163,12 @@ BEGIN
RETURN NEW; -- @DIFFUPDATES@ The following is not needed until doing diff updates, and slows the main index process down RETURN NEW; -- @DIFFUPDATES@ The following is not needed until doing diff updates, and slows the main index process down
IF NEW.rank_address > 0 THEN
IF (ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_IsValid(NEW.geometry)) 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 -- Performance: We just can't handle re-indexing for country level changes
IF st_area(NEW.geometry) < 1 THEN IF st_area(NEW.geometry) < 1 THEN
-- mark items within the geometry for re-indexing -- mark items within the geometry for re-indexing
-- RAISE WARNING 'placex poly insert: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type; -- 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) -- 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)) update placex set indexed_status = 2 where (st_covers(NEW.geometry, placex.geometry) OR ST_Intersects(NEW.geometry, placex.geometry))
@@ -1197,7 +1198,7 @@ BEGIN
diameter := 0.001; -- 50 to 100 meters diameter := 0.001; -- 50 to 100 meters
END IF; END IF;
IF diameter > 0 THEN IF diameter > 0 THEN
-- RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter; -- RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter;
IF NEW.rank_search >= 26 THEN IF NEW.rank_search >= 26 THEN
-- roads may cause reparenting for >27 rank places -- 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); update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter);
@@ -1209,7 +1210,7 @@ BEGIN
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); 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;
END IF;
END IF; END IF;
-- add to tables for special search -- add to tables for special search