From e4918e3e94af27d1499252b0121ee1c81248fe35 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Wed, 31 Jul 2024 13:31:00 +0200 Subject: [PATCH 1/3] v2.0.0-beta.1 --- CHANGELOG.md | 5 ++++- README.md | 2 +- examples/item-planet.json | 2 +- examples/item-sentinel2.json | 2 +- json-schema/schema.json | 4 ++-- package.json | 6 +++--- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7adacc..78dbbb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v2.0.0-beta.1] + ### Added - Add link `rel="gcps"` to Ground Control Points document @@ -24,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release -[Unreleased]: +[Unreleased]: +[v2.0.0-beta.1]: [v1.1.0]: [v1.0.0]: diff --git a/README.md b/README.md index 7b157ff..b4f09ea 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Raster Extension Specification - **Title:** Raster -- **Identifier:** +- **Identifier:** - **Field Name Prefix:** raster - **Scope:** Item, Collection - **Extension [Maturity Classification](https://github.com/radiantearth/stac-spec/tree/master/extensions/README.md#extension-maturity):** Candidate diff --git a/examples/item-planet.json b/examples/item-planet.json index 6972f01..73b5cc4 100644 --- a/examples/item-planet.json +++ b/examples/item-planet.json @@ -5,7 +5,7 @@ "https://stac-extensions.github.io/projection/v1.0.0/schema.json", "https://stac-extensions.github.io/eo/v1.0.0/schema.json", "https://stac-extensions.github.io/processing/v1.0.0/schema.json", - "https://stac-extensions.github.io/raster/v1.1.0/schema.json" + "https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json" ], "stac_version": "1.0.0", "links": [], diff --git a/examples/item-sentinel2.json b/examples/item-sentinel2.json index 46fc408..96b0c3d 100644 --- a/examples/item-sentinel2.json +++ b/examples/item-sentinel2.json @@ -5,7 +5,7 @@ "https://stac-extensions.github.io/eo/v1.0.0/schema.json", "https://stac-extensions.github.io/view/v1.0.0/schema.json", "https://stac-extensions.github.io/projection/v1.0.0/schema.json", - "https://stac-extensions.github.io/raster/v1.1.0/schema.json" + "https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json" ], "id": "S2B_33SVB_20210221_0_L2A", "bbox": [ diff --git a/json-schema/schema.json b/json-schema/schema.json index 2a3e53e..4a90222 100644 --- a/json-schema/schema.json +++ b/json-schema/schema.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://stac-extensions.github.io/raster/v1.1.0/schema.json#", + "$id": "https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json#", "title": "raster Extension", "description": "STAC Raster Extension for STAC Items.", "oneOf": [ @@ -69,7 +69,7 @@ "stac_extensions": { "type": "array", "contains": { - "const": "https://stac-extensions.github.io/raster/v1.1.0/schema.json" + "const": "https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json" } } } diff --git a/package.json b/package.json index 397f7c8..ff783a1 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "stac-extensions", - "version": "1.1.0", + "version": "2.0.0-beta.1", "scripts": { "test": "npm run check-markdown && npm run check-examples", "check-markdown": "remark . -f -r .github/remark.yaml", - "check-examples": "stac-node-validator . --lint --verbose --schemaMap https://stac-extensions.github.io/raster/v1.1.0/schema.json=./json-schema/schema.json", - "format-examples": "stac-node-validator . --format --schemaMap https://stac-extensions.github.io/raster/v1.1.0/schema.json=./json-schema/schema.json" + "check-examples": "stac-node-validator . --lint --verbose --schemaMap https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json=./json-schema/schema.json", + "format-examples": "stac-node-validator . --format --schemaMap https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json=./json-schema/schema.json" }, "dependencies": { "remark-cli": "^8.0.0", From 8455a55f442a5233e52b6f032d5d7287915c3ef7 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Thu, 1 Aug 2024 14:02:56 +0200 Subject: [PATCH 2/3] Update extensions and fix schema --- examples/item-planet.json | 6 +++--- examples/item-sentinel2.json | 4 ++-- json-schema/schema.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/item-planet.json b/examples/item-planet.json index 06926b6..8dce1f1 100644 --- a/examples/item-planet.json +++ b/examples/item-planet.json @@ -2,9 +2,9 @@ "stac_extensions": [ "https://stac-extensions.github.io/sat/v1.0.0/schema.json", "https://stac-extensions.github.io/view/v1.0.0/schema.json", - "https://stac-extensions.github.io/projection/v1.1.0/schema.json", + "https://stac-extensions.github.io/projection/v2.0.0/schema.json", "https://stac-extensions.github.io/eo/v2.0.0-beta.1/schema.json", - "https://stac-extensions.github.io/processing/v1.0.0/schema.json", + "https://stac-extensions.github.io/processing/v1.2.0/schema.json", "https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json" ], "stac_version": "1.0.0", @@ -1210,7 +1210,7 @@ "view:sun_azimuth": 94.82318, "view:incidence_angle": 0.1531593, "view:off_nadir": 0.1102388, - "proj:epsg": 32750, + "proj:code": "EPSG:32750", "processing:level": "L3B", "title": "Planetscope PS2 L3B 01/10/2018 01:54:33", "disaster:call_id": 857 diff --git a/examples/item-sentinel2.json b/examples/item-sentinel2.json index 5c01971..d4def00 100644 --- a/examples/item-sentinel2.json +++ b/examples/item-sentinel2.json @@ -4,7 +4,7 @@ "stac_extensions": [ "https://stac-extensions.github.io/eo/v2.0.0-beta.1/schema.json", "https://stac-extensions.github.io/view/v1.0.0/schema.json", - "https://stac-extensions.github.io/projection/v1.1.0/schema.json", + "https://stac-extensions.github.io/projection/v2.0.0/schema.json", "https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json" ], "id": "S2B_33SVB_20210221_0_L2A", @@ -50,7 +50,7 @@ ], "gsd": 10, "view:off_nadir": 0, - "proj:epsg": 32633, + "proj:code": "EPSG:32633", "sentinel:utm_zone": 33, "sentinel:latitude_band": "S", "sentinel:grid_square": "VB", diff --git a/json-schema/schema.json b/json-schema/schema.json index 171a923..9d8e993 100644 --- a/json-schema/schema.json +++ b/json-schema/schema.json @@ -11,7 +11,7 @@ "stac_extensions": { "type": "array", "contains": { - "const": "https://stac-extensions.github.io/raster/v1.1.0/schema.json" + "const": "https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json" } } }, From 51b7572835ef2a4b4d1b77ecf9800f400827ff43 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Thu, 1 Aug 2024 14:18:03 +0200 Subject: [PATCH 3/3] Add improved version of the JSON Schema --- CHANGELOG.md | 4 + json-schema/schema.json | 416 +++++++++++++++++++++++++--------------- 2 files changed, 267 insertions(+), 153 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43e917d..610250b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `raster:bands` - use `bands` in instead +### Fixed + +- Improved and stricter JSON Schema + ## [v1.1.0] ### Added diff --git a/json-schema/schema.json b/json-schema/schema.json index 9d8e993..4abacac 100644 --- a/json-schema/schema.json +++ b/json-schema/schema.json @@ -1,12 +1,10 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://stac-extensions.github.io/raster/v2.0.0-beta.1/schema.json#", - "title": "raster Extension", - "description": "STAC Raster Extension for STAC Items.", + "title": "Raster Extension", + "description": "STAC Raster Extension for STAC Items and STAC Collections.", "type": "object", - "required": [ - "stac_extensions" - ], + "required": ["stac_extensions", "type"], "properties": { "stac_extensions": { "type": "array", @@ -15,218 +13,330 @@ } } }, - "oneOf": [ + "allOf": [ { - "$comment": "This is the schema for STAC Items.", - "type": "object", - "required": [ - "type", - "properties", - "assets" - ], - "properties": { - "type": { - "const": "Feature" - }, + "$comment": "Items", + "if": { "properties": { - "$ref": "#/definitions/fields" - }, - "assets": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/fields" + "type": { + "const": "Feature" } } }, - "anyOf": [ - { - "properties": { + "then": { + "allOf": [ + { "properties": { - "$ref": "#/definitions/require_any_or_bands" + "properties": { + "$ref": "#/definitions/validate_properties" + } } + }, + { + "$ref": "#/definitions/validate_assets" } - }, - { - "$ref": "#/definitions/require_in_assets" - } - ] + ], + "anyOf": [ + { + "required": ["properties"], + "properties": { + "properties": { + "$ref": "#/definitions/require_properties" + } + } + }, + { + "$ref": "#/definitions/require_assets" + } + ] + } }, { - "$comment": "This is the schema for STAC Collections.", - "type": "object", - "required": [ - "type" - ], - "properties": { - "type": { - "const": "Collection" - }, - "assets": { - "$ref": "#/definitions/fields" - }, - "item_assets": { - "$ref": "#/definitions/fields" + "$comment": "Collections", + "if": { + "properties": { + "type": { + "const": "Collection" + } } }, - "anyOf": [ - { - "$ref": "#/definitions/require_in_item_assets" - }, - { - "$ref": "#/definitions/require_in_assets" - }, - { - "properties": { - "summaries": { - "$ref": "#/definitions/require_any_or_bands" + "then": { + "allOf": [ + { + "$ref": "#/definitions/validate_assets" + }, + { + "properties": { + "item_assets": { + "additionalProperties": { + "$ref": "#/definitions/validate_properties" + } + } + } + }, + { + "properties": { + "summaries": { + "type": "object", + "$comment": "We can't properly validate summary objects types (min/max or schemas) yet.", + "allOf": [ + { + "$ref": "#/definitions/validate_bands" + }, + { + "properties": { + "raster:bits_per_sample": { + "type": ["array", "object"], + "items": { + "$ref": "#/definitions/raster:bits_per_sample" + } + } + } + }, + { + "properties": { + "raster:sampling": { + "type": ["array", "object"], + "items": { + "$ref": "#/definitions/raster:sampling" + } + } + } + }, + { + "properties": { + "raster:scale": { + "type": ["array", "object"], + "items": { + "$ref": "#/definitions/raster:scale" + } + } + } + }, + { + "properties": { + "raster:offset": { + "type": ["array", "object"], + "items": { + "$ref": "#/definitions/raster:offset" + } + } + } + }, + { + "properties": { + "raster:spatial_resolution": { + "type": ["array", "object"], + "items": { + "$ref": "#/definitions/raster:spatial_resolution" + } + } + } + }, + { + "properties": { + "raster:histogram": { + "type": ["array", "object"], + "items": { + "$ref": "#/definitions/raster:histogram" + } + } + } + } + ] + } } } - } - ] + ], + "anyOf": [ + { + "$ref": "#/definitions/require_assets" + }, + { + "required": ["item_assets"], + "properties": { + "item_assets": { + "$ref": "#/definitions/asset_contains" + } + } + }, + { + "required": ["summaries"], + "properties": { + "summaries": { + "$ref": "#/definitions/require_properties" + } + } + } + ] + } } ], "definitions": { - "require_any_or_bands": { + "require_properties": { "anyOf": [ { - "$ref": "#/definitions/require_any" + "$ref": "#/definitions/require_fields" }, { "$ref": "#/definitions/require_in_bands" } ] }, - "require_any": { - "anyOf": [ - {"required": ["raster:bits_per_sample"]}, - {"required": ["raster:sampling"]}, - {"required": ["raster:scale"]}, - {"required": ["raster:offset"]}, - {"required": ["raster:spatial_resolution"]}, - {"required": ["raster:histogram"]} - ] - }, - "require_in_bands": { - "required": [ - "bands" - ], + "validate_bands": { + "type": "object", "properties": { "bands": { "type": "array", - "contains": { - "$ref": "#/definitions/require_any" + "items": { + "$ref": "#/definitions/fields" } } } }, - "require_in_assets": { - "required": [ - "assets" - ], + "validate_properties": { + "allOf": [ + { + "$ref": "#/definitions/fields" + }, + { + "$ref": "#/definitions/validate_bands" + } + ] + }, + "require_assets": { + "required": ["assets"], "properties": { "assets": { - "not": { - "additionalProperties": { - "not": { - "$ref": "#/definitions/require_any_or_bands" - } - } - } + "$ref": "#/definitions/asset_contains" } } }, - "require_in_item_assets": { - "required": [ - "item_assets" - ], + "validate_assets": { "properties": { - "item_assets": { - "not": { - "additionalProperties": { - "not": { - "$ref": "#/definitions/require_any_or_bands" - } - } + "assets": { + "additionalProperties": { + "$ref": "#/definitions/validate_properties" } } } }, - "fields": { + "asset_contains": { "type": "object", + "not": { + "additionalProperties": { + "not": { + "$ref": "#/definitions/require_properties" + } + } + } + }, + "require_in_bands": { + "required": ["bands"], "properties": { "bands": { "type": "array", - "items": { - "$ref": "#/definitions/fields" + "contains": { + "$ref": "#/definitions/require_fields" } - }, + } + } + }, + "require_fields": { + "anyOf": [ + {"required": ["raster:bits_per_sample"]}, + {"required": ["raster:sampling"]}, + {"required": ["raster:scale"]}, + {"required": ["raster:offset"]}, + {"required": ["raster:spatial_resolution"]}, + {"required": ["raster:histogram"]} + ] + }, + "fields": { + "type": "object", + "properties": { "raster:bits_per_sample": { - "title": "The actual number of bits used for this band", - "type": "integer" + "$ref": "#/definitions/raster:bits_per_sample" }, "raster:sampling": { - "title": "Pixel sampling in the band", - "type": "string", - "enum": [ - "area", - "point" - ] + "$ref": "#/definitions/raster:sampling" }, "raster:scale": { - "title": "multiplicator factor of the pixel value to transform into the value", - "type": "number" + "$ref": "#/definitions/raster:scale" }, "raster:offset": { - "title": "number to be added to the pixel value to transform into the value", - "type": "number" + "$ref": "#/definitions/raster:offset" }, "raster:spatial_resolution": { - "title": "Average spatial resolution (in meters) of the pixels in the band", - "type": "number" + "$ref": "#/definitions/raster:spatial_resolution" }, "raster:histogram": { - "title": "Histogram", - "type": "object", - "additionalItems": false, - "required": [ - "count", - "min", - "max", - "buckets" - ], - "additionalProperties": false, - "properties": { - "count": { - "title": "number of buckets", - "type": "number" - }, - "min": { - "title": "Minimum value of the buckets", - "type": "number" - }, - "max": { - "title": "Maximum value of the buckets", - "type": "number" - }, - "buckets": { - "title": "distribution buckets", - "type": "array", - "minItems": 3, - "items": { - "title": "number of pixels in the bucket", - "type": "integer" - } - } - } + "$ref": "#/definitions/raster:histogram" } }, "patternProperties": { "^(?!raster:)": {} }, "additionalProperties": false + }, + "raster:bits_per_sample": { + "title": "The actual number of bits used for this band", + "type": "integer" + }, + "raster:sampling": { + "title": "Pixel sampling in the band", + "type": "string", + "enum": [ + "area", + "point" + ] + }, + "raster:scale": { + "title": "multiplicator factor of the pixel value to transform into the value", + "type": "number" + }, + "raster:offset": { + "title": "number to be added to the pixel value to transform into the value", + "type": "number" + }, + "raster:spatial_resolution": { + "title": "Average spatial resolution (in meters) of the pixels in the band", + "type": "number" + }, + "raster:histogram": { + "title": "Histogram", + "type": "object", + "additionalItems": false, + "required": [ + "count", + "min", + "max", + "buckets" + ], + "additionalProperties": false, + "properties": { + "count": { + "title": "number of buckets", + "type": "number" + }, + "min": { + "title": "Minimum value of the buckets", + "type": "number" + }, + "max": { + "title": "Maximum value of the buckets", + "type": "number" + }, + "buckets": { + "title": "distribution buckets", + "type": "array", + "minItems": 3, + "items": { + "title": "number of pixels in the bucket", + "type": "integer" + } + } + } } } } - - -