From: marc tobias Date: Fri, 6 Apr 2018 14:11:54 +0000 (+0200) Subject: details page: add a perma-link X-Git-Tag: v3.2.0~97^2~1 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/4743a5e1661f853466664696112f53df92d6adf8 details page: add a perma-link --- diff --git a/lib/output.php b/lib/output.php index fd6226bc..9d4b7502 100644 --- a/lib/output.php +++ b/lib/output.php @@ -39,3 +39,14 @@ function detailsLink($aFeature, $sTitle = false) return ''.($sTitle?$sTitle:$aFeature['place_id']).''; } + +function detailsPermaLink($aFeature, $sRefText = false) +{ + $sOSMType = formatOSMType($aFeature['osm_type'], false); + + if ($sOSMType) { + $sLabel = $sRefText ? $sRefText : $sOSMType.' '.$aFeature['osm_id']; + return ''.$sLabel.''; + } + return ''; +} diff --git a/lib/template/details-html.php b/lib/template/details-html.php index ef7d9248..b7a96373 100644 --- a/lib/template/details-html.php +++ b/lib/template/details-html.php @@ -119,7 +119,7 @@ } kv('Coverage' , ($aPointDetails['isarea']=='t'?'Polygon':'Point') ); kv('Centre Point' , $aPointDetails['lat'].','.$aPointDetails['lon'] ); - kv('OSM' , osmLink($aPointDetails) ); + kv('OSM' , osmLink($aPointDetails) . ' ('.detailsPermaLink($aPointDetails, 'this page').')' ); if ($aPointDetails['wikipedia']) { kv('Wikipedia Calculated' , wikipediaLink($aPointDetails) ); diff --git a/website/details.php b/website/details.php index 24e8cd76..9e8d99a4 100755 --- a/website/details.php +++ b/website/details.php @@ -16,15 +16,21 @@ $sLanguagePrefArraySQL = 'ARRAY['.join(',', array_map('getDBQuoted', $aLangPrefO $sPlaceId = $oParams->getString('place_id'); $sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R')); $iOsmId = $oParams->getInt('osmid', -1); +$sClass = $oParams->getString('class'); $oDB =& getDB(); if ($sOsmType && $iOsmId > 0) { $sSQL = sprintf( - "SELECT place_id FROM placex WHERE osm_type='%s' AND osm_id=%d ORDER BY type='postcode' ASC", + "SELECT place_id FROM placex WHERE osm_type='%s' AND osm_id=%d", $sOsmType, $iOsmId ); + // osm_type and osm_id are not unique enough + if ($sClass) { + $sSQL .= " AND class='".$sClass."'"; + } + $sSQL .= " ORDER BY type='postcode', class ASC"; $sPlaceId = chksql($oDB->getOne($sSQL)); // Be nice about our error messages for broken geometry