simplify code

This commit is contained in:
sonora 2017-10-28 09:52:34 +02:00
parent 346d99d653
commit 22aa402169
3 changed files with 17 additions and 21 deletions

View file

@ -685,26 +685,24 @@ public class RouteDataObject {
return direction;
}
public int isStopForward(boolean direction) {
for (int i = 0; i < types.length; i++) {
public int isStopApplicable(boolean direction) {
int sz = types.length;
for (int i = 0; i < sz; i++) {
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
if (r.getTag().equals("highway") && r.getValue().equals("stop")) {
for (int j = 0; j < types.length; j++) {
if (r.getTag().equals("direction")) {
String dv = r.getValue();
if ((dv.equals("forward") && direction == true) || (dv.equals("backward") && direction == false)) {
return 1;
} else if ((dv.equals("forward") && direction == false) || (dv.equals("backward") && direction == true)) {
return -1;
}
}
// stop=all usually tagged on conflicting node itself, so not needed here
//if (r.getTag().equals("stop") && r.getValue().equals("all")) {
// return 1;
//}
if (r.getTag().equals("direction")) {
String dv = r.getValue();
if ((dv.equals("forward") && direction == true) || (dv.equals("backward") && direction == false)) {
return 1;
} else if ((dv.equals("forward") && direction == false) || (dv.equals("backward") && direction == true)) {
return -1;
}
}
// stop=all usually tagged on conflicting node itself, so not needed here
//if (r.getTag().equals("stop") && r.getValue().equals("all")) {
// return 1;
//}
}
// Open: Could add some analysis if a STOP without directional tagging is shortly _behind_ an intersection
return 0; //no directional info detected
}

View file

@ -273,9 +273,9 @@ public class WaypointHelper {
AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, 0, loc);
// For STOP first check if it has directional info
// Issue #2885: This seems to fail
// TODO: Check if this is needed here
if (info != null && info.getType() != null && info.getType() == AlarmInfoType.STOP) {
if (ro.isStopForward(ro.bearingVsRouteDirection(loc)) == -1) {
if (ro.isStopApplicable(ro.bearingVsRouteDirection(loc)) == -1) {
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();

View file

@ -191,9 +191,7 @@ public class RouteCalculationResult {
loc.setLongitude(MapUtils.get31LongitudeX(x31));
AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, locInd, loc);
// 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))) {
if ((info != null) && !((info.getType() == AlarmInfoType.STOP) && (res.getObject().isStopApplicable(res.isForwardDirection()) == -1))) {
alarms.add(info);
}
}