Fix #3602
This commit is contained in:
parent
38a41d1b02
commit
6b21f53a06
8 changed files with 41 additions and 20 deletions
|
@ -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<String, String> 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;
|
||||
}
|
||||
|
|
|
@ -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<String, String>();
|
||||
}
|
||||
return tags.put(key.toLowerCase(), value);
|
||||
return tags.put(key, value);
|
||||
}
|
||||
|
||||
public void replaceTags(Map<String, String> toPut) {
|
||||
|
|
|
@ -73,6 +73,7 @@ public class OsmBaseStorage {
|
|||
protected InputStream streamForProgress;
|
||||
protected List<IOsmStorageFilter> filters = new ArrayList<IOsmStorageFilter>();
|
||||
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){
|
||||
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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
String tags = query.getString(5);
|
||||
String[] split = tags.split("\\$\\$\\$");
|
||||
for(int i=0; i<split.length - 1; i+= 2){
|
||||
entity.putTag(split[i].trim(), split[i+1].trim());
|
||||
entity.putTagNoLC(split[i].trim(), split[i+1].trim());
|
||||
}
|
||||
p.setEntity(entity);
|
||||
p.setAction(query.getString(3));
|
||||
|
|
|
@ -112,19 +112,19 @@ public class AddPOIAction extends QuickAction {
|
|||
if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) {
|
||||
final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase());
|
||||
if (poiType != null) {
|
||||
newNode.putTag(poiType.getOsmTag(), poiType.getOsmValue());
|
||||
newNode.putTagNoLC(poiType.getOsmTag(), poiType.getOsmValue());
|
||||
if (poiType.getOsmTag2() != null) {
|
||||
newNode.putTag(poiType.getOsmTag2(), poiType.getOsmValue2());
|
||||
newNode.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
|
||||
}
|
||||
} else if (!Algorithms.isEmpty(tag.getValue())) {
|
||||
newNode.putTag(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue());
|
||||
newNode.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue());
|
||||
|
||||
}
|
||||
if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) {
|
||||
newNode.putTag(tag.getKey(), tag.getValue());
|
||||
newNode.putTagNoLC(tag.getKey(), tag.getValue());
|
||||
}
|
||||
} else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) {
|
||||
newNode.putTag(tag.getKey(), tag.getValue());
|
||||
newNode.putTagNoLC(tag.getKey(), tag.getValue());
|
||||
}
|
||||
}
|
||||
EditPoiDialogFragment.commitNode(action, newNode, mOpenstreetmapUtil.getEntityInfo(newNode.getId()), "", false,
|
||||
|
|
Loading…
Reference in a new issue