Fix bug with road duplication and many times saying same command (keep left or keep right)
This commit is contained in:
parent
6f8956887d
commit
df33571d12
2 changed files with 30 additions and 14 deletions
|
@ -229,8 +229,9 @@ public class RouteDataObject {
|
|||
}
|
||||
px = getPoint31XTile(nx);
|
||||
py = getPoint31YTile(nx);
|
||||
total += Math.abs(px - x) + Math.abs(py - y);
|
||||
} while (total < 100);
|
||||
// translate into meters
|
||||
total += Math.abs(px - x) * 0.011d + Math.abs(py - y) * 0.01863d;
|
||||
} while (total < 70);
|
||||
return -Math.atan2( x - px, y - py );
|
||||
}
|
||||
}
|
|
@ -41,6 +41,7 @@ public class BinaryRoutePlanner {
|
|||
protected static final Log log = LogUtil.getLog(BinaryRoutePlanner.class);
|
||||
|
||||
private static final int ROUTE_POINTS = 11;
|
||||
private static final float TURN_DEGREE_MIN = 45;
|
||||
|
||||
|
||||
public BinaryRoutePlanner(NativeLibrary nativeLib, BinaryMapIndexReader... map) {
|
||||
|
@ -776,7 +777,6 @@ public class BinaryRoutePlanner {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static final float TURN_DEGREE_MIN = 45;
|
||||
|
||||
/**
|
||||
* Helper method to prepare final result
|
||||
|
@ -1134,12 +1134,18 @@ public class BinaryRoutePlanner {
|
|||
return t;
|
||||
}
|
||||
|
||||
private long getPoint(RouteDataObject road, int pointInd) {
|
||||
return (((long) road.getPoint31XTile(pointInd)) << 31) + (long) road.getPoint31YTile(pointInd);
|
||||
}
|
||||
|
||||
|
||||
private void attachRoadSegments(RoutingContext ctx, List<RouteSegmentResult> result, int routeInd, int pointInd, boolean plus) {
|
||||
RouteSegmentResult rr = result.get(routeInd);
|
||||
RouteDataObject road = rr.getObject();
|
||||
RoutingTile tl = loadRoutes(ctx, road.getPoint31XTile(pointInd), road.getPoint31YTile(pointInd));
|
||||
long l = (((long) road.getPoint31XTile(pointInd)) << 31) + (long) road.getPoint31YTile(pointInd);
|
||||
long l = getPoint(road, pointInd);
|
||||
long nextL = pointInd < road.getPointsLength() - 1 ? getPoint(road, pointInd + 1) : 0;
|
||||
long prevL = pointInd > 0 ? getPoint(road, pointInd - 1) : 0;
|
||||
|
||||
// attach additional roads to represent more information about the route
|
||||
RouteSegmentResult previousResult = null;
|
||||
|
@ -1165,15 +1171,24 @@ public class BinaryRoutePlanner {
|
|||
while (routeSegment != null) {
|
||||
if (routeSegment.road.getId() != road.getId() && routeSegment.road.getId() != previousRoadId) {
|
||||
RouteDataObject addRoad = routeSegment.road;
|
||||
|
||||
// TODO restrictions can be considered as well
|
||||
int oneWay = ctx.getRouter().isOneWay(addRoad);
|
||||
if (oneWay >= 0 && routeSegment.segmentStart < addRoad.getPointsLength() - 1) {
|
||||
long pointL = getPoint(addRoad, routeSegment.segmentStart + 1);
|
||||
if(pointL != nextL && pointL != prevL) {
|
||||
// if way contains same segment (nodes) as different way (do not attach it)
|
||||
rr.attachRoute(pointInd, new RouteSegmentResult(addRoad, routeSegment.segmentStart, addRoad.getPointsLength() - 1));
|
||||
}
|
||||
}
|
||||
if (oneWay <= 0 && routeSegment.segmentStart > 0) {
|
||||
long pointL = getPoint(addRoad, routeSegment.segmentStart - 1);
|
||||
// if way contains same segment (nodes) as different way (do not attach it)
|
||||
if(pointL != nextL && pointL != prevL) {
|
||||
rr.attachRoute(pointInd, new RouteSegmentResult(addRoad, routeSegment.segmentStart, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
routeSegment = routeSegment.next;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue