Skip to content

Commit

Permalink
Merge pull request #21585 from osmandapp/rzr-lang-link
Browse files Browse the repository at this point in the history
TravelGpx: restore localized names for tracks and points
  • Loading branch information
Chumva authored Dec 20, 2024
2 parents 8741e56 + 37778c5 commit e9c6bbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 8 additions & 3 deletions OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ public GpxTrackAnalysis getAnalysis() {
@Override
public WptPt createWptPt(@NonNull Amenity amenity, @Nullable String lang) {
WptPt wptPt = new WptPt();
wptPt.setName(amenity.getName());
wptPt.setLat(amenity.getLocation().getLatitude());
wptPt.setLon(amenity.getLocation().getLongitude());
wptPt.setName(amenity.getName());

Map<String, String> wptPtExtensions = wptPt.getExtensionsToWrite();
amenity.getNamesMap(true).forEach((key, value) -> wptPtExtensions.put("name:" + key, value));

for (String obfTag : amenity.getAdditionalInfoKeys()) {
String value = amenity.getAdditionalInfo(obfTag);
if (!Algorithms.isEmpty(value)) {
Expand All @@ -96,12 +100,13 @@ public WptPt createWptPt(@NonNull Amenity amenity, @Nullable String lang) {
} else if (WPT_EXTRA_TAGS.equals(obfTag)) {
Gson gson = new Gson();
Type type = new TypeToken<Map<String, String>>() {}.getType();
wptPt.getExtensionsToWrite().putAll(gson.fromJson(value, type));
wptPtExtensions.putAll(gson.fromJson(value, type));
} else if (!doNotSaveWptTags.contains(obfTag)) {
wptPt.getExtensionsToWrite().put(obfTag, value);
wptPtExtensions.put(obfTag, value);
}
}
}

return wptPt;
}

Expand Down
11 changes: 9 additions & 2 deletions OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,14 @@ public boolean publish(Amenity amenity) {
if (amenity.isRouteTrack()) {
if (!isAlreadyProcessed) {
isAlreadyProcessed = true;
reconstructGpxTagsFromAmenityType(amenity, gpxFileExtensions);
reconstructActivityFromAmenity(amenity, gpxFileExtensions);
amenity.getNamesMap(true).forEach((lang, value) ->
{
if (!"ref".equals(lang) && !"sym".equals(lang)) {
gpxFileExtensions.put("name:" + lang, value);
}
}
);
for (String tag : amenity.getAdditionalInfoKeys()) {
String value = amenity.getAdditionalInfo(tag);
if (tag.startsWith(OBF_POINTS_GROUPS_PREFIX)) {
Expand Down Expand Up @@ -1192,7 +1199,7 @@ public boolean isCancelled() {
};
}

private void reconstructGpxTagsFromAmenityType(Amenity amenity, Map<String, String> gpxFileExtensions) {
private void reconstructActivityFromAmenity(Amenity amenity, Map<String, String> gpxFileExtensions) {
if (amenity.isRouteTrack() && amenity.getSubType() != null) {
String subType = amenity.getSubType();
if (subType.startsWith(ROUTES_PREFIX)) {
Expand Down

0 comments on commit e9c6bbf

Please sign in to comment.