use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class TargetPointsHelper method navigateToPoint.
public void navigateToPoint(final LatLon point, boolean updateRoute, int intermediate, PointDescription historyName) {
if (point != null) {
final PointDescription pointDescription;
if (historyName == null) {
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
} else {
pointDescription = historyName;
}
if (pointDescription.isLocation() && Algorithms.isEmpty(pointDescription.getName())) {
pointDescription.setName(PointDescription.getSearchAddressStr(ctx));
}
if (intermediate < 0 || intermediate > intermediatePoints.size()) {
if (intermediate > intermediatePoints.size()) {
final TargetPoint pn = getPointToNavigate();
if (pn != null) {
settings.insertIntermediatePoint(pn.getLatitude(), pn.getLongitude(), pn.pointDescription, intermediatePoints.size());
}
}
settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), pointDescription);
} else {
settings.insertIntermediatePoint(point.getLatitude(), point.getLongitude(), pointDescription, intermediate);
}
} else {
cancelTargetPointAddressRequest();
cancelAllIntermediatePointsAddressRequests();
settings.clearPointToNavigate();
settings.clearIntermediatePoints();
}
readFromSettings();
updateRouteAndRefresh(updateRoute);
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class OsmandAidlApi method addMapMarker.
boolean addMapMarker(AMapMarker marker) {
if (marker != null) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, marker.getName() != null ? marker.getName() : "");
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
markersHelper.addMapMarker(new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude()), pd);
refreshMap();
return true;
} else {
return false;
}
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class OsmandAidlApi method updateMapMarker.
boolean updateMapMarker(AMapMarker markerPrev, AMapMarker markerNew) {
if (markerPrev != null && markerNew != null) {
LatLon latLon = new LatLon(markerPrev.getLatLon().getLatitude(), markerPrev.getLatLon().getLongitude());
LatLon latLonNew = new LatLon(markerNew.getLatLon().getLatitude(), markerNew.getLatLon().getLongitude());
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
for (MapMarker m : mapMarkers) {
if (m.getOnlyName().equals(markerPrev.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : "");
MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.index);
marker.id = m.id;
marker.creationDate = m.creationDate;
marker.visitedDate = m.visitedDate;
markersHelper.moveMapMarker(marker, latLonNew);
refreshMap();
return true;
}
}
return false;
} else {
return false;
}
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapControlsLayer method getPointDescriptionForTarget.
private PointDescription getPointDescriptionForTarget(LatLon latLon) {
final MapContextMenu menu = mapActivity.getContextMenu();
PointDescription pointDescription;
if (menu.isActive() && latLon.equals(menu.getLatLon())) {
pointDescription = menu.getPointDescriptionForTarget();
} else {
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
}
return pointDescription;
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapControlsLayer method addFirstIntermediate.
public void addFirstIntermediate(LatLon latLon) {
if (latLon != null) {
RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) {
PointDescription pointDescription = getPointDescriptionForTarget(latLon);
mapActivity.getContextMenu().close();
final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) {
targets.navigateToPoint(latLon, true, 0, pointDescription);
} else if (targets.getIntermediatePoints().isEmpty()) {
startRoutePlanningWithDestination(latLon, pointDescription, targets);
}
} else {
addDestination(latLon);
}
}
}
Aggregations