]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/AddressDetails.php
Addresses with housenumber 0 are found
[nominatim.git] / lib / AddressDetails.php
index 618e10c908ad0d962bb2f9c37d3f91920497aee4..61823b4ce9dc504010ed33e67aeb575df400d047 100644 (file)
@@ -14,10 +14,10 @@ class AddressDetails
     public function __construct(&$oDB, $iPlaceID, $sHousenumber, $mLangPref)
     {
         if (is_array($mLangPref)) {
     public function __construct(&$oDB, $iPlaceID, $sHousenumber, $mLangPref)
     {
         if (is_array($mLangPref)) {
-            $mLangPref = 'ARRAY['.join(',', array_map('getDBQuoted', $mLangPref)).']';
+            $mLangPref = $oDB->getArraySQL($oDB->getDBQuotedList($mLangPref));
         }
 
         }
 
-        if (!$sHousenumber) {
+        if (!isset($sHousenumber)) {
             $sHousenumber = -1;
         }
 
             $sHousenumber = -1;
         }
 
@@ -26,12 +26,12 @@ class AddressDetails
         $sSQL .= ' FROM get_addressdata('.$iPlaceID.','.$sHousenumber.')';
         $sSQL .= ' ORDER BY rank_address DESC, isaddress DESC';
 
         $sSQL .= ' FROM get_addressdata('.$iPlaceID.','.$sHousenumber.')';
         $sSQL .= ' ORDER BY rank_address DESC, isaddress DESC';
 
-        $this->aAddressLines = chksql($oDB->getAll($sSQL));
+        $this->aAddressLines = $oDB->getAll($sSQL);
     }
 
     private static function isAddress($aLine)
     {
     }
 
     private static function isAddress($aLine)
     {
-        return $aLine['isaddress'] == 't' || $aLine['type'] == 'country_code';
+        return $aLine['isaddress'] || $aLine['type'] == 'country_code';
     }
 
     public function getAddressDetails($bAll = false)
     }
 
     public function getAddressDetails($bAll = false)
@@ -49,7 +49,7 @@ class AddressDetails
         $sPrevResult = '';
 
         foreach ($this->aAddressLines as $aLine) {
         $sPrevResult = '';
 
         foreach ($this->aAddressLines as $aLine) {
-            if ($aLine['isaddress'] == 't' && $sPrevResult != $aLine['localname']) {
+            if ($aLine['isaddress'] && $sPrevResult != $aLine['localname']) {
                 $sPrevResult = $aLine['localname'];
                 $aParts[] = $sPrevResult;
             }
                 $sPrevResult = $aLine['localname'];
                 $aParts[] = $sPrevResult;
             }
@@ -76,14 +76,14 @@ class AddressDetails
                 $bFallback = true;
             }
 
                 $bFallback = true;
             }
 
-            $sName = false;
-            if (isset($aLine['localname']) && $aLine['localname']) {
+            $sName = null;
+            if (isset($aLine['localname']) && $aLine['localname']!=='') {
                 $sName = $aLine['localname'];
                 $sName = $aLine['localname'];
-            } elseif (isset($aLine['housenumber']) && $aLine['housenumber']) {
+            } elseif (isset($aLine['housenumber']) && $aLine['housenumber']!=='') {
                 $sName = $aLine['housenumber'];
             }
 
                 $sName = $aLine['housenumber'];
             }
 
-            if ($sName) {
+            if (isset($sName)) {
                 $sTypeLabel = strtolower(isset($aTypeLabel['simplelabel']) ? $aTypeLabel['simplelabel'] : $aTypeLabel['label']);
                 $sTypeLabel = str_replace(' ', '_', $sTypeLabel);
                 if (!isset($aAddress[$sTypeLabel])
                 $sTypeLabel = strtolower(isset($aTypeLabel['simplelabel']) ? $aTypeLabel['simplelabel'] : $aTypeLabel['label']);
                 $sTypeLabel = str_replace(' ', '_', $sTypeLabel);
                 if (!isset($aAddress[$sTypeLabel])
@@ -97,6 +97,7 @@ class AddressDetails
                 }
             }
         }
                 }
             }
         }
+
         return $aAddress;
     }
 
         return $aAddress;
     }