Class: MeasureUtil

MeasureUtil()

new MeasureUtil()

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

Source:

Methods

(static) angle(start, end) → {Number}

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 http://stackoverflow.com/a/31136507

Parameters:
Name Type Description
start Array.<Number>

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

end Array.<Number>

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

Source:
Returns:

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

Type
Number

(static) angle360(start, end) → {Number}

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 http://stackoverflow.com/a/31136507

Parameters:
Name Type Description
start Array.<Number>

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

end Array.<Number>

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

Source:
Returns:

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

Type
Number

(static) formatAngle(line, decimalPlacesInToolTips) → {String}

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

Parameters:
Name Type Default Description
line OlGeomLineString

The linestring to get the angle from. As this line is comming 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.

Source:
Returns:

The formatted angle of the line.

Type
String

(static) formatArea(polygon, map, decimalPlacesInToolTips, geodesic) → {String}

Format length output for the tooltip.

Parameters:
Name Type Default Description
polygon OlGeomPolygon

The drawn polygon.

map OlMap

An OlMap.

decimalPlacesInToolTips Number

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

geodesic Boolean true

Is the measurement geodesic.

Source:
Returns:

The formatted area of the polygon.

Type
String

(static) formatLength(line, map, decimalPlacesInToolTips, geodesic) → {String}

Format length output for the tooltip.

Parameters:
Name Type Default Description
line OlGeomMultiLineString

The drawn line.

map OlMap

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).

Source:
Returns:

The formatted length of the line.

Type
String

(static) makeClockwise(angle360) → {Number}

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:
Name Type Description
angle360 Number

The input angle obtained counter-clockwise.

Source:
Returns:

The clockwise angle.

Type
Number

(static) makeZeroDegreesAtNorth(angle360) → {Number}

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:
Name Type Description
angle360 Number

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

Source:
Returns:

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

Type
Number