X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/1529666232c5d72813280c081a4dc086cd0f9910..4c9cfe2532273955619e7a651260c0e085c070e1:/sql/functions/placex_triggers.sql?ds=inline diff --git a/sql/functions/placex_triggers.sql b/sql/functions/placex_triggers.sql index 38b3421f..0102d2c8 100644 --- a/sql/functions/placex_triggers.sql +++ b/sql/functions/placex_triggers.sql @@ -92,7 +92,7 @@ BEGIN END IF; IF fallback THEN - IF ST_Area(bbox) < 0.01 THEN + IF ST_Area(bbox) < 0.005 THEN -- for smaller features get the nearest road SELECT getNearestRoadPlaceId(poi_partition, bbox) INTO parent_place_id; --DEBUG: RAISE WARNING 'Checked for nearest way (%)', parent_place_id; @@ -581,6 +581,15 @@ BEGIN RETURN NEW; END IF; + -- Postcodes are just here to compute the centroids. They are not searchable + -- unless they are a boundary=postal_code. + -- There was an error in the style so that boundary=postal_code used to be + -- imported as place=postcode. That's why relations are allowed to pass here. + -- This can go away in a couple of versions. + IF NEW.class = 'place' and NEW.type = 'postcode' and NEW.osm_type != 'R' THEN + RETURN NEW; + END IF; + -- Speed up searches - just use the centroid of the feature -- cheaper but less acurate NEW.centroid := ST_PointOnSurface(NEW.geometry); @@ -596,7 +605,9 @@ BEGIN (NEW.extratags->'capital') = 'yes', NEW.address->'postcode'); -- We must always increase the address level relative to the admin boundary. - IF NEW.class = 'boundary' and NEW.type = 'administrative' and NEW.osm_type = 'R' THEN + IF NEW.class = 'boundary' and NEW.type = 'administrative' + and NEW.osm_type = 'R' and NEW.rank_address > 0 + THEN parent_address_level := get_parent_address_level(NEW.centroid, NEW.admin_level); IF parent_address_level >= NEW.rank_address THEN IF parent_address_level >= 24 THEN