From 6b21f53a06d56b55154d2f89a0a36e3638c4fd9b Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 3 Apr 2017 22:28:52 +0200 Subject: [PATCH] Fix #3602 --- OsmAnd-java/src/net/osmand/NativeLibrary.java | 10 ++++++++++ OsmAnd-java/src/net/osmand/osm/edit/Entity.java | 8 ++++++-- OsmAnd-java/src/net/osmand/osm/io/OsmBaseStorage.java | 7 ++++++- .../net/osmand/plus/osmedit/EditPoiDialogFragment.java | 10 +++++----- .../osmand/plus/osmedit/OpenstreetmapLocalUtil.java | 8 ++++---- .../osmand/plus/osmedit/OpenstreetmapRemoteUtil.java | 6 ++++-- .../osmand/plus/osmedit/OpenstreetmapsDbHelper.java | 2 +- .../osmand/plus/quickaction/actions/AddPOIAction.java | 10 +++++----- 8 files changed, 41 insertions(+), 20 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/NativeLibrary.java b/OsmAnd-java/src/net/osmand/NativeLibrary.java index 81ce6cab00..b33b8ea195 100644 --- a/OsmAnd-java/src/net/osmand/NativeLibrary.java +++ b/OsmAnd-java/src/net/osmand/NativeLibrary.java @@ -20,6 +20,7 @@ import java.util.Map; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion; import net.osmand.binary.RouteDataObject; +import net.osmand.data.LatLon; import net.osmand.data.MapObject; import net.osmand.data.QuadRect; import net.osmand.render.RenderingRuleSearchRequest; @@ -360,6 +361,7 @@ public class NativeLibrary { private String iconRes; private int order; private boolean visible; + private LatLon labelLatLon; public Map getTags() { return tags; @@ -373,6 +375,14 @@ public class NativeLibrary { return order; } + public void setLabelLatLon(LatLon labelLatLon) { + this.labelLatLon = labelLatLon; + } + + public LatLon getLabelLatLon() { + return labelLatLon; + } + public void setOrder(int order) { this.order = order; } diff --git a/OsmAnd-java/src/net/osmand/osm/edit/Entity.java b/OsmAnd-java/src/net/osmand/osm/edit/Entity.java index 8828185acd..685131981d 100644 --- a/OsmAnd-java/src/net/osmand/osm/edit/Entity.java +++ b/OsmAnd-java/src/net/osmand/osm/edit/Entity.java @@ -120,7 +120,7 @@ public abstract class Entity implements Serializable { public Entity(Entity copy, long id) { this.id = id; for (String t : copy.getTagKeySet()) { - putTag(t, copy.getTag(t)); + putTagNoLC(t, copy.getTag(t)); } this.dataLoaded = copy.dataLoaded; } @@ -153,10 +153,14 @@ public abstract class Entity implements Serializable { } public String putTag(String key, String value) { + return putTagNoLC(key.toLowerCase(), value); + } + + public String putTagNoLC(String key, String value) { if (tags == null) { tags = new LinkedHashMap(); } - return tags.put(key.toLowerCase(), value); + return tags.put(key, value); } public void replaceTags(Map toPut) { diff --git a/OsmAnd-java/src/net/osmand/osm/io/OsmBaseStorage.java b/OsmAnd-java/src/net/osmand/osm/io/OsmBaseStorage.java index 1e380363b5..8e9c8349ff 100644 --- a/OsmAnd-java/src/net/osmand/osm/io/OsmBaseStorage.java +++ b/OsmAnd-java/src/net/osmand/osm/io/OsmBaseStorage.java @@ -73,6 +73,7 @@ public class OsmBaseStorage { protected InputStream streamForProgress; protected List filters = new ArrayList(); protected boolean supressWarnings = true; + protected boolean convertTagsToLC = true; protected boolean parseEntityInfo; @@ -223,7 +224,11 @@ public class OsmBaseStorage { if (ELEM_TAG.equals(name)) { String key = parser.getAttributeValue("",ATTR_K); if(key != null){ - currentParsedEntity.putTag(key, parser.getAttributeValue("",ATTR_V)); + if(convertTagsToLC) { + currentParsedEntity.putTag(key, parser.getAttributeValue("",ATTR_V)); + } else { + currentParsedEntity.putTagNoLC(key, parser.getAttributeValue("",ATTR_V)); + } } } else if (ELEM_ND.equals(name)) { Long id = parseId(parser, ATTR_REF, -1); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 2ad32624c4..e42dffa70d 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -398,19 +398,19 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase()); if (poiType != null) { - node.putTag(poiType.getOsmTag(), poiType.getOsmValue()); + node.putTagNoLC(poiType.getOsmTag(), poiType.getOsmValue()); if (poiType.getOsmTag2() != null) { - node.putTag(poiType.getOsmTag2(), poiType.getOsmValue2()); + node.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); } } else if (!Algorithms.isEmpty(tag.getValue())) { - node.putTag(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue()); + node.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue()); } if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) { - node.putTag(tag.getKey(), tag.getValue()); + node.putTagNoLC(tag.getKey(), tag.getValue()); } } else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) { - node.putTag(tag.getKey(), tag.getValue()); + node.putTagNoLC(tag.getKey(), tag.getValue()); } } commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), "", false, diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java index f63a80b376..27c20ff791 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java @@ -57,15 +57,15 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { Node entity = new Node(n.getLocation().getLatitude(), n.getLocation().getLongitude(), nodeId); - entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); + entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); if(poiType.getOsmTag2() != null) { - entity.putTag(poiType.getOsmTag2(), poiType.getOsmValue2()); + entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); } if(!Algorithms.isEmpty(n.getName())) { - entity.putTag(OSMTagKey.NAME.getValue(), n.getName()); + entity.putTagNoLC(OSMTagKey.NAME.getValue(), n.getName()); } if(!Algorithms.isEmpty(n.getOpeningHours())) { - entity.putTag(OSMTagKey.OPENING_HOURS.getValue(), n.getOpeningHours()); + entity.putTagNoLC(OSMTagKey.OPENING_HOURS.getValue(), n.getOpeningHours()); } // check whether this is node (because id of node could be the same as relation) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index 4dc3c109bd..38e0f5a55d 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -323,13 +323,14 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { getSiteApi() + "api/0.6/node/" + nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$ if (res != null) { OsmBaseStorage st = new OsmBaseStorage(); + st.setConvertTagsToLC(false); st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$ EntityId id = new Entity.EntityId(EntityType.NODE, nodeId); Node entity = (Node) st.getRegisteredEntities().get(id); // merge non existing tags for (String rtag : entity.getTagKeySet()) { if (!n.getTagKeySet().contains(rtag)) { - n.putTag(rtag, entity.getTag(rtag)); + n.putTagNoLC(rtag, entity.getTag(rtag)); } } if(MapUtils.getDistance(n.getLatLon(), entity.getLatLon()) < 10) { @@ -362,6 +363,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { getSiteApi() + "api/0.6/node/" + nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$ if (res != null) { OsmBaseStorage st = new OsmBaseStorage(); + st.setConvertTagsToLC(false); st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$ EntityId id = new Entity.EntityId(EntityType.NODE, nodeId); Node entity = (Node) st.getRegisteredEntities().get(id); @@ -372,7 +374,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { PoiType poiType = n.getType().getPoiTypeByKeyName(n.getSubType()); if(poiType.getOsmValue().equals(entity.getTag(poiType.getOsmTag()))) { entity.removeTag(poiType.getOsmTag()); - entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); + entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); } else { // later we could try to determine tags } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java index 3249a54c40..72a5da6165 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java @@ -113,7 +113,7 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper { String tags = query.getString(5); String[] split = tags.split("\\$\\$\\$"); for(int i=0; i