FeatureCollections

Core. FeatureCollections

Source:
FeatureCollection object validation functions used within Core.

Methods

(static) featureCollection(featureCollectionObject) → {boolean}

Source:
See:
Verifies an object is a valid GeoJSON FeatureCollection. This object requires a "type" member that must equal 'FeatureCollection', and a "features" member that contains either a valid GeoJSON Feature or an empty array. Foreign members are allowed with the exceptions thrown below. If present, bounding boxes must be valid.
Example
const testFeatureCollection = {
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [102.0, 0.5]
        }
    },
    ...
    ]
}
const multiPoint = {
    type: "MultiPoint",
    coordinates: [
        [101.0, 0.0],
        [102.0, 1.0]
    ]
}

const goodExample1 = featureCollection(testFeatureCollection)) // true

const badExample1 = featureCollection(multiPoint)) // throws error
const badExample2 = featureCollection(testFeatureCollection.features)) // throws error
Parameters:
Name Type Description
featureCollectionObject object a GeoJSON LineString Geometry object
Throws:
  • Argument not an object
    Type
    Error
  • Must have a type property with value 'FeatureCollection'
    Type
    Error
  • Forbidden from having a property 'coordinates', 'geometries', 'geometry', or 'properties'
    Type
    Error
  • Bounding box must be valid (if present)
    Type
    Error
Returns:
True if a valid GeoJSON FeatureCollection. If invalid, it will throw an error.
Type
boolean