mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
link against place nodes by place type
If a boundary relation has no label member preferably link against a place node with the same place type. Also inherit the rank_address from the place node (only has an effect when linking via lable member or place type).
This commit is contained in:
@@ -204,9 +204,26 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
-- If extratags has a place tag, look for linked nodes by their place type.
|
||||||
|
-- Area and node still have to have the same name.
|
||||||
|
IF bnd.extratags ? 'place' and bnd_name is not null THEN
|
||||||
|
FOR linked_placex IN
|
||||||
|
SELECT * FROM placex
|
||||||
|
WHERE make_standard_name(name->'name') = bnd_name
|
||||||
|
AND placex.class = 'place' AND placex.type = bnd.extratags->'place'
|
||||||
|
AND placex.osm_type = 'N'
|
||||||
|
AND placex.rank_search < 26 -- needed to select the right index
|
||||||
|
AND _st_covers(bnd.geometry, placex.geometry)
|
||||||
|
LOOP
|
||||||
|
--DEBUG: RAISE WARNING 'Found type-matching place node %', linked_placex.osm_id;
|
||||||
|
RETURN linked_placex;
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- Search for relation members with role admin_center.
|
-- Search for relation members with role admin_center.
|
||||||
IF bnd.osm_type = 'R' and bnd_name is not null
|
IF bnd.osm_type = 'R' and bnd_name is not null
|
||||||
and relation_members is not null THEN
|
and relation_members is not null
|
||||||
|
THEN
|
||||||
FOR rel_member IN
|
FOR rel_member IN
|
||||||
SELECT get_rel_node_members(relation_members,
|
SELECT get_rel_node_members(relation_members,
|
||||||
ARRAY['admin_center','admin_centre']) as member
|
ARRAY['admin_center','admin_centre']) as member
|
||||||
@@ -231,7 +248,7 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Name searches can be done for ways as well as relations
|
-- Name searches can be done for ways as well as relations
|
||||||
IF bnd.osm_type in ('W','R') and bnd_name is not null THEN
|
IF bnd_name is not null THEN
|
||||||
--DEBUG: RAISE WARNING 'Looking for nodes with matching names';
|
--DEBUG: RAISE WARNING 'Looking for nodes with matching names';
|
||||||
FOR linked_placex IN
|
FOR linked_placex IN
|
||||||
SELECT placex.* from placex
|
SELECT placex.* from placex
|
||||||
@@ -241,7 +258,7 @@ BEGIN
|
|||||||
AND placex.rank_search < 26 -- needed to select the right index
|
AND placex.rank_search < 26 -- needed to select the right index
|
||||||
AND _st_covers(bnd.geometry, placex.geometry)
|
AND _st_covers(bnd.geometry, placex.geometry)
|
||||||
LOOP
|
LOOP
|
||||||
--DEBUG: RAISE WARNING 'Found matching place node %', linkedPlacex.osm_id;
|
--DEBUG: RAISE WARNING 'Found matching place node %', linked_placex.osm_id;
|
||||||
RETURN linked_placex;
|
RETURN linked_placex;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
END IF;
|
END IF;
|
||||||
@@ -824,6 +841,9 @@ BEGIN
|
|||||||
NEW.centroid := coalesce(location.centroid,
|
NEW.centroid := coalesce(location.centroid,
|
||||||
ST_Centroid(location.geometry));
|
ST_Centroid(location.geometry));
|
||||||
|
|
||||||
|
-- Use the address rank of the linked place
|
||||||
|
NEW.rank_address := location.rank_address;
|
||||||
|
|
||||||
-- merge in the label name
|
-- merge in the label name
|
||||||
IF NOT location.name IS NULL THEN
|
IF NOT location.name IS NULL THEN
|
||||||
NEW.name := location.name || NEW.name;
|
NEW.name := location.name || NEW.name;
|
||||||
|
|||||||
@@ -143,3 +143,33 @@ Feature: Linking of places
|
|||||||
| object | centroid | name+name | extratags+linked_place |
|
| object | centroid | name+name | extratags+linked_place |
|
||||||
| R13 | 0.006 0.00001 | Garbo | hamlet |
|
| R13 | 0.006 0.00001 | Garbo | hamlet |
|
||||||
|
|
||||||
|
Scenario: Boundaries with place tags are linked against places with same type
|
||||||
|
Given the places
|
||||||
|
| osm | class | type | admin | name | extra+place | geometry |
|
||||||
|
| R13 | boundary | administrative | 5 | Berlin | city |poly-area:0.1 |
|
||||||
|
And the places
|
||||||
|
| osm | class | type | name | geometry |
|
||||||
|
| N2 | place | city | Berlin | 0.006 0.00001 |
|
||||||
|
When importing
|
||||||
|
Then placex contains
|
||||||
|
| object | linked_place_id |
|
||||||
|
| N2 | R13 |
|
||||||
|
And placex contains
|
||||||
|
| object | rank_address |
|
||||||
|
| R13 | 16 |
|
||||||
|
|
||||||
|
Scenario: Boundaries without place tags only link against same admin level
|
||||||
|
Given the places
|
||||||
|
| osm | class | type | admin | name | geometry |
|
||||||
|
| R13 | boundary | administrative | 5 | Berlin |poly-area:0.1 |
|
||||||
|
And the places
|
||||||
|
| osm | class | type | name | geometry |
|
||||||
|
| N2 | place | city | Berlin | 0.006 0.00001 |
|
||||||
|
When importing
|
||||||
|
Then placex contains
|
||||||
|
| object | linked_place_id |
|
||||||
|
| N2 | - |
|
||||||
|
And placex contains
|
||||||
|
| object | rank_address |
|
||||||
|
| R13 | 10 |
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user