mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-15 10:57:58 +00:00
excluded place nodes outside parent boundaries from addresses
Changes slightly the logic which decides if a guessed places (i.e. a place node) is included in an address: it will be part of the address only if it is inside the next lower available boundary. This fixes problematic cases where neighbouring entities have additional admin levels.
This commit is contained in:
@@ -13,6 +13,17 @@ create type nearfeature as (
|
||||
isguess boolean
|
||||
);
|
||||
|
||||
drop type nearfeaturecentr cascade;
|
||||
create type nearfeaturecentr as (
|
||||
place_id BIGINT,
|
||||
keywords int[],
|
||||
rank_address integer,
|
||||
rank_search integer,
|
||||
distance float,
|
||||
isguess boolean,
|
||||
centroid GEOMETRY
|
||||
);
|
||||
|
||||
CREATE TABLE location_area_country () INHERITS (location_area_large);
|
||||
CREATE INDEX idx_location_area_country_geometry ON location_area_country USING GIST (geometry);
|
||||
|
||||
@@ -46,21 +57,21 @@ CREATE INDEX idx_location_road_-partition-_place_id ON location_road_-partition-
|
||||
|
||||
-- end
|
||||
|
||||
create or replace function getNearFeatures(in_partition INTEGER, point GEOMETRY, maxrank INTEGER, isin_tokens INT[]) RETURNS setof nearfeature AS $$
|
||||
create or replace function getNearFeatures(in_partition INTEGER, point GEOMETRY, maxrank INTEGER, isin_tokens INT[]) RETURNS setof nearfeaturecentr AS $$
|
||||
DECLARE
|
||||
r nearfeature%rowtype;
|
||||
r nearfeaturecentr%rowtype;
|
||||
BEGIN
|
||||
|
||||
-- start
|
||||
IF in_partition = -partition- THEN
|
||||
FOR r IN
|
||||
SELECT place_id, keywords, rank_address, rank_search, min(ST_Distance(point, centroid)) as distance, isguess FROM (
|
||||
SELECT place_id, keywords, rank_address, rank_search, min(ST_Distance(point, centroid)) as distance, isguess, centroid FROM (
|
||||
SELECT * FROM location_area_large_-partition- WHERE ST_Contains(geometry, point) and rank_search < maxrank
|
||||
UNION ALL
|
||||
SELECT * FROM location_area_country WHERE ST_Contains(geometry, point) and rank_search < maxrank
|
||||
) as location_area
|
||||
GROUP BY place_id, keywords, rank_address, rank_search, isguess, centroid
|
||||
ORDER BY rank_address desc, isin_tokens && keywords desc, isguess asc,
|
||||
ORDER BY rank_address, isin_tokens && keywords desc, isguess asc,
|
||||
ST_Distance(point, centroid) *
|
||||
CASE
|
||||
WHEN rank_address = 16 AND rank_search = 15 THEN 0.2 -- capital city
|
||||
|
||||
Reference in New Issue
Block a user