bcgov / ols-router

BC Advanced Route Planner
https://bcgov.github.io/ols-router/
Apache License 2.0
24 stars 11 forks source link

betweenPairs - route not found impacting all pairs #346

Closed BK01 closed 2 years ago

BK01 commented 2 years ago

Description: When submitting a betweenPairs request that contains cases of route not found, all resulting pairs are assigned a distance of zero. In the example provided below, three cases of route not found (coordinate was far from road) had to be removed in order to successfully acquire distance values for the other cases.

Success case: https://router.api.gov.bc.ca/distance/betweenPairs.json?fromPoints=-116.8898,51.2292&toPoints=-114.8855556,49.7330556,-114.9216667,50.0241667,-115.0627778,49.5038889,-115.0830556,49.0997222,-115.1116667,49.2997222,-115.1888889,49.0219444,-115.2175,49.2330556,-115.2175,49.3830556,-115.2972,49.3768,-115.3008333,49.3830556,-115.4175,49.4163889,-115.6341667,49.6163889,-115.7341667,49.7830556,-115.7341667,49.9163889,-115.7466667,49.5077778,-115.7841667,49.7830556,-115.8088889,50.16,-115.8319444,49.2880556,-115.8566667,50.3358333,-115.9566667,49.6372222,-115.9816667,49.6847222,-115.9888889,50.4633333,-116.0305556,50.5055556,-116.0758333,50.6197222,-116.0841667,49.0830556,-116.1355556,50.6994444,-116.2372222,50.4580556,-116.2675,50.8330556,-116.3369444,49.1580556,-116.3677778,50.8997222,-116.4511111,50.9830556,-116.463,49.0884,-116.4666667,49.09,-116.4880556,51.3955556,-116.5522222,49.1797222,-116.5985,49.085,-116.6344444,51.0663889&outputSRS=4326&criteria=shortest&distanceUnit=km&correctSide=false&disable=sc,tf,ev,td&routeDescription=Routing_results

Failure case: https://router.api.gov.bc.ca/distance/betweenPairs.json?fromPoints=-116.8898,51.2292&toPoints=-114.8855556,49.7330556,-114.9216667,50.0241667,-115.0627778,49.5038889,-115.0830556,49.0997222,-115.1116667,49.2997222,-115.1888889,49.0219444,-115.2175,49.2330556,-115.2175,49.3830556,-115.2972,49.3768,-115.3008333,49.3830556,-115.3855,50.0400,-115.4175,49.4163889,-115.6341667,49.6163889,-115.7341667,49.7830556,-115.7341667,49.9163889,-115.7466667,49.5077778,-115.7841667,49.7830556,-115.8088889,50.16,-115.8319444,49.2880556,-115.8566667,50.3358333,-115.9455287,50.5514165,-115.9566667,49.6372222,-115.9816667,49.6847222,-115.9888889,50.4633333,-116.0305556,50.5055556,-116.0758333,50.6197222,-116.0841667,49.0830556,-116.1355556,50.6994444,-116.2372222,50.4580556,-116.2400605,49.0506033,-116.2675,50.8330556,-116.3369444,49.1580556,-116.3677778,50.8997222,-116.4511111,50.9830556,-116.4630,49.0884,-116.4666667,49.09,-116.4880556,51.3955556,-116.5522222,49.1797222,-116.5985,49.0850,-116.6344444,51.0663889&outputSRS=4326&criteria=shortest&distanceUnit=km&correctSide=false&disable=sc,tf,ev,td&routeDescription=Routing_results

Points that needed to be removed (far from road, or on a FSR):

-115.3855,50.0400 -115.9455287,50.5514165 -116.2400605,49.0506033

cmhodgson commented 2 years ago

Right now, the logic in the code that identifies which edge is closest to each input point is shared among betweenPairs and all other multi-point inputs, eg. multi-point routing. In the case of multi-point routing, any invalid point is cause to invalidate the route. However, for BetweenPairs it probably makes sense to allow for some invalid points. It shouldn't be too hard to change the logic to support this.

cmhodgson commented 2 years ago

After investigating this issue, I figured I might as well go ahead and fix it as the investigation was a good part of the work required to fix it. I now have a version that can handle any number of from/to points too far from a road, and simply returns a -1 time and distance and a routeFound:false value for any pairs that include one of those points.

BK01 commented 2 years ago

Excellent. The team is ready to accept a PR when you're ready.

BK01 commented 2 years ago

Update was validated in routerdlv.api.gov.bc.ca.

BK01 commented 2 years ago

Update was validated in routertst.api.gov.bc.ca.