From e259f94ae7443d3f8c00e7d97f5d518ed1916083 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Thu, 4 Apr 2024 17:15:12 +0200 Subject: [PATCH] clean-up --- .github/workflows/publish.yaml | 4 +- .github/workflows/test.yaml | 4 +- CHANGELOG.md | 2 +- README.md | 26 +- json-schema/schema.json | 422 +++++++++++++++------------------ 5 files changed, 212 insertions(+), 246 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 9cba42f..a0c34b1 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -7,8 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Inject env variables - uses: rlespinasse/github-slug-action@v3.x - - uses: actions/checkout@v2 + uses: rlespinasse/github-slug-action@v4 + - uses: actions/checkout@v4 - name: deploy JSON Schema for version ${{ env.GITHUB_REF_SLUG }} uses: peaceiris/actions-gh-pages@v3 with: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index dbe73cf..45fd78f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,10 +4,10 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: 'lts/*' - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: | npm install npm test diff --git a/CHANGELOG.md b/CHANGELOG.md index 691f4c5..76e3953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Allow CommonMark for the `description` fields. -- `name` is required rather than `description` +- `classification:classes`: `name` is required rather than `description` ### Fixed diff --git a/README.md b/README.md index dfa5c67..eb16e4a 100644 --- a/README.md +++ b/README.md @@ -51,14 +51,14 @@ These classification objects can be used in the following places: *Describes multiple classes stored in a field of a continuous range of bits* -| Field Name | Type | Description | -| ----------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------- | -| offset | `integer` | **REQUIRED.** Offset to first bit in the field | -| length | `integer` | **REQUIRED.** Number of bits in the field | -| classes | `[Class]` | **REQUIRED.** Classes represented by the field values | -| roles | `[string]` | see [Asset Roles](https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#asset-roles) | +| Field Name | Type | Description | +| ----------- | ---------- | ------------------------------------------------------------ | +| offset | `integer` | **REQUIRED.** Offset to first bit in the field | +| length | `integer` | **REQUIRED.** Number of bits in the field | +| classes | `[Class]` | **REQUIRED.** Classes represented by the field values | +| name | `string` | Short name of the class for machine readability. Must consist only of letters, numbers, `-`, and `_` characters. | | description | `string` | A short description of the classification. [CommonMark 0.29](http://commonmark.org/) syntax MAY be used for rich text representation. | -| name | `string` | Short name of the class for machine readability | +| roles | `[string]` | see [Asset Roles](https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#asset-roles) | A Bit Field stores classes within a range of bits in a data value. The range is described by the offset of the first bit from the rightmost position, and the length of bits used to store the class values. @@ -113,12 +113,12 @@ For a real world example, see [Landsat 8's Quality raster](https://www.usgs.gov/ | Field Name | Type | Description | | ----------- | ---------- | -------------------------------------------------------------------------------------------------------------------- | -| value | `integer` | **REQUIRED.** Value of the class | -| description | `string` | Description of the class. [CommonMark 0.29](http://commonmark.org/) syntax MAY be used for rich text representation. | -| name | `string` | **REQUIRED.** Short name of the class for machine readability. Must consist only of letters, numbers, `-`, and `_` characters. | -| title | `string` | Human-readable name for use in, e.g., a map legend. | -| color_hint | RGB string | suggested color for rendering (Hex RGB code in upper-case without leading #) | -| nodata | `boolean` | If set to `true` classifies a value as a no-data value, defaults to `false` | +| value | integer | **REQUIRED.** Value of the class | +| name | string | **REQUIRED.** Short name of the class for machine readability. Must consist only of letters, numbers, `-`, and `_` characters. | +| title | string | Human-readable name for use in, e.g., a map legend. | +| description | string | Description of the class. [CommonMark 0.29](http://commonmark.org/) syntax MAY be used for rich text representation. | +| color_hint | string | Suggested color for rendering (Hex RGB code in upper-case without leading #) | +| nodata | boolean | If set to `true` classifies a value as a no-data value, defaults to `false` | Class objects enumerate data values and their corresponding classes. A cloud mask raster could contain the following four classes: diff --git a/json-schema/schema.json b/json-schema/schema.json index 66ceac0..49542a0 100644 --- a/json-schema/schema.json +++ b/json-schema/schema.json @@ -1,238 +1,204 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://stac-extensions.github.io/classification/v1.1.0/schema.json#", - "title": "Classification Extension", - "description": "STAC Classification Extension for STAC Items and STAC Collections.", - "oneOf": [ - { - "$comment": "This is the schema for STAC Items.", + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://stac-extensions.github.io/classification/v1.1.0/schema.json#", + "title": "Classification Extension", + "description": "STAC Classification Extension for STAC Items and STAC Collections.", + "type": "object", + "required": ["stac_extensions"], + "properties": { + "stac_extensions": { + "type": "array", + "contains": { + "const": "https://stac-extensions.github.io/classification/v1.1.0/schema.json" + } + } + }, + "oneOf": [ + { + "$comment": "This is the schema for STAC Items.", + "type": "object", + "required": ["type", "properties", "assets"], + "properties": { + "type": { + "const": "Feature" + }, + "properties": { + "$comment": "This validates the fields in Item Properties, but does not require them.", + "$ref": "#/definitions/fields" + }, + "assets": { + "$comment": "This validates the fields in Item Assets (including in Raster Band Objects), but does not require them.", + "type": "object", + "additionalProperties": { "allOf": [ - { - "$ref": "#/definitions/stac_extensions" - }, - { - "type": "object", - "required": [ - "type", - "properties", - "assets" - ], - "properties": { - "type": { - "const": "Feature" - }, - "properties": { - "$comment": "This validates the fields in Item Properties, but does not require them.", - "$ref": "#/definitions/fields" - }, - "assets": { - "$comment": "This validates the fields in Item Assets (including in Raster Band Objects), but does not require them.", - "type": "object", - "additionalProperties": { - "allOf": [ - { - "$ref": "#/definitions/fields" - }, - { - "$ref": "#/definitions/raster_bands" - } - ] - } - } - } - } + { + "$ref": "#/definitions/fields" + }, + { + "$ref": "#/definitions/raster_bands" + } ] + } + } + } + }, + { + "$comment": "This is the schema for STAC Collections.", + "type": "object", + "required": ["type"], + "properties": { + "type": { + "const": "Collection" }, - { - "$comment": "This is the schema for STAC Collections.", + "assets": { + "$comment": "This validates the fields in Collection Assets, but does not require them.", + "type": "object", + "additionalProperties": { "allOf": [ - { - "$ref": "#/definitions/stac_extensions" - }, - { - "type": "object", - "required": [ - "type" - ], - "properties": { - "type": { - "const": "Collection" - }, - "assets": { - "$comment": "This validates the fields in Collection Assets, but does not require them.", - "type": "object", - "additionalProperties": { - "allOf": [ - { - "$ref": "#/definitions/fields" - }, - { - "$ref": "#/definitions/raster_bands" - } - ] - } - }, - "item_assets": { - "$comment": "This validates the fields in Item Asset Definitions, but does not require them.", - "type": "object", - "additionalProperties": { - "allOf": [ - { - "$ref": "#/definitions/fields" - }, - { - "$ref": "#/definitions/raster_bands" - } - ] - } - }, - "summaries": { - "$comment": "This validates the fields in Summaries, but does not require them.", - "$ref": "#/definitions/fields" - } - } - } + { + "$ref": "#/definitions/fields" + }, + { + "$ref": "#/definitions/raster_bands" + } ] - } - ], - "definitions": { - "stac_extensions": { - "type": "object", - "required": [ - "stac_extensions" - ], - "properties": { - "stac_extensions": { - "type": "array", - "contains": { - "const": "https://stac-extensions.github.io/classification/v1.1.0/schema.json" - } - } - } - }, - "require_any_field": { - "$comment": "Please list all fields here so that we can force the existance of one of them in other parts of the schemas.", - "anyOf": [ - { - "required": [ - "classification:bitfields" - ] - }, - { - "required": [ - "classification:classes" - ] - } + } + }, + "item_assets": { + "$comment": "This validates the fields in Item Asset Definitions, but does not require them.", + "type": "object", + "additionalProperties": { + "allOf": [ + { + "$ref": "#/definitions/fields" + }, + { + "$ref": "#/definitions/raster_bands" + } ] + } }, - "fields": { - "$comment": "Add your new fields here. Don't require them here, do that above in the corresponding schema.", - "type": "object", - "properties": { - "classification:bitfields": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/bit_field_object" - } - }, - "classification:classes": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/class_object" - } - } - }, - "patternProperties": { - "^(?!classification:)": {} - }, - "additionalProperties": false - }, - "class_object": { - "$comment": "Object for storing classes", - "type": "object", - "required": [ - "value", - "name" - ], - "properties": { - "value": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "name": { - "type": "string", - "pattern": "^[0-9A-Za-z-_]+$" - }, - "title": { - "type": "string" - }, - "color_hint": { - "type": "string", - "pattern": "^([0-9A-Fa-f]{6})$" - }, - "nodata": { - "type": "boolean" - } - } - }, - "bit_field_object": { - "$comment": "Object for storing bit fields", - "type": "object", - "required": [ - "offset", - "length", - "classes" - ], - "properties": { - "offset": { - "type": "integer", - "minimum": 0 - }, - "length": { - "type": "integer", - "minimum": 1 - }, - "classes": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/class_object" - } - }, - "roles": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "type": "string" - } - }, - "description": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "raster_bands": { - "$comment": "Classification fields on the Raster Extension raster:bands object", - "type": "object", - "properties": { - "raster:bands": { - "type": "array", - "items": { - "$ref": "#/definitions/fields" - } - } - } + "summaries": { + "$comment": "This validates the fields in Summaries, but does not require them.", + "$ref": "#/definitions/fields" + } + } + } + ], + "definitions": { + "require_any_field": { + "$comment": "Please list all fields here so that we can force the existance of one of them in other parts of the schemas.", + "anyOf": [ + { + "required": ["classification:bitfields"] + }, + { + "required": ["classification:classes"] + } + ] + }, + "fields": { + "$comment": "Add your new fields here. Don't require them here, do that above in the corresponding schema.", + "type": "object", + "properties": { + "classification:bitfields": { + "type": "array", + "uniqueItems": true, + "minItems": 1, + "items": { + "$ref": "#/definitions/bit_field_object" + } + }, + "classification:classes": { + "type": "array", + "uniqueItems": true, + "minItems": 1, + "items": { + "$ref": "#/definitions/class_object" + } + } + }, + "patternProperties": { + "^(?!classification:)": {} + }, + "additionalProperties": false + }, + "class_object": { + "$comment": "Object for storing classes", + "type": "object", + "required": ["value", "name"], + "properties": { + "value": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string", + "pattern": "^[0-9A-Za-z-_]+$" + }, + "title": { + "type": "string" + }, + "color_hint": { + "type": "string", + "pattern": "^([0-9A-Fa-f]{6})$" + }, + "nodata": { + "type": "boolean" + } + } + }, + "bit_field_object": { + "$comment": "Object for storing bit fields", + "type": "object", + "required": ["offset", "length", "classes"], + "properties": { + "offset": { + "type": "integer", + "minimum": 0 + }, + "length": { + "type": "integer", + "minimum": 1 + }, + "classes": { + "type": "array", + "uniqueItems": true, + "minItems": 1, + "items": { + "$ref": "#/definitions/class_object" + } + }, + "roles": { + "type": "array", + "uniqueItems": true, + "minItems": 1, + "items": { + "type": "string" + } + }, + "description": { + "type": "string" + }, + "name": { + "type": "string", + "pattern": "^[0-9A-Za-z-_]+$" + } + } + }, + "raster_bands": { + "$comment": "Classification fields on the Raster Extension raster:bands object", + "type": "object", + "properties": { + "raster:bands": { + "type": "array", + "items": { + "$ref": "#/definitions/fields" + } } + } } -} \ No newline at end of file + } +}