use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.
the class DashboardOnMap method navigationAction.
public void navigationAction() {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
mapActivity.getMapActions().enterRoutePlanningMode(null, null);
} else {
mapActivity.getRoutingHelper().setRoutePlanningMode(true);
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
mapActivity.refreshMap();
}
boolean animate = !getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get();
hideDashboard(animate);
}
use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.
the class MapViewTrackingUtilities method updateLocation.
@Override
public void updateLocation(Location location) {
myLocation = location;
showViewAngle = false;
if (location != null) {
locationProvider = location.getProvider();
if (settings.DRIVING_REGION_AUTOMATIC.get() && !drivingRegionUpdated && !app.isApplicationInitializing()) {
drivingRegionUpdated = true;
detectDrivingRegion(new LatLon(location.getLatitude(), location.getLongitude()));
}
}
if (mapView != null) {
RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
if (isMapLinkedToLocation() && location != null) {
Pair<Integer, Double> zoom = null;
Float rotation = null;
if (settings.AUTO_ZOOM_MAP.get()) {
zoom = autozoom(location);
}
int currentMapRotation = settings.ROTATE_MAP.get();
float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS.get();
boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0 && isSmallSpeedForDirectionOfMovement(location, speedForDirectionOfMovement);
boolean smallSpeedForCompass = isSmallSpeedForCompass(location);
boolean smallSpeedForAnimation = isSmallSpeedForAnimation(location);
// boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get();
showViewAngle = (!location.hasBearing() || smallSpeedForCompass) && (tb != null && tb.containsLatLon(location.getLatitude(), location.getLongitude()));
if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
if (smallSpeedForDirectionOfMovement) {
showViewAngle = routePlanningMode;
} else if (location.hasBearing() && !smallSpeedForCompass) {
// special case when bearing equals to zero (we don't change anything)
if (location.getBearing() != 0f) {
rotation = -location.getBearing();
}
}
} else if (currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS) {
// disable compass rotation in that mode
showViewAngle = routePlanningMode;
}
registerUnregisterSensor(location, smallSpeedForDirectionOfMovement);
if (settings.ANIMATE_MY_LOCATION.get() && !smallSpeedForAnimation && !movingToMyLocation && settings.WAKE_ON_VOICE_INT.get() == 0) {
mapView.getAnimatedDraggingThread().startMoving(location.getLatitude(), location.getLongitude(), zoom, rotation, false);
} else {
if (zoom != null) {
mapView.getAnimatedDraggingThread().startZooming(zoom.first, zoom.second, false);
}
if (rotation != null) {
mapView.setRotate(rotation);
}
mapView.setLatLon(location.getLatitude(), location.getLongitude());
}
} else if (location != null) {
showViewAngle = (!location.hasBearing() || isSmallSpeedForCompass(location)) && (tb != null && tb.containsLatLon(location.getLatitude(), location.getLongitude()));
registerUnregisterSensor(location, false);
}
RoutingHelper routingHelper = app.getRoutingHelper();
followingMode = routingHelper.isFollowingMode();
if (routePlanningMode != routingHelper.isRoutePlanningMode()) {
switchToRoutePlanningMode();
}
// When location is changed we need to refresh map in order to show movement!
mapView.refreshMap();
}
if (dashboard != null) {
dashboard.updateMyLocation(location);
}
if (contextMenu != null) {
contextMenu.updateMyLocation(location);
}
}
use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.
the class MapViewTrackingUtilities method switchToRoutePlanningMode.
public void switchToRoutePlanningMode() {
RoutingHelper routingHelper = app.getRoutingHelper();
routePlanningMode = routingHelper.isRoutePlanningMode();
updateSettings();
if (!routePlanningMode && followingMode) {
backToLocationImpl();
}
}
use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.
the class MapActivityLayers method createLayers.
public void createLayers(final OsmandMapTileView mapView) {
OsmandApplication app = getApplication();
RoutingHelper routingHelper = app.getRoutingHelper();
// first create to make accessible
mapTextLayer = new MapTextLayer();
// 5.95 all labels
mapView.addLayer(mapTextLayer, 5.95f);
// 8. context menu layer
contextMenuLayer = new ContextMenuLayer(activity);
mapView.addLayer(contextMenuLayer, 8);
// mapView.addLayer(underlayLayer, -0.5f);
mapTileLayer = new MapTileLayer(true);
mapView.addLayer(mapTileLayer, 0.0f);
mapView.setMainLayer(mapTileLayer);
// 0.5 layer
mapVectorLayer = new MapVectorLayer(mapTileLayer, false);
mapView.addLayer(mapVectorLayer, 0.5f);
downloadedRegionsLayer = new DownloadedRegionsLayer();
mapView.addLayer(downloadedRegionsLayer, 0.5f);
// 0.9 gpx layer
gpxLayer = new GPXLayer();
mapView.addLayer(gpxLayer, 0.9f);
// 1. route layer
routeLayer = new RouteLayer(routingHelper);
mapView.addLayer(routeLayer, 1);
// 2. osm bugs layer
// 3. poi layer
poiMapLayer = new POIMapLayer(activity);
mapView.addLayer(poiMapLayer, 3);
// 4. favorites layer
mFavouritesLayer = new FavouritesLayer();
mapView.addLayer(mFavouritesLayer, 4);
// 4.6 measurement tool layer
measurementToolLayer = new MeasurementToolLayer();
mapView.addLayer(measurementToolLayer, 4.6f);
// 5. transport layer
transportStopsLayer = new TransportStopsLayer(activity);
mapView.addLayer(transportStopsLayer, 5);
// 5.95 all text labels
// 6. point location layer
locationLayer = new PointLocationLayer(activity.getMapViewTrackingUtilities());
mapView.addLayer(locationLayer, 6);
// 7. point navigation layer
navigationLayer = new PointNavigationLayer(activity);
mapView.addLayer(navigationLayer, 7);
// 7.3 map markers layer
mapMarkersLayer = new MapMarkersLayer(activity);
mapView.addLayer(mapMarkersLayer, 7.3f);
// 7.5 Impassible roads
impassableRoadsLayer = new ImpassableRoadsLayer(activity);
mapView.addLayer(impassableRoadsLayer, 7.5f);
// 7.8 ruler control layer
rulerControlLayer = new RulerControlLayer(activity);
mapView.addLayer(rulerControlLayer, 7.8f);
// 8. context menu layer
// 9. map info layer
mapInfoLayer = new MapInfoLayer(activity, routeLayer);
mapView.addLayer(mapInfoLayer, 9);
// 11. route info layer
mapControlsLayer = new MapControlsLayer(activity);
mapView.addLayer(mapControlsLayer, 11);
// 12. quick actions layer
mapQuickActionLayer = new MapQuickActionLayer(activity, contextMenuLayer);
mapView.addLayer(mapQuickActionLayer, 12);
contextMenuLayer.setMapQuickActionLayer(mapQuickActionLayer);
mapControlsLayer.setMapQuickActionLayer(mapQuickActionLayer);
transparencyListener = new StateChangedListener<Integer>() {
@Override
public void stateChanged(Integer change) {
mapTileLayer.setAlpha(change);
mapVectorLayer.setAlpha(change);
mapView.refreshMap();
}
};
app.getSettings().MAP_TRANSPARENCY.addListener(transparencyListener);
OsmandPlugin.createLayers(mapView, activity);
app.getAppCustomization().createLayers(mapView, activity);
app.getAidlApi().registerMapLayers(activity);
}
use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.
the class OsmAndLocationProvider method setLocation.
private void setLocation(net.osmand.Location location) {
if (location == null) {
updateGPSInfo(null);
}
if (location != null) {
simulatePosition = null;
if (gpsSignalLost) {
gpsSignalLost = false;
final RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0) {
routingHelper.getVoiceRouter().gpsLocationRecover();
}
}
}
enhanceLocation(location);
scheduleCheckIfGpsLost(location);
final RoutingHelper routingHelper = app.getRoutingHelper();
// 1. Logging services
if (location != null) {
app.getSavingTrackHelper().updateLocation(location);
OsmandPlugin.updateLocationPlugins(location);
}
// 2. routing
net.osmand.Location updatedLocation = location;
if (routingHelper.isFollowingMode()) {
if (location == null || isPointAccurateForRouting(location)) {
// Update routing position and get location for sticking mode
updatedLocation = routingHelper.setCurrentLocation(location, settings.SNAP_TO_ROAD.get());
}
} else if (routingHelper.isRoutePlanningMode() && settings.getPointToStart() == null) {
routingHelper.setCurrentLocation(location, false);
} else if (getLocationSimulation().isRouteAnimating()) {
routingHelper.setCurrentLocation(location, false);
}
app.getWaypointHelper().locationChanged(location);
this.location = updatedLocation;
// Update information
updateLocation(this.location);
}
Aggregations