- }
-//var_dump($aAddress);
-//exit;
- return $aAddress;
-
- $aHouseNumber = $oDB->getRow('select housenumber, get_name_by_language(name,ARRAY[\'addr:housename\']) as housename,rank_search,postcode from placex where place_id = '.$iPlaceID);
- $sHouseNumber = $aHouseNumber['housenumber'];
- $sHouseName = $aHouseNumber['housename'];
- $sPostcode = $aHouseNumber['postcode'];
- $iRank = $aHouseNumber['rank_search'];
-
- // Address
- $sSQL = "select country_code, placex.place_id, osm_type, osm_id, class, type, housenumber, admin_level, rank_address, rank_search, ";
- $sSQL .= "get_searchrank_label(rank_search) as rank_search_label, fromarea, isaddress, distance, ";
- $sSQL .= " CASE WHEN type = 'postcode' THEN postcode ELSE get_name_by_language(name,$sLanguagePrefArraySQL) END as localname, ";
- $sSQL .= " length(name::text) as namelength ";
- $sSQL .= " from place_addressline join placex on (address_place_id = placex.place_id)";
- $sSQL .= " where place_addressline.place_id = $iPlaceID and (rank_address > 0 OR address_place_id = $iPlaceID)";
- if (!$bRaw) $sSQL .= " and isaddress";
- $sSQL .= " order by cached_rank_address desc,isaddress desc,fromarea desc,distance asc,rank_search desc,namelength desc";
-//var_dump($sSQL);
- $aAddressLines = $oDB->getAll($sSQL);
- if (PEAR::IsError($aAddressLines))
- {
- var_dump($aAddressLines);
- exit;
- }
- if ($bRaw) return $aAddressLines;
-
- $aClassType = getClassTypes();
-
- $iMinRank = 100;
- $aAddress = array();
- if ($iRank >= 28 && $sHouseNumber) $aAddress['house_number'] = $sHouseNumber;
- if ($iRank >= 28 && $sHouseName) $aAddress['house_name'] = $sHouseName;
- foreach($aAddressLines as $aLine)
- {
- if (!$sCountryCode) $sCountryCode = $aLine['country_code'];
- if ($aLine['rank_address'] < $iMinRank)