@@ -502,25 +502,8 @@ private PointList computePointAtDistanceThreshold(BufferFeature startFeature, Do
502
502
503
503
Double currentDistance = endFeature .getDistance ();
504
504
GHPoint3D previousPoint = pointList .get (0 );
505
- PointList pathList = new PointList ();
506
505
507
- for (GHPoint3D currentPoint : pointList ) {
508
- // Filter zero-points made by PointList() scaling
509
- if (currentPoint .lat != 0 && currentPoint .lon != 0 ) {
510
- // Check if exceeds thresholdDistance
511
- currentDistance += DistancePlaneProjection .DIST_PLANE .calcDist (currentPoint .getLat (),
512
- currentPoint .getLon (), previousPoint .getLat (), previousPoint .getLon ());
513
- if (currentDistance >= thresholdDistance ) {
514
- return pathList ;
515
- }
516
-
517
- pathList .add (currentPoint );
518
- previousPoint = currentPoint ;
519
- }
520
- }
521
-
522
- // Default to full path in case the threshold isn't hit
523
- return pathList ;
506
+ return computePathListWithinThreshold (thresholdDistance , pointList , currentDistance , previousPoint );
524
507
}
525
508
526
509
/**
@@ -564,9 +547,22 @@ private PointList computeWayGeometryOfStartingEdge(BufferFeature startFeature, B
564
547
565
548
double currentDistance = 0.0 ;
566
549
GHPoint3D previousPoint = tempList .get (0 );
567
- pathList = new PointList ();
568
550
569
- for (GHPoint3D currentPoint : tempList ) {
551
+ return computePathListWithinThreshold (thresholdDistance , tempList , currentDistance , previousPoint );
552
+ }
553
+
554
+ /**
555
+ * Generates a list of points to create a path that does not exceed a threshold.
556
+ *
557
+ * @param thresholdDistance max distance to not exceed
558
+ * @param origList the original list to loop through during calculations
559
+ * @param currentDistance sum of the distance while moving through the original list
560
+ * @param previousPoint point to compute the distance from
561
+ * @return a PointList containing a path not exceeding the threshold
562
+ */
563
+ private PointList computePathListWithinThreshold (Double thresholdDistance , PointList origList , double currentDistance , GHPoint3D previousPoint ) {
564
+ PointList pathList = new PointList ();
565
+ for (GHPoint3D currentPoint : origList ) {
570
566
// Filter zero-points made by PointList() scaling
571
567
if (currentPoint .lat != 0 && currentPoint .lon != 0 ) {
572
568
// Check if exceeds thresholdDistance
@@ -580,7 +576,7 @@ private PointList computeWayGeometryOfStartingEdge(BufferFeature startFeature, B
580
576
previousPoint = currentPoint ;
581
577
}
582
578
}
583
-
579
+ // Default to full path in case the threshold isn't hit
584
580
return pathList ;
585
581
}
586
582
0 commit comments