Skip to content

Commit

Permalink
Fix broken wptPt tags in TravelGpx createWptPt
Browse files Browse the repository at this point in the history
  • Loading branch information
RZR-UA committed Dec 10, 2024
1 parent e7edb2c commit 677c968
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import net.osmand.data.Amenity;
import net.osmand.util.Algorithms;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import net.osmand.shared.gpx.GpxTrackAnalysis;

Expand Down Expand Up @@ -65,6 +64,8 @@ public GpxTrackAnalysis getAnalysis() {
return analysis;
}

private static final Set<String> doNotSaveWptTags = Set.of("route_id", "route_name");

@NonNull
@Override
public WptPt createWptPt(@NonNull Amenity amenity, @Nullable String lang) {
Expand All @@ -75,26 +76,24 @@ public WptPt createWptPt(@NonNull Amenity amenity, @Nullable String lang) {
for (String obfTag : amenity.getAdditionalInfoKeys()) {
String value = amenity.getAdditionalInfo(obfTag);
if (!Algorithms.isEmpty(value)) {
String gpxTag = allowedPointObfToGpxTags.get(obfTag);
if (gpxTag != null) {
wptPt.getExtensionsToWrite().put(gpxTag, value);
}
if (OBF_POINTS_GROUPS_CATEGORY.equals(obfTag)) {
wptPt.setCategory(value);
} else if ("name".equals(obfTag)) {
wptPt.setName(value);
} else if ("description".equals(obfTag)) {
wptPt.setDesc(value);
} else if ("note".equals(obfTag)) {
wptPt.setComment(value);
} else if ("colour".equals(obfTag) && amenity.getAdditionalInfoKeys().contains("color")) {
// ignore "colour" if "color" exists
} else if (!doNotSaveWptTags.contains(obfTag)) {
wptPt.getExtensionsToWrite().put(obfTag, value);
}
}
}
return wptPt;
}

private final static Map<String, String> allowedPointObfToGpxTags = new HashMap<>();

static {
allowedPointObfToGpxTags.put("color", "color");
allowedPointObfToGpxTags.put("gpx_icon", "icon");
allowedPointObfToGpxTags.put("gpx_bg", "background");
}

@NonNull
@Override
public String getPointFilterString() {
Expand Down

0 comments on commit 677c968

Please sign in to comment.