diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index a7d3e853a7..990da169d1 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -167,7 +167,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment editPoiData.setIsInEdit(true); for (Entry tag : editPoiData.getTagValues().entrySet()) { if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG) - || tag.getKey().equals(OSMSettings.OSMTagKey.NAME.getValue())) + || tag.getKey().equals(OSMSettings.OSMTagKey.NAME.getValue()) || tag.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX)) continue; addTagView(tag.getKey(), tag.getValue()); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index 731cde3284..27d85343e5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -23,6 +23,8 @@ public class EditPoiData { private Node entity; public static final String POI_TYPE_TAG = "poi_type_tag"; + public static final String REMOVE_TAG_PREFIX = "----"; + public static final String REMOVE_TAG_VALUE = "DELETE"; private boolean hasChangesBeenMade = false; private Map allTranslatedSubTypes; private PoiCategory category; @@ -99,7 +101,6 @@ public class EditPoiData { } } - public Map getTagValues() { return Collections.unmodifiableMap(tagValues); } @@ -109,6 +110,7 @@ public class EditPoiData { checkNotInEdit(); try { isInEdit = true; + tagValues.remove(REMOVE_TAG_PREFIX+tag); tagValues.put(tag, value); notifyDatasetChanged(tag); } finally { @@ -137,6 +139,7 @@ public class EditPoiData { checkNotInEdit(); try { isInEdit = true; + tagValues.put(REMOVE_TAG_PREFIX+tag, REMOVE_TAG_VALUE); tagValues.remove(tag); notifyDatasetChanged(tag); } finally { @@ -185,6 +188,8 @@ public class EditPoiData { retrieveType(); PoiType pt = getPoiTypeDefined(); if(pt != null) { + tagValues.put(REMOVE_TAG_PREFIX+pt.getOsmTag(), REMOVE_TAG_VALUE); + tagValues.put(REMOVE_TAG_PREFIX+pt.getOsmTag2(), REMOVE_TAG_VALUE); tagValues.remove(pt.getOsmTag()); tagValues.remove(pt.getOsmTag2()); category = pt.getCategory(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 4ef2940f66..c092a795b6 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -426,24 +426,29 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId()); OsmPoint.Action action = node.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; for (Map.Entry tag : editPoiData.getTagValues().entrySet()) { - if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { - final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase()); - if (poiType != null) { - node.putTagNoLC(poiType.getOsmTag(), poiType.getOsmValue()); - if (poiType.getOsmTag2() != null) { - node.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); - } - } else if (!Algorithms.isEmpty(tag.getValue())) { - node.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue()); - - } - if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) { - node.putTagNoLC(tag.getKey(), tag.getValue()); - } - } else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) { + if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) && + !tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { node.putTagNoLC(tag.getKey(), tag.getValue()); } } + String poiTypeTag = editPoiData.getTagValues().get(EditPoiData.POI_TYPE_TAG); + if (poiTypeTag != null) { + final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(poiTypeTag.trim().toLowerCase()); + if (poiType != null) { + node.putTagNoLC(poiType.getOsmTag(), poiType.getOsmValue()); + node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag()); + if (poiType.getOsmTag2() != null) { + node.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); + node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); + } + } else if (!Algorithms.isEmpty(poiTypeTag)) { + node.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), poiTypeTag); + + } + if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) { + node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag); + } + } commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), "", false, new CallbackWithObject() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index 38e0f5a55d..e69ce85bde 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -222,7 +222,8 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { for (String k : n.getTagKeySet()) { String val = n.getTag(k); - if (val.length() == 0 || k.length() == 0 || "poi_type_tag".equals(k)) + if (val.length() == 0 || k.length() == 0 || EditPoiData.POI_TYPE_TAG.equals(k) || + k.startsWith(EditPoiData.REMOVE_TAG_PREFIX) || n.getTag(EditPoiData.REMOVE_TAG_PREFIX + k) != null) continue; ser.startTag(null, "tag"); //$NON-NLS-1$ ser.attribute(null, "k", k); //$NON-NLS-1$