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.
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
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;
-- 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;
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';
| 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
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
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
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
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
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
| 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
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