some code for STOP directional analysis

This commit is contained in:
sonora 2017-10-27 20:33:35 +02:00
parent 6c7f4f7913
commit 346d99d653
2 changed files with 8 additions and 13 deletions

View file

@ -272,24 +272,15 @@ public class WaypointHelper {
RouteTypeRule typeRule = reg.quickGetEncodingRule(pointTypes[r]);
AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, 0, loc);
// Check if stop has directional info
// For STOP first check if it has directional info
// Issue #2885: This seems to fail
if (info != null && info.getType() != null && info.getType() == AlarmInfoType.STOP) {
// TODO: better than bearingVsRouteDirection would be routeVsWayDirection analysis
if (ro.isStopForward(ro.bearingVsRouteDirection(loc)) == -1) {
info = null;
}
// TODO: Could add some analysis here if a stop without directional tagging is shortly _behind_ an intersection
//Toast.makeText(app.getApplicationContext(), Double.toString(ro.directionRoute(0, true)) + ",\n" + Double.toString(loc.getBearing()) + ",\n" + Double.toString(MapUtils.alignAngleDifference(ro.directionRoute(0, true) - loc.getBearing() / 180f * Math.PI))), Toast.LENGTH_LONG).show();
}
// Issue #2873 may indicate we need some sort of check here if Alarm is in forward direction
// But cannot reproduce the issue for now
//if (loc.hasBearing()) {
// if (Math.abs(MapUtils.alignAngleDifference(bearingTo("actual alarm location") - loc.getBearing() / 180f * Math.PI)) >= Math.PI / 2f) {
// info = null;
// }
//Toast.makeText(app.getApplicationContext(), Double.toString(ro.directionRoute(0, true)) + ",\n" + Double.toString(loc.getBearing()) + ",\n" + Double.toString(MapUtils.alignAngleDifference(ro.directionRoute(0, true) - loc.getBearing() / 180f * Math.PI))), Toast.LENGTH_LONG).show();
//}
if (info != null) {
if (info.getType() != AlarmInfoType.SPEED_CAMERA || showCameras) {
long ms = System.currentTimeMillis();

View file

@ -14,6 +14,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.TurnType;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import android.content.Context;
@ -189,7 +190,10 @@ public class RouteCalculationResult {
loc.setLatitude(MapUtils.get31LatitudeY(y31));
loc.setLongitude(MapUtils.get31LongitudeX(x31));
AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, locInd, loc);
if(info != null) {
// For STOP first check if it has directional info
// Issue #2885: This seems to fail
// Open: Could also add some analysis if a STOP without directional tagging is shortly _behind_ an intersection
if ((info != null) && !((info.getType() == AlarmInfoType.STOP) && (res.getObject().isStopForward(res.isForwardDirection()) == -1))) {
alarms.add(info);
}
}