X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/6a455ffa0bd1cfea8337ee31867848f5719b47fc..c284914cbfba70d364f0a00f51eaf23b510d91a5:/src/handlebar_helpers.js diff --git a/src/handlebar_helpers.js b/src/handlebar_helpers.js index 4f11821..20ecb7c 100644 --- a/src/handlebar_helpers.js +++ b/src/handlebar_helpers.js @@ -17,23 +17,23 @@ Handlebars.registerHelper({ return ((aAddressLine.isaddress && aAddressLine.isaddress == 'f') ? 'notused' : ''); }, // { osm_type: 'R', osm_id: 12345 } - // relation 12345relation 12345' + sOSMType + ' ' + aPlace.osm_id + '' + '' + sOSMType + ' ' + aPlace.osm_id + '' ); }, /* en:London_Borough_of_Redbridge => https://en.wikipedia.org/wiki/London_Borough_of_Redbridge */ wikipediaLink: function(aPlace) { - if (! aPlace.wikipedia) return ''; + if (! aPlace.calculated_wikipedia) return ''; - var parts = aPlace.wikipedia.split(':', 2); + var parts = aPlace.calculated_wikipedia.split(':', 2); - var sTitle = Handlebars.escapeExpression(aPlace.wikipedia), + var sTitle = Handlebars.escapeExpression(aPlace.calculated_wikipedia), sLanguage = Handlebars.escapeExpression(parts[0]), sArticle = Handlebars.escapeExpression(parts[1]); @@ -42,20 +42,31 @@ Handlebars.registerHelper({ ); }, // { osm_type: 'R', osm_id: 12345 } - // relation 12345details detailsLink: function(aFeature, sTitle) { if (!aFeature) return ''; if (!aFeature.place_id) return ''; - sTitle = 'details >'; - var sTitle = Handlebars.escapeExpression(sTitle); + sTitle = Handlebars.escapeExpression(sTitle || 'details >'); return new Handlebars.SafeString( - '' + (sTitle ? sTitle : aFeature.place_id ) + '' + '' + sTitle + '' + ); + }, + detailsPermaLink: function(aFeature, sTitle) { + if (!aFeature) return ''; + + var sOSMType = formatOSMType(aFeature.osm_type, false); + if (!sOSMType) return ''; + + sTitle = Handlebars.escapeExpression(sTitle || sOSMType + ' ' + aFeature.osm_id); + + return new Handlebars.SafeString( + '' + sTitle + '' ); }, coverageType: function(aPlace) { - return (aPlace.isarea === 't' ? 'Polygon' : 'Point'); + return (aPlace.isarea ? 'Polygon' : 'Point'); }, // fDistance is in meters formatDistance: function(fDistanceMeters) { @@ -80,7 +91,8 @@ Handlebars.registerHelper({ formatMapIcon: function(sIcon) { if (!sIcon) return; - var url = sIcon.match(/png$/) ? Nominatim_Config.Images_Base_Url + '/' + sIcon : Nominatim_Config.Images_Base_Url + 'nominatim/images/mapicons/' + sIcon + '.n.32.png'; + var url = sIcon; + if (!url.match(/^http/)) url = get_config_value('Images_Base_Url') + url; return new Handlebars.SafeString( '' @@ -100,6 +112,60 @@ 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; + + var c = 0; + for (var type in aPlace.hierarchy) { + c = c + type.length+1; + } + if (c < 500) return; + + return new Handlebars.SafeString( + '
There are more child objects which are not shown.
' + ); + }, zoomLevels: function(iSelectedZoom) { var aZoomLevels = [ /* 0 */ 'Continent / Sea', @@ -128,7 +194,9 @@ Handlebars.registerHelper({ var select = $('