X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/153dbb71b8fe632c3cbda3834b012bf9db77d365..9934421442bf1a815096ef06ffa3f8c9ea11c0ac:/lib-php/website/details.php diff --git a/lib-php/website/details.php b/lib-php/website/details.php index 8e350a8c..0d67ec83 100644 --- a/lib-php/website/details.php +++ b/lib-php/website/details.php @@ -53,7 +53,7 @@ if ($sOsmType && $iOsmId > 0) { // Be nice about our error messages for broken geometry - if (!$sPlaceId) { + if (!$sPlaceId && $oDB->tableExists('import_polygon_error')) { $sSQL = 'SELECT '; $sSQL .= ' osm_type, '; $sSQL .= ' osm_id, '; @@ -81,29 +81,35 @@ if ($sOsmType && $iOsmId > 0) { exit; } } -} - -if ($sPlaceId === false) userError('Please select a place id'); + if ($sPlaceId === false) { + throw new \Exception('No place with that OSM ID found.', 404); + } +} else { + if ($sPlaceId === false) { + userError('Required parameters missing. Need either osmtype/osmid or place_id.'); + } +} $iPlaceID = (int)$sPlaceId; if (CONST_Use_US_Tiger_Data) { $iParentPlaceID = $oDB->getOne('SELECT parent_place_id FROM location_property_tiger WHERE place_id = '.$iPlaceID); - if ($iParentPlaceID) $iPlaceID = $iParentPlaceID; + if ($iParentPlaceID) { + $iPlaceID = $iParentPlaceID; + } } // interpolated house numbers $iParentPlaceID = $oDB->getOne('SELECT parent_place_id FROM location_property_osmline WHERE place_id = '.$iPlaceID); -if ($iParentPlaceID) $iPlaceID = $iParentPlaceID; +if ($iParentPlaceID) { + $iPlaceID = $iParentPlaceID; +} // artificial postcodes $iParentPlaceID = $oDB->getOne('SELECT parent_place_id FROM location_postcode WHERE place_id = '.$iPlaceID); -if ($iParentPlaceID) $iPlaceID = $iParentPlaceID; - -if (CONST_Use_Aux_Location_data) { - $iParentPlaceID = $oDB->getOne('SELECT parent_place_id FROM location_property_aux WHERE place_id = '.$iPlaceID); - if ($iParentPlaceID) $iPlaceID = $iParentPlaceID; +if ($iParentPlaceID) { + $iPlaceID = $iParentPlaceID; } $hLog = logStart($oDB, 'details', $_SERVER['QUERY_STRING'], $aLangPrefOrder); @@ -140,7 +146,7 @@ $sSQL .= " WHERE place_id = $iPlaceID"; $aPointDetails = $oDB->getRow($sSQL, null, 'Could not get details of place object.'); if (!$aPointDetails) { - userError('Unknown place id.'); + throw new \Exception('No place with that place ID found.', 404); } $aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];