- Source:
Coordinate validation functions used within Core.
Methods
(static) valid2DCoordinate(coordinate) → {boolean}
- Source:
- See:
Verifies a two element coordinate meets WGS-84 and GeoJSON validity
requirements.
Example
const goodCoord = valid2DCoordinate([10, 20]) // true
const badExample1 = valid2DBoundingBox([10, -200]) // throws error for latitude being out of range
const badExample2 = valid2DBoundingBox([10, 20, 0]) // throws error for 3D Coordinate
Parameters:
Name | Type | Description |
---|---|---|
coordinate |
Array.<number> | A WGS-84 array of [longitude, latitude] |
Throws:
-
-
Input must be an array of only two elments
- Type
- Error
-
-
-
Longitude must be a number between -180 and 180
- Type
- RangeError
-
-
-
Latitude must be a number between -90 and 90
- Type
- RangeError
-
Returns:
True if a valid 2D GeoJSON coordinate. If invalid, it will throw an error.
- Type
- boolean
(static) valid3DCoordinate(coordinate) → {boolean}
- Source:
- See:
Verifies a three element coordinate meets WGS-84 and GeoJSON validity
requirements.
Example
const goodCoord = valid3DCoordinate([10, 20, 0]) // true
const badExample1 = valid3DBoundingBox([10, -200, 0]) // throws error for latitude being out of range
const badExample2 = valid3DBoundingBox([10, 20, '0']) // throws error for altitude being a string instead of number
const badExample3 = valid3DBoundingBox([10, 0]) // throws error for 2D Coordinate
Parameters:
Name | Type | Description |
---|---|---|
coordinate |
Array.<number> | A WGS-84 array of [longitude, latitude, alititude] |
Throws:
-
-
Input must be an array of only three elments
- Type
- Error
-
-
-
Altitude value must be numeric
- Type
- Error
-
Returns:
True if a valid 3D GeoJSON coordinate. If invalid, it will throw an error.
- Type
- boolean
(static) validCoordinate(coordinate) → {boolean}
- Source:
- See:
Verifies a two or three element coordinate meets WGS-84 and GeoJSON validity
requirements.
Example
const goodCoord1 = validCoordinate([10, 20]) // true
const goodCoord2 = validCoordinate([10, 20, 0]) // true
const badExample1 = validCoordinate([10, -200]) // throws error for latitude being out of range
const badExample2 = validCoordinate([10, 20, '0']) // throws error for altitude being a string instead of number
Parameters:
Name | Type | Description |
---|---|---|
coordinate |
Array.<number> | A WGS-84 array of [longitude, latitude] or [longitude, latitude, alititude] |
Throws:
-
Input must be an array of only two or three elments
- Type
- Error
Returns:
True if a valid 2D or 3D GeoJSON coordinate. If invalid, it will throw an
error.
- Type
- boolean