From 20f270fe814e54e9322f65b58d93bbe24989a18e Mon Sep 17 00:00:00 2001 From: Marc Tobias Metten Date: Mon, 9 Apr 2018 19:21:50 +0200 Subject: [PATCH] bring in line with API (https://github.com/openstreetmap/Nominatim/pull/968) --- src/assets/js/detailpage.js | 4 +++- src/handlebar_helpers.js | 41 +++++++++++++++++++++++++++++++++++ src/templates/detailspage.hbs | 6 ++--- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/assets/js/detailpage.js b/src/assets/js/detailpage.js index 299103e..301b725 100644 --- a/src/assets/js/detailpage.js +++ b/src/assets/js/detailpage.js @@ -72,6 +72,8 @@ jQuery(document).ready(function(){ update_data_date(); - init_map_on_detail_page(aFeature.lat, aFeature.lon, aFeature.geometry); + var lat = aFeature.centroid.coordinates[1]; + var lon = aFeature.centroid.coordinates[0]; + init_map_on_detail_page(lat, lon, aFeature.geometry); }); }); \ No newline at end of file diff --git a/src/handlebar_helpers.js b/src/handlebar_helpers.js index b40b11a..22d3815 100644 --- a/src/handlebar_helpers.js +++ b/src/handlebar_helpers.js @@ -111,6 +111,47 @@ Handlebars.registerHelper({ return capitalize(aPlace.type.replace(/_/g, ' ')); } }, + formatSearchRank: function(iRank) { + // same as + // https://github.com/openstreetmap/Nominatim/blob/master/sql/functions.sql + // get_searchrank_label() + + if (iRank < 2) { + return 'continent'; + } else if (iRank < 4) { + return 'sea'; + } else if (iRank < 8) { + return 'country'; + } else if (iRank < 12) { + return 'state'; + } else if (iRank < 16) { + return 'county'; + } else if (iRank == 16) { + return 'city'; + } else if (iRank == 17) { + return 'town / island'; + } else if (iRank == 18) { + return 'village / hamlet'; + } else if (iRank == 20) { + return 'suburb'; + } else if (iRank == 21) { + return 'postcode area'; + } else if (iRank == 22) { + return 'croft / farm / locality / islet'; + } else if (iRank == 23) { + return 'postcode area'; + } else if (iRank == 25) { + return 'postcode point'; + } else if (iRank == 26) { + return 'street / major landmark'; + } else if (iRank == 27) { + return 'minory street / path'; + } else if (iRank == 28) { + return 'house / building'; + } else { + return 'other: ' + iRank; + } + }, tooManyHierarchyLinesWarning: function(aPlace) { if (!aPlace.hierarchy) return; diff --git a/src/templates/detailspage.hbs b/src/templates/detailspage.hbs index 8328f1c..22b4b07 100644 --- a/src/templates/detailspage.hbs +++ b/src/templates/detailspage.hbs @@ -69,7 +69,7 @@ Rank - {{aPlace.rank_search_label}} + {{formatSearchRank aPlace.rank_search}} {{#if aPlace.calculated_importance}} @@ -85,8 +85,8 @@ {{coverageType aPlace}} - Centre Point - {{aPlace.lat}},{{aPlace.lon}} + Centre Point (lat,lon) + {{aPlace.centroid.coordinates.[1]}},{{aPlace.centroid.coordinates.[0]}} OSM -- 2.39.5