Skip to content

Commit

Permalink
Label boundaries by regional official designations
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Jan 12, 2025
1 parent 0c6ded3 commit e7f1141
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/assets/javascripts/index/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ OSM.Query = function (map) {
var tags = feature.tags;
var 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 {
var prefixes = I18n.t("geocoder.search_osm_nominatim.prefix");
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/geocoder_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ def search_osm_nominatim
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 = false
place_type = false
place.elements["extratags"].elements.each("tag") do |extratag|
prefix_name = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => prefix_name if extratag.attributes["key"] == "linked_place" || extratag.attributes["key"] == "place"
border_type = t "geocoder.search_osm_nominatim.border_types.#{extratag.attributes['value']}", :default => prefix_name if extratag.attributes["key"] == "border_type"
place_type = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => prefix_name if extratag.attributes["key"] == "linked_place" || extratag.attributes["key"] == "place"
end
prefix_name = place_type || border_type || prefix_name
end
prefix = t ".prefix_format", :name => prefix_name
object_type = place.attributes["osm_type"]
Expand Down
27 changes: 27 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,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"
Expand Down

0 comments on commit e7f1141

Please sign in to comment.