X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/ec2d491dc8939ecf28ab84e26955bc7189618096..6c6560ca53b7fe270eeb5069664e8eb5f078d658:/website/details.php diff --git a/website/details.php b/website/details.php index b9818bbf..39fa0afa 100644 --- a/website/details.php +++ b/website/details.php @@ -30,6 +30,11 @@ $oDB->connect(); $sLanguagePrefArraySQL = $oDB->getArraySQL($oDB->getDBQuotedList($aLangPrefOrder)); +if ($sOutputFormat == 'html' && !$sPlaceId && !$sOsmType) { + include(CONST_BasePath.'/lib/template/details-index-html.php'); + exit; +} + if ($sOsmType && $iOsmId > 0) { $sSQL = 'SELECT place_id FROM placex WHERE osm_type = :type AND osm_id = :id'; // osm_type and osm_id are not unique enough @@ -39,6 +44,16 @@ if ($sOsmType && $iOsmId > 0) { $sSQL .= ' ORDER BY class ASC'; $sPlaceId = $oDB->getOne($sSQL, array(':type' => $sOsmType, ':id' => $iOsmId)); + + // Nothing? Maybe it's an interpolation. + // XXX Simply returns the first parent street it finds. It should + // get a house number and get the right interpolation. + if (!$sPlaceId && $sOsmType == 'W' && (!$sClass || $sClass == 'place')) { + $sSQL = 'SELECT place_id FROM location_property_osmline' + .' WHERE osm_id = :id LIMIT 1'; + $sPlaceId = $oDB->getOne($sSQL, array(':id' => $iOsmId)); + } + // Be nice about our error messages for broken geometry if (!$sPlaceId) { @@ -220,11 +235,17 @@ if ($bIncludeKeywords) { $aPlaceSearchName = $oDB->getRow($sSQL); if (!empty($aPlaceSearchName)) { - $sSQL = 'SELECT * FROM word WHERE word_id in ('.substr($aPlaceSearchName['name_vector'], 1, -1).')'; - $aPlaceSearchNameKeywords = $oDB->getAll($sSQL); + $sWordIds = substr($aPlaceSearchName['name_vector'], 1, -1); + if (!empty($sWordIds)) { + $sSQL = 'SELECT * FROM word WHERE word_id in ('.$sWordIds.')'; + $aPlaceSearchNameKeywords = $oDB->getAll($sSQL); + } - $sSQL = 'SELECT * FROM word WHERE word_id in ('.substr($aPlaceSearchName['nameaddress_vector'], 1, -1).')'; - $aPlaceSearchAddressKeywords = $oDB->getAll($sSQL); + $sWordIds = substr($aPlaceSearchName['nameaddress_vector'], 1, -1); + if (!empty($sWordIds)) { + $sSQL = 'SELECT * FROM word WHERE word_id in ('.$sWordIds.')'; + $aPlaceSearchAddressKeywords = $oDB->getAll($sSQL); + } } }