]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/AddressDetails.php
Merge pull request #1358 from mtmail/travis-php-7dot1
[nominatim.git] / lib / AddressDetails.php
index badf868de8774ab5c568b1119a51594e8c987882..2d40c84f4efc35e90421798cc14f35a35bde3f68 100644 (file)
@@ -22,16 +22,16 @@ class AddressDetails
         }
 
         $sSQL = 'SELECT *,';
         }
 
         $sSQL = 'SELECT *,';
-        $sSQL .= '  get_name_by_language(name,'.$mLangPref.') as localname';
+        $sSQL .= ' get_name_by_language(name,'.$mLangPref.') as localname';
         $sSQL .= ' FROM get_addressdata('.$iPlaceID.','.$sHousenumber.')';
         $sSQL .= ' FROM get_addressdata('.$iPlaceID.','.$sHousenumber.')';
-        $sSQL .= ' ORDER BY rank_address desc,isaddress DESC';
+        $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)
@@ -40,7 +40,7 @@ class AddressDetails
             return $this->aAddressLines;
         }
 
             return $this->aAddressLines;
         }
 
-        return array_filter($this->aAddressLines, 'AddressDetails::isAddress');
+        return array_filter($this->aAddressLines, array(__CLASS__, 'isAddress'));
     }
 
     public function getLocaleAddress()
     }
 
     public function getLocaleAddress()
@@ -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;
             }
@@ -103,7 +103,7 @@ class AddressDetails
     public function getAdminLevels()
     {
         $aAddress = array();
     public function getAdminLevels()
     {
         $aAddress = array();
-        foreach ($this->aAddressLines as $aLine) {
+        foreach (array_reverse($this->aAddressLines) as $aLine) {
             if (self::isAddress($aLine)
                 && isset($aLine['admin_level'])
                 && $aLine['admin_level'] < 15
             if (self::isAddress($aLine)
                 && isset($aLine['admin_level'])
                 && $aLine['admin_level'] < 15