Search in sources :

Example 6 with EntityInfo

use of net.osmand.osm.edit.EntityInfo in project Osmand by osmandapp.

the class UploadOpenstreetmapPointAsyncTask method doInBackground.

@Override
protected Map<OsmPoint, String> doInBackground(OsmPoint... points) {
    Map<OsmPoint, String> loadErrorsMap = new HashMap<>();
    boolean uploaded = false;
    for (OsmPoint point : points) {
        if (interruptUploading)
            break;
        if (point.getGroup() == OsmPoint.Group.POI) {
            OpenstreetmapPoint p = (OpenstreetmapPoint) point;
            EntityInfo entityInfo = null;
            if (OsmPoint.Action.CREATE != p.getAction()) {
                entityInfo = remotepoi.loadNode(p.getEntity());
            }
            Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false, null);
            if (n != null) {
                uploaded = true;
                plugin.getDBPOI().deletePOI(p);
                publishProgress(p);
            }
            loadErrorsMap.put(point, n != null ? null : "Unknown problem");
        } else if (point.getGroup() == OsmPoint.Group.BUG) {
            OsmNotesPoint p = (OsmNotesPoint) point;
            String errorMessage = remotebug.commit(p, p.getText(), p.getAction(), loadAnonymous).warning;
            if (errorMessage == null) {
                plugin.getDBBug().deleteAllBugModifications(p);
                publishProgress(p);
            }
            loadErrorsMap.put(point, errorMessage);
        }
    }
    if (uploaded && closeChangeSet) {
        remotepoi.closeChangeSet();
    }
    return loadErrorsMap;
}
Also used : HashMap(java.util.HashMap) EntityInfo(net.osmand.osm.edit.EntityInfo) Node(net.osmand.osm.edit.Node)

Aggregations

EntityInfo (net.osmand.osm.edit.EntityInfo)6 Node (net.osmand.osm.edit.Node)6 EntityId (net.osmand.osm.edit.Entity.EntityId)4 Relation (net.osmand.osm.edit.Relation)4 Way (net.osmand.osm.edit.Way)4 IOException (java.io.IOException)3 Entity (net.osmand.osm.edit.Entity)3 FileOutputStream (java.io.FileOutputStream)2 HashMap (java.util.HashMap)2 EntityType (net.osmand.osm.edit.Entity.EntityType)2 OsmStorageWriter (net.osmand.osm.io.OsmStorageWriter)2 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)2 BinaryParser (crosby.binary.BinaryParser)1 DenseNodes (crosby.binary.Osmformat.DenseNodes)1 HeaderBlock (crosby.binary.Osmformat.HeaderBlock)1 Info (crosby.binary.Osmformat.Info)1 MemberType (crosby.binary.Osmformat.Relation.MemberType)1 BlockInputStream (crosby.binary.file.BlockInputStream)1 Container (java.awt.Container)1 WindowAdapter (java.awt.event.WindowAdapter)1