@@ -323,7 +323,7 @@ private BufferFeature computeStartFeature(List<Integer> edgeList, Double startLa
323
323
*/
324
324
private BufferFeature computeEdgeAtDistanceThreshold (final BufferFeature startFeature , Double thresholdDistance ,
325
325
String roadName , Boolean upstreamPath , Boolean upstreamStart ) {
326
- List <Integer > usedEdges = new ArrayList <>() {
326
+ List <Integer > usedEdges = new ArrayList <Integer >() {
327
327
{
328
328
add (startFeature .getEdge ());
329
329
}
@@ -339,6 +339,9 @@ private BufferFeature computeEdgeAtDistanceThreshold(final BufferFeature startFe
339
339
nodeAccess .getLat (currentNode ), nodeAccess .getLon (currentNode ));
340
340
double previousDistance = 0.0 ;
341
341
Integer currentEdge = -1 ;
342
+ // Create previous values to use in case we don't meet the threshold
343
+ Integer previousEdge = currentEdge ;
344
+ int previousNode = currentNode ;
342
345
343
346
if (currentDistance >= thresholdDistance ) {
344
347
return startFeature ;
@@ -431,7 +434,12 @@ else if (tempState.get(this.roundaboutAccessEnc)) {
431
434
currentEdge = potentialRoundaboutEdgesWithoutName .get (0 );
432
435
usedEdges .add (currentEdge );
433
436
} else {
434
- throw new WebApplicationException ("Dead end found." );
437
+ // Instead of throwing an exception, we break the loop and return the
438
+ // path up to the current edge even though we haven't met the threshold.
439
+ // Assign current edge & node to previous and break the loop.
440
+ currentEdge = previousEdge ;
441
+ currentNode = previousNode ;
442
+ break ;
435
443
}
436
444
}
437
445
@@ -462,6 +470,9 @@ else if (tempState.get(this.roundaboutAccessEnc)) {
462
470
// Move to next node
463
471
currentNode = otherNode ;
464
472
currentState = graph .getEdgeIteratorState (currentEdge , Integer .MIN_VALUE );
473
+ // Update previous values
474
+ previousEdge = currentEdge ;
475
+ previousNode = currentNode ;
465
476
}
466
477
467
478
return new BufferFeature (currentEdge , currentNode ,
0 commit comments