]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/lib/helpers.js
formatLabel: dont print -Yes- as label
[nominatim-ui.git] / src / lib / helpers.js
index 2dfb186aaaf602a12baf8c6becd1080b00bbfe2a..de1cfd41b2fd3dad879a784645ab2f8effeee352 100644 (file)
@@ -1,8 +1,6 @@
 module.exports.formatOSMType = formatOSMType;
-module.exports.formatShortOSMType = formatShortOSMType;
 module.exports.osmLink = osmLink;
 module.exports.formatLabel = formatLabel;
-module.exports.detailsURL = detailsURL;
 module.exports.wikipediaLink = wikipediaLink;
 module.exports.coverageType = coverageType;
 module.exports.isAdminBoundary = isAdminBoundary;
@@ -28,19 +26,12 @@ function formatOSMType(sType, bExcludeExternal) {
   return '';
 }
 
-function formatShortOSMType(sType) {
-  if (sType === 'node') return 'N';
-  if (sType === 'way') return 'W';
-  if (sType === 'relation') return 'R';
-  return '';
-}
-
 function osmLink(aPlace) {
   if (!aPlace.osm_type) return '';
   var sOSMType = formatOSMType(aPlace.osm_type, false);
   if (!sOSMType) return '';
 
-  return '<a href="https://www.openstreetmap.org/' + sOSMType + '/' + aPlace.osm_id + '">' + sOSMType + ' ' + aPlace.osm_id + '</a>'
+  return '<a href="https://www.openstreetmap.org/' + sOSMType + '/' + aPlace.osm_id + '">' + sOSMType + ' ' + aPlace.osm_id + '</a>';
 }
 
 function formatLabel(aPlace) {
@@ -50,8 +41,8 @@ function formatLabel(aPlace) {
     return s && s[0].toUpperCase() + s.slice(1);
   }
 
-  if (aPlace.type && aPlace.type === 'yes' && aPlace.class) {
-    return capitalize(aPlace.class.replace(/_/g, ' '));
+  if (aPlace.type && aPlace.type === 'yes' && aPlace.category) {
+    return capitalize(aPlace.category.replace(/_/g, ' '));
   }
   if (aPlace.type) {
     return capitalize(aPlace.type.replace(/_/g, ' '));
@@ -59,26 +50,7 @@ function formatLabel(aPlace) {
   return '';
 }
 
-// 'details.html?osmtype=R&osmid=2181874&class=boundary'
-function detailsURL(aFeature) {
-  if (!aFeature) return '';
-
-  var sOSMType = aFeature.osm_type;
-  if (sOSMType && sOSMType.length !== 1) {
-    sOSMType = formatShortOSMType(aFeature.osm_type, false); // node => N
-  }
-  if (!sOSMType) return '';
-
-  var sURL = 'details.html?osmtype=' + sOSMType + '&osmid=' + aFeature.osm_id;
-  if (aFeature.class) {
-    sURL = sURL + '&class=' + encodeURIComponent(aFeature.class);
-  } else if (aFeature.category) {
-    sURL = sURL + '&class=' +encodeURIComponent(aFeature.category);
-  }
-  return sURL;
-}
-
-  /* en:London_Borough_of_Redbridge => https://en.wikipedia.org/wiki/London_Borough_of_Redbridge */
+/* en:London_Borough_of_Redbridge => https://en.wikipedia.org/wiki/London_Borough_of_Redbridge */
 function wikipediaLink(aPlace) {
   if (!aPlace.calculated_wikipedia) return '';
 
@@ -128,7 +100,7 @@ function formatPlaceType(aPlace) {
 
 // Any over 15 are invalid data in OSM anyway
 function formatAdminLevel(iLevel) {
-  return (iLevel < 15 ? iLevel : '');
+  return (iLevel && iLevel < 15 ? iLevel : '');
 }
 
 function formatDistance(fDistance, bInMeters) {
@@ -180,5 +152,4 @@ function zoomLevels() {
     /* 21 */ ''
   ];
   return aZoomLevels;
-
-}
\ No newline at end of file
+}