Fix pedestrian routing between transport stops
This commit is contained in:
parent
d568c61d7a
commit
6853d7ca76
7 changed files with 55 additions and 10 deletions
|
@ -578,7 +578,21 @@ public class RouteDataObject {
|
|||
public boolean loop(){
|
||||
return pointsX[0] == pointsX[pointsX.length - 1] && pointsY[0] == pointsY[pointsY.length - 1] ;
|
||||
}
|
||||
|
||||
|
||||
public boolean platform(){
|
||||
int sz = types.length;
|
||||
for(int i=0; i<sz; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
if(r.getTag().equals("railway") && r.getValue().equals("platform")) {
|
||||
return true;
|
||||
}
|
||||
if(r.getTag().equals("public_transport") && r.getValue().equals("platform")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean roundabout(){
|
||||
int sz = types.length;
|
||||
for(int i=0; i<sz; i++) {
|
||||
|
|
|
@ -55,6 +55,10 @@ public class RoutePlannerFrontEnd {
|
|||
}
|
||||
|
||||
public RouteSegmentPoint findRouteSegment(double lat, double lon, RoutingContext ctx, List<RouteSegmentPoint> list) throws IOException {
|
||||
return findRouteSegment(lat, lon, ctx, list, false);
|
||||
}
|
||||
|
||||
public RouteSegmentPoint findRouteSegment(double lat, double lon, RoutingContext ctx, List<RouteSegmentPoint> list, boolean transportStop) throws IOException {
|
||||
int px = MapUtils.get31TileNumberX(lon);
|
||||
int py = MapUtils.get31TileNumberY(lat);
|
||||
ArrayList<RouteDataObject> dataObjects = new ArrayList<RouteDataObject>();
|
||||
|
@ -92,7 +96,26 @@ public class RoutePlannerFrontEnd {
|
|||
}
|
||||
});
|
||||
if (list.size() > 0) {
|
||||
RouteSegmentPoint ps = list.get(0);
|
||||
RouteSegmentPoint ps = null;
|
||||
if (ctx.publicTransport) {
|
||||
for (RouteSegmentPoint p : list) {
|
||||
if (transportStop && p.distSquare > 100) {
|
||||
break;
|
||||
}
|
||||
boolean platform = p.road.platform();
|
||||
if (transportStop && platform) {
|
||||
ps = p;
|
||||
break;
|
||||
}
|
||||
if (!transportStop && !platform) {
|
||||
ps = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ps == null) {
|
||||
ps = list.get(0);
|
||||
}
|
||||
ps.others = list;
|
||||
return ps;
|
||||
}
|
||||
|
@ -185,17 +208,17 @@ public class RoutePlannerFrontEnd {
|
|||
}
|
||||
int indexNotFound = 0;
|
||||
List<RouteSegmentPoint> points = new ArrayList<RouteSegmentPoint>();
|
||||
if (!addSegment(start, ctx, indexNotFound++, points)) {
|
||||
if (!addSegment(start, ctx, indexNotFound++, points, ctx.startTransportStop)) {
|
||||
return null;
|
||||
}
|
||||
if (intermediates != null) {
|
||||
for (LatLon l : intermediates) {
|
||||
if (!addSegment(l, ctx, indexNotFound++, points)) {
|
||||
if (!addSegment(l, ctx, indexNotFound++, points, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!addSegment(end, ctx, indexNotFound++, points)) {
|
||||
if (!addSegment(end, ctx, indexNotFound++, points, ctx.targetTransportStop)) {
|
||||
return null;
|
||||
}
|
||||
ctx.calculationProgress.nextIteration();
|
||||
|
@ -315,8 +338,8 @@ public class RoutePlannerFrontEnd {
|
|||
|
||||
}
|
||||
|
||||
private boolean addSegment(LatLon s, RoutingContext ctx, int indexNotFound, List<RouteSegmentPoint> res) throws IOException {
|
||||
RouteSegmentPoint f = findRouteSegment(s.getLatitude(), s.getLongitude(), ctx, null);
|
||||
private boolean addSegment(LatLon s, RoutingContext ctx, int indexNotFound, List<RouteSegmentPoint> res, boolean transportStop) throws IOException {
|
||||
RouteSegmentPoint f = findRouteSegment(s.getLatitude(), s.getLongitude(), ctx, null, transportStop);
|
||||
if (f == null) {
|
||||
ctx.calculationProgress.segmentNotFound = indexNotFound;
|
||||
return false;
|
||||
|
|
|
@ -41,7 +41,6 @@ public class RouteResultPreparation {
|
|||
*/
|
||||
List<RouteSegmentResult> prepareResult(RoutingContext ctx, FinalRouteSegment finalSegment) throws IOException {
|
||||
List<RouteSegmentResult> result = convertFinalSegmentToResults(ctx, finalSegment);
|
||||
combineWayPointsForAreaRouting(ctx, result);
|
||||
prepareResult(ctx, result);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,11 @@ public class RoutingContext {
|
|||
// 1. Initial variables
|
||||
public int startX;
|
||||
public int startY;
|
||||
public boolean startTransportStop;
|
||||
public int targetX;
|
||||
public int targetY;
|
||||
public boolean targetTransportStop;
|
||||
public boolean publicTransport;
|
||||
// deprecated
|
||||
public long firstRoadId;
|
||||
public int firstRoadDirection;
|
||||
|
|
|
@ -29,6 +29,9 @@ public class RouteCalculationParams {
|
|||
public boolean fast;
|
||||
public boolean leftSide;
|
||||
public boolean inSnapToRoadMode;
|
||||
public boolean inPublicTransportMode;
|
||||
public boolean startTransportStop;
|
||||
public boolean targetTransportStop;
|
||||
public RouteCalculationProgress calculationProgress;
|
||||
public RouteCalculationProgressCallback calculationProgressCallback;
|
||||
public RouteCalculationResultListener resultListener;
|
||||
|
|
|
@ -648,6 +648,9 @@ public class RouteProvider {
|
|||
&& precalculated == null;
|
||||
ctx.leftSideNavigation = params.leftSide;
|
||||
ctx.calculationProgress = params.calculationProgress;
|
||||
ctx.publicTransport = params.inPublicTransportMode;
|
||||
ctx.startTransportStop = params.startTransportStop;
|
||||
ctx.targetTransportStop = params.targetTransportStop;
|
||||
if(params.previousToRecalculate != null && params.onlyStartPointChanged) {
|
||||
int currentRoute = params.previousToRecalculate.getCurrentRoute();
|
||||
List<RouteSegmentResult> originalRoute = params.previousToRecalculate.getOriginalRoute();
|
||||
|
|
|
@ -895,7 +895,7 @@ public class RoutingHelper {
|
|||
RouteCalculationResult prev = route;
|
||||
synchronized (RoutingHelper.this) {
|
||||
if (res.isCalculated()) {
|
||||
if (!params.inSnapToRoadMode) {
|
||||
if (!params.inSnapToRoadMode && !params.inPublicTransportMode) {
|
||||
route = res;
|
||||
}
|
||||
if (params.resultListener != null) {
|
||||
|
@ -908,7 +908,7 @@ public class RoutingHelper {
|
|||
currentRunningJob = null;
|
||||
}
|
||||
if(res.isCalculated()){
|
||||
if (!params.inSnapToRoadMode) {
|
||||
if (!params.inSnapToRoadMode && !params.inPublicTransportMode) {
|
||||
setNewRoute(prev, res, params.start);
|
||||
}
|
||||
} else if (onlineSourceWithoutInternet) {
|
||||
|
|
Loading…
Reference in a new issue