From: Sarah Hoffmann Date: Wed, 23 Sep 2020 17:10:42 +0000 (+0200) Subject: Merge pull request #1975 from lonvia/simplify-parent-assignment-for-unlisted-places X-Git-Tag: v3.6.0~65 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/6625e93be673a2b400a466f2f024d97716f8da72?ds=sidebyside;hp=-c Merge pull request #1975 from lonvia/simplify-parent-assignment-for-unlisted-places Use closest containing place area for parent of unlisted addr:place --- 6625e93be673a2b400a466f2f024d97716f8da72 diff --combined sql/functions/placex_triggers.sql index ad0f041d,e8bbdb18..9ef83b82 --- a/sql/functions/placex_triggers.sql +++ b/sql/functions/placex_triggers.sql @@@ -93,13 -93,15 +93,15 @@@ BEGI IF fallback THEN IF addr_street is null and addr_place is not null THEN - -- The address is attached to a place we don't know. Find the - -- nearest place instead. + -- The address is attached to a place we don't know. + -- Instead simply use the containing area with the largest rank. FOR location IN - SELECT place_id FROM getNearFeatures(poi_partition, bbox, 26, '{}'::INTEGER[]) - ORDER BY rank_address DESC, isguess asc, distance LIMIT 1 + SELECT place_id FROM placex + WHERE bbox @ geometry AND _ST_Covers(geometry, ST_Centroid(bbox)) + AND rank_address between 5 and 25 + ORDER BY rank_address desc LOOP - parent_place_id := location.place_id; + RETURN location.place_id; END LOOP; ELSEIF ST_Area(bbox) < 0.005 THEN -- for smaller features get the nearest road @@@ -450,16 -452,11 +452,16 @@@ BEGI -- 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 address ? 'place')); - 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 address ? 'place')); + UPDATE placex SET indexed_status = 2 + WHERE ST_Intersects(NEW.geometry, placex.geometry) + and indexed_status = 0 + and ((rank_address = 0 and rank_search > NEW.rank_address) + or rank_address > NEW.rank_address + or (class = 'place' and osm_type = 'N') + ) + and (rank_search < 28 + or name is not null + or (NEW.rank_address >= 16 and address ? 'place')); END IF; ELSE -- mark nearby items for re-indexing, where 'nearby' depends on the features rank_search and is a complete guess :(