Merge osm changes

This commit is contained in:
Victor Shcherb 2015-11-15 21:42:05 +01:00
parent 2f66485e4f
commit 41ae394384
4 changed files with 12 additions and 3 deletions

View file

@ -305,6 +305,7 @@ public class EditPoiDialogFragment extends DialogFragment {
private void save() { private void save() {
Node original = editPoiData.getEntity(); Node original = editPoiData.getEntity();
final boolean offlineEdit = mOpenstreetmapUtil instanceof OpenstreetmapLocalUtil;
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() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; OsmPoint.Action action = node.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) { for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
@ -319,6 +320,9 @@ public class EditPoiDialogFragment extends DialogFragment {
node.putTag(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue()); node.putTag(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue());
} }
if(offlineEdit && !Algorithms.isEmpty(tag.getValue())) {
node.putTag(tag.getKey(), tag.getValue());
}
} else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) { } else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) {
node.putTag(tag.getKey(), tag.getValue()); node.putTag(tag.getKey(), tag.getValue());
} }
@ -330,7 +334,7 @@ public class EditPoiDialogFragment extends DialogFragment {
@Override @Override
public void run() { public void run() {
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
if (plugin != null && mOpenstreetmapUtil instanceof OpenstreetmapLocalUtil) { if (plugin != null && offlineEdit) {
List<OpenstreetmapPoint> points = plugin.getDBPOI().getOpenstreetmapPoints(); List<OpenstreetmapPoint> points = plugin.getDBPOI().getOpenstreetmapPoints();
if (getActivity() instanceof MapActivity && points.size() > 0) { if (getActivity() instanceof MapActivity && points.size() > 0) {
OsmPoint point = points.get(points.size() - 1); OsmPoint point = points.get(points.size() - 1);

View file

@ -61,7 +61,7 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
Node entity = new Node(n.getLocation().getLatitude(), Node entity = new Node(n.getLocation().getLatitude(),
n.getLocation().getLongitude(), n.getLocation().getLongitude(),
nodeId); nodeId);
entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getOsmValue()); entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getTranslation());
if(poiType.getOsmTag2() != null) { if(poiType.getOsmTag2() != null) {
entity.putTag(poiType.getOsmTag2(), poiType.getOsmValue2()); entity.putTag(poiType.getOsmTag2(), poiType.getOsmValue2());
} }

View file

@ -364,7 +364,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
if (entity != null && MapUtils.getDistance(entity.getLatLon(), n.getLocation()) < 50) { if (entity != null && MapUtils.getDistance(entity.getLatLon(), n.getLocation()) < 50) {
PoiType poiType = n.getType().getPoiTypeByKeyName(n.getSubType()); PoiType poiType = n.getType().getPoiTypeByKeyName(n.getSubType());
entity.removeTag(poiType.getOsmTag()); entity.removeTag(poiType.getOsmTag());
entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getOsmValue()); entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getTranslation());
return entity; return entity;
} }
return null; return null;

View file

@ -570,6 +570,8 @@ public class OsmEditsFragment extends OsmAndListFragment
sz.endTag("", "create"); sz.endTag("", "create");
sz.startTag("", "modify"); sz.startTag("", "modify");
writeContent(sz, points, OsmPoint.Action.MODIFY); writeContent(sz, points, OsmPoint.Action.MODIFY);
writeContent(sz, points, OsmPoint.Action.REOPEN);
sz.endTag("", "modify"); sz.endTag("", "modify");
sz.startTag("", "delete"); sz.startTag("", "delete");
writeContent(sz, points, OsmPoint.Action.DELETE); writeContent(sz, points, OsmPoint.Action.DELETE);
@ -601,6 +603,9 @@ public class OsmEditsFragment extends OsmAndListFragment
sz.attribute("", "version", "1"); sz.attribute("", "version", "1");
for (String tag : p.getEntity().getTagKeySet()) { for (String tag : p.getEntity().getTagKeySet()) {
String val = p.getEntity().getTag(tag); String val = p.getEntity().getTag(tag);
if (val == null || val.length() == 0 || tag.length() == 0 || "poi_type_tag".equals(tag)) {
continue;
}
sz.startTag("", "tag"); sz.startTag("", "tag");
sz.attribute("", "k", tag); sz.attribute("", "k", tag);
sz.attribute("", "v", val); sz.attribute("", "v", val);