X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/1879cf902c8271b8f5e15a8272adebe3c0d10193..e1dc4379e0cd100200ac53752442143ca4846fc5:/lib-sql/functions/placex_triggers.sql diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index 386140f4..9d0d73b5 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -481,24 +481,20 @@ BEGIN name_vector := array_merge(name_vector, hnr_vector); END IF; - IF is_place_addr THEN - addr_place_ids := token_addr_place_search_tokens(token_info); - IF not addr_place_ids <@ parent_name_vector THEN - -- make sure addr:place terms are always searchable - nameaddress_vector := array_merge(nameaddress_vector, addr_place_ids); - -- If there is a housenumber, also add the place name as a name, - -- so we can search it by the usual housenumber+place algorithms. - IF hnr_vector is not null THEN - name_vector := array_merge(name_vector, addr_place_ids); - END IF; - END IF; - END IF; - -- Cheating here by not recomputing all terms but simply using the ones -- from the parent object. nameaddress_vector := array_merge(nameaddress_vector, parent_name_vector); nameaddress_vector := array_merge(nameaddress_vector, parent_address_vector); + -- make sure addr:place terms are always searchable + IF is_place_addr THEN + addr_place_ids := token_addr_place_search_tokens(token_info); + IF hnr_vector is not null AND not addr_place_ids <@ parent_name_vector + THEN + name_vector := array_merge(name_vector, hnr_vector); + END IF; + nameaddress_vector := array_merge(nameaddress_vector, addr_place_ids); + END IF; END; $$ LANGUAGE plpgsql; @@ -672,7 +668,7 @@ BEGIN NEW.place_id := nextval('seq_place'); NEW.indexed_status := 1; --STATUS_NEW - NEW.centroid := ST_PointOnSurface(NEW.geometry); + NEW.centroid := get_center_point(NEW.geometry); NEW.country_code := lower(get_country_code(NEW.centroid)); NEW.partition := get_partition(NEW.country_code); @@ -731,10 +727,12 @@ BEGIN {% if not disable_diff_updates %} -- The following is not needed until doing diff updates, and slows the main index process down - IF NEW.rank_address > 0 THEN + IF NEW.rank_address between 2 and 27 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 + IF (NEW.rank_address < 26 and st_area(NEW.geometry) < 1) + OR (NEW.rank_address >= 26 and st_area(NEW.geometry) < 0.01) + THEN -- mark items within the geometry for re-indexing -- RAISE WARNING 'placex poly insert: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type; @@ -749,9 +747,11 @@ BEGIN or name is not null or (NEW.rank_address >= 16 and address ? 'place')); END IF; - ELSE + ELSEIF ST_GeometryType(NEW.geometry) not in ('ST_LineString', 'ST_MultiLineString') + OR ST_Length(NEW.geometry) < 0.5 + THEN -- mark nearby items for re-indexing, where 'nearby' depends on the features rank_search and is a complete guess :( - diameter := update_place_diameter(NEW.rank_search); + diameter := update_place_diameter(NEW.rank_address); 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 @@ -870,7 +870,7 @@ BEGIN END IF; -- Compute a preliminary centroid. - NEW.centroid := ST_PointOnSurface(NEW.geometry); + NEW.centroid := get_center_point(NEW.geometry); -- recalculate country and partition IF NEW.rank_search = 4 AND NEW.address is not NULL AND NEW.address ? 'country' THEN @@ -1265,6 +1265,8 @@ BEGIN END IF; ELSEIF NEW.rank_address > 25 THEN max_rank := 25; + ELSEIF NEW.class in ('place','boundary') and NEW.type in ('postcode','postal_code') THEN + max_rank := NEW.rank_search; ELSE max_rank := NEW.rank_address; END IF; @@ -1401,6 +1403,8 @@ BEGIN {% if debug %}RAISE WARNING 'placex_delete:12 % %',OLD.osm_type,OLD.osm_id;{% endif %} + UPDATE location_postcode SET indexed_status = 2 WHERE parent_place_id = OLD.place_id; + RETURN OLD; END;