Tweak car routing
This commit is contained in:
parent
5b13001be8
commit
90d574c04e
2 changed files with 21 additions and 7 deletions
|
@ -32,7 +32,7 @@ public class BinaryRoutePlanner {
|
|||
|
||||
private final static boolean PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = true;
|
||||
private final BinaryMapIndexReader[] map;
|
||||
private static int DEFAULT_HEURISTIC_COEFFICIENT = 3;
|
||||
private static int DEFAULT_HEURISTIC_COEFFICIENT = 1;
|
||||
|
||||
private static final Log log = LogUtil.getLog(BinaryRoutePlanner.class);
|
||||
|
||||
|
@ -302,7 +302,7 @@ public class BinaryRoutePlanner {
|
|||
if (firstOfSegment) {
|
||||
RouteSegment possibleObstacle = next;
|
||||
while (possibleObstacle != null) {
|
||||
/*obstaclesTime += */ctx.router.defineObstacle(possibleObstacle.road, possibleObstacle.segmentStart);
|
||||
obstaclesTime += ctx.router.defineObstacle(possibleObstacle.road, possibleObstacle.segmentStart);
|
||||
possibleObstacle = possibleObstacle.next;
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public class BinaryRoutePlanner {
|
|||
// 3.2 calculate possible ways to put into priority queue
|
||||
while (next != null) {
|
||||
long nts = (next.road.getId() << 8l) + next.segmentStart;
|
||||
/* next.road.id >> 1 != road.id >> 1 - used that line for debug with osm map */
|
||||
/* next.road.getId() >> 3 (1) != road.getId() >> 3 (1) - used that line for debug with osm map */
|
||||
// road.id could be equal on roundabout, but we should accept them
|
||||
if (!visitedSegments.contains(nts)) {
|
||||
int type = -1;
|
||||
|
|
|
@ -135,13 +135,27 @@ public class CarRouter extends VehicleRouter {
|
|||
public double calculateTurnTime(RouteSegment segment, RouteSegment next, int segmentEnd) {
|
||||
boolean end = (segmentEnd == segment.road.getPointsLength() - 1 || segmentEnd == 0);
|
||||
boolean start = next.segmentStart == 0;
|
||||
if (end) {
|
||||
if(!start){
|
||||
return 15;
|
||||
// that addition highly affects to trunk roads !(prefer trunk/motorway)
|
||||
if (end && start) {
|
||||
if (next.road.getPointsLength() > 1) {
|
||||
int x = segment.road.getPoint31XTile(segmentEnd);
|
||||
int y = segment.road.getPoint31XTile(segmentEnd);
|
||||
int prevSegmentEnd = segmentEnd - 1;
|
||||
if(prevSegmentEnd < 0){
|
||||
prevSegmentEnd = segmentEnd + 1;
|
||||
}
|
||||
int px = segment.road.getPoint31XTile(prevSegmentEnd);
|
||||
int py = segment.road.getPoint31XTile(prevSegmentEnd);
|
||||
double a1 = Math.atan2(y - py, x - px);
|
||||
double a2 = Math.atan2(y - next.road.getPoint31YTile(1), x - next.road.getPoint31XTile(1));
|
||||
double diff = Math.abs(a1 - a2);
|
||||
if (diff > Math.PI / 2 && diff < 3 * Math.PI / 2) {
|
||||
return 25;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return 25;
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue