Skip to content

Commit

Permalink
Improve JSON Schema, e.g. fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Mar 25, 2024
1 parent 15d89f5 commit b4c7b51
Showing 1 changed file with 53 additions and 22 deletions.
75 changes: 53 additions & 22 deletions json-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://stac-extensions.github.io/sentinel-2/v1.0.0/schema.json",
"title": "Sentinel-2 Extension",
"description": "Sentinel-2 Extension to STAC Items.",
"allOf": [
"description": "STAC Sentinel-2 Extension for STAC Items and STAC Collection Summaries.",
"type": "object",
"required": ["stac_extensions"],
"properties": {
"stac_extensions": {
"type": "array",
"contains": {
"const": "https://stac-extensions.github.io/sentinel-2/v1.0.0/schema.json"
}
}
},
"oneOf": [
{
"$comment": "This is the schema for STAC Items.",
"type": "object",
"required": [
"type",
"properties"
],
"required": ["type", "properties"],
"properties": {
"type": {
"const": "Feature"
},
"properties": {
"allOf": [
{
"required": []
"$ref": "#/definitions/require_any"
},
{
"$ref": "#/definitions/fields"
Expand All @@ -27,23 +35,46 @@
}
},
{
"$ref": "#/definitions/stac_extensions"
}
],
"definitions": {
"stac_extensions": {
"$comment": "This is the schema for STAC Collections, or more specifically only Collection Summaries in this case. By default, only checks the existence of the properties, but not the schema of the summaries.",
"type": "object",
"required": [
"stac_extensions"
],
"required": ["type", "summaries"],
"properties": {
"stac_extensions": {
"type": "array",
"contains": {
"const": "https://stac-extensions.github.io/sentinel-2/v1.0.0/schema.json"
}
"type": {
"const": "Collection"
},
"summaries": {
"$ref": "#/definitions/require_any"
}
}
}
],
"definitions": {
"require_any": {
"$comment": "Please list all fields here so that we can force the existence of one of them in other parts of the schemas.",
"anyOf": [
{ "required": ["s2:tile_id"] },
{ "required": ["s2:datatake_id"] },
{ "required": ["s2:product_uri"] },
{ "required": ["s2:datastrip_id"] },
{ "required": ["s2:product_type"] },
{ "required": ["s2:datatake_type"] },
{ "required": ["s2:generation_time"] },
{ "required": ["s2:processing_baseline"] },
{ "required": ["s2:water_percentage"] },
{ "required": ["s2:snow_ice_percentage"] },
{ "required": ["s2:vegetation_percentage"] },
{ "required": ["s2:thin_cirrus_percentage"] },
{ "required": ["s2:cloud_shadow_percentage"] },
{ "required": ["s2:nodata_pixel_percentage"] },
{ "required": ["s2:unclassified_percentage"] },
{ "required": ["s2:dark_features_percentage"] },
{ "required": ["s2:not_vegetated_percentage"] },
{ "required": ["s2:degraded_msi_data_percentage"] },
{ "required": ["s2:high_proba_clouds_percentage"] },
{ "required": ["s2:medium_proba_clouds_percentage"] },
{ "required": ["s2:saturated_defective_pixel_percentage"] },
{ "required": ["s2:reflectance_conversion_factor"] }
]
},
"fields": {
"type": "object",
Expand Down Expand Up @@ -104,7 +135,7 @@
"title": "Mean Solar Azimuth",
"type": "number",
"minimum": 0,
"maximum": 180,
"maximum": 180,
"deprecated": true
},
"s2:snow_ice_percentage": {
Expand Down Expand Up @@ -198,4 +229,4 @@
"additionalProperties": false
}
}
}
}

0 comments on commit b4c7b51

Please sign in to comment.