/** * 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 */ public 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 boolean resolveStartLower = startIndex2 == endIndex2; LinearLocation startLoc = locationOf(startIndex2, resolveStartLower); // LinearLocation endLoc = locationOf(endIndex2, true); // LinearLocation startLoc = locationOf(startIndex2); LinearLocation endLoc = locationOf(endIndex2); return ExtractLineByLocation.extract(linearGeom, startLoc, endLoc); }