@squawk
    Preparing search index...

    Function densify

    • Computes evenly spaced points along the great-circle arc between two geographic positions, no more than maxSegmentNm apart, starting at the first position and ending at the second. Useful for drawing a long leg on a flat map projection, where a straight line between the endpoints visibly departs from the arc the distance describes.

      The arc is split into the fewest equal segments that keep each one within maxSegmentNm, so a 100 NM leg at a 25 NM limit yields 5 points and a leg shorter than the limit yields just its 2 endpoints. The endpoints are returned exactly as given; intermediate longitudes are normalized to the range [-180, 180], so an arc crossing the antimeridian changes sign partway, and a consumer drawing it on a map unwraps the longitudes first. For antipodal inputs the arc is underdetermined; the points follow the initial bearing bearing returns, so the result is still finite and deterministic.

      Parameters

      • lat1: number

        Latitude of the start point in decimal degrees.

      • lon1: number

        Longitude of the start point in decimal degrees.

      • lat2: number

        Latitude of the end point in decimal degrees.

      • lon2: number

        Longitude of the end point in decimal degrees.

      • maxSegmentNm: number

        Longest allowed distance between consecutive points in nautical miles. Must be a positive finite number.

      Returns Coordinates[]

      The points along the arc in order, including both endpoints.

      RangeError when maxSegmentNm is not a positive finite number.