Skip to content

Commit e58bd16

Browse files
committed
Update layers schmea to use object/properties and allow extra columns
1 parent c964dc6 commit e58bd16

2 files changed

Lines changed: 24 additions & 17 deletions

File tree

json_schema/geopackage_layers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gpt
12

23
_component = __file__.split('.')[0]
34
_schemafile = '.'.join([_component, 'schema', 'json'])
@@ -7,8 +8,12 @@
78
schema = json.load(f)
89

910
def validate(gpkg_path):
10-
import fiona
11-
data = fiona.listlayers(gpkg_path)
11+
# import fiona
12+
# data = fiona.listlayers(gpkg_path)
13+
gpkg = gpt.read_file(gpkg_path)
14+
15+
# This is a workaround during devel, until I understand how to tell jsonschema about the DataFrames
16+
data = {ln:ln for ln in gpkg.list()}
1217

1318
import jsonschema
1419
res = jsonschema.validate(data, schema)

json_schema/geopackage_layers.schema.json

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33

44
"title": "Match Geopackage layers list",
55

6-
"$comment": "Works for, e.g., ['units','contacts','bla'], but not for ['bla','units','contacts']",
7-
"$example": ["units","contacts","another-column"],
6+
"$comment": "Defines mandatory layers, and allows extra ones.",
7+
"$example": "{'geologic_contacts':'bla','geologic_units':'blu','layer_styles':'foo','linear_features':'wow','surface_features':'yay'}",
88

9-
"definitions": {
10-
"layers": {
11-
"type": "string",
12-
"enum": ["units", "contacts"]
13-
}
9+
"type": "object",
10+
11+
"properties": {
12+
"layer_styles" : { "type" : "string" },
13+
"geologic_units" : { "type" : "string" },
14+
"linear_features" : { "type" : "string" },
15+
"surface_features" : { "type" : "string" },
16+
"geologic_contacts" : { "type" : "string" }
1417
},
1518

16-
"type": "array",
17-
"items": [
18-
{
19-
"$ref": "#/definitions/layers"
20-
}
19+
"required" : [
20+
"geologic_contacts",
21+
"geologic_units",
22+
"layer_styles",
23+
"linear_features",
24+
"surface_features"
2125
],
22-
"minItems": 2,
2326

24-
"uniqueItems": true,
25-
"additionalItems": { "type": "string" }
27+
"additionalProperties": true
2628
}

0 commit comments

Comments
 (0)