python-osw-validation 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_osw_validation/__init__.py +20 -8
- python_osw_validation/extracted_data_validator.py +17 -9
- python_osw_validation/schema/opensidewalks.edges.schema-0.3.json +0 -18
- python_osw_validation/schema/opensidewalks.lines.schema-0.3.json +0 -4
- python_osw_validation/version.py +1 -1
- {python_osw_validation-0.4.2.dist-info → python_osw_validation-0.4.4.dist-info}/METADATA +19 -16
- {python_osw_validation-0.4.2.dist-info → python_osw_validation-0.4.4.dist-info}/RECORD +10 -10
- {python_osw_validation-0.4.2.dist-info → python_osw_validation-0.4.4.dist-info}/WHEEL +0 -0
- {python_osw_validation-0.4.2.dist-info → python_osw_validation-0.4.4.dist-info}/licenses/LICENSE +0 -0
- {python_osw_validation-0.4.2.dist-info → python_osw_validation-0.4.4.dist-info}/top_level.txt +0 -0
|
@@ -8,7 +8,7 @@ import geopandas as gpd
|
|
|
8
8
|
import jsonschema_rs
|
|
9
9
|
|
|
10
10
|
from .zipfile_handler import ZipFileHandler
|
|
11
|
-
from .extracted_data_validator import ExtractedDataValidator, OSW_DATASET_FILES
|
|
11
|
+
from .extracted_data_validator import ExtractedDataValidator, OSW_DATASET_FILES, dataset_key_for_filename
|
|
12
12
|
from .version import __version__
|
|
13
13
|
from .helpers import (
|
|
14
14
|
_add_additional_properties_hint,
|
|
@@ -269,18 +269,27 @@ class OSWValidation:
|
|
|
269
269
|
return None
|
|
270
270
|
|
|
271
271
|
basename = os.path.basename(text).lower()
|
|
272
|
-
stem, _ = os.path.splitext(basename)
|
|
273
272
|
for key in self.dataset_schema_paths:
|
|
274
273
|
if (
|
|
275
|
-
|
|
276
|
-
or
|
|
277
|
-
or
|
|
278
|
-
or
|
|
274
|
+
basename == f"{key}.geojson"
|
|
275
|
+
or basename == f"{key}.osw.geojson"
|
|
276
|
+
or basename.endswith(f".{key}.geojson")
|
|
277
|
+
or basename.endswith(f".{key}.osw.geojson")
|
|
279
278
|
):
|
|
280
279
|
return key
|
|
281
280
|
|
|
282
281
|
return None
|
|
283
282
|
|
|
283
|
+
def _schema_key_from_schema_url(self, schema_url: Any) -> Optional[str]:
|
|
284
|
+
if not isinstance(schema_url, str):
|
|
285
|
+
return None
|
|
286
|
+
|
|
287
|
+
lower_url = schema_url.lower()
|
|
288
|
+
for key in self.dataset_schema_paths:
|
|
289
|
+
if lower_url.endswith(f"/{key}.schema.json"):
|
|
290
|
+
return key
|
|
291
|
+
return None
|
|
292
|
+
|
|
284
293
|
def _is_nullish_value(self, value: Any) -> bool:
|
|
285
294
|
if value is None:
|
|
286
295
|
return True
|
|
@@ -371,6 +380,10 @@ class OSWValidation:
|
|
|
371
380
|
if schema_key and schema_key in self.dataset_schema_paths:
|
|
372
381
|
return self.dataset_schema_paths[schema_key]
|
|
373
382
|
|
|
383
|
+
schema_key = self._schema_key_from_schema_url(geojson_data.get('$schema'))
|
|
384
|
+
if schema_key and schema_key in self.dataset_schema_paths:
|
|
385
|
+
return self.dataset_schema_paths[schema_key]
|
|
386
|
+
|
|
374
387
|
return self.line_schema_path
|
|
375
388
|
|
|
376
389
|
# ----------------------------
|
|
@@ -423,8 +436,7 @@ class OSWValidation:
|
|
|
423
436
|
# Load GeoDataFrames for integrity checks
|
|
424
437
|
for file in validator.files:
|
|
425
438
|
file_path = os.path.join(file)
|
|
426
|
-
osw_file =
|
|
427
|
-
if osw_key in os.path.basename(file_path)), '')
|
|
439
|
+
osw_file = dataset_key_for_filename(os.path.basename(file_path))
|
|
428
440
|
try:
|
|
429
441
|
gdf = _read_geojson_without_ext(file_path)
|
|
430
442
|
except Exception as e:
|
|
@@ -50,18 +50,21 @@ _FILENAME_TO_KEY = {
|
|
|
50
50
|
|
|
51
51
|
def _matches_dataset_filename(basename: str, dataset_key: str) -> bool:
|
|
52
52
|
lower_name = basename.lower()
|
|
53
|
-
if not lower_name.endswith(".geojson"):
|
|
54
|
-
return False
|
|
55
|
-
|
|
56
|
-
stem = lower_name[:-len(".geojson")]
|
|
57
53
|
return (
|
|
58
|
-
|
|
59
|
-
or
|
|
60
|
-
or
|
|
61
|
-
or
|
|
54
|
+
lower_name == f"{dataset_key}.geojson"
|
|
55
|
+
or lower_name == f"{dataset_key}.osw.geojson"
|
|
56
|
+
or lower_name.endswith(f".{dataset_key}.geojson")
|
|
57
|
+
or lower_name.endswith(f".{dataset_key}.osw.geojson")
|
|
62
58
|
)
|
|
63
59
|
|
|
64
60
|
|
|
61
|
+
def dataset_key_for_filename(basename: str):
|
|
62
|
+
for dataset_key in OSW_DATASET_FILES.keys():
|
|
63
|
+
if _matches_dataset_filename(basename, dataset_key):
|
|
64
|
+
return dataset_key
|
|
65
|
+
return None
|
|
66
|
+
|
|
67
|
+
|
|
65
68
|
class ExtractedDataValidator:
|
|
66
69
|
def __init__(self, extracted_dir: str):
|
|
67
70
|
self.extracted_dir = extracted_dir
|
|
@@ -118,7 +121,12 @@ class ExtractedDataValidator:
|
|
|
118
121
|
)
|
|
119
122
|
if unsupported_files:
|
|
120
123
|
allowed_fmt = ", ".join(allowed_keys)
|
|
121
|
-
allowed_names =
|
|
124
|
+
allowed_names = (
|
|
125
|
+
f"{{{allowed_fmt}}}.geojson, "
|
|
126
|
+
f"*.{{{allowed_fmt}}}.geojson, "
|
|
127
|
+
f"{{{allowed_fmt}}}.OSW.geojson, or "
|
|
128
|
+
f"*.{{{allowed_fmt}}}.OSW.geojson"
|
|
129
|
+
)
|
|
122
130
|
self.error = (f"Unsupported .geojson files present: {', '.join(unsupported_files)}. "
|
|
123
131
|
f"Allowed file names are {allowed_names}")
|
|
124
132
|
return False
|
|
@@ -217,7 +217,6 @@
|
|
|
217
217
|
},
|
|
218
218
|
"length": {
|
|
219
219
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
220
|
-
"maximum": 5000,
|
|
221
220
|
"minimum": 0,
|
|
222
221
|
"type": "number"
|
|
223
222
|
},
|
|
@@ -399,7 +398,6 @@
|
|
|
399
398
|
},
|
|
400
399
|
"length": {
|
|
401
400
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
402
|
-
"maximum": 5000,
|
|
403
401
|
"minimum": 0,
|
|
404
402
|
"type": "number"
|
|
405
403
|
},
|
|
@@ -525,7 +523,6 @@
|
|
|
525
523
|
},
|
|
526
524
|
"length": {
|
|
527
525
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
528
|
-
"maximum": 5000,
|
|
529
526
|
"minimum": 0,
|
|
530
527
|
"type": "number"
|
|
531
528
|
},
|
|
@@ -614,7 +611,6 @@
|
|
|
614
611
|
},
|
|
615
612
|
"length": {
|
|
616
613
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
617
|
-
"maximum": 5000,
|
|
618
614
|
"minimum": 0,
|
|
619
615
|
"type": "number"
|
|
620
616
|
},
|
|
@@ -709,7 +705,6 @@
|
|
|
709
705
|
},
|
|
710
706
|
"length": {
|
|
711
707
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
712
|
-
"maximum": 5000,
|
|
713
708
|
"minimum": 0,
|
|
714
709
|
"type": "number"
|
|
715
710
|
},
|
|
@@ -797,7 +792,6 @@
|
|
|
797
792
|
},
|
|
798
793
|
"length": {
|
|
799
794
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
800
|
-
"maximum": 5000,
|
|
801
795
|
"minimum": 0,
|
|
802
796
|
"type": "number"
|
|
803
797
|
},
|
|
@@ -885,7 +879,6 @@
|
|
|
885
879
|
},
|
|
886
880
|
"length": {
|
|
887
881
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
888
|
-
"maximum": 5000,
|
|
889
882
|
"minimum": 0,
|
|
890
883
|
"type": "number"
|
|
891
884
|
},
|
|
@@ -980,7 +973,6 @@
|
|
|
980
973
|
},
|
|
981
974
|
"length": {
|
|
982
975
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
983
|
-
"maximum": 5000,
|
|
984
976
|
"minimum": 0,
|
|
985
977
|
"type": "number"
|
|
986
978
|
},
|
|
@@ -1068,7 +1060,6 @@
|
|
|
1068
1060
|
},
|
|
1069
1061
|
"length": {
|
|
1070
1062
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1071
|
-
"maximum": 5000,
|
|
1072
1063
|
"minimum": 0,
|
|
1073
1064
|
"type": "number"
|
|
1074
1065
|
},
|
|
@@ -1156,7 +1147,6 @@
|
|
|
1156
1147
|
},
|
|
1157
1148
|
"length": {
|
|
1158
1149
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1159
|
-
"maximum": 5000,
|
|
1160
1150
|
"minimum": 0,
|
|
1161
1151
|
"type": "number"
|
|
1162
1152
|
},
|
|
@@ -1244,7 +1234,6 @@
|
|
|
1244
1234
|
},
|
|
1245
1235
|
"length": {
|
|
1246
1236
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1247
|
-
"maximum": 5000,
|
|
1248
1237
|
"minimum": 0,
|
|
1249
1238
|
"type": "number"
|
|
1250
1239
|
},
|
|
@@ -1332,7 +1321,6 @@
|
|
|
1332
1321
|
},
|
|
1333
1322
|
"length": {
|
|
1334
1323
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1335
|
-
"maximum": 5000,
|
|
1336
1324
|
"minimum": 0,
|
|
1337
1325
|
"type": "number"
|
|
1338
1326
|
},
|
|
@@ -1426,7 +1414,6 @@
|
|
|
1426
1414
|
},
|
|
1427
1415
|
"length": {
|
|
1428
1416
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1429
|
-
"maximum": 5000,
|
|
1430
1417
|
"minimum": 0,
|
|
1431
1418
|
"type": "number"
|
|
1432
1419
|
},
|
|
@@ -1523,7 +1510,6 @@
|
|
|
1523
1510
|
},
|
|
1524
1511
|
"length": {
|
|
1525
1512
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1526
|
-
"maximum": 5000,
|
|
1527
1513
|
"minimum": 0,
|
|
1528
1514
|
"type": "number"
|
|
1529
1515
|
},
|
|
@@ -1617,7 +1603,6 @@
|
|
|
1617
1603
|
},
|
|
1618
1604
|
"length": {
|
|
1619
1605
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1620
|
-
"maximum": 5000,
|
|
1621
1606
|
"minimum": 0,
|
|
1622
1607
|
"type": "number"
|
|
1623
1608
|
},
|
|
@@ -1711,7 +1696,6 @@
|
|
|
1711
1696
|
},
|
|
1712
1697
|
"length": {
|
|
1713
1698
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1714
|
-
"maximum": 5000,
|
|
1715
1699
|
"minimum": 0,
|
|
1716
1700
|
"type": "number"
|
|
1717
1701
|
},
|
|
@@ -1800,7 +1784,6 @@
|
|
|
1800
1784
|
},
|
|
1801
1785
|
"length": {
|
|
1802
1786
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1803
|
-
"maximum": 5000,
|
|
1804
1787
|
"minimum": 0,
|
|
1805
1788
|
"type": "number"
|
|
1806
1789
|
},
|
|
@@ -1888,7 +1871,6 @@
|
|
|
1888
1871
|
},
|
|
1889
1872
|
"length": {
|
|
1890
1873
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
1891
|
-
"maximum": 5000,
|
|
1892
1874
|
"minimum": 0,
|
|
1893
1875
|
"type": "number"
|
|
1894
1876
|
},
|
|
@@ -170,7 +170,6 @@
|
|
|
170
170
|
},
|
|
171
171
|
"length": {
|
|
172
172
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
173
|
-
"maximum": 5000,
|
|
174
173
|
"minimum": 0,
|
|
175
174
|
"type": "number"
|
|
176
175
|
},
|
|
@@ -224,7 +223,6 @@
|
|
|
224
223
|
},
|
|
225
224
|
"length": {
|
|
226
225
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
227
|
-
"maximum": 5000,
|
|
228
226
|
"minimum": 0,
|
|
229
227
|
"type": "number"
|
|
230
228
|
}
|
|
@@ -253,7 +251,6 @@
|
|
|
253
251
|
},
|
|
254
252
|
"length": {
|
|
255
253
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
256
|
-
"maximum": 5000,
|
|
257
254
|
"minimum": 0,
|
|
258
255
|
"type": "number"
|
|
259
256
|
}
|
|
@@ -296,7 +293,6 @@
|
|
|
296
293
|
},
|
|
297
294
|
"length": {
|
|
298
295
|
"description": "A field for the length of an entity in meters. This field is always inferred from the geometry.",
|
|
299
|
-
"maximum": 5000,
|
|
300
296
|
"minimum": 0,
|
|
301
297
|
"type": "number"
|
|
302
298
|
},
|
python_osw_validation/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.4.
|
|
1
|
+
__version__ = '0.4.4'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python_osw_validation
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.4
|
|
4
4
|
Summary: Python library for OSW validation
|
|
5
5
|
Home-page: https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation
|
|
6
6
|
Author: Sujata Misra
|
|
@@ -33,7 +33,7 @@ Dynamic: summary
|
|
|
33
33
|
|
|
34
34
|
[](https://pypi.org/project/python-osw-validation/)
|
|
35
35
|
[](https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/actions/workflows/unit_tests.yml)
|
|
36
|
-

|
|
37
37
|
|
|
38
38
|
This package validates OSW GeoJSON datasets packaged as a ZIP file.
|
|
39
39
|
|
|
@@ -103,29 +103,32 @@ validator = OSWValidation(
|
|
|
103
103
|
|
|
104
104
|
## Supported filenames
|
|
105
105
|
|
|
106
|
-
The validator accepts
|
|
106
|
+
The validator accepts four filename formats for each dataset type:
|
|
107
107
|
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
- `.polygons.geojson`
|
|
113
|
-
- `.zones.geojson`
|
|
108
|
+
- `<dataset>.geojson`
|
|
109
|
+
- `*.<dataset>.geojson`
|
|
110
|
+
- `<dataset>.OSW.geojson`
|
|
111
|
+
- `*.<dataset>.OSW.geojson`
|
|
114
112
|
|
|
115
|
-
|
|
113
|
+
Where `<dataset>` is one of:
|
|
116
114
|
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
115
|
+
- `edges`
|
|
116
|
+
- `lines`
|
|
117
|
+
- `nodes`
|
|
118
|
+
- `points`
|
|
119
|
+
- `polygons`
|
|
120
|
+
- `zones`
|
|
123
121
|
|
|
124
122
|
Examples:
|
|
125
123
|
|
|
124
|
+
- `nodes.geojson` is valid
|
|
126
125
|
- `gs_metaline_falls_uga.nodes.geojson` is valid
|
|
126
|
+
- `nodes.OSW.geojson` is valid
|
|
127
127
|
- `gs_yarrow_point.edges.geojson` is valid
|
|
128
|
+
- `wa.microsoft.graph.edges.OSW.geojson` is valid
|
|
128
129
|
- `roadEdges.geojson` is invalid
|
|
130
|
+
- `roadedges.geojson` is invalid
|
|
131
|
+
- `River._edges_.geojson` is invalid
|
|
129
132
|
|
|
130
133
|
If a dataset uses canonical OSW 0.3 names that start with `opensidewalks.`, then only these exact names are allowed:
|
|
131
134
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
python_osw_validation/__init__.py,sha256=
|
|
2
|
-
python_osw_validation/extracted_data_validator.py,sha256=
|
|
1
|
+
python_osw_validation/__init__.py,sha256=TnXG51m-hm4gcHE5E5QovPu6Nnm7GeM7dgEVjmNCT3k,34074
|
|
2
|
+
python_osw_validation/extracted_data_validator.py,sha256=ry5M6XO-fwijVc1XCIAMmfeR3n45V-NkSWPuJNF6vJ4,6949
|
|
3
3
|
python_osw_validation/geometry_mapping_validator.py,sha256=KscmfgSwTiXbf8IPx-RXuTIXPYY4PHDwvBeb2WmhpVA,14137
|
|
4
4
|
python_osw_validation/helpers.py,sha256=iLVJZS1-AaLsbP0ngHZLW208dKSnM2k52JFal4Nuxcg,9203
|
|
5
|
-
python_osw_validation/version.py,sha256=
|
|
5
|
+
python_osw_validation/version.py,sha256=xKUiX0ZYXbYTA8dYVoy7bcY2aZprczNMGX4XQ_Q1slw,22
|
|
6
6
|
python_osw_validation/zipfile_handler.py,sha256=jXnP-8O5AAOBapuNF3-XdFVM1MHiPaWpl_wlbX-aqhY,2631
|
|
7
|
-
python_osw_validation/schema/opensidewalks.edges.schema-0.3.json,sha256=
|
|
8
|
-
python_osw_validation/schema/opensidewalks.lines.schema-0.3.json,sha256=
|
|
7
|
+
python_osw_validation/schema/opensidewalks.edges.schema-0.3.json,sha256=yE4K97WEdQBMHlVo5k9uheJ8TzHE6Tfupekxq_uv5Bk,78976
|
|
8
|
+
python_osw_validation/schema/opensidewalks.lines.schema-0.3.json,sha256=AlZuNu4dxEvnnqamHoogg9Y0yZMEyUtB0r854SF0xYo,9326
|
|
9
9
|
python_osw_validation/schema/opensidewalks.nodes.schema-0.3.json,sha256=yEv4pIY69YvPHhSiQmvU21HeI426V-Z4j2K7ONQAwLM,14445
|
|
10
10
|
python_osw_validation/schema/opensidewalks.points.schema-0.3.json,sha256=WYmlC4QFD-JUCnM0w3GBVI1E-LmCTRmTrGla1Z7o9Kw,13035
|
|
11
11
|
python_osw_validation/schema/opensidewalks.polygons.schema-0.3.json,sha256=VzDpHv1ZVT42cAk9n3gsFZjS7WcflQzSbjN-aNIVTYM,16286
|
|
12
12
|
python_osw_validation/schema/opensidewalks.schema-0.3.json,sha256=vyyGzPpqLxr1e5wFfNKzlA1sr6tmhHKM7ntaTk8z5k8,278489
|
|
13
13
|
python_osw_validation/schema/opensidewalks.zones.schema-0.3.json,sha256=JCqoCJj-dCuPVPHWSUQhRJMebaJ9IrzHWwTVAC6j7dY,11281
|
|
14
|
-
python_osw_validation-0.4.
|
|
15
|
-
python_osw_validation-0.4.
|
|
16
|
-
python_osw_validation-0.4.
|
|
17
|
-
python_osw_validation-0.4.
|
|
18
|
-
python_osw_validation-0.4.
|
|
14
|
+
python_osw_validation-0.4.4.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
15
|
+
python_osw_validation-0.4.4.dist-info/METADATA,sha256=rtDNQFVz6QIpEBSqStehNTY3h1MCNSD2KsE6PS8Xx7Y,6782
|
|
16
|
+
python_osw_validation-0.4.4.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
17
|
+
python_osw_validation-0.4.4.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
|
|
18
|
+
python_osw_validation-0.4.4.dist-info/RECORD,,
|
|
File without changes
|
{python_osw_validation-0.4.2.dist-info → python_osw_validation-0.4.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{python_osw_validation-0.4.2.dist-info → python_osw_validation-0.4.4.dist-info}/top_level.txt
RENAMED
|
File without changes
|