1 OSM.featurePrefix = function (feature) {
2 const tags = feature.tags || {};
4 if (tags.boundary === "administrative" && (tags.border_type || tags.admin_level)) {
5 return OSM.i18n.t("geocoder.search_osm_nominatim.border_types." + tags.border_type, {
6 defaultValue: OSM.i18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
7 defaultValue: OSM.i18n.t("geocoder.search_osm_nominatim.prefix.boundary.administrative")
12 const prefixes = OSM.i18n.t("geocoder.search_osm_nominatim.prefix");
14 // Prefer an exact value mapping from any tag before falling back to a
15 // title-cased value of the first tag that has a prefix group.
16 for (const key in tags) {
17 if (prefixes[key]?.[tags[key]]) return prefixes[key][tags[key]];
19 for (const key in tags) {
21 const value = tags[key];
22 return value.slice(0, 1).toUpperCase() + value.slice(1).replace(/_/g, " ");
26 return OSM.i18n.t("javascripts.query." + feature.type);
29 OSM.featureName = function (feature) {
30 const tags = feature.tags || {},
31 localeKeys = (OSM.preferred_languages || []).map(locale => `name:${locale}`);
33 for (const key of [...localeKeys, "name", "ref", "addr:housename"]) {
34 if (tags[key]) return tags[key];
36 if (tags["addr:housenumber"] && tags["addr:street"]) return `${tags["addr:housenumber"]} ${tags["addr:street"]}`;
38 return "#" + feature.id;