lineSliceAlong function

Feature<LineString> lineSliceAlong(
  1. Feature<LineString> line,
  2. double startDist,
  3. double stopDist, [
  4. Unit unit = Unit.kilometers,
])

Takes a line, at a start distance startDist and a stop distance stopDist and returns a subsection of the line in-between those distances.

If startDist and stopDist resolve to the same point on line, null is returned as the resolved line would only contain one point which isn't supported by LineString.

This can be useful for extracting only the part of a route between distances on the route.

Implementation

Feature<LineString> lineSliceAlong(
  Feature<LineString> line,
  double startDist,
  double stopDist, [
  Unit unit = Unit.kilometers,
]) {
  return Feature<LineString>(
    geometry: lineSliceAlongRaw(line.geometry!, startDist, stopDist, unit),
    properties: line.properties,
  );
}