Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

JSON schema and validation for layer configs

Jason Kent021f6724a6be
diff --git a/config/default/common/config/wv.json/layers/modis/aqua/MODIS_Aqua_Thermal_Anomalies_All.json b/config/default/common/config/wv.json/layers/modis/aqua/MODIS_Aqua_Thermal_Anomalies_All.json
index 2211c7d15..432630afa 100644
--- a/config/default/common/config/wv.json/layers/modis/aqua/MODIS_Aqua_Thermal_Anomalies_All.json
+++ b/config/default/common/config/wv.json/layers/modis/aqua/MODIS_Aqua_Thermal_Anomalies_All.json
@@ -14,7 +14,7 @@
"id": "FIRMS_MODIS_Thermal_Anomalies_polar"
}
},
- "transition": "true",
+ "transition": true,
"period": "daily",
"layergroup": "Fires and Thermal Anomalies",
"product": "MYD14",
diff --git a/config/default/common/config/wv.json/layers/modis/aqua/MODIS_Aqua_Thermal_Anomalies_Day.json b/config/default/common/config/wv.json/layers/modis/aqua/MODIS_Aqua_Thermal_Anomalies_Day.json
index 140b0bda5..c2192eb39 100644
--- a/config/default/common/config/wv.json/layers/modis/aqua/MODIS_Aqua_Thermal_Anomalies_Day.json
+++ b/config/default/common/config/wv.json/layers/modis/aqua/MODIS_Aqua_Thermal_Anomalies_Day.json
@@ -21,13 +21,13 @@
"id": "MODIS_All_Thermal_Anomalies",
"immutable": true
},
- "transition": "true",
"tracks": [
"OrbitTracks_Aqua_Ascending"
],
"daynight": [
"day"
],
+ "transition": true,
"breakPointLayer": {
"id": "MODIS_Aqua_Thermal_Anomalies_Day",
"type": "wms",
diff --git a/config/default/common/config/wv.json/layers/modis/terra/MODIS_Terra_Thermal_Anomalies_Day.json b/config/default/common/config/wv.json/layers/modis/terra/MODIS_Terra_Thermal_Anomalies_Day.json
index 65b7e37f5..5b6160249 100644
--- a/config/default/common/config/wv.json/layers/modis/terra/MODIS_Terra_Thermal_Anomalies_Day.json
+++ b/config/default/common/config/wv.json/layers/modis/terra/MODIS_Terra_Thermal_Anomalies_Day.json
@@ -11,7 +11,7 @@
"layergroup": "Fires and Thermal Anomalies",
"product": "MOD14",
"type": "vector",
- "transition": "true",
+ "transition": true,
"vectorStyle": {
"id": "FIRMS_MODIS_Thermal_Anomalies",
"arctic": {
@@ -20,7 +20,7 @@
},
"palette": {
"id": "MODIS_All_Thermal_Anomalies",
- "immutable": "true"
+ "immutable": true
},
"tracks": [
"OrbitTracks_Terra_Descending"
diff --git a/config/default/common/config/wv.json/layers/reference/Coastlines.json b/config/default/common/config/wv.json/layers/reference/Coastlines.json
index c30d868d3..a8625d208 100644
--- a/config/default/common/config/wv.json/layers/reference/Coastlines.json
+++ b/config/default/common/config/wv.json/layers/reference/Coastlines.json
@@ -6,20 +6,23 @@
"description": "reference/Coastlines",
"group": "overlays",
"format": "image/png",
- "noTransition": "true",
"layergroup": "Reference",
+ "noTransition": true,
"projections": {
"antarctic": {
"subtitle": "SCAR Antarctic Digital Database / Coastlines",
- "tags": "borders reference"
+ "tags": "borders reference",
+ "source": "GIBS:antarctic"
},
"geographic": {
"subtitle": "© OpenStreetMap contributors",
- "tags": "borders reference osm"
+ "tags": "borders reference osm",
+ "source": "GIBS:geographic"
},
"arctic": {
"subtitle": "© OpenStreetMap contributors",
- "tags": "borders reference osm"
+ "tags": "borders reference osm",
+ "source": "GIBS:arctic"
}
},
"wrapX": true
diff --git a/config/default/common/config/wv.json/layers/reference/Graticule.json b/config/default/common/config/wv.json/layers/reference/Graticule.json
index 786e7e66c..23a5b4586 100644
--- a/config/default/common/config/wv.json/layers/reference/Graticule.json
+++ b/config/default/common/config/wv.json/layers/reference/Graticule.json
@@ -7,7 +7,7 @@
"description": "reference/Graticule",
"group": "overlays",
"format": "image/png",
- "noTransition": "true",
+ "noTransition": true,
"type": "variable",
"layergroup": "Latitude-Longitude Lines",
"projections": {
@@ -25,7 +25,8 @@
},
"geographic": {
"subtitle": "OpenLayers / Graticule Control",
- "type": "graticule"
+ "type": "graticule",
+ "source": ""
}
}
}
diff --git a/config/default/common/config/wv.json/layers/reference/Reference_Features.json b/config/default/common/config/wv.json/layers/reference/Reference_Features.json
index 040afabf6..106011e58 100644
--- a/config/default/common/config/wv.json/layers/reference/Reference_Features.json
+++ b/config/default/common/config/wv.json/layers/reference/Reference_Features.json
@@ -7,7 +7,6 @@
"description": "reference/Reference_Features",
"tags": "osm reference, country, countries, state, province",
"group": "overlays",
- "noTransition": "true",
"layergroup": "Reference",
"wrapX": true
}
diff --git a/config/default/common/config/wv.json/layers/reference/Reference_Labels.json b/config/default/common/config/wv.json/layers/reference/Reference_Labels.json
index 0d787556a..ddfba31f4 100644
--- a/config/default/common/config/wv.json/layers/reference/Reference_Labels.json
+++ b/config/default/common/config/wv.json/layers/reference/Reference_Labels.json
@@ -7,8 +7,8 @@
"description": "reference/Reference_Labels",
"tags": "osm reference, country, countries, state, province, cities, city",
"group": "overlays",
- "noTransition": "true",
"layergroup": "Reference",
+ "noTransition": true,
"wrapX": true
}
}
diff --git a/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_All.json b/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_All.json
index 29ecb90f4..e6f2e20f2 100644
--- a/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_All.json
+++ b/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_All.json
@@ -16,7 +16,7 @@
"id": "FIRMS_VIIRS_Thermal_Anomalies_polar"
}
},
- "transition": "true",
+ "transition": true,
"palette": {
"id": "VIIRS_All_Thermal_Anomalies",
"immutable": true
diff --git a/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_Day.json b/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_Day.json
index bc713f623..271be8903 100644
--- a/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_Day.json
+++ b/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_Day.json
@@ -19,13 +19,13 @@
"id": "VIIRS_All_Thermal_Anomalies",
"immutable": true
},
- "transition": "true",
"tracks": [
"OrbitTracks_NOAA-20_Ascending"
],
"daynight": [
"day"
],
+ "transition": true,
"breakPointLayer": {
"id": "VIIRS_NOAA20_Thermal_Anomalies_375m_Day",
"type": "wms",
diff --git a/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_Night.json b/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_Night.json
index 2a2f4385d..f44efa2bf 100644
--- a/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_Night.json
+++ b/config/default/common/config/wv.json/layers/viirs/VIIRS_NOAA20_Thermal_Anomalies_375m_Night.json
@@ -19,10 +19,7 @@
"id": "VIIRS_All_Thermal_Anomalies",
"immutable": true
},
- "transition": "true",
- "tracks": [
- "OrbitTracks_NOAA-20_Descending"
- ],
+ "transition": true,
"breakPointLayer": {
"id": "VIIRS_NOAA20_Thermal_Anomalies_375m_Night",
"type": "wms",
diff --git a/doc/config/layers.md b/doc/config/layers.md
index 4f9a7b2f5..9fae5caff 100644
--- a/doc/config/layers.md
+++ b/doc/config/layers.md
@@ -100,7 +100,6 @@ Example:
* **noTransition**: For WMTS layers only, if set to `true`, the map will not display lower-resolution tiles while loading.
* **transition**: For WMS layers only, if set to `true`, the map will display lower-resolution tiles while loading.
* **product**: Identifier of the product to use when searching the Common Metadata Repository (CMR) to download data. Can also be a list of identifiers to map the layer to multiple CMR products. See the [Data Download documentation](../data_download.md) for more information.
-* **style**: For WMTS layers only, this sets the WMTS `style` parameter accordingly; defaults to `default` if not set.
* **tileSize**: For WMS layers only, an array of pixel dimensions used to tile the requests. For example, `[512, 512]`
* **daynight**: Classify a layer as day or night. This information will be displayed within the title of the layer in the Measurement / Sources add modal view if provided.
* **track**: Classify a layer's track direction. This will usually be either ascending or descending and will be displayed within the title of the layer in the Measurement / Sources add modal view if provided.
diff --git a/requirements.txt b/requirements.txt
index 4d12275c7..522cd10a9 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,4 +3,5 @@ isodate==0.6.0
six==1.11.0
xmltodict==0.11.0
urllib3[secure]==1.24.3
-requests==2.20.0
\ No newline at end of file
+requests==2.20.0
+jsonschema==3.2.0
\ No newline at end of file
diff --git a/schemas/layer-config.json b/schemas/layer-config.json
new file mode 100644
index 000000000..59acb2171
--- /dev/null
+++ b/schemas/layer-config.json
@@ -0,0 +1,299 @@
+{
+ "$id": "https://worldview.earthdata.nasa.gov/layer-config",
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "Layer Configuration",
+ "description": "Layer Configuration Schema",
+ "type": "object",
+ "properties": {
+ "layers": {
+ "type": "object",
+ "patternProperties": {
+ "^.": { "$ref": "#/definitions/layer" }
+ }
+ }
+ },
+ "definitions": {
+ "layer": {
+ "type": "object",
+ "required": [
+ "group"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "id": {
+ "description": "TODO only allow/require for WMS?",
+ "type": "string"
+ },
+ "title": {
+ "type": "string"
+ },
+ "subtitle": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "tags": {
+ "type": "string"
+ },
+ "group": {
+ "type": "string",
+ "enum": ["overlays", "baselayers"]
+ },
+ "layergroup": {
+ "description": "TODO this seems to only be used to check for 'reference_orbits' to determine if a layer is an orbit track",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string"
+ }
+ },
+ "product": {
+ "anyOf": [
+ { "type": "string" },
+ { "type": "array" }
+ ]
+ },
+ "palette": {
+ "$ref": "#/definitions/palette"
+ },
+ "projections": {
+ "$ref": "#/definitions/projections"
+ },
+ "type": {
+ "$ref": "#/definitions/type"
+ },
+ "format": {
+ "$ref": "#/definitions/format"
+ },
+ "period": {
+ "type": "string",
+ "enum": [
+ "subdaily",
+ "daily",
+ "monthly",
+ "yearly"
+ ]
+ },
+ "startDate": {
+ "$ref": "#/definitions/date"
+ },
+ "endDate": {
+ "$ref": "#/definitions/date"
+ },
+ "futureLayer": {
+ "type": "boolean",
+ "description": "TODO Do we really need this?"
+ },
+ "futureTime": {
+ "type": "string",
+ "pattern": "^[1-9][DMY]$"
+ },
+ "transition": {
+ "type": "boolean"
+ },
+ "noTransition": {
+ "type": "boolean"
+ },
+ "vectorStyle": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "arctic": {
+ "$ref": "#/definitions/vectorStyle"
+ },
+ "antarctic": {
+ "$ref": "#/definitions/vectorStyle"
+ },
+ "geographic": {
+ "$ref": "#/definitions/vectorStyle"
+ },
+ "webmerc": {
+ "$ref": "#/definitions/vectorStyle"
+ }
+ }
+ },
+ "breakPointLayer": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "type": {
+ "$ref": "#/definitions/type"
+ },
+ "format": {
+ "$ref": "#/definitions/format"
+ },
+ "breakpointType": {
+ "type": "string"
+ },
+ "projections": {
+ "$ref": "#/definitions/projections"
+ }
+ }
+ },
+ "wrapX": {
+ "type": "boolean"
+ },
+ "wrapadjacentdays": {
+ "type": "boolean"
+ },
+ "availability": {
+ "type": "object",
+ "properties": {
+ "rollingWindow": {},
+ "historicalRanges": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/dateRange"
+ }
+ }
+ }
+ },
+ "inactive": {
+ "type": "boolean",
+ "description": "TODO should be removed for vis metadata replacement!"
+ },
+ "track": {
+ "description": "TODO should be removed for vis metadata replacement!",
+ "type": "string"
+ },
+ "layer": {
+ "type": "string"
+ }
+ },
+ "allOf": [
+ {
+ "description": "Prevents this one-off 'layer' prop from being allowed on other layers",
+ "if": {
+ "properties": {
+ "id": {
+ "not": { "const": "World_Database_on_Protected_Areas" }
+ }
+ }
+ },
+ "then": {
+ "properties": {
+ "layer": {
+ "not": { "type": "string" }
+ }
+ }
+ }
+ },
+ {
+ "description": "",
+ "if": {
+ "properties": {
+ "type": { "const": "wms" }
+ },
+ "required": [ "type" ]
+ },
+ "then": {
+ "required": [ "format" ]
+ }
+ }
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "wms",
+ "wmts",
+ "vector",
+ "variable"
+ ]
+ },
+ "format": {
+ "type": "string",
+ "enum": [
+ "image/jpeg",
+ "image/png"
+ ]
+ },
+ "date": {
+ "type": "string",
+ "pattern": "^(\\d{4})(-(\\d{2}))??(-(\\d{2}))??(T(\\d{2}):(\\d{2})(:(\\d{2}))??(\\.(\\d+))??(([\\+\\-]{1}\\d{2}:\\d{2})|Z)??)??$"
+ },
+ "dateRange": {
+ "type": "object",
+ "properties": {
+ "startDate": {
+ "$ref": "#/definitions/date"
+ },
+ "endDate": {
+ "$ref": "#/definitions/date"
+ },
+ "dateInterval": {
+ "description": "TODO should this be a number?",
+ "type": "string"
+ }
+ }
+ },
+ "vectorStyle": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ },
+ "required": [ "id" ]
+ },
+ "palette": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "recommended": {
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string"
+ }
+ },
+ "immutable": {
+ "type": "boolean"
+ }
+ }
+ },
+ "projections": {
+ "type": "object",
+ "properties": {
+ "geographic": {
+ "$ref": "#/definitions/projection"
+ },
+ "arctic": {
+ "$ref": "#/definitions/projection"
+ },
+ "antarctic": {
+ "$ref": "#/definitions/projection"
+ },
+ "webmerc": {
+ "$ref": "#/definitions/projection"
+ }
+ }
+ },
+ "projection": {
+ "type": "object",
+ "properties": {
+ "layer": {
+ "type": "string"
+ },
+ "subtitle": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ },
+ "matrixSet": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": true,
+ "required": [ "source" ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/tasks/buildOptions.sh b/tasks/buildOptions.sh
index 11659e6df..72e8e5a43 100755
--- a/tasks/buildOptions.sh
+++ b/tasks/buildOptions.sh
@@ -61,6 +61,9 @@ mkdir -p "$BUILD_DIR/colormaps"
mkdir -p "$BUILD_DIR/vectorstyles"
mkdir -p "$BUILD_DIR/vectordata"
+"$PYTHON_SCRIPTS_DIR/validateConfigs.py" "$SRC_DIR/common/config/wv.json/layers" \
+ "$BASE/schemas/layer-config.json"
+
if [ -e "$BUILD_DIR/features.json" ] ; then
cp "$BUILD_DIR/features.json" "$BUILD_DIR/config/wv.json/_features.json"
fi
diff --git a/tasks/python3/validateConfigs.py b/tasks/python3/validateConfigs.py
new file mode 100755
index 000000000..91bbfdfa0
--- /dev/null
+++ b/tasks/python3/validateConfigs.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+from jsonschema import Draft7Validator
+from optparse import OptionParser
+import os
+import re
+import json
+import glob
+
+
+prog = os.path.basename(__file__)
+parser = OptionParser(usage="Usage: %s <input_directory> <schema_file>" % prog)
+(options, args) = parser.parse_args()
+input_directory = args[0]
+schema_file = args[1]
+
+layerConfigFiles = []
+invalidJsonFiles = []
+
+print('%s: Validating layer configs...' % (prog))
+
+layerConfigSchema = json.load(open(schema_file))
+
+files = glob.glob(input_directory + '/**/*.json', recursive=True)
+
+for file_path in files:
+ configJson = json.load(open(file_path))
+ # Validate against the JSON schema
+ val = Draft7Validator(layerConfigSchema)
+ errors = sorted(val.iter_errors(configJson), key=lambda e: e.path)
+ split_path = file_path.split('/')
+ name_index = len(split_path) - 1
+ file_name = split_path[name_index]
+ if len(errors):
+ invalidJsonFiles.append(file_name)
+
+ for err in errors:
+ print('%s: ERROR: %s' % (prog, file_name))
+ print('%s: %s' % (prog, err.message))
+
+if len(invalidJsonFiles) > 0:
+ print('%s: FAILED: %s layer configs failed validation.' % (prog, len(invalidJsonFiles)))
+else:
+ print('%s: PASSED: All layer configs passed validation!' % (prog))
+
+