From: Sarah Hoffmann Date: Thu, 9 Apr 2020 21:00:34 +0000 (+0200) Subject: Merge pull request #1741 from filimongeorge/patch-1 X-Git-Tag: v3.5.0~47 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/320d46cc9605184d194c925feff83634e721d752?hp=7f7d29fdd1ccd747434e65b259fc9cab6afb30e9 Merge pull request #1741 from filimongeorge/patch-1 Updated Import and Update .md file --- diff --git a/lib/AddressDetails.php b/lib/AddressDetails.php index 8d2b3e08..3322c6b2 100644 --- a/lib/AddressDetails.php +++ b/lib/AddressDetails.php @@ -9,10 +9,13 @@ require_once(CONST_BasePath.'/lib/ClassTypes.php'); */ class AddressDetails { + private $iPlaceID; private $aAddressLines; public function __construct(&$oDB, $iPlaceID, $sHousenumber, $mLangPref) { + $this->iPlaceID = $iPlaceID; + if (is_array($mLangPref)) { $mLangPref = $oDB->getArraySQL($oDB->getDBQuotedList($mLangPref)); } @@ -115,7 +118,7 @@ class AddressDetails */ public function addGeocodeJsonAddressParts(&$aJson) { - foreach ($this->aAddressLines as $aLine) { + foreach (array_reverse($this->aAddressLines) as $aLine) { if (!$aLine['isaddress']) { continue; } @@ -124,13 +127,19 @@ class AddressDetails continue; } - $iRank = (int)$aLine['rank_address']; - if ($aLine['type'] == 'postcode' || $aLine['type'] == 'postal_code') { $aJson['postcode'] = $aLine['localname']; } elseif ($aLine['type'] == 'house_number') { $aJson['housenumber'] = $aLine['localname']; - } elseif ($iRank > 25 && $iRank < 28) { + } + + if ($this->iPlaceID == $aLine['place_id']) { + continue; + } + + $iRank = (int)$aLine['rank_address']; + + if ($iRank > 25 && $iRank < 28) { $aJson['street'] = $aLine['localname']; } elseif ($iRank >= 22 && $iRank <= 25) { $aJson['locality'] = $aLine['localname']; diff --git a/lib/setup/SetupClass.php b/lib/setup/SetupClass.php index b422ded1..aa1b291d 100755 --- a/lib/setup/SetupClass.php +++ b/lib/setup/SetupClass.php @@ -529,11 +529,10 @@ class SetupFunctions public function index($bIndexNoanalyse) { - $sOutputFile = ''; $sBaseCmd = CONST_BasePath.'/nominatim/nominatim.py' .' -d '.escapeshellarg($this->aDSNInfo['database']) .' -P '.escapeshellarg($this->aDSNInfo['port']) - .' -t '.escapeshellarg($this->iInstances.$sOutputFile); + .' -t '.escapeshellarg($this->iInstances); if (!$this->bQuiet) { $sBaseCmd .= ' -v'; } diff --git a/lib/template/address-geocodejson.php b/lib/template/address-geocodejson.php index 98c368b3..0066e80e 100644 --- a/lib/template/address-geocodejson.php +++ b/lib/template/address-geocodejson.php @@ -30,7 +30,9 @@ if (empty($aPlace)) { $aFilteredPlaces['properties']['geocoding']['label'] = $aPlace['langaddress']; - $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename']; + if ($aPlace['placename'] !== null) { + $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename']; + } if (isset($aPlace['address'])) { $aPlace['address']->addGeocodeJsonAddressParts( diff --git a/lib/template/search-geocodejson.php b/lib/template/search-geocodejson.php index dfb402bd..3e3a31c4 100644 --- a/lib/template/search-geocodejson.php +++ b/lib/template/search-geocodejson.php @@ -20,7 +20,9 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) { $aPlace['properties']['geocoding']['label'] = $aPointDetails['langaddress']; - $aPlace['properties']['geocoding']['name'] = $aPointDetails['placename']; + if ($aPointDetails['placename'] !== null) { + $aPlace['properties']['geocoding']['name'] = $aPointDetails['placename']; + } if (isset($aPointDetails['address'])) { $aPointDetails['address']->addGeocodeJsonAddressParts( diff --git a/test/bdd/api/reverse/geocodejson.feature b/test/bdd/api/reverse/geocodejson.feature index b32bf1ca..44f8288b 100644 --- a/test/bdd/api/reverse/geocodejson.feature +++ b/test/bdd/api/reverse/geocodejson.feature @@ -11,10 +11,10 @@ Feature: Parameters for Reverse API Scenario: Town street-level address with street When sending geocodejson reverse coordinates 47.066,9.504 Then results contain - | street | city | postcode | country | + | name | city | postcode | country | | Gnetsch | Balzers | 9496 | Liechtenstein | - Scenario: Town street-level address with footway + Scenario: Poi street-level address with footway When sending geocodejson reverse coordinates 47.0653,9.5007 Then results contain | street | city | postcode | country | diff --git a/test/bdd/api/search/geocodejson.feature b/test/bdd/api/search/geocodejson.feature index 97cb220b..52c535bb 100644 --- a/test/bdd/api/search/geocodejson.feature +++ b/test/bdd/api/search/geocodejson.feature @@ -11,7 +11,7 @@ Feature: Parameters for Search API Scenario: Town street-level address with street When sending geocodejson search query "Gnetsch, Balzers" with address Then results contain - | street | city | postcode | country | + | name | city | postcode | country | | Gnetsch | Balzers | 9496 | Liechtenstein | Scenario: Town street-level address with footway