extractPointWithOffset method

Coordinate extractPointWithOffset(
  1. double index,
  2. double offsetDistance
)

Computes the {@link Coordinate} for the point on the line at the given index, offset by the given distance. If the index is out of range the first or last point on the line will be returned. The computed point is offset to the left of the line if the offset distance is positive, to the right if negative.

The Z-ordinate of the computed point will be interpolated from the Z-ordinates of the line segment containing it, if they exist.

@param index the index of the desired point @param offsetDistance the distance the point is offset from the segment (positive is to the left, negative is to the right) @return the Coordinate at the given index

Implementation

Coordinate extractPointWithOffset(double index, double offsetDistance) {
  LinearLocation loc = LengthLocationMap.getLocationStatic(linearGeom, index);
  LinearLocation locLow = loc.toLowest(linearGeom);
  return locLow
      .getSegment(linearGeom)
      .pointAlongOffset(locLow.getSegmentFraction(), offsetDistance);
}