python-osw-validation 0.4.3__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/version.py +1 -1
- {python_osw_validation-0.4.3.dist-info → python_osw_validation-0.4.4.dist-info}/METADATA +18 -15
- {python_osw_validation-0.4.3.dist-info → python_osw_validation-0.4.4.dist-info}/RECORD +8 -8
- {python_osw_validation-0.4.3.dist-info → python_osw_validation-0.4.4.dist-info}/WHEEL +0 -0
- {python_osw_validation-0.4.3.dist-info → python_osw_validation-0.4.4.dist-info}/licenses/LICENSE +0 -0
- {python_osw_validation-0.4.3.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
|
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
|
|
@@ -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,8 +1,8 @@
|
|
|
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
7
|
python_osw_validation/schema/opensidewalks.edges.schema-0.3.json,sha256=yE4K97WEdQBMHlVo5k9uheJ8TzHE6Tfupekxq_uv5Bk,78976
|
|
8
8
|
python_osw_validation/schema/opensidewalks.lines.schema-0.3.json,sha256=AlZuNu4dxEvnnqamHoogg9Y0yZMEyUtB0r854SF0xYo,9326
|
|
@@ -11,8 +11,8 @@ python_osw_validation/schema/opensidewalks.points.schema-0.3.json,sha256=WYmlC4Q
|
|
|
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.3.dist-info → python_osw_validation-0.4.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{python_osw_validation-0.4.3.dist-info → python_osw_validation-0.4.4.dist-info}/top_level.txt
RENAMED
|
File without changes
|