Search in sources :

Example 11 with OpenstreetmapPoint

use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.

the class OsmEditsFragment method showOnMap.

private void showOnMap(OsmPoint osmPoint, int itemPosition) {
    selectedItemPosition = itemPosition;
    boolean isOsmPoint = osmPoint instanceof OpenstreetmapPoint;
    String type = osmPoint.getGroup() == Group.POI ? PointDescription.POINT_TYPE_POI : PointDescription.POINT_TYPE_OSM_BUG;
    String name = (isOsmPoint ? ((OpenstreetmapPoint) osmPoint).getName() : ((OsmNotesPoint) osmPoint).getText());
    FavoritesActivity.showOnMap(requireActivity(), this, osmPoint.getLatitude(), osmPoint.getLongitude(), 15, new PointDescription(type, name), true, osmPoint);
}
Also used : OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) PointDescription(net.osmand.data.PointDescription)

Example 12 with OpenstreetmapPoint

use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.

the class OsmEditsFragment method fetchData.

private void fetchData() {
    boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
    osmEdits = new ArrayList<>();
    List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
    List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
    osmEdits.addAll(l1);
    osmEdits.addAll(l2);
    ListView listView = getListView();
    listView.setDivider(null);
    listView.setEmptyView(emptyView);
    if (osmEdits.size() > 0 && footerView == null && portrait) {
        footerView = getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, listView, false);
        listView.addFooterView(footerView);
    }
    List<Object> items = createItemsList();
    listAdapter = new OsmEditsAdapter(getMyApplication(), items);
    listAdapter.setSelectedOsmEdits(osmEditsSelected);
    listAdapter.setAdapterListener(new OsmEditsAdapter.OsmEditsAdapterListener() {

        @Override
        public void onHeaderCheckboxClick(boolean checked) {
            if (checked) {
                selectAll();
            } else {
                deselectAll();
            }
            updateSelectionTitle(actionMode);
        }

        @Override
        public void onItemSelect(OsmPoint point, boolean checked) {
            if (checked) {
                osmEditsSelected.add(point);
            } else {
                osmEditsSelected.remove(point);
            }
            updateSelectionMode(actionMode);
        }

        @Override
        public void onItemShowMap(OsmPoint point, int position) {
            showOnMap(point, position);
        }

        @Override
        public void onOptionsClick(OsmPoint note) {
            openPopUpMenu(note);
        }
    });
    listAdapter.setPortrait(portrait);
    listView.setAdapter(listAdapter);
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OsmEditsAdapter(net.osmand.plus.plugins.osmedit.OsmEditsAdapter) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) ListView(android.widget.ListView)

Example 13 with OpenstreetmapPoint

use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.

the class SendPoiBottomSheetFragment method onRightBottomButtonClick.

@Override
protected void onRightBottomButtonClick() {
    ProgressDialogPoiUploader progressDialogPoiUploader = null;
    Activity activity = getActivity();
    if (activity instanceof MapActivity) {
        progressDialogPoiUploader = new SimpleProgressDialogPoiUploader((MapActivity) activity);
    } else if (getParentFragment() instanceof ProgressDialogPoiUploader) {
        progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
    }
    if (progressDialogPoiUploader != null) {
        String comment = messageEditText.getText().toString();
        if (comment.length() > 0) {
            for (OsmPoint osmPoint : poi) {
                if (osmPoint.getGroup() == OsmPoint.Group.POI) {
                    ((OpenstreetmapPoint) osmPoint).setComment(comment);
                    break;
                }
            }
        }
        progressDialogPoiUploader.showProgressDialog(poi, closeChangeSet.isChecked(), false);
    }
    dismiss();
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) FragmentActivity(androidx.fragment.app.FragmentActivity) Activity(android.app.Activity) MapActivity(net.osmand.plus.activities.MapActivity) MapActivity(net.osmand.plus.activities.MapActivity)

Example 14 with OpenstreetmapPoint

use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.

the class UploadOpenstreetmapPointAsyncTask method doInBackground.

@Override
protected Map<OsmPoint, String> doInBackground(OsmPoint... points) {
    TrafficStats.setThreadStatsTag(THREAD_ID);
    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;
            p.trimChangedTagNamesValues();
            if (OsmPoint.Action.CREATE != p.getAction()) {
                entityInfo = remotepoi.loadEntity(p.getEntity());
            }
            Entity n = remotepoi.commitEntityImpl(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 : Entity(net.osmand.osm.edit.Entity) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) HashMap(java.util.HashMap) EntityInfo(net.osmand.osm.edit.EntityInfo) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)

Example 15 with OpenstreetmapPoint

use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.

the class OpenstreetmapLocalUtil method commitEntityImpl.

@Override
public Entity commitEntityImpl(Action action, Entity entity, EntityInfo info, String comment, boolean closeChangeSet, Set<String> changedTags) {
    Entity newEntity = entity;
    if (entity.getId() == -1) {
        if (entity instanceof Node) {
            newEntity = new Node((Node) entity, Math.min(-2, plugin.getDBPOI().getMinID() - 1));
        } else if (entity instanceof Way) {
            newEntity = new Way(Math.min(-2, plugin.getDBPOI().getMinID() - 1), ((Way) entity).getNodeIds(), entity.getLatitude(), entity.getLongitude());
        } else {
            return null;
        }
    }
    OpenstreetmapPoint p = new OpenstreetmapPoint();
    newEntity.setChangedTags(changedTags);
    p.setEntity(newEntity);
    p.setAction(action);
    p.setComment(comment);
    if (p.getAction() == OsmPoint.Action.DELETE && newEntity.getId() < 0) {
        // if it is our local poi
        plugin.getDBPOI().deletePOI(p);
    } else {
        plugin.getDBPOI().addOpenstreetmap(p);
    }
    for (OnNodeCommittedListener listener : listeners) {
        listener.onNoteCommitted();
    }
    return newEntity;
}
Also used : Entity(net.osmand.osm.edit.Entity) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) Node(net.osmand.osm.edit.Node) Way(net.osmand.osm.edit.Way)

Aggregations

OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)30 OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)18 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)17 Entity (net.osmand.osm.edit.Entity)10 ArrayList (java.util.ArrayList)8 PoiType (net.osmand.osm.PoiType)8 File (java.io.File)5 Node (net.osmand.osm.edit.Node)5 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)5 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)5 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)5 OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)5 QuickAction (net.osmand.plus.quickaction.QuickAction)5 List (java.util.List)4 ITileSource (net.osmand.map.ITileSource)4 MapActivity (net.osmand.plus.activities.MapActivity)4 AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)4 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)4 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)4 View (android.view.View)3