Label boundaries by regional official designations

This commit is contained in:
Minh Nguyễn 2025-01-11 15:37:37 -08:00
parent 7006aa9839
commit 7869631e83
3 changed files with 37 additions and 4 deletions

View file

@ -68,9 +68,11 @@ OSM.Query = function (map) {
const tags = feature.tags;
let prefix = "";
if (tags.boundary === "administrative" && tags.admin_level) {
prefix = I18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
defaultValue: I18n.t("geocoder.search_osm_nominatim.prefix.boundary.administrative")
if (tags.boundary === "administrative" && (tags.border_type || tags.admin_level)) {
prefix = I18n.t("geocoder.search_osm_nominatim.border_types." + tags.border_type, {
defaultValue: I18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
defaultValue: I18n.t("geocoder.search_osm_nominatim.prefix.boundary.administrative")
})
});
} else {
const prefixes = I18n.t("geocoder.search_osm_nominatim.prefix");

View file

@ -101,10 +101,14 @@ class GeocoderController < ApplicationController
if klass == "boundary" && type == "administrative"
rank = (place.attributes["address_rank"].to_i + 1) / 2
prefix_name = t "geocoder.search_osm_nominatim.admin_levels.level#{rank}", :default => prefix_name
border_type = nil
place_type = nil
place_tags = %w[linked_place place]
place.elements["extratags"].elements.each("tag") do |extratag|
prefix_name = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => prefix_name if place_tags.include?(extratag.attributes["key"])
border_type = t "geocoder.search_osm_nominatim.border_types.#{extratag.attributes['value']}", :default => border_type if extratag.attributes["key"] == "border_type"
place_type = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => place_type if place_tags.include?(extratag.attributes["key"])
end
prefix_name = place_type || border_type || prefix_name
end
prefix = t ".prefix_format", :name => prefix_name
object_type = place.attributes["osm_type"]

View file

@ -1506,6 +1506,33 @@ en:
level9: "Administrative Boundary (Level 9)"
level10: "Administrative Boundary (Level 10)"
level11: "Administrative Boundary (Level 11)"
border_types:
arrondissement: "Arrondissement Boundary"
borough: "Borough Boundary"
cercle: "Cercle Boundary"
city: "City Boundary"
comarca: "Comarca Boundary"
county: "County Boundary"
departement: "Departmental Boundary"
department: "Departmental Boundary"
district: "District Boundary"
distrito: "District Boundary"
freguesia: "Freguesia Boundary"
local_authority: "Local Authority Boundary"
municipality: "Municipal Boundary"
municipi: "Municipal Boundary"
município: "Municipal Boundary"
nation: "International Boundary"
national: "International Boundary"
neighbourhood: "Neighborhood Boundary"
parish: "Parish Boundary"
province: "Provincial Boundary"
região: "Regional Boundary"
region: "Regional Boundary"
state: "State Boundary"
town: "Town Boundary"
township: "Township Boundary"
village: "Village Boundary"
results:
no_results: "No results found"
more_results: "More results"