BoundingBoxes

Core. BoundingBoxes

Source:
Bounding Box validation functions used within Core.

Methods

(static) valid2DBoundingBox(bboxArray) → {boolean}

Source:
See:
Verifies a two dimensional bounding box meets WGS-84 and GeoJSON validity requirements.
Example
const goodBBox = valid2DBoundingBox([-10, -20, 20, -10]) // true
const crossesAntimeridian = valid2DBoundingBox([170, -20, -170, 20]) // true

const badExample1 = valid2DBoundingBox([-10, -200, 20, -10]) // throws error for south being out of range
const badExample2 = valid2DBoundingBox([-10, -20, '20', -10]) // throws error for non-numeric value
Parameters:
Name Type Description
bboxArray Array.<number> A WGS-84 array of in format [west, south, east, north].
Throws:
  • Input must be an array of only four elements of type number
    Type
    Error
  • Longitude must be a number between -180 and 180
    Type
    RangeError
  • Latitude must be a number between -90 and 90
    Type
    RangeError
  • North must be greater than or equal to south
    Type
    RangeError
Returns:
True if a valid 2D GeoJSON coordinate. If invalid, it will throw an error.
Type
boolean

(static) valid3DBoundingBox(bboxArray) → {boolean}

Source:
See:
Verifies a three dimensional bounding box meets WGS-84 and GeoJSON validity requirements.
Example
const goodBBox = valid3DBoundingBox([-10, -20, -100, 20, 10, 0]) // true
const crossesAntimeridian = valid3DBoundingBox([170, -20, -22.5, 20, -170, 12345.678]) // true

const badExample1 = valid3DBoundingBox([-10, -91, 0, 10, 20, 0]) // throws error for south being out of range
const badExample2 = valid3DBoundingBox([-10, -10, "0", 10, 20, 0]) // throws error for non-numeric value
Parameters:
Name Type Description
bboxArray Array.<number> A six element WGS-84 array of numbers in format [west, south, depth, east, north, altitude].
Throws:
  • Input must be an array of only four elements of type number
    Type
    Error
  • Depth and altitude must be numeric.
    Type
    Error
  • Longitude must be a number between -180 and 180
    Type
    RangeError
  • Latitude must be a number between -90 and 90
    Type
    RangeError
  • North must be greater than or equal to south
    Type
    RangeError
  • Altitude must be greater than or equal to depth
    Type
    RangeError
Returns:
True if a valid 3D GeoJSON coordinate. If invalid, it will throw an error.
Type
boolean

(static) validBoundingBox(bboxArray) → {boolean}

Source:
See:
Verifies either a two or three dimensional bounding box meets WGS-84 and GeoJSON validity requirements.
Example
const good2DBBox = validBoundingBox([-10, -20, 20, -10]) // true
const good3DBBox = validBoundingBox([-10, -20, -100, 20, 10, 0]) // true

const badExample1 = validBoundingBox([-10, -91, 10, 20]) // throws error for south being out of range
const badExample2 = validBoundingBox([-10, -10, "0", 10, 20, 0]) // throws error for non-numeric value
Parameters:
Name Type Description
bboxArray Array.<number> A WGS-84 array of [west, south, east, north] or [west, south, depth, east, north, altitude]. Longitude must be between -180 to 180. Latitude must be between -90 to 90. If present, depth and altitude must be a number between -Infinity to Infinity. The standard does not specify units altitude represents (i.e. meters, feet, etc.).
Throws:
Input must be an array of only four or six elments
Type
Error
Returns:
True if a valid 2D or 3D GeoJSON bounding box. If invalid, it will throw an error.
Type
boolean