*/
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));
}
*/
public function addGeocodeJsonAddressParts(&$aJson)
{
- foreach ($this->aAddressLines as $aLine) {
+ foreach (array_reverse($this->aAddressLines) as $aLine) {
if (!$aLine['isaddress']) {
continue;
}
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'];
$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(
$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(
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 |
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