From 2ab0c034c7bd469248d821165cb5d64fc2ef9df4 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 16 Mar 2021 10:04:45 +0200 Subject: [PATCH] Fix #5958 --- .../main/java/net/osmand/osm/MapPoiTypes.java | 2 ++ .../src/main/java/net/osmand/osm/PoiType.java | 32 +++++++++++++++---- .../net/osmand/plus/osmedit/AddPOIAction.java | 3 ++ .../plus/osmedit/AdvancedEditPoiFragment.java | 4 ++- .../net/osmand/plus/osmedit/EditPoiData.java | 11 ++++--- .../plus/osmedit/EditPoiDialogFragment.java | 4 +++ .../plus/osmedit/OpenstreetmapLocalUtil.java | 3 ++ 7 files changed, 48 insertions(+), 11 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java index e273fa4e7f..869cf7d962 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java @@ -658,6 +658,8 @@ public class MapPoiTypes { tp.setOsmValue(parser.getAttributeValue("", "value")); tp.setOsmEditTagValue(parser.getAttributeValue("", "edit_tag"), parser.getAttributeValue("", "edit_value")); + tp.setOsmEditTagValue2(parser.getAttributeValue("", "edit_tag2"), + parser.getAttributeValue("", "edit_value2")); tp.setOsmTag2(parser.getAttributeValue("", "tag2")); tp.setOsmValue2(parser.getAttributeValue("", "value2")); diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/PoiType.java b/OsmAnd-java/src/main/java/net/osmand/osm/PoiType.java index 5651cf0e03..a3a905fb80 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/PoiType.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/PoiType.java @@ -16,9 +16,10 @@ public class PoiType extends AbstractPoiType { private String editTag; private String editValue; + private String editTag2; + private String editValue2; private boolean filterOnly; - private String nameTag; private boolean text; private boolean nameOnly; @@ -68,27 +69,46 @@ public class PoiType extends AbstractPoiType { this.editTag = osmTag; this.editValue = editValue; } - + + public void setOsmEditTagValue2(String osmTag, String editValue) { + this.editTag2 = osmTag; + this.editValue2 = editValue; + } + public String getEditOsmTag() { - if(isReference()) { + if (isReference()) { return referenceType.getEditOsmTag(); } - if(editTag == null) { + if (editTag == null) { return getOsmTag(); } return editTag; } public String getEditOsmValue() { - if(isReference()) { + if (isReference()) { return referenceType.getEditOsmValue(); } - if(editValue == null) { + if (editValue == null) { return getOsmValue(); } return editValue; } + public String getEditOsmTag2() { + if (isReference()) { + return referenceType.getEditOsmTag2(); + } + return editTag2; + } + + public String getEditOsmValue2() { + if (isReference()) { + return referenceType.getEditOsmValue2(); + } + return editValue2; + } + public void setOsmTag(String osmTag) { this.osmTag = osmTag; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java index a46ddb0ba1..1404815c4c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java @@ -147,6 +147,9 @@ public class AddPOIAction extends QuickAction { if (poiType.getOsmTag2() != null) { newNode.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); } + if (poiType.getEditOsmTag2() != null) { + newNode.putTagNoLC(poiType.getEditOsmTag2(), poiType.getEditOsmValue2()); + } } else if (!Algorithms.isEmpty(tag.getValue())) { PoiCategory category = editPoiData.getPoiCategory(); if (category != null) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index a99afa7a22..4ebf968c24 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -323,7 +323,9 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment if (poiType.getOsmTag2() != null) { stringSet.add(poiType.getOsmTag2()); } - + if (poiType.getEditOsmTag2() != null) { + stringSet.add(poiType.getEditOsmTag2()); + } } if (poiType.getEditOsmValue() != null) { values.add(poiType.getEditOsmValue()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index 7dab7780b0..77f8acace0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -237,11 +237,13 @@ public class EditPoiData { private void removeTypeTagWithPrefix(boolean needRemovePrefix) { if (currentPoiType != null) { if (needRemovePrefix) { - tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE); tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag2(), REMOVE_TAG_VALUE); } else { - tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag()); tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2()); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag()); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag2()); } removeCurrentTypeTag(); } @@ -249,9 +251,10 @@ public class EditPoiData { private void removeCurrentTypeTag() { if (currentPoiType != null) { - tagValues.remove(currentPoiType.getEditOsmTag()); tagValues.remove(currentPoiType.getOsmTag2()); - changedTags.removeAll(Arrays.asList(currentPoiType.getEditOsmTag(), currentPoiType.getOsmTag2())); + tagValues.remove(currentPoiType.getEditOsmTag()); + tagValues.remove(currentPoiType.getEditOsmTag2()); + changedTags.removeAll(Arrays.asList(currentPoiType.getEditOsmTag(),currentPoiType.getEditOsmTag2(), currentPoiType.getOsmTag2())); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 946d79ca18..6ea10fe5ef 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -515,6 +515,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); } + if (poiType.getEditOsmTag2() != null) { + entity.putTagNoLC(poiType.getEditOsmTag2(), poiType.getEditOsmValue2()); + entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getEditOsmTag2()); + } } else if (!Algorithms.isEmpty(poiTypeTag)) { PoiCategory category = editPoiData.getPoiCategory(); if (category != null) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java index 4d42026026..fc0c62d263 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java @@ -127,6 +127,9 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { if (poiType.getOsmTag2() != null) { entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); } + if (poiType.getEditOsmTag2() != null) { + entity.putTagNoLC(poiType.getEditOsmTag2(), poiType.getEditOsmValue2()); + } } if (!Algorithms.isEmpty(mapObject.getName())) { entity.putTagNoLC(OSMTagKey.NAME.getValue(), mapObject.getName());