X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/10620c71bb7999ed89ca45e545d9ce611a5e1476..14e6dab005c49a77ac49b6503f7807e620ea0ed3:/website/reverse.php?ds=inline diff --git a/website/reverse.php b/website/reverse.php index f6fc9da3..f569ffac 100755 --- a/website/reverse.php +++ b/website/reverse.php @@ -25,6 +25,10 @@ $sOutputFormat = $_GET['format']; } + // Show address breakdown + $bShowAddressDetails = true; + if (isset($_GET['addressdetails'])) $bShowAddressDetails = (bool)$_GET['addressdetails']; + // Prefered language $aLangPrefOrder = getPrefferedLangauges(); $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]"; @@ -72,7 +76,7 @@ $fSearchDiam = 0.0001; $iPlaceID = null; $aArea = false; - $fMaxAreaDistance = 10; + $fMaxAreaDistance = 1; while(!$iPlaceID && $fSearchDiam < $fMaxAreaDistance) { $fSearchDiam = $fSearchDiam * 2; @@ -107,17 +111,9 @@ } // The point we found might be too small - use the address to find what it is a child of - $sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = $iPlaceID order by cached_rank_address desc,isaddress desc,distance desc"; -//var_dump($sSQL); - $iPlaceID = $oDB->getOne($sSQL); - if (PEAR::IsError($iPlaceID)) + if ($iPlaceID) { - var_Dump($sSQL, $iPlaceID); - exit; - } - if ($iPlaceID && $aPlace['place_id'] && $iMaxRank < 28) - { - $sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = ".$aPlace['place_id']." order by cached_rank_address desc,isaddress desc,distance desc"; + $sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = $iPlaceID order by cached_rank_address desc,isaddress desc,distance desc limit 1"; //var_dump($sSQL); $iPlaceID = $oDB->getOne($sSQL); if (PEAR::IsError($iPlaceID)) @@ -125,10 +121,22 @@ var_Dump($sSQL, $iPlaceID); exit; } - } - if (!$iPlaceID) - { - $iPlaceID = $aPlace['place_id']; + + if ($iPlaceID && $aPlace['place_id'] && $iMaxRank < 28) + { + $sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = ".$aPlace['place_id']." order by cached_rank_address desc,isaddress desc,distance desc"; +//var_dump($sSQL); + $iPlaceID = $oDB->getOne($sSQL); + if (PEAR::IsError($iPlaceID)) + { + var_Dump($sSQL, $iPlaceID); + exit; + } + } + if (!$iPlaceID) + { + $iPlaceID = $aPlace['place_id']; + } } } @@ -137,12 +145,16 @@ $sSQL = "select placex.*,"; $sSQL .= " get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,"; $sSQL .= " get_name_by_language(name, $sLanguagePrefArraySQL) as placename,"; - $sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref"; + $sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref,"; + $sSQL .= " st_y(st_centroid(geometry)) as lat, st_x(st_centroid(geometry)) as lon"; $sSQL .= " from placex where place_id = $iPlaceID "; +//var_dump($sSQL); $aPlace = $oDB->getRow($sSQL); - $aAddress = getAddressDetails($oDB, $sLanguagePrefArraySQL, $iPlaceID, $aPlace['country_code']); - + if ($bShowAddressDetails) + { + $aAddress = getAddressDetails($oDB, $sLanguagePrefArraySQL, $iPlaceID, $aPlace['country_code']); + } $aClassType = getClassTypes(); $sAddressType = ''; if (isset($aClassType[$aPlace['class'].':'.$aPlace['type'].':'.$aPlace['admin_level']]))