Fix #2023.
This commit is contained in:
parent
17e9590518
commit
a5c225875b
4 changed files with 29 additions and 18 deletions
|
@ -167,7 +167,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
||||||
editPoiData.setIsInEdit(true);
|
editPoiData.setIsInEdit(true);
|
||||||
for (Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
for (Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
||||||
if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)
|
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;
|
continue;
|
||||||
addTagView(tag.getKey(), tag.getValue());
|
addTagView(tag.getKey(), tag.getValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ public class EditPoiData {
|
||||||
private Node entity;
|
private Node entity;
|
||||||
|
|
||||||
public static final String POI_TYPE_TAG = "poi_type_tag";
|
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 boolean hasChangesBeenMade = false;
|
||||||
private Map<String, PoiType> allTranslatedSubTypes;
|
private Map<String, PoiType> allTranslatedSubTypes;
|
||||||
private PoiCategory category;
|
private PoiCategory category;
|
||||||
|
@ -99,7 +101,6 @@ public class EditPoiData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Map<String, String> getTagValues() {
|
public Map<String, String> getTagValues() {
|
||||||
return Collections.unmodifiableMap(tagValues);
|
return Collections.unmodifiableMap(tagValues);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +110,7 @@ public class EditPoiData {
|
||||||
checkNotInEdit();
|
checkNotInEdit();
|
||||||
try {
|
try {
|
||||||
isInEdit = true;
|
isInEdit = true;
|
||||||
|
tagValues.remove(REMOVE_TAG_PREFIX+tag);
|
||||||
tagValues.put(tag, value);
|
tagValues.put(tag, value);
|
||||||
notifyDatasetChanged(tag);
|
notifyDatasetChanged(tag);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -137,6 +139,7 @@ public class EditPoiData {
|
||||||
checkNotInEdit();
|
checkNotInEdit();
|
||||||
try {
|
try {
|
||||||
isInEdit = true;
|
isInEdit = true;
|
||||||
|
tagValues.put(REMOVE_TAG_PREFIX+tag, REMOVE_TAG_VALUE);
|
||||||
tagValues.remove(tag);
|
tagValues.remove(tag);
|
||||||
notifyDatasetChanged(tag);
|
notifyDatasetChanged(tag);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -185,6 +188,8 @@ public class EditPoiData {
|
||||||
retrieveType();
|
retrieveType();
|
||||||
PoiType pt = getPoiTypeDefined();
|
PoiType pt = getPoiTypeDefined();
|
||||||
if(pt != null) {
|
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.getOsmTag());
|
||||||
tagValues.remove(pt.getOsmTag2());
|
tagValues.remove(pt.getOsmTag2());
|
||||||
category = pt.getCategory();
|
category = pt.getCategory();
|
||||||
|
|
|
@ -426,22 +426,27 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId());
|
Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId());
|
||||||
OsmPoint.Action action = node.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
OsmPoint.Action action = node.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
||||||
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
||||||
if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) {
|
if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) &&
|
||||||
final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase());
|
!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) {
|
if (poiType != null) {
|
||||||
node.putTagNoLC(poiType.getOsmTag(), poiType.getOsmValue());
|
node.putTagNoLC(poiType.getOsmTag(), poiType.getOsmValue());
|
||||||
|
node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag());
|
||||||
if (poiType.getOsmTag2() != null) {
|
if (poiType.getOsmTag2() != null) {
|
||||||
node.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
|
node.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
|
||||||
|
node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2());
|
||||||
}
|
}
|
||||||
} else if (!Algorithms.isEmpty(tag.getValue())) {
|
} else if (!Algorithms.isEmpty(poiTypeTag)) {
|
||||||
node.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue());
|
node.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), poiTypeTag);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) {
|
if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) {
|
||||||
node.putTagNoLC(tag.getKey(), tag.getValue());
|
node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag);
|
||||||
}
|
|
||||||
} else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) {
|
|
||||||
node.putTagNoLC(tag.getKey(), tag.getValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), "", false,
|
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), "", false,
|
||||||
|
|
|
@ -222,7 +222,8 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||||
|
|
||||||
for (String k : n.getTagKeySet()) {
|
for (String k : n.getTagKeySet()) {
|
||||||
String val = n.getTag(k);
|
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;
|
continue;
|
||||||
ser.startTag(null, "tag"); //$NON-NLS-1$
|
ser.startTag(null, "tag"); //$NON-NLS-1$
|
||||||
ser.attribute(null, "k", k); //$NON-NLS-1$
|
ser.attribute(null, "k", k); //$NON-NLS-1$
|
||||||
|
|
Loading…
Reference in a new issue