Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TravelGpx: restore localized names for tracks and points #21585

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
RZR-UA marked this conversation as resolved.
Show resolved Hide resolved

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
Loading