intoduce bearingVsRouteDirection method
This commit is contained in:
parent
b92ba08265
commit
08a5ed8494
3 changed files with 14 additions and 16 deletions
|
@ -9,6 +9,8 @@ import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
|||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
import net.osmand.Location;
|
||||
|
||||
|
||||
public class RouteDataObject {
|
||||
/*private */static final int RESTRICTION_SHIFT = 3;
|
||||
|
@ -410,6 +412,15 @@ public class RouteDataObject {
|
|||
return directionRoute(startPoint, plus, 5);
|
||||
}
|
||||
|
||||
public boolean bearingVsRouteDirection(Location loc) {
|
||||
boolean direction = true;
|
||||
if(loc != null && loc.hasBearing()) {
|
||||
double diff = MapUtils.alignAngleDifference(directionRoute(0, true) - loc.getBearing() / 180f * Math.PI);
|
||||
direction = Math.abs(diff) < Math.PI / 2f;
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
|
||||
public double distance(int startPoint, int endPoint) {
|
||||
if(startPoint > endPoint) {
|
||||
int k = endPoint;
|
||||
|
|
|
@ -262,13 +262,7 @@ public class WaypointHelper {
|
|||
}
|
||||
|
||||
public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc, MetricsConstants mc, boolean showCameras) {
|
||||
boolean direction = true;
|
||||
if (loc.hasBearing()) {
|
||||
double diff = MapUtils.alignAngleDifference(ro.directionRoute(0, true) -
|
||||
loc.getBearing() / 180f * Math.PI);
|
||||
direction = Math.abs(diff) < Math.PI / 2f;
|
||||
}
|
||||
float mxspeed = ro.getMaximumSpeed(direction);
|
||||
float mxspeed = ro.getMaximumSpeed(ro.bearingVsRouteDirection(loc));
|
||||
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f;
|
||||
AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, loc, delta);
|
||||
if (speedAlarm != null) {
|
||||
|
|
|
@ -390,14 +390,7 @@ public class RouteInfoWidgetsFactory {
|
|||
&& trackingUtilities.isMapLinkedToLocation()) {
|
||||
RouteDataObject ro = locationProvider.getLastKnownRouteSegment();
|
||||
if(ro != null) {
|
||||
boolean direction = true;
|
||||
Location loc = locationProvider.getLastKnownLocation();
|
||||
if(loc != null && loc.hasBearing()) {
|
||||
double diff = MapUtils.alignAngleDifference(ro.directionRoute(0, true) -
|
||||
loc.getBearing() / 180f * Math.PI);
|
||||
direction = Math.abs(diff) < Math.PI / 2f;
|
||||
}
|
||||
mx = ro.getMaximumSpeed(direction);
|
||||
mx = ro.getMaximumSpeed(ro.bearingVsRouteDirection(locationProvider.getLastKnownLocation()));
|
||||
}
|
||||
} else if (rh != null) {
|
||||
mx = rh.getCurrentMaxSpeed();
|
||||
|
|
Loading…
Reference in a new issue