X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c7eea2e41914b0757d6deb3cd595ae6b7458db38..f0d962f8a0bd6aac32c07420956c35479d5ec467:/lib/template/details-html.php diff --git a/lib/template/details-html.php b/lib/template/details-html.php index da36167c..ae36b411 100644 --- a/lib/template/details-html.php +++ b/lib/template/details-html.php @@ -2,6 +2,7 @@ header("content-type: text/html; charset=UTF-8"); ?> + @@ -11,13 +12,19 @@ function headline($sTitle) { - echo "

".$sTitle."

\n"; + echo "

".$sTitle."

\n"; + } + + function headline3($sTitle) + { + echo "

".$sTitle."

\n"; } function osm_link($aFeature) { $sOSMType = ($aFeature['osm_type'] == 'N'?'node':($aFeature['osm_type'] == 'W'?'way':($aFeature['osm_type'] == 'R'?'relation':''))); - if ($sOSMType) { + if ($sOSMType) + { return ''.$sOSMType.' '.$aFeature['osm_id'].''; } return ''; @@ -28,7 +35,7 @@ if ($aFeature['wikipedia']) { list($sWikipediaLanguage,$sWikipediaArticle) = explode(':',$aFeature['wikipedia']); - return ''.$aFeature['wikipedia'].''; + return ''.$aFeature['wikipedia'].''; } return ''; } @@ -40,7 +47,19 @@ function format_distance($fDistance) { - return'~'.(round($fDistance,1)).' km'; + // $fDistance is in meters + if ($fDistance < 1) + { + return '0'; + } + elseif ($fDistance < 1000) + { + return'~'.(round($fDistance,0)).' m'; + } + else + { + return'~'.(round($fDistance/1000,1)).' km'; + } } function kv($sKey,$sValue) @@ -59,18 +78,6 @@ return $sHTML; } - // function hash_to_subtable($aAssociatedList) - // { - // $sHTML = ''; - // foreach($aAssociatedList as $sKey => $sValue) - // { - // $sHTML = $sHTML . ''."\n"; - // } - // $sHTML = $sHTML . '
'.$sKey.''.$sValue.'
'; - // return $sHTML; - // } - - function map_icon($sIcon) { if ($sIcon){ @@ -82,23 +89,35 @@ function _one_row($aAddressLine){ $bNotUsed = (isset($aAddressLine['isaddress']) && $aAddressLine['isaddress'] == 'f'); - echo ''; - echo ' '.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'No Name').''; - echo ' ' . $aAddressLine['class'].':'.$aAddressLine['type'] . ''; - echo ' ' . osm_link($aAddressLine) . ''; - echo ' ' . (isset($aAddressLine['admin_level']) ? $aAddressLine['admin_level'] : '') . ''; - // echo '' . (isset($aAddressLine['rank_search_label']) ? $aAddressLine['rank_search_label'] : '') .''; - // echo ', '.($aAddressLine['fromarea']=='t'?'Polygon':'Point').''; - echo ' ' . format_distance($aAddressLine['distance']).'';; - echo ' ' . nominatim_link($aAddressLine,'details >') . '';; + echo ''."\n"; + echo ' '.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'No Name')."\n"; + echo ' ' . $aAddressLine['class'].':'.$aAddressLine['type'] . "\n"; + echo ' ' . osm_link($aAddressLine) . "\n"; + echo ' ' . (isset($aAddressLine['admin_level']) ? $aAddressLine['admin_level'] : '') . "\n"; + echo ' ' . format_distance($aAddressLine['distance'])."\n"; + echo ' ' . nominatim_link($aAddressLine,'details >') . "\n"; echo "\n"; } + function _one_keyword_row($keyword_token,$word_id){ + echo "\n"; + echo ''; + // mark partial tokens (those starting with a space) with a star for readability + echo ($keyword_token[0]==' '?'*':''); + echo $keyword_token; + if (isset($word_id)) + { + echo 'word id: '.$word_id; + } + echo "\n"; + } + ?> +
@@ -154,7 +173,6 @@ Type OSM Admin level - Distance @@ -169,8 +187,6 @@ } ?> - - '; foreach($aLinkedLines as $aAddressLine) { _one_row($aAddressLine); } - echo ''; } @@ -193,7 +207,7 @@ headline('Name Keywords'); foreach($aPlaceSearchNameKeywords as $aRow) { - echo '
'.$aRow['word_token']."
\n"; + _one_keyword_row($aRow['word_token'], $aRow['word_id']); } } @@ -202,10 +216,10 @@ headline('Address Keywords'); foreach($aPlaceSearchAddressKeywords as $aRow) { - echo '
'.($aRow['word_token'][0]==' '?'*':'').$aRow['word_token'].'('.$aRow['word_id'].')'."
\n"; + _one_keyword_row($aRow['word_token'], $aRow['word_id']); } } - + if (sizeof($aParentOfLines)) { headline('Parent Of'); @@ -223,47 +237,47 @@ foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines) { $sGroupHeading = ucwords($sGroupHeading); - echo "

$sGroupHeading

\n"; + headline3($sGroupHeading); - echo ''; foreach($aParentOfLines as $aAddressLine) { _one_row($aAddressLine); } - echo '
'; } if (sizeof($aParentOfLines) >= 500) { echo '

There are more child objects which are not shown.

'; } } - // headline('Other Parts'); - // headline('Linked To'); + echo "\n"; ?>
- + - +