w := getorcreate_word_id(s);
- IF NOT (ARRAY[w] <@ result) THEN
+ IF w IS NOT NULL AND NOT (ARRAY[w] <@ result) THEN
result := result || w;
END IF;
w := getorcreate_word_id(s);
- IF NOT (ARRAY[w] <@ result) THEN
+ IF w IS NOT NULL AND NOT (ARRAY[w] <@ result) THEN
result := result || w;
END IF;
BEGIN
--DEBUG: RAISE WARNING '% %',NEW.osm_type,NEW.osm_id;
- -- just block these
- IF NEW.class = 'highway' and NEW.type in ('turning_circle','traffic_signals','mini_roundabout','noexit','crossing') THEN
--- RAISE WARNING 'bad highway %',NEW.osm_id;
- RETURN null;
+ -- 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;
RETURN null;
return NULL;
END IF;
NEW.rank_search := NEW.admin_level * 2;
- NEW.rank_address := NEW.rank_search;
+ IF NEW.type = 'administrative' THEN
+ NEW.rank_address := NEW.rank_search;
+ ELSE
+ NEW.rank_address := 0;
+ END IF;
ELSEIF NEW.class = 'landuse' AND ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') THEN
NEW.rank_search := 22;
NEW.rank_address := NEW.rank_search;
--DEBUG: RAISE WARNING '%', existingplacex;
END IF;
- -- Just block these - lots and pointless
- IF NEW.class = 'highway' and NEW.type in ('turning_circle','traffic_signals','mini_roundabout','noexit','crossing') THEN
- RETURN null;
+ -- 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
RETURN null;
END IF;
IF existingplacex.osm_type IS NULL THEN
IF existing.osm_type IS NOT NULL THEN
+ -- pathological case caused by the triggerless copy into place during initial import
+ -- force delete even for large areas, it will be reinserted later
+ UPDATE place set geometry = ST_SetSRID(ST_Point(0,0), 4326) where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type;
DELETE from place where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type;
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, '')
OR coalesce(existing.housenumber, '') != coalesce(NEW.housenumber, '')
country_code = NEW.country_code,
parent_place_id = null,
extratags = NEW.extratags,
- admin_level = NEW.admin_level,
+ admin_level = CASE WHEN NEW.admin_level > 15 THEN 15 ELSE NEW.admin_level END,
indexed_status = 2,
geometry = NEW.geometry
where place_id = existingplacex.place_id;