diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 1253b42d6d..b0dfce9d1a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -3283,6 +3283,7 @@ public class OsmandSettings { } public final CommonPreference ROUTE_RECALCULATION_DISTANCE = new FloatPreference("routing_recalc_distance", 0.f).makeProfile(); + public final CommonPreference ROUTE_STRAIGHT_ANGLE = new FloatPreference("routing_straight_angle", 30.f).makeProfile(); public final OsmandPreference USE_OSM_LIVE_FOR_ROUTING = new BooleanPreference("enable_osmc_routing", true).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 0921e5d518..94a56369d3 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -60,7 +60,7 @@ public class RouteCalculationResult { protected final ApplicationMode appMode; protected final RouteProvider.RouteService routeService; protected final double routeRecalcDistance; - protected final double routeVisibleAngle = 30; + protected final double routeVisibleAngle; // Note always currentRoute > get(currentDirectionInfo).routeOffset, // but currentRoute <= get(currentDirectionInfo+1).routeOffset @@ -73,8 +73,6 @@ public class RouteCalculationResult { protected Location currentStraightAnglePoint = null; - - public RouteCalculationResult(String errorMessage) { this.errorMessage = errorMessage; this.routingTime = 0; @@ -90,6 +88,7 @@ public class RouteCalculationResult { this.routeService = null; this.appMode = null; this.routeRecalcDistance = 0; + this.routeVisibleAngle = 0; } public RouteCalculationResult(List list, List directions, RouteCalculationParams params, List waypoints, boolean addMissingTurns) { @@ -126,8 +125,11 @@ public class RouteCalculationResult { this.routeService = params.mode.getRouteService(); if(params.ctx != null) { this.routeRecalcDistance = params.ctx.getSettings().ROUTE_RECALCULATION_DISTANCE.getModeValue(params.mode); + this.routeVisibleAngle = routeService == RouteProvider.RouteService.STRAIGHT ? + params.ctx.getSettings().ROUTE_STRAIGHT_ANGLE.getModeValue(params.mode) : 0; } else { this.routeRecalcDistance = 0; + this.routeVisibleAngle = 0; } } @@ -160,6 +162,8 @@ public class RouteCalculationResult { updateDirectionsTime(this.directions, this.listDistance); this.alarmInfo = Collections.unmodifiableList(alarms); this.routeRecalcDistance = ctx.getSettings().ROUTE_RECALCULATION_DISTANCE.getModeValue(mode); + this.routeVisibleAngle = routeService == RouteProvider.RouteService.STRAIGHT ? + ctx.getSettings().ROUTE_STRAIGHT_ANGLE.getModeValue(mode) : 0; } public ApplicationMode getAppMode() { diff --git a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java index 7de21eb4c0..874696db07 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java @@ -993,7 +993,9 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } else if (lastProjection != null) { lt = lastProjection; } - addLocation(tb, lt, style, tx, ty, angles, distances, 0, styles); // first point + if(lt != null) { + addLocation(tb, lt, style, tx, ty, angles, distances, 0, styles); // first point + } } addLocation(tb, ls, style, tx, ty, angles, distances, dist, styles); previousVisible = true; @@ -1118,7 +1120,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont if (directTo) { routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, null, 0); - } else if(straight){ + } else if (straight) { routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, helper.getLastFixedLocation(), route.getCurrentStraightAngleRoute()); } else {