BoundingBoxes

Matchers. BoundingBoxes

Source:
See:
A set of matchers related to validating bounding boxes.

Methods

(static) isValid2DBoundingBox(bboxArray)

Source:
See:
Verifies a two dimensional bounding box meets WGS-84 and GeoJSON validity requirements.
Examples
test('Object is valid GeoJSON', () => {
     expect([-20, 10, -10, 20]).isValid2DBoundingBox()
     expect([170, -20, -170, 20]).isValid2DBoundingBox() // Crosses antimeridian
 })
test('Object is NOT valid GeoJSON', () => {
     expect([-180.01, -10, -160, 10]).not.isValid2DBoundingBox() // Longitude out of range
     expect([-20, 10, 0, -10, 20, 0]).not.isValid2DBoundingBox() //3D bounding box
     expect([-20, 10, -10, false]).not.isValid2DBoundingBox() // Non-numeric value
 })
Parameters:
Name Type Description
bboxArray Array.<number> A four element array of numbers in format [west, south, east, north]. Longitude must be between -180 to 180. Latitude must be between -90 to 90. North must be greater than or equal to south. Bounding boxes that cross the antimeridian will have an eastern value less than the western value.

(static) isValid3DBoundingBox(bboxArray)

Source:
See:
Verifies a three dimensional bounding box meets WGS-84 and GeoJSON validity requirements.
Examples
test('Object is valid GeoJSON', () => {
     expect([-10, -20, -100, 20, 10, 0]).isValid3DBoundingBox()
     expect([170, -20, -22.5, 20, -170, 12345.678]).isValid3DBoundingBox() // Crosses antimeridian
 })
test('Object is NOT valid GeoJSON', () => {
     expect([-10, -91, 0, 10, 20, 0]).not.isValid3DBoundingBox() // south out of range
     expect([-20, 10, -10, 20]).not.isValid3DBoundingBox() //2D bounding box
     expect([-10, -10, "0", 10, 20, 0]).not.isValid2DBoundingBox() // 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]. Longitude must be between -180 to 180. Latitude must be between -90 to 90. North must be greater than or equal to south. Altitude must be greater than or equal to depth. Bounding boxes that cross the antimeridian will have an eastern value less than the western value.

(static) isValidBoundingBox(coordinateArray)

Source:
See:
Verifies a two or three dimensional bounding box meets WGS-84 and GeoJSON validity requirements.
Examples
test('Object is valid GeoJSON', () => {
     expect([220, 56]).not.isValidCoordinate() // Longitude out of range
     expect([22, 45.733, '0']).not.isValidCoordinate()
     // Nested Arrays
     expect([[22, 45.733, 0]]).not.isValidCoordinate()
     expect([[22, 45.733, 0], [180, 90, 0]]).not.isValidCoordinate()
     expect([-20, 10, -10, 20]).isValidBoundingBox()
     expect([170, -20, -170, 20]).isValidBoundingBox()
     expect([-10, -20, -100, 20, 10, 0]).isValidBoundingBox()
     expect([170, -20, -22.5, 20, -170, 12345.678]).isValidBoundingBox()
 })
test('Object is NOT valid GeoJSON', () => {
     expect([-180.01, -10, -160, 10]).not.isValidBoundingBox() // Longitude out of range
     expect([-10, -10, "0", 10, 20, 0]).not.isValidBoundingBox() // Non-numeric value
 })
Parameters:
Name Type Description
coordinateArray 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.).