[gnome-maps/wip/mlundblad/localized-names-from-overpass: 3/3] WIP: overpass: Use localized name tag when available...
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/localized-names-from-overpass: 3/3] WIP: overpass: Use localized name tag when available...
- Date: Wed, 21 Oct 2020 20:57:13 +0000 (UTC)
commit 0cf91031a1d58da3be39f603cc0633a2b31507f9
Author: Marcus Lundblad <ml update uu se>
Date: Thu Oct 8 23:29:17 2020 +0200
WIP: overpass: Use localized name tag when available...
src/overpass.js | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/overpass.js b/src/overpass.js
index af1ea389..9c0feb06 100644
--- a/src/overpass.js
+++ b/src/overpass.js
@@ -22,6 +22,7 @@ const Geocode = imports.gi.GeocodeGlib;
const GObject = imports.gi.GObject;
const Soup = imports.gi.Soup;
+const OSMNames = imports.osmNames;
const PhotonParser = imports.photonParser;
const Place = imports.place;
const Utils = imports.utils;
@@ -200,8 +201,9 @@ var Overpass = GObject.registerClass({
if (!(element && element.tags))
return;
- if (element.tags.name)
- place.name = element.tags.name;
+ let name = this._getLocalizedName(element.tags, place);
+ if (name)
+ place.name = name;
if (element.tags.population)
place.population = element.tags.population;
if (element.tags['contact:website'])
@@ -230,6 +232,24 @@ var Overpass = GObject.registerClass({
place.note = element.tags.note;
}
+ _getLocalizedName(tags, place) {
+ let language = Utils.getLanguage();
+
+ Utils.debug('tags: ' + JSON.stringify(tags, null, 2));
+ Utils.debug('language: ' + language);
+ Utils.debug('country: ' + place.country_code);
+
+ let name = OSMNames.getNameForLanguage(tags, language);
+
+ if (!name)
+ name =
+ OSMNames.getFallbackNameForLanguage(tags,
+ place.country_code,
+ language);
+
+ return name;
+ }
+
_getQueryUrl(osmType, osmId) {
return Format.vprintf('%s?data=%s', [BASE_URL,
this._generateOverpassQuery(osmType,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]