@terrestris/ol-util
    Preparing search index...

    This class provides some static methods which might be helpful when working with measurements.

    MeasureUtil

    Index

    Constructors

    Methods

    • Determine the angle between two coordinates. The angle will be between -180° and 180°, with 0° being in the east. The angle will increase counter-clockwise.

      Inspired by https://stackoverflow.com/a/31136507

      Parameters

      • start: number[]

        The start coordinates of the line with the x-coordinate being at index 0 and y-coordinate being at index 1.

      • end: number[]

        The end coordinates of the line with the x-coordinate being at index 0 and y-coordinate being at index 1.

      Returns number

      the angle in degrees, ranging from -180° to 180°.

    • Determine the angle between two coordinates. The angle will be between 0° and 360°, with 0° being in the east. The angle will increase counter-clockwise.

      Inspired by https://stackoverflow.com/a/31136507

      Parameters

      • start: number[]

        The start coordinates of the line with the x-coordinate being at index 0 and y-coordinate being at index 1.

      • end: number[]

        The end coordinates of the line with the x-coordinate being at index 0 and y-coordinate being at index 1.

      Returns number

      the angle in degrees, ranging from 0° and 360°.

    • Returns the angle of the passed linestring in degrees, with 'N' being the 0°-line and the angle increases in clockwise direction.

      Parameters

      • line: LineString

        The linestring to get the angle from. As this line is coming from our internal draw interaction, we know that it will only consist of two points.

      • decimalPlacesInToolTips: number = 2

        How many decimal places will be allowed for the measure tooltips.

      Returns string

      The formatted angle of the line.

    • Format area output for the tooltip.

      Parameters

      • geom: Polygon | Circle

        The drawn geometry (circle or polygon).

      • map: Map

        An OlMap.

      • decimalPlacesInToolTips: number

        How many decimal places will be allowed for the measure tooltips.

      • geodesic: boolean = true

        Is the measurement geodesic.

      Returns string

      The formatted area of the polygon.

    • Format length output for the tooltip.

      Parameters

      • line: LineString

        The drawn line.

      • map: Map

        An OlMap.

      • decimalPlacesInToolTips: number

        How many decimal places will be allowed for the measure tooltips

      • geodesic: boolean = true

        Is the measurement geodesic (default is true).

      Returns string

      The formatted length of the line (units: km, m or mm).

    • Get the area of an OlGeomPolygon.

      Parameters

      • polygon: Polygon

        The drawn polygon.

      • map: Map

        An OlMap.

      • geodesic: boolean = true

        Is the measurement geodesic (default is true).

      • radius: number = 6371008.8

        Sphere radius. By default, the radius of the earth is used (Clarke 1866 Authalic Sphere, 6371008.8).

      Returns number

      The area of the polygon in square meter.

    • Get the estimated area of an OlGeomCircle.

      Parameters

      • circleGeom: Circle

        The drawn circle.

      • map: Map

        An OlMap.

      Returns number

      The area of the circle in square meter.

    • Get the length of a OlGeomLineString.

      Parameters

      • line: LineString

        The drawn line.

      • map: Map

        An OlMap.

      • geodesic: boolean = true

        Is the measurement geodesic (default is true).

      • radius: number = 6371008.8

        Sphere radius. By default, the radius of the earth is used (Clarke 1866 Authalic Sphere, 6371008.8).

      • decimalPrecision: number = 6

        Set the decimal precision on length value for non-geodesic map (default value 6)

      Returns number

      The length of line in meters.

    • Given an angle between 0° and 360° this angle returns the exact opposite of the angle, e.g. for 90° you'll get back 270°. This effectively turns the direction of the angle from counter-clockwise to clockwise.

      Parameters

      • angle360: number

        The input angle obtained counter-clockwise.

      Returns number

      The clockwise angle.

    • This methods adds an offset of 90° to an counter-clockwise increasing angle of a line so that the origin (0°) lies at the top (in the north).

      Parameters

      • angle360: number

        The input angle obtained counter-clockwise, with 0° degrees being in the east.

      Returns number

      The adjusted angle, with 0° being in the north.