add unknown addr:place to address output

When a POI has no addr:street but an addr:place that is not
contained in the name list of the parent place, then remember
this situation and merge the content of addr:place into the
address output.

We don't need to care about translations in this case because
it is obvious that no object with translations exists if the
parent isn't the object named in addr:place.
This commit is contained in:
Sarah Hoffmann
2020-09-23 11:55:18 +02:00
parent f2ff351da4
commit c84e7e72f1
3 changed files with 41 additions and 23 deletions

View File

@@ -101,6 +101,7 @@ DECLARE
postcode_isexact BOOL;
searchclass TEXT;
searchtype TEXT;
search_unlisted_place TEXT;
countryname HSTORE;
BEGIN
-- The place ein question might not have a direct entry in place_addressline.
@@ -155,11 +156,13 @@ BEGIN
IF for_place_id IS NULL THEN
SELECT parent_place_id, country_code, housenumber, rank_search,
postcode, address is not null and address ? 'postcode',
name, class, type
name, class, type,
address -> '_unlisted_place' as unlisted_place
FROM placex
WHERE place_id = in_place_id and rank_search > 27
INTO for_place_id, searchcountrycode, searchhousenumber, searchrankaddress,
searchpostcode, postcode_isexact, searchhousename, searchclass, searchtype;
searchpostcode, postcode_isexact, searchhousename, searchclass,
searchtype, search_unlisted_place;
END IF;
-- If for_place_id is still NULL at this point then the object has its own
@@ -279,6 +282,11 @@ BEGIN
RETURN NEXT location;
END IF;
IF search_unlisted_place is not null THEN
RETURN NEXT ROW(null, null, null, hstore('name', search_unlisted_place),
'place', 'locality', null, null, true, true, 26, 0)::addressline;
END IF;
IF searchpostcode IS NOT NULL THEN
location := ROW(null, null, null, hstore('ref', searchpostcode), 'place',
'postcode', null, null, false, true, 5, 0)::addressline;

View File

@@ -575,6 +575,7 @@ BEGIN
-- update not necessary for osmline, cause linked_place_id does not exist
NEW.extratags := NEW.extratags - 'linked_place'::TEXT;
NEW.address := NEW.address - '_unlisted_place'::TEXT;
IF NEW.linked_place_id is not null THEN
--DEBUG: RAISE WARNING 'place already linked to %', NEW.linked_place_id;
@@ -740,9 +741,18 @@ BEGIN
IF NEW.parent_place_id is not null THEN
-- Get the details of the parent road
SELECT p.country_code, p.postcode FROM placex p
SELECT p.country_code, p.postcode, p.name FROM placex p
WHERE p.place_id = NEW.parent_place_id INTO location;
IF addr_street is null and addr_place is not null THEN
-- Check if the addr:place tag is part of the parent name
SELECT count(*) INTO i
FROM svals(location.name) AS pname WHERE pname = addr_place;
IF i = 0 THEN
NEW.address = NEW.address || hstore('_unlisted_place', addr_place);
END IF;
END IF;
NEW.country_code := location.country_code;
--DEBUG: RAISE WARNING 'Got parent details from search name';

View File

@@ -27,8 +27,8 @@ Feature: Creation of search terms
| N1 | #23 | Rose Street, Walltown |
When searching for "23 Rose Street, Walltown"
Then results contain
| osm_type | osm_id |
| N | 1 |
| osm_type | osm_id | name |
| N | 1 | 23, Rose Street |
Scenario: Unnamed POI has no search entry when it has known addr: tags
Given the scene roads-with-pois
@@ -42,8 +42,8 @@ Feature: Creation of search terms
Then search_name has no entry for N1
When searching for "23 Rose Street, Walltown"
Then results contain
| osm_type | osm_id |
| N | 1 |
| osm_type | osm_id | name |
| N | 1 | 23, Rose Street |
Scenario: Unnamed POI must have a house number to get a search entry
Given the scene roads-with-pois
@@ -72,12 +72,12 @@ Feature: Creation of search terms
When searching for "23 Rose Street"
Then exactly 1 results are returned
And results contain
| osm_type | osm_id |
| W | 1 |
| osm_type | osm_id | name |
| W | 1 | Rose Street, Strange Town |
When searching for "23 Walltown"
Then results contain
| osm_type | osm_id |
| N | 1 |
| osm_type | osm_id | name |
| N | 1 | 23, Walltown, Strange Town |
Scenario: Unnamed POIs doesn't inherit parent name when addr:place is present only in parent address
Given the scene roads-with-pois
@@ -95,13 +95,13 @@ Feature: Creation of search terms
When searching for "23 Rose Street, Walltown"
Then exactly 1 result is returned
And results contain
| osm_type | osm_id |
| W | 1 |
| osm_type | osm_id | name |
| W | 1 | Rose Street, Strange Town |
When searching for "23 Walltown"
Then exactly 1 result is returned
And results contain
| osm_type | osm_id |
| N | 1 |
| osm_type | osm_id | name |
| N | 1 | 23, Walltown, Strange Town |
Scenario: Unnamed POIs does inherit parent name when unknown addr:place and addr:street is present
Given the scene roads-with-pois
@@ -115,8 +115,8 @@ Feature: Creation of search terms
Then search_name has no entry for N1
When searching for "23 Rose Street"
Then results contain
| osm_type | osm_id |
| N | 1 |
| osm_type | osm_id | name |
| N | 1 | 23, Rose Street |
When searching for "23 Lily Street"
Then exactly 0 results are returned
@@ -132,8 +132,8 @@ Feature: Creation of search terms
Then search_name has no entry for N1
When searching for "23 Rose Street"
Then results contain
| osm_type | osm_id |
| N | 1 |
| osm_type | osm_id | name |
| N | 1 | 23, Rose Street |
When searching for "23 Lily Street"
Then exactly 0 results are returned
@@ -151,8 +151,8 @@ Feature: Creation of search terms
| N1 | #Green Moss | Rose Street, Walltown |
When searching for "Green Moss, Rose Street, Walltown"
Then results contain
| osm_type | osm_id |
| N | 1 |
| osm_type | osm_id | name |
| N | 1 | Green Moss, Rose Street |
Scenario: Named POI doesn't inherit parent name when addr:place is present only in parent address
Given the scene roads-with-pois
@@ -171,8 +171,8 @@ Feature: Creation of search terms
Then exactly 0 result is returned
When searching for "Green Moss, Walltown"
Then results contain
| osm_type | osm_id |
| N | 1 |
| osm_type | osm_id | name |
| N | 1 | Green Moss, Walltown, Strange Town |
Scenario: Named POIs inherit address from parent
Given the scene roads-with-pois