docs: private static void douglasPeuckerReduction(ArrayList<GeoPoint> shape, boolean[] marked, double tolerance, int firstIdx, int lastIdx)
      {
          if (lastIdx <= firstIdx + 1) {
              // overlapping indexes, just return
              return;
          }
  
          // loop over the points between the first and last points
          // and find the point that is the farthest away
  
          double maxDistance = 0.0;
          int indexFarthest = 0;
  
          GeoPoint firstPoint = shape.get(firstIdx);
          GeoPoint lastPoint = shape.get(lastIdx);
  
          for (int idx = firstIdx + 1; idx < lastIdx; idx++) {
              GeoPoint point = shape.get(idx);
  
              double distance = orthogonalDistance(point, firstPoint, lastPoint);
  
              // keep the point with the greatest distance
              if (distance > maxDistance) {
                  maxDistance = distance;
                  indexFarthest = idx;
              }
          }
  
          if (maxDistance > tolerance) {
              //The farthest point is outside the tolerance: it is marked and the algorithm continues.
              marked[indexFarthest] = true;
  
              // reduce the shape between the starting point to newly found point
              douglasPeuckerReduction(shape, marked, tolerance, firstIdx, indexFarthest);
  
              // reduce the shape between the newly found point and the finishing point
              douglasPeuckerReduction(shape, marked, tolerance, indexFarthest, lastIdx);
          }
          //else: the farthest point is within the tolerance, the whole segment is discarded.
      }