From e0d29f398ef4160ffdf47c1a42a0af9fcf632bf4 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 27 May 2020 11:16:27 +0200 Subject: [PATCH 1/2] each address line must fill at most one geocodejson field This fixes an issue where a postcode with rank_address 5 would also appear in the state field. --- lib/AddressDetails.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/AddressDetails.php b/lib/AddressDetails.php index dd867079..a27d3e79 100644 --- a/lib/AddressDetails.php +++ b/lib/AddressDetails.php @@ -117,8 +117,12 @@ class AddressDetails if ($aLine['type'] == 'postcode' || $aLine['type'] == 'postal_code') { $aJson['postcode'] = $aLine['localname']; - } elseif ($aLine['type'] == 'house_number') { + continue; + } + + if ($aLine['type'] == 'house_number') { $aJson['housenumber'] = $aLine['localname']; + continue; } if ($this->iPlaceID == $aLine['place_id']) { From aea915aa8da8e5a19ad97d915593c90f062608fc Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 27 May 2020 11:31:50 +0200 Subject: [PATCH 2/2] prefer linked place type over own place type For state cities, tagging might prefer the place=state on the admin boundary. The linked place is a more reliable indicator. --- sql/functions/address_lookup.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/functions/address_lookup.sql b/sql/functions/address_lookup.sql index 7885d0a9..55fa23f2 100644 --- a/sql/functions/address_lookup.sql +++ b/sql/functions/address_lookup.sql @@ -207,7 +207,7 @@ BEGIN FOR location IN SELECT placex.place_id, osm_type, osm_id, name, class, type, - coalesce(extratags->'place', extratags->'linked_place') as place_type, + coalesce(extratags->'linked_place', extratags->'place') as place_type, admin_level, fromarea, isaddress, CASE WHEN rank_address = 11 THEN 5 ELSE rank_address END as rank_address, distance, country_code, postcode