Skip to content

Commit d4c6235

Browse files
committed
1 parent 6f403d2 commit d4c6235

5 files changed

Lines changed: 30 additions & 82 deletions

json_schema/geopackage_layers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def validate(gpkg_path, schema='geopackage_layers.schema.json'):
5555
# version of json-schema (currently draft-07) we're using in one single place.
5656

5757
# Since we have "refs" in our schemas, we need a resolver to link them
58-
resolver = RefResolver.from_schema(schema_store['base.schema.json'], store=schema_store)
58+
# resolver = RefResolver.from_schema(schema_store['base.schema.json'], store=schema_store)
59+
resolver = RefResolver.from_schema(schema_store[schema], store=schema_store)
5960

6061
# Get the correct (or best) validator for our schema's version
6162
Validator = validator_for(schema_store['base.schema.json'])
@@ -64,7 +65,15 @@ def validate(gpkg_path, schema='geopackage_layers.schema.json'):
6465
validator = Validator(schema_store[schema], resolver=resolver)
6566

6667
gpkg = gpt.read_file(gpkg_path)
68+
6769
data = gpkg.to_dict()
70+
data.pop('layer_styles')
71+
print("\nGeoPackage DICT layers/columns:")
72+
for name,table in data.items():
73+
print(name)
74+
print(list(table.keys()))
75+
print()
6876

6977
res = validator.validate(data)
78+
# jsonschema.validate(data, schema_store[schema])
7079
return res

json_schema/geopackage_layers.schema.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
{
2-
"$ref": "base.schema.json",
3-
42
"title": "Match Geopackage layers list",
5-
63
"$comment": "Defines mandatory layers, and allows extra ones.",
74
"$example": "{'geologic_contacts':'bla','geologic_units':'blu','layer_styles':'foo','linear_features':'wow','surface_features':'yay'}",
85

9-
"type": "object",
6+
"type" : "object",
107

118
"properties": {
12-
13-
"layer_styles" : { "$ref" : "layer_layer_styles.json" },
9+
"layer_styles" : { "$ref" : "layer_layer_styles.json#" },
1410
"geologic_units" : { "type" : "object" },
1511
"linear_features" : { "type" : "object" },
1612
"surface_features" : { "type" : "object" },
17-
"geologic_contacts" : { "type" : "object" }
13+
"geologic_contacts" : { "$ref" : "layer_geologic_contacts.json#" }
1814
},
1915

2016
"required" : [

json_schema/geopackage_units.schema.json

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$id": "layer_geologic_contacts.json",
3+
"title": "QGIS 'geologic_contacts' schema",
4+
"description": "Defines the entries/rows of the table across the columns.",
5+
6+
"type" : "object",
7+
8+
"properties" : {
9+
"Contact_ty" : { "type" : "object" },
10+
"geometry" : { "type" : "object" }
11+
},
12+
"required": [
13+
"Contact_ty",
14+
"geometry"
15+
]
16+
}

json_schema/layer_layer_styles.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"title": "QGIS 'layer_styles' schema",
44
"description": "Defines the entries/rows of the table across the columns.",
55

6-
"type": "object"
6+
"type" : "object"
77
}

0 commit comments

Comments
 (0)