diff --git a/schemas/2020-12/ietf/geojson/bounding-box.json b/schemas/2020-12/ietf/geojson/bounding-box.json new file mode 100644 index 00000000..51c2a5a3 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/bounding-box.json @@ -0,0 +1,80 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON Bounding Box", + "description": "An array of numbers representing a bounding box that encloses a GeoJSON object, with coordinates in the order: westernmost, southernmost, easternmost, northernmost", + "examples": [ + [ -180, -90, 180, 90 ], + [ -122.5, 37.5, -122.0, 38.0 ], + [ -180, -90, 0, 180, 90, 1000 ] + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-5" ], + "type": "array", + "anyOf": [ + { + "description": "2D bounding box", + "maxItems": 4, + "minItems": 4, + "prefixItems": [ + { + "description": "Westernmost longitude", + "$comment": "RFC 7946 does not constrain longitude range", + "type": "number" + }, + { + "description": "Southernmost latitude", + "$ref": "../../iso/coordinate/2022/latitude.json" + }, + { + "description": "Easternmost longitude", + "$comment": "RFC 7946 does not constrain longitude range", + "type": "number" + }, + { + "description": "Northernmost latitude", + "$ref": "../../iso/coordinate/2022/latitude.json" + } + ] + }, + { + "description": "3D bounding box", + "maxItems": 6, + "minItems": 6, + "prefixItems": [ + { + "description": "Westernmost longitude", + "$comment": "RFC 7946 does not constrain longitude range", + "type": "number" + }, + { + "description": "Southernmost latitude", + "$ref": "../../iso/coordinate/2022/latitude.json" + }, + { + "description": "Minimum altitude", + "$ref": "../../iso/coordinate/2022/altitude.json" + }, + { + "description": "Easternmost longitude", + "$comment": "RFC 7946 does not constrain longitude range", + "type": "number" + }, + { + "description": "Northernmost latitude", + "$ref": "../../iso/coordinate/2022/latitude.json" + }, + { + "description": "Maximum altitude", + "$ref": "../../iso/coordinate/2022/altitude.json" + } + ] + }, + { + "description": "Higher dimension bounding box", + "minItems": 7, + "items": { + "type": "number" + } + } + ] +} diff --git a/schemas/2020-12/ietf/geojson/feature-collection.json b/schemas/2020-12/ietf/geojson/feature-collection.json new file mode 100644 index 00000000..411497bf --- /dev/null +++ b/schemas/2020-12/ietf/geojson/feature-collection.json @@ -0,0 +1,53 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON FeatureCollection", + "description": "A collection of Feature objects", + "examples": [ + { + "type": "FeatureCollection", + "features": [] + }, + { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": null, + "properties": null + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": { + "name": "Example" + } + } + ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.3" ], + "type": "object", + "required": [ "type", "features" ], + "properties": { + "type": { + "const": "FeatureCollection" + }, + "features": { + "type": "array", + "items": { + "$ref": "feature.json" + } + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "coordinates": false, + "geometries": false, + "geometry": false, + "properties": false + } +} diff --git a/schemas/2020-12/ietf/geojson/feature.json b/schemas/2020-12/ietf/geojson/feature.json new file mode 100644 index 00000000..d4c66876 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/feature.json @@ -0,0 +1,72 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON Feature", + "description": "A spatially bounded entity that combines a geometry with additional properties", + "examples": [ + { + "type": "Feature", + "geometry": null, + "properties": null + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": { + "name": "Example" + } + }, + { + "type": "Feature", + "id": "feature-1", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": null + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.2" ], + "type": "object", + "required": [ "type", "geometry", "properties" ], + "properties": { + "type": { + "const": "Feature" + }, + "id": { + "type": [ "number", "string" ] + }, + "geometry": { + "anyOf": [ + { + "const": null + }, + { + "$ref": "geometry.json" + }, + { + "$ref": "geometry-collection.json" + } + ] + }, + "properties": { + "anyOf": [ + { + "const": null + }, + { + "type": "object" + } + ] + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "coordinates": false, + "geometries": false, + "features": false + } +} diff --git a/schemas/2020-12/ietf/geojson/geometry-collection.json b/schemas/2020-12/ietf/geojson/geometry-collection.json new file mode 100644 index 00000000..26b835cf --- /dev/null +++ b/schemas/2020-12/ietf/geojson/geometry-collection.json @@ -0,0 +1,48 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON GeometryCollection", + "description": "A geometry object that represents a collection of geometry objects", + "examples": [ + { + "type": "GeometryCollection", + "geometries": [] + }, + { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + } + ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.8" ], + "type": "object", + "required": [ "type", "geometries" ], + "properties": { + "type": { + "const": "GeometryCollection" + }, + "geometries": { + "type": "array", + "items": { + "$ref": "geometry.json" + } + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "geometry": false, + "properties": false, + "features": false + } +} diff --git a/schemas/2020-12/ietf/geojson/geometry.json b/schemas/2020-12/ietf/geojson/geometry.json new file mode 100644 index 00000000..1326150b --- /dev/null +++ b/schemas/2020-12/ietf/geojson/geometry.json @@ -0,0 +1,51 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON Geometry", + "description": "A geometry object representing coordinates in geographic space, excluding GeometryCollection", + "examples": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1" ], + "anyOf": [ + { + "$ref": "point.json" + }, + { + "$ref": "line-string.json" + }, + { + "$ref": "polygon.json" + }, + { + "$ref": "multi-point.json" + }, + { + "$ref": "multi-line-string.json" + }, + { + "$ref": "multi-polygon.json" + } + ] +} diff --git a/schemas/2020-12/ietf/geojson/line-string-coordinates.json b/schemas/2020-12/ietf/geojson/line-string-coordinates.json new file mode 100644 index 00000000..347021f4 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/line-string-coordinates.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON LineString Coordinates", + "description": "An array of two or more positions representing the coordinates of a LineString geometry", + "examples": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ], + [ + [ 0, 0 ], + [ 1, 1 ], + [ 2, 0 ] + ], + [ + [ 0, 0, 0 ], + [ 1, 1, 10 ], + [ 2, 0, 20 ] + ] + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.4" ], + "type": "array", + "minItems": 2, + "items": { + "$ref": "point-coordinates.json" + } +} diff --git a/schemas/2020-12/ietf/geojson/line-string.json b/schemas/2020-12/ietf/geojson/line-string.json new file mode 100644 index 00000000..1fb3ce84 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/line-string.json @@ -0,0 +1,40 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON LineString", + "description": "A geometry object representing a connected sequence of two or more positions", + "examples": [ + { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ], + [ 2, 0 ] + ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.4" ], + "type": "object", + "required": [ "type", "coordinates" ], + "properties": { + "type": { + "const": "LineString" + }, + "coordinates": { + "$ref": "line-string-coordinates.json" + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "geometry": false, + "properties": false, + "features": false + } +} diff --git a/schemas/2020-12/ietf/geojson/linear-ring-coordinates.json b/schemas/2020-12/ietf/geojson/linear-ring-coordinates.json new file mode 100644 index 00000000..0f9a55f5 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/linear-ring-coordinates.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON Linear Ring Coordinates", + "description": "An array of four or more positions representing a closed linear ring, where the first and last positions are equivalent", + "examples": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ], + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 1 ], + [ 0, 0 ] + ] + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.6" ], + "type": "array", + "minItems": 4, + "items": { + "$ref": "point-coordinates.json" + } +} diff --git a/schemas/2020-12/ietf/geojson/multi-line-string.json b/schemas/2020-12/ietf/geojson/multi-line-string.json new file mode 100644 index 00000000..3ff0165f --- /dev/null +++ b/schemas/2020-12/ietf/geojson/multi-line-string.json @@ -0,0 +1,50 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON MultiLineString", + "description": "A geometry object representing multiple LineString geometries", + "examples": [ + { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ] + }, + { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ], + [ + [ 2, 2 ], + [ 3, 3 ] + ] + ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.5" ], + "type": "object", + "required": [ "type", "coordinates" ], + "properties": { + "type": { + "const": "MultiLineString" + }, + "coordinates": { + "type": "array", + "items": { + "$ref": "line-string-coordinates.json" + } + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "geometry": false, + "properties": false, + "features": false + } +} diff --git a/schemas/2020-12/ietf/geojson/multi-point.json b/schemas/2020-12/ietf/geojson/multi-point.json new file mode 100644 index 00000000..a0925542 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/multi-point.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON MultiPoint", + "description": "A geometry object representing multiple positions", + "examples": [ + { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ] + ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.3" ], + "type": "object", + "required": [ "type", "coordinates" ], + "properties": { + "type": { + "const": "MultiPoint" + }, + "coordinates": { + "type": "array", + "items": { + "$ref": "point-coordinates.json" + } + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "geometry": false, + "properties": false, + "features": false + } +} diff --git a/schemas/2020-12/ietf/geojson/multi-polygon.json b/schemas/2020-12/ietf/geojson/multi-polygon.json new file mode 100644 index 00000000..85e928c2 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/multi-polygon.json @@ -0,0 +1,62 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON MultiPolygon", + "description": "A geometry object representing multiple Polygon geometries", + "examples": [ + { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ] + }, + { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + [ + [ + [ 2, 2 ], + [ 3, 2 ], + [ 3, 3 ], + [ 2, 2 ] + ] + ] + ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.7" ], + "type": "object", + "required": [ "type", "coordinates" ], + "properties": { + "type": { + "const": "MultiPolygon" + }, + "coordinates": { + "type": "array", + "items": { + "$ref": "polygon-coordinates.json" + } + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "geometry": false, + "properties": false, + "features": false + } +} diff --git a/schemas/2020-12/ietf/geojson/point-coordinates.json b/schemas/2020-12/ietf/geojson/point-coordinates.json new file mode 100644 index 00000000..637a385b --- /dev/null +++ b/schemas/2020-12/ietf/geojson/point-coordinates.json @@ -0,0 +1,30 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON Position", + "description": "An array of numbers representing a geographic position, with longitude first, latitude second, and optional altitude third", + "examples": [ + [ -122.419, 37.7749 ], + [ 0, 0 ], + [ -122.419, 37.7749, 10.5 ] + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.1" ], + "type": "array", + "minItems": 2, + "prefixItems": [ + { + "description": "Longitude in decimal degrees", + "$comment": "RFC 7946 does not constrain longitude range", + "type": "number" + }, + { + "$ref": "../../iso/coordinate/2022/latitude.json" + }, + { + "$ref": "../../iso/coordinate/2022/altitude.json" + } + ], + "items": { + "type": "number" + } +} diff --git a/schemas/2020-12/ietf/geojson/point.json b/schemas/2020-12/ietf/geojson/point.json new file mode 100644 index 00000000..f633e627 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/point.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON Point", + "description": "A geometry object representing a single position in coordinate space", + "examples": [ + { + "type": "Point", + "coordinates": [ -122.419, 37.7749 ] + }, + { + "type": "Point", + "coordinates": [ 0, 0, 10 ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.2" ], + "type": "object", + "required": [ "type", "coordinates" ], + "properties": { + "type": { + "const": "Point" + }, + "coordinates": { + "$ref": "point-coordinates.json" + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "geometry": false, + "properties": false, + "features": false + } +} diff --git a/schemas/2020-12/ietf/geojson/polygon-coordinates.json b/schemas/2020-12/ietf/geojson/polygon-coordinates.json new file mode 100644 index 00000000..bdd46944 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/polygon-coordinates.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON Polygon Coordinates", + "description": "An array of linear ring coordinate arrays, where the first is the exterior ring and any subsequent rings are interior holes", + "examples": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + [ + [ + [ 0, 0 ], + [ 10, 0 ], + [ 10, 10 ], + [ 0, 10 ], + [ 0, 0 ] + ], + [ + [ 2, 2 ], + [ 8, 2 ], + [ 8, 8 ], + [ 2, 8 ], + [ 2, 2 ] + ] + ] + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.6" ], + "type": "array", + "items": { + "$ref": "linear-ring-coordinates.json" + } +} diff --git a/schemas/2020-12/ietf/geojson/polygon.json b/schemas/2020-12/ietf/geojson/polygon.json new file mode 100644 index 00000000..ff6f8d95 --- /dev/null +++ b/schemas/2020-12/ietf/geojson/polygon.json @@ -0,0 +1,55 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON Polygon", + "description": "A geometry object representing an area enclosed by an exterior linear ring and zero or more interior rings (holes)", + "examples": [ + { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + }, + { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 10, 0 ], + [ 10, 10 ], + [ 0, 10 ], + [ 0, 0 ] + ], + [ + [ 2, 2 ], + [ 8, 2 ], + [ 8, 8 ], + [ 2, 8 ], + [ 2, 2 ] + ] + ] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3.1.6" ], + "type": "object", + "required": [ "type", "coordinates" ], + "properties": { + "type": { + "const": "Polygon" + }, + "coordinates": { + "$ref": "polygon-coordinates.json" + }, + "bbox": { + "$ref": "bounding-box.json" + }, + "geometry": false, + "properties": false, + "features": false + } +} diff --git a/schemas/2020-12/ietf/geojson/schema.json b/schemas/2020-12/ietf/geojson/schema.json new file mode 100644 index 00000000..5266c04f --- /dev/null +++ b/schemas/2020-12/ietf/geojson/schema.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "RFC 7946 GeoJSON", + "description": "A format for encoding a variety of geographic data structures", + "examples": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": { + "name": "Example" + } + }, + { + "type": "FeatureCollection", + "features": [] + } + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.rfc-editor.org/rfc/rfc7946#section-3" ], + "anyOf": [ + { + "$ref": "geometry.json" + }, + { + "$ref": "geometry-collection.json" + }, + { + "$ref": "feature.json" + }, + { + "$ref": "feature-collection.json" + } + ] +} diff --git a/test/ietf/geojson/bounding-box.test.json b/test/ietf/geojson/bounding-box.test.json new file mode 100644 index 00000000..61236e9a --- /dev/null +++ b/test/ietf/geojson/bounding-box.test.json @@ -0,0 +1,141 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/bounding-box.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an array", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Empty array - too few items", + "data": [], + "valid": false + }, + { + "description": "One item - too few items", + "data": [ 0 ], + "valid": false + }, + { + "description": "Two items - too few items", + "data": [ 0, 0 ], + "valid": false + }, + { + "description": "Three items - too few items", + "data": [ 0, 0, 1 ], + "valid": false + }, + { + "description": "Valid 2D bounding box", + "data": [ -180, -90, 180, 90 ], + "valid": true + }, + { + "description": "Valid 3D bounding box", + "data": [ -180, -90, 0, 180, 90, 1000 ], + "valid": true + }, + { + "description": "Valid bounding box with decimal numbers", + "data": [ -122.5, 37.5, -122.0, 38.0 ], + "valid": true + }, + { + "description": "Valid bounding box with negative values", + "data": [ -10.5, -20.5, -5.0, -10.0 ], + "valid": true + }, + { + "description": "Invalid - contains string", + "data": [ 0, 0, "1", 1 ], + "valid": false + }, + { + "description": "Invalid - contains null", + "data": [ 0, 0, null, 1 ], + "valid": false + }, + { + "description": "Invalid - contains boolean", + "data": [ 0, 0, true, 1 ], + "valid": false + }, + { + "description": "Invalid - contains object", + "data": [ + 0, + 0, + {}, + 1 + ], + "valid": false + }, + { + "description": "Invalid - contains array", + "data": [ + 0, + 0, + [], + 1 + ], + "valid": false + }, + { + "description": "Invalid 2D bbox - south latitude below -90", + "data": [ 0, -91, 1, 0 ], + "valid": false + }, + { + "description": "Invalid 2D bbox - south latitude above 90", + "data": [ 0, 91, 1, 0 ], + "valid": false + }, + { + "description": "Invalid 2D bbox - north latitude below -90", + "data": [ 0, 0, 1, -91 ], + "valid": false + }, + { + "description": "Invalid 2D bbox - north latitude above 90", + "data": [ 0, 0, 1, 91 ], + "valid": false + }, + { + "description": "Invalid 3D bbox - south latitude out of range", + "data": [ 0, -91, 0, 1, 0, 100 ], + "valid": false + }, + { + "description": "Invalid 3D bbox - north latitude out of range", + "data": [ 0, 0, 0, 1, 91, 100 ], + "valid": false + }, + { + "description": "Valid higher dimension bounding box (loose validation)", + "data": [ 0, 0, 0, 0, 1, 1, 1, 1 ], + "valid": true + } + ] +} diff --git a/test/ietf/geojson/feature-collection.test.json b/test/ietf/geojson/feature-collection.test.json new file mode 100644 index 00000000..9e7b1d20 --- /dev/null +++ b/test/ietf/geojson/feature-collection.test.json @@ -0,0 +1,305 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/feature-collection.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing features property", + "data": { + "type": "FeatureCollection" + }, + "valid": false + }, + { + "description": "Missing type property", + "data": { + "features": [] + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "Feature", + "features": [] + }, + "valid": false + }, + { + "description": "Valid empty FeatureCollection", + "data": { + "type": "FeatureCollection", + "features": [] + }, + "valid": true + }, + { + "description": "Valid FeatureCollection with one feature", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": null, + "properties": null + } + ] + }, + "valid": true + }, + { + "description": "Valid FeatureCollection with multiple features", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": { + "name": "Point A" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 1, 1 ] + }, + "properties": { + "name": "Point B" + } + } + ] + }, + "valid": true + }, + { + "description": "Valid FeatureCollection with bbox", + "data": { + "type": "FeatureCollection", + "features": [], + "bbox": [ -180, -90, 180, 90 ] + }, + "valid": true + }, + { + "description": "RFC 7946 Section 5 - 2D bbox", + "data": { + "type": "FeatureCollection", + "bbox": [ 100.0, 0.0, 105.0, 1.0 ], + "features": [] + }, + "valid": true + }, + { + "description": "RFC 7946 Section 5 - 3D bbox", + "data": { + "type": "FeatureCollection", + "bbox": [ 100.0, 0.0, -100.0, 105.0, 1.0, 0.0 ], + "features": [] + }, + "valid": true + }, + { + "description": "RFC 7946 Section 1.5 - FeatureCollection example", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 102.0, 0.5 ] + }, + "properties": { + "prop0": "value0" + } + }, + { + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [ 102.0, 0.0 ], + [ 103.0, 1.0 ], + [ 104.0, 0.0 ], + [ 105.0, 1.0 ] + ] + }, + "properties": { + "prop0": "value0", + "prop1": 0.0 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ 100.0, 0.0 ], + [ 101.0, 0.0 ], + [ 101.0, 1.0 ], + [ 100.0, 1.0 ], + [ 100.0, 0.0 ] + ] + ] + }, + "properties": { + "prop0": "value0", + "prop1": { + "this": "that" + } + } + } + ] + }, + "valid": true + }, + { + "description": "Valid FeatureCollection with various geometries", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": null + }, + { + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "properties": null + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + }, + "properties": null + } + ] + }, + "valid": true + }, + { + "description": "Invalid - features is not an array", + "data": { + "type": "FeatureCollection", + "features": {} + }, + "valid": false + }, + { + "description": "Invalid - feature missing required properties", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature" + } + ] + }, + "valid": false + }, + { + "description": "Invalid - feature has wrong type", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Point", + "geometry": null, + "properties": null + } + ] + }, + "valid": false + }, + { + "description": "Invalid - forbidden member coordinates", + "data": { + "type": "FeatureCollection", + "features": [], + "coordinates": [ 0, 0 ] + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometries", + "data": { + "type": "FeatureCollection", + "features": [], + "geometries": [] + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometry", + "data": { + "type": "FeatureCollection", + "features": [], + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member properties", + "data": { + "type": "FeatureCollection", + "features": [], + "properties": null + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/feature.test.json b/test/ietf/geojson/feature.test.json new file mode 100644 index 00000000..142ba50a --- /dev/null +++ b/test/ietf/geojson/feature.test.json @@ -0,0 +1,258 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/feature.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing geometry and properties", + "data": { + "type": "Feature" + }, + "valid": false + }, + { + "description": "Missing properties", + "data": { + "type": "Feature", + "geometry": null + }, + "valid": false + }, + { + "description": "Missing geometry", + "data": { + "type": "Feature", + "properties": null + }, + "valid": false + }, + { + "description": "Missing type", + "data": { + "geometry": null, + "properties": null + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "Point", + "geometry": null, + "properties": null + }, + "valid": false + }, + { + "description": "Valid Feature with null geometry", + "data": { + "type": "Feature", + "geometry": null, + "properties": null + }, + "valid": true + }, + { + "description": "Valid Feature with Point geometry", + "data": { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": null + }, + "valid": true + }, + { + "description": "Valid Feature with properties object", + "data": { + "type": "Feature", + "geometry": null, + "properties": { + "name": "Test", + "value": 123 + } + }, + "valid": true + }, + { + "description": "Valid Feature with numeric id", + "data": { + "type": "Feature", + "id": 123, + "geometry": null, + "properties": null + }, + "valid": true + }, + { + "description": "Valid Feature with string id", + "data": { + "type": "Feature", + "id": "feature-1", + "geometry": null, + "properties": null + }, + "valid": true + }, + { + "description": "RFC 7946 Section 5 - Feature with bbox", + "data": { + "type": "Feature", + "bbox": [ -10.0, -10.0, 10.0, 10.0 ], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ -10.0, -10.0 ], + [ 10.0, -10.0 ], + [ 10.0, 10.0 ], + [ -10.0, -10.0 ] + ] + ] + }, + "properties": null + }, + "valid": true + }, + { + "description": "RFC 7946 Section 6.1 - Feature with foreign members", + "data": { + "type": "Feature", + "id": "f1", + "geometry": null, + "properties": null, + "title": "Example Feature" + }, + "valid": true + }, + { + "description": "Valid Feature with bbox", + "data": { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": null, + "bbox": [ -1, -1, 1, 1 ] + }, + "valid": true + }, + { + "description": "Valid Feature with all geometry types", + "data": { + "type": "Feature", + "geometry": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + } + ] + }, + "properties": null + }, + "valid": true + }, + { + "description": "Invalid - properties is not null or object", + "data": { + "type": "Feature", + "geometry": null, + "properties": "invalid" + }, + "valid": false + }, + { + "description": "Invalid - properties is array", + "data": { + "type": "Feature", + "geometry": null, + "properties": [] + }, + "valid": false + }, + { + "description": "Invalid - id is boolean", + "data": { + "type": "Feature", + "id": true, + "geometry": null, + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - id is object", + "data": { + "type": "Feature", + "id": {}, + "geometry": null, + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member coordinates", + "data": { + "type": "Feature", + "geometry": null, + "properties": null, + "coordinates": [ 0, 0 ] + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometries", + "data": { + "type": "Feature", + "geometry": null, + "properties": null, + "geometries": [] + }, + "valid": false + }, + { + "description": "Invalid - forbidden member features", + "data": { + "type": "Feature", + "geometry": null, + "properties": null, + "features": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/geometry-collection.test.json b/test/ietf/geojson/geometry-collection.test.json new file mode 100644 index 00000000..2c0cd7f2 --- /dev/null +++ b/test/ietf/geojson/geometry-collection.test.json @@ -0,0 +1,240 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/geometry-collection.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing geometries property", + "data": { + "type": "GeometryCollection" + }, + "valid": false + }, + { + "description": "Missing type property", + "data": { + "geometries": [] + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "Point", + "geometries": [] + }, + "valid": false + }, + { + "description": "Valid empty GeometryCollection", + "data": { + "type": "GeometryCollection", + "geometries": [] + }, + "valid": true + }, + { + "description": "Valid GeometryCollection with Point", + "data": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + } + ] + }, + "valid": true + }, + { + "description": "Valid GeometryCollection with multiple geometries", + "data": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + } + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Appendix A.7 - GeometryCollection", + "data": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ 100.0, 0.0 ] + }, + { + "type": "LineString", + "coordinates": [ + [ 101.0, 0.0 ], + [ 102.0, 1.0 ] + ] + } + ] + }, + "valid": true + }, + { + "description": "Valid GeometryCollection with all geometry types", + "data": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + }, + { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ] + ] + }, + { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ] + }, + { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ] + } + ] + }, + "valid": true + }, + { + "description": "Valid GeometryCollection with bbox", + "data": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + } + ], + "bbox": [ -1, -1, 1, 1 ] + }, + "valid": true + }, + { + "description": "Invalid - geometry with invalid type", + "data": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Unknown", + "coordinates": [ 0, 0 ] + } + ] + }, + "valid": false + }, + { + "description": "Invalid - geometries is not an array", + "data": { + "type": "GeometryCollection", + "geometries": {} + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometry", + "data": { + "type": "GeometryCollection", + "geometries": [], + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member properties", + "data": { + "type": "GeometryCollection", + "geometries": [], + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member features", + "data": { + "type": "GeometryCollection", + "geometries": [], + "features": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/geometry.test.json b/test/ietf/geojson/geometry.test.json new file mode 100644 index 00000000..0f35681d --- /dev/null +++ b/test/ietf/geojson/geometry.test.json @@ -0,0 +1,136 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/geometry.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Valid Point geometry", + "data": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "valid": true + }, + { + "description": "Valid LineString geometry", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": true + }, + { + "description": "Valid Polygon geometry", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPoint geometry", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiLineString geometry", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPolygon geometry", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ] + }, + "valid": true + }, + { + "description": "Invalid - unknown geometry type", + "data": { + "type": "Unknown", + "coordinates": [ 0, 0 ] + }, + "valid": false + }, + { + "description": "Invalid - Feature is not a geometry", + "data": { + "type": "Feature", + "properties": null, + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - GeometryCollection is not included", + "data": { + "type": "GeometryCollection", + "geometries": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/line-string-coordinates.test.json b/test/ietf/geojson/line-string-coordinates.test.json new file mode 100644 index 00000000..631e6884 --- /dev/null +++ b/test/ietf/geojson/line-string-coordinates.test.json @@ -0,0 +1,101 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/line-string-coordinates.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an array", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Empty array - too few positions", + "data": [], + "valid": false + }, + { + "description": "One position - too few positions", + "data": [ + [ 0, 0 ] + ], + "valid": false + }, + { + "description": "Valid LineString with two positions", + "data": [ + [ 0, 0 ], + [ 1, 1 ] + ], + "valid": true + }, + { + "description": "Valid LineString with three positions", + "data": [ + [ 0, 0 ], + [ 1, 1 ], + [ 2, 0 ] + ], + "valid": true + }, + { + "description": "Valid LineString with 3D positions", + "data": [ + [ 0, 0, 0 ], + [ 1, 1, 10 ], + [ 2, 0, 20 ] + ], + "valid": true + }, + { + "description": "Invalid - position has only one coordinate", + "data": [ + [ 0 ], + [ 1, 1 ] + ], + "valid": false + }, + { + "description": "Invalid - position contains string", + "data": [ + [ "0", 0 ], + [ 1, 1 ] + ], + "valid": false + }, + { + "description": "Invalid - position is not an array", + "data": [ + 0, + [ 1, 1 ] + ], + "valid": false + }, + { + "description": "Invalid - position is null", + "data": [ + null, + [ 1, 1 ] + ], + "valid": false + } + ] +} diff --git a/test/ietf/geojson/line-string.test.json b/test/ietf/geojson/line-string.test.json new file mode 100644 index 00000000..525e1670 --- /dev/null +++ b/test/ietf/geojson/line-string.test.json @@ -0,0 +1,186 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/line-string.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing coordinates property", + "data": { + "type": "LineString" + }, + "valid": false + }, + { + "description": "Missing type property", + "data": { + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "Point", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": false + }, + { + "description": "Valid LineString with two positions", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Appendix A.2 - LineString", + "data": { + "type": "LineString", + "coordinates": [ + [ 100.0, 0.0 ], + [ 101.0, 1.0 ] + ] + }, + "valid": true + }, + { + "description": "Valid LineString with three positions", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ], + [ 2, 0 ] + ] + }, + "valid": true + }, + { + "description": "Valid LineString with 3D coordinates", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0, 0 ], + [ 1, 1, 10 ] + ] + }, + "valid": true + }, + { + "description": "Valid LineString with bbox", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ], + "bbox": [ 0, 0, 1, 1 ] + }, + "valid": true + }, + { + "description": "Invalid - only one position", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ] + ] + }, + "valid": false + }, + { + "description": "Invalid - position has only one coordinate", + "data": { + "type": "LineString", + "coordinates": [ + [ 0 ], + [ 1, 1 ] + ] + }, + "valid": false + }, + { + "description": "Invalid - coordinates is not an array", + "data": { + "type": "LineString", + "coordinates": {} + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometry", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ], + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member properties", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ], + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member features", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ], + "features": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/linear-ring-coordinates.test.json b/test/ietf/geojson/linear-ring-coordinates.test.json new file mode 100644 index 00000000..7a9ad547 --- /dev/null +++ b/test/ietf/geojson/linear-ring-coordinates.test.json @@ -0,0 +1,121 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/linear-ring-coordinates.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an array", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Empty array - too few positions", + "data": [], + "valid": false + }, + { + "description": "One position - too few positions", + "data": [ + [ 0, 0 ] + ], + "valid": false + }, + { + "description": "Two positions - too few positions", + "data": [ + [ 0, 0 ], + [ 1, 1 ] + ], + "valid": false + }, + { + "description": "Three positions - too few positions", + "data": [ + [ 0, 0 ], + [ 1, 1 ], + [ 0, 1 ] + ], + "valid": false + }, + { + "description": "Valid linear ring with four positions (closed triangle)", + "data": [ + [ 0, 0 ], + [ 1, 0 ], + [ 0, 1 ], + [ 0, 0 ] + ], + "valid": true + }, + { + "description": "Valid linear ring with five positions (closed rectangle)", + "data": [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 1 ], + [ 0, 0 ] + ], + "valid": true + }, + { + "description": "Valid linear ring with 3D positions", + "data": [ + [ 0, 0, 0 ], + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] + ], + "valid": true + }, + { + "description": "Invalid - position has only one coordinate", + "data": [ + [ 0 ], + [ 1, 0 ], + [ 0, 1 ], + [ 0, 0 ] + ], + "valid": false + }, + { + "description": "Invalid - position contains string", + "data": [ + [ "0", 0 ], + [ 1, 0 ], + [ 0, 1 ], + [ 0, 0 ] + ], + "valid": false + }, + { + "description": "Invalid - position is not an array", + "data": [ + 0, + [ 1, 0 ], + [ 0, 1 ], + [ 0, 0 ] + ], + "valid": false + } + ] +} diff --git a/test/ietf/geojson/multi-line-string.test.json b/test/ietf/geojson/multi-line-string.test.json new file mode 100644 index 00000000..38aed59e --- /dev/null +++ b/test/ietf/geojson/multi-line-string.test.json @@ -0,0 +1,229 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/multi-line-string.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing coordinates property", + "data": { + "type": "MultiLineString" + }, + "valid": false + }, + { + "description": "Missing type property", + "data": { + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ] + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "LineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ] + }, + "valid": false + }, + { + "description": "Valid MultiLineString with empty coordinates", + "data": { + "type": "MultiLineString", + "coordinates": [] + }, + "valid": true + }, + { + "description": "Valid MultiLineString with one line", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiLineString with multiple lines", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ], + [ + [ 2, 2 ], + [ 3, 3 ] + ] + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Appendix A.5 - MultiLineString", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 100.0, 0.0 ], + [ 101.0, 1.0 ] + ], + [ + [ 102.0, 2.0 ], + [ 103.0, 3.0 ] + ] + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Section 3.1.9 - Antimeridian cutting", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 170.0, 45.0 ], + [ 180.0, 45.0 ] + ], + [ + [ -180.0, 45.0 ], + [ -170.0, 45.0 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiLineString with 3D coordinates", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0, 0 ], + [ 1, 1, 10 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiLineString with bbox", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ], + "bbox": [ 0, 0, 1, 1 ] + }, + "valid": true + }, + { + "description": "Invalid - LineString with only one position", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ] + ] + ] + }, + "valid": false + }, + { + "description": "Invalid - coordinates is not an array", + "data": { + "type": "MultiLineString", + "coordinates": {} + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometry", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ], + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member properties", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ], + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member features", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ], + "features": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/multi-point.test.json b/test/ietf/geojson/multi-point.test.json new file mode 100644 index 00000000..8dde0911 --- /dev/null +++ b/test/ietf/geojson/multi-point.test.json @@ -0,0 +1,180 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/multi-point.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing coordinates property", + "data": { + "type": "MultiPoint" + }, + "valid": false + }, + { + "description": "Missing type property", + "data": { + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "Point", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": false + }, + { + "description": "Valid MultiPoint with empty coordinates", + "data": { + "type": "MultiPoint", + "coordinates": [] + }, + "valid": true + }, + { + "description": "Valid MultiPoint with one point", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPoint with multiple points", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ], + [ 2, 2 ] + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Appendix A.4 - MultiPoint", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 100.0, 0.0 ], + [ 101.0, 1.0 ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPoint with 3D coordinates", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0, 0 ], + [ 1, 1, 10 ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPoint with bbox", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ], + "bbox": [ 0, 0, 1, 1 ] + }, + "valid": true + }, + { + "description": "Invalid - position has only one coordinate", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0 ], + [ 1, 1 ] + ] + }, + "valid": false + }, + { + "description": "Invalid - coordinates is not an array", + "data": { + "type": "MultiPoint", + "coordinates": {} + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometry", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ] + ], + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member properties", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ] + ], + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member features", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ] + ], + "features": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/multi-polygon.test.json b/test/ietf/geojson/multi-polygon.test.json new file mode 100644 index 00000000..3162aee2 --- /dev/null +++ b/test/ietf/geojson/multi-polygon.test.json @@ -0,0 +1,300 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/multi-polygon.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing coordinates property", + "data": { + "type": "MultiPolygon" + }, + "valid": false + }, + { + "description": "Missing type property", + "data": { + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ] + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ] + }, + "valid": false + }, + { + "description": "Valid MultiPolygon with empty coordinates", + "data": { + "type": "MultiPolygon", + "coordinates": [] + }, + "valid": true + }, + { + "description": "Valid MultiPolygon with one polygon", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPolygon with multiple polygons", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + [ + [ + [ 2, 2 ], + [ 3, 2 ], + [ 3, 3 ], + [ 2, 2 ] + ] + ] + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Appendix A.6 - MultiPolygon", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 102.0, 2.0 ], + [ 103.0, 2.0 ], + [ 103.0, 3.0 ], + [ 102.0, 3.0 ], + [ 102.0, 2.0 ] + ] + ], + [ + [ + [ 100.0, 0.0 ], + [ 101.0, 0.0 ], + [ 101.0, 1.0 ], + [ 100.0, 1.0 ], + [ 100.0, 0.0 ] + ], + [ + [ 100.2, 0.2 ], + [ 100.2, 0.8 ], + [ 100.8, 0.8 ], + [ 100.8, 0.2 ], + [ 100.2, 0.2 ] + ] + ] + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Section 3.1.9 - Antimeridian crossing", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 180.0, 40.0 ], + [ 180.0, 50.0 ], + [ 170.0, 50.0 ], + [ 170.0, 40.0 ], + [ 180.0, 40.0 ] + ] + ], + [ + [ + [ -170.0, 40.0 ], + [ -170.0, 50.0 ], + [ -180.0, 50.0 ], + [ -180.0, 40.0 ], + [ -170.0, 40.0 ] + ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPolygon with 3D coordinates", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0, 0 ], + [ 1, 0, 0 ], + [ 1, 1, 0 ], + [ 0, 0, 0 ] + ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPolygon with bbox", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ], + "bbox": [ 0, 0, 1, 1 ] + }, + "valid": true + }, + { + "description": "Invalid - linear ring with too few positions", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 0, 0 ] + ] + ] + ] + }, + "valid": false + }, + { + "description": "Invalid - coordinates is not an array", + "data": { + "type": "MultiPolygon", + "coordinates": {} + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometry", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ], + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member properties", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ], + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member features", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ], + "features": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/point-coordinates.test.json b/test/ietf/geojson/point-coordinates.test.json new file mode 100644 index 00000000..ae0d6665 --- /dev/null +++ b/test/ietf/geojson/point-coordinates.test.json @@ -0,0 +1,127 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/point-coordinates.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an array", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Empty array - too few items", + "data": [], + "valid": false + }, + { + "description": "One item - too few items", + "data": [ 0 ], + "valid": false + }, + { + "description": "Valid 2D position (longitude, latitude)", + "data": [ -122.419, 37.7749 ], + "valid": true + }, + { + "description": "Valid 3D position with altitude", + "data": [ -122.419, 37.7749, 10.5 ], + "valid": true + }, + { + "description": "Valid position with integer coordinates", + "data": [ 0, 0 ], + "valid": true + }, + { + "description": "Valid position with negative coordinates", + "data": [ -180, -90 ], + "valid": true + }, + { + "description": "Valid position at antimeridian", + "data": [ 180, 0 ], + "valid": true + }, + { + "description": "Invalid - contains string", + "data": [ "0", 0 ], + "valid": false + }, + { + "description": "Invalid - contains null", + "data": [ null, 0 ], + "valid": false + }, + { + "description": "Invalid - contains boolean", + "data": [ true, 0 ], + "valid": false + }, + { + "description": "Invalid - contains object", + "data": [ + {}, + 0 + ], + "valid": false + }, + { + "description": "Invalid - contains array", + "data": [ + [], + 0 + ], + "valid": false + }, + { + "description": "Valid position at south pole", + "data": [ 0, -90 ], + "valid": true + }, + { + "description": "Valid position at north pole", + "data": [ 0, 90 ], + "valid": true + }, + { + "description": "Invalid - latitude below -90", + "data": [ 0, -90.1 ], + "valid": false + }, + { + "description": "Invalid - latitude above 90", + "data": [ 0, 90.1 ], + "valid": false + }, + { + "description": "Invalid - latitude way out of range (positive)", + "data": [ 0, 100 ], + "valid": false + }, + { + "description": "Invalid - latitude way out of range (negative)", + "data": [ 0, -100 ], + "valid": false + } + ] +} diff --git a/test/ietf/geojson/point.test.json b/test/ietf/geojson/point.test.json new file mode 100644 index 00000000..ecacfda5 --- /dev/null +++ b/test/ietf/geojson/point.test.json @@ -0,0 +1,159 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/point.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing coordinates property", + "data": { + "type": "Point" + }, + "valid": false + }, + { + "description": "Missing type property", + "data": { + "coordinates": [ 0, 0 ] + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "LineString", + "coordinates": [ 0, 0 ] + }, + "valid": false + }, + { + "description": "Valid Point with 2D coordinates", + "data": { + "type": "Point", + "coordinates": [ -122.419, 37.7749 ] + }, + "valid": true + }, + { + "description": "RFC 7946 Appendix A.1 - Point", + "data": { + "type": "Point", + "coordinates": [ 100.0, 0.0 ] + }, + "valid": true + }, + { + "description": "Valid Point with 3D coordinates", + "data": { + "type": "Point", + "coordinates": [ -122.419, 37.7749, 10 ] + }, + "valid": true + }, + { + "description": "Valid Point with bbox", + "data": { + "type": "Point", + "coordinates": [ 0, 0 ], + "bbox": [ -1, -1, 1, 1 ] + }, + "valid": true + }, + { + "description": "Invalid - coordinates has only one value", + "data": { + "type": "Point", + "coordinates": [ 0 ] + }, + "valid": false + }, + { + "description": "Invalid - coordinates contains string", + "data": { + "type": "Point", + "coordinates": [ "0", 0 ] + }, + "valid": false + }, + { + "description": "Invalid - coordinates is not an array", + "data": { + "type": "Point", + "coordinates": {} + }, + "valid": false + }, + { + "description": "Invalid - type is not a string", + "data": { + "type": 123, + "coordinates": [ 0, 0 ] + }, + "valid": false + }, + { + "description": "Invalid - bbox has too few items", + "data": { + "type": "Point", + "coordinates": [ 0, 0 ], + "bbox": [ 0, 0, 1 ] + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometry", + "data": { + "type": "Point", + "coordinates": [ 0, 0 ], + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member properties", + "data": { + "type": "Point", + "coordinates": [ 0, 0 ], + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member features", + "data": { + "type": "Point", + "coordinates": [ 0, 0 ], + "features": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/polygon-coordinates.test.json b/test/ietf/geojson/polygon-coordinates.test.json new file mode 100644 index 00000000..4fe47545 --- /dev/null +++ b/test/ietf/geojson/polygon-coordinates.test.json @@ -0,0 +1,120 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/polygon-coordinates.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an array", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Empty array - valid (no rings)", + "data": [], + "valid": true + }, + { + "description": "Valid polygon with exterior ring only", + "data": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + "valid": true + }, + { + "description": "Valid polygon with exterior and interior ring (hole)", + "data": [ + [ + [ 0, 0 ], + [ 10, 0 ], + [ 10, 10 ], + [ 0, 10 ], + [ 0, 0 ] + ], + [ + [ 2, 2 ], + [ 8, 2 ], + [ 8, 8 ], + [ 2, 8 ], + [ 2, 2 ] + ] + ], + "valid": true + }, + { + "description": "Valid polygon with 3D coordinates", + "data": [ + [ + [ 0, 0, 0 ], + [ 1, 0, 0 ], + [ 1, 1, 0 ], + [ 0, 0, 0 ] + ] + ], + "valid": true + }, + { + "description": "Invalid - linear ring with too few positions", + "data": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 0, 0 ] + ] + ], + "valid": false + }, + { + "description": "Invalid - linear ring position has only one coordinate", + "data": [ + [ + [ 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + "valid": false + }, + { + "description": "Invalid - linear ring position contains string", + "data": [ + [ + [ "0", 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + "valid": false + }, + { + "description": "Invalid - linear ring is not an array", + "data": [ "not an array" ], + "valid": false + } + ] +} diff --git a/test/ietf/geojson/polygon.test.json b/test/ietf/geojson/polygon.test.json new file mode 100644 index 00000000..e63693a8 --- /dev/null +++ b/test/ietf/geojson/polygon.test.json @@ -0,0 +1,258 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/polygon.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Missing coordinates property", + "data": { + "type": "Polygon" + }, + "valid": false + }, + { + "description": "Missing type property", + "data": { + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + }, + "valid": false + }, + { + "description": "Wrong type value", + "data": { + "type": "Point", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + }, + "valid": false + }, + { + "description": "Valid Polygon with exterior ring", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Appendix A.3 - Polygon without holes", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 100.0, 0.0 ], + [ 101.0, 0.0 ], + [ 101.0, 1.0 ], + [ 100.0, 1.0 ], + [ 100.0, 0.0 ] + ] + ] + }, + "valid": true + }, + { + "description": "RFC 7946 Appendix A.3 - Polygon with holes", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 100.0, 0.0 ], + [ 101.0, 0.0 ], + [ 101.0, 1.0 ], + [ 100.0, 1.0 ], + [ 100.0, 0.0 ] + ], + [ + [ 100.8, 0.8 ], + [ 100.8, 0.2 ], + [ 100.2, 0.2 ], + [ 100.2, 0.8 ], + [ 100.8, 0.8 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid Polygon with exterior and interior ring", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 10, 0 ], + [ 10, 10 ], + [ 0, 10 ], + [ 0, 0 ] + ], + [ + [ 2, 2 ], + [ 8, 2 ], + [ 8, 8 ], + [ 2, 8 ], + [ 2, 2 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid Polygon with 3D coordinates", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0, 0 ], + [ 1, 0, 0 ], + [ 1, 1, 0 ], + [ 0, 0, 0 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid Polygon with bbox", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + "bbox": [ 0, 0, 1, 1 ] + }, + "valid": true + }, + { + "description": "Valid Polygon with empty coordinates", + "data": { + "type": "Polygon", + "coordinates": [] + }, + "valid": true + }, + { + "description": "Invalid - linear ring with too few positions", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 0, 0 ] + ] + ] + }, + "valid": false + }, + { + "description": "Invalid - coordinates is not an array", + "data": { + "type": "Polygon", + "coordinates": {} + }, + "valid": false + }, + { + "description": "Invalid - forbidden member geometry", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + "geometry": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member properties", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + "properties": null + }, + "valid": false + }, + { + "description": "Invalid - forbidden member features", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ], + "features": [] + }, + "valid": false + } + ] +} diff --git a/test/ietf/geojson/schema.test.json b/test/ietf/geojson/schema.test.json new file mode 100644 index 00000000..51a2011d --- /dev/null +++ b/test/ietf/geojson/schema.test.json @@ -0,0 +1,184 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../schemas/2020-12/ietf/geojson/schema.json", + "tests": [ + { + "description": "Invalid type - string", + "data": "not an object", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Empty object - missing required properties", + "data": {}, + "valid": false + }, + { + "description": "Valid Point", + "data": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "valid": true + }, + { + "description": "Valid LineString", + "data": { + "type": "LineString", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": true + }, + { + "description": "Valid Polygon", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPoint", + "data": { + "type": "MultiPoint", + "coordinates": [ + [ 0, 0 ], + [ 1, 1 ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiLineString", + "data": { + "type": "MultiLineString", + "coordinates": [ + [ + [ 0, 0 ], + [ 1, 1 ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid MultiPolygon", + "data": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ 0, 0 ], + [ 1, 0 ], + [ 1, 1 ], + [ 0, 0 ] + ] + ] + ] + }, + "valid": true + }, + { + "description": "Valid GeometryCollection", + "data": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ 0, 0 ] + } + ] + }, + "valid": true + }, + { + "description": "Valid Feature with null geometry", + "data": { + "type": "Feature", + "geometry": null, + "properties": null + }, + "valid": true + }, + { + "description": "Valid Feature with Point geometry", + "data": { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + }, + "properties": { + "name": "Test" + } + }, + "valid": true + }, + { + "description": "Valid FeatureCollection", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": null, + "properties": null + } + ] + }, + "valid": true + }, + { + "description": "Valid empty FeatureCollection", + "data": { + "type": "FeatureCollection", + "features": [] + }, + "valid": true + }, + { + "description": "Invalid - unknown type", + "data": { + "type": "Unknown", + "coordinates": [ 0, 0 ] + }, + "valid": false + }, + { + "description": "Invalid - missing type property", + "data": { + "coordinates": [ 0, 0 ] + }, + "valid": false + } + ] +}