interpolate method

Mappoint? interpolate(
  1. double distance
)

Interpolates on the segment and returns the coordinate of the interpolation result. Returns null if distance is < 0 or > length().

Implementation

Mappoint? interpolate(double distance) {
  if (distance < 0) {
    return null;
  }

  for (LineSegment segment in segments) {
    double length = segment.length();
    if (distance <= length) {
      return segment.pointAlongLineSegment(distance);
    }
    distance -= length;
  }
  return null;
}