extractLine method

Geometry extractLine(
  1. double startIndex,
  2. double endIndex
)

Computes the {@link LineString} for the interval on the line between the given indices. If the endIndex lies before the startIndex, the computed geometry is reversed.

@param startIndex the index of the start of the interval @param endIndex the index of the end of the interval @return the linear interval between the indices

Implementation

Geometry extractLine(double startIndex, double endIndex) {
  double startIndex2 = clampIndex(startIndex);
  double endIndex2 = clampIndex(endIndex);
  // if extracted line is zero-length, resolve start lower as well to ensure they are equal
  bool resolveStartLower = startIndex2 == endIndex2;
  LinearLocation startLoc =
      locationOfWithResolver(startIndex2, resolveStartLower);
//    LinearLocation endLoc = locationOf(endIndex2, true);
//    LinearLocation startLoc = locationOf(startIndex2);
  LinearLocation endLoc = locationOf(endIndex2);
  return ExtractLineByLocation.extractStatic(linearGeom, startLoc, endLoc);
}