Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toHave3DBoundingBox #55

Open
M-Scott-Lassiter opened this issue Jun 8, 2022 · 0 comments
Open

toHave3DBoundingBox #55

M-Scott-Lassiter opened this issue Jun 8, 2022 · 0 comments
Assignees
Labels
new matcher proposal Proposal for a new GeoJSON matcher
Projects

Comments

@M-Scott-Lassiter
Copy link
Owner

Description

Bounding boxes are an optional GeoJSON property that describe a box of longitude boundaries that run along meridians and latitude boundaries that are parallel to the equator. A 2D Bounding Box only describes longitude and latitude boundaries, whereas a 3D Bounding Box describes an additional min and max altitude/depth value.

A GeoJSON object MAY have a member named "bbox" to include information on the coordinate range for its Geometries, Features, or FeatureCollections. The value of the bbox member MUST be an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries.

The "bbox" values define shapes with edges that follow lines of constant longitude, latitude, and elevation.
~ https://datatracker.ietf.org/doc/html/rfc7946#section-5

This matcher evaluates any Geometry, GeometryCollection, Feature, or FeatureCollection object to ensure it has a valid 2D bounding box. It will not check any subsets of these objects (i.e. it will not check all "geometries" in the collection also have 3D bounding boxes).

It takes an optional argument of a valid bounding box array, bboxEquals. If present, the feature must have a bounding box that exactly equals this value.

Example Matcher Usage

const testCollection = {
    type: "FeatureCollection",
    bbox: [-100.0, -10, 10, 49.5],
    features: [
        {
            type: "Feature",
            geometry: {...}
        },
        {
            type: "Feature",
            bbox: [-20, -5, 0, 0, 5, 200]
            geometry: {...}
        }
    ]
}
const testPolygon = {
    type: "Polygon",
    bbox: [-10, -10, 0, 10, 10, 0],
    coordinates: [
        [
            [-10.0, -10.0],
            [10.0, -10.0],
            [10.0, 10.0],
            [-10.0, -10.0]
        ]
    ]
}

expect(testPolygon).toHave3DBoundingBox()
expect(testCollection.features[1]).toHave3DBoundingBox([-20, -5, 0, 0, 5, 200])


expect(testCollection).not.toHave3DBoundingBox()
expect(testCollection.features[0]).not.toHave3DBoundingBox()
expect(testCollection.features[1]).not.toHave3DBoundingBox([-10, -10, 0, 10, 10, 0])
expect(testPolygon.bbox).not.toHave3DBoundingBox()

Passing Tests

Valid GeoJSON Objects with a BBox

Check with and without optional bboxEquals

  • Each of the seven Geometry, Feature, and FeatureCollection valid objects

Valid GeoJSON Objects with a BBox

A GeometryCollection, Feature, and FeatureCollection that has a BBox, but

  • one or more components do not
  • one or more have a 2D bounding box

Failing Tests

Invalid Inputs To Matcher

Rejects each of the following:

  • Each of the seven Geometry, Feature, and FeatureCollection objects when invalid
  • Arrays: [], [0, 0], [0, 0, 0], [[-20], [10], [-10], [20]], [0, 0, 0, 0], [0, 0, 0, 0, 0, 0]
  • undefined, null, false, true, 0
  • { someProp: 'I am not GeoJSON', id: 4 }
  • {}
  • '',
  • 'Random Feature',
  • JSON.stringify({
        type: 'Feature',
        geometry: null,
        properties: null
    })

Valid GeoJSON Objects without a BBox

Each of the seven Geometry, Feature, and FeatureCollection valid objects

Valid GeoJSON Objects with Component BBox but no Overall BBox

A GeometryCollection, Feature, and FeatureCollection that has no BBox, but the geometries do

Valid GeoJSON Objects with a BBox, bboxEquals Does Not Match

Each of the seven Geometry, Feature, and FeatureCollection valid objects

Incorrect number of array elements in bboxEquals

All items in "Invalid Inputs To Matcher" except the 4 element array

@M-Scott-Lassiter M-Scott-Lassiter added the new matcher proposal Proposal for a new GeoJSON matcher label Jun 8, 2022
@M-Scott-Lassiter M-Scott-Lassiter added this to To do in Functional via automation Jun 8, 2022
@M-Scott-Lassiter M-Scott-Lassiter self-assigned this Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new matcher proposal Proposal for a new GeoJSON matcher
Projects
Functional
  
To do
Development

No branches or pull requests

1 participant