python-osw-validation 0.2.12__py3-none-any.whl → 0.2.14__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 +46 -14
- python_osw_validation/schema/Linestring_schema.json +53 -0
- python_osw_validation/schema/Point_schema.json +53 -0
- python_osw_validation/schema/Polygon_schema.json +53 -0
- python_osw_validation/version.py +1 -1
- {python_osw_validation-0.2.12.dist-info → python_osw_validation-0.2.14.dist-info}/METADATA +1 -1
- python_osw_validation-0.2.14.dist-info/RECORD +14 -0
- python_osw_validation-0.2.12.dist-info/RECORD +0 -14
- {python_osw_validation-0.2.12.dist-info → python_osw_validation-0.2.14.dist-info}/LICENSE +0 -0
- {python_osw_validation-0.2.12.dist-info → python_osw_validation-0.2.14.dist-info}/WHEEL +0 -0
- {python_osw_validation-0.2.12.dist-info → python_osw_validation-0.2.14.dist-info}/top_level.txt +0 -0
|
@@ -202,8 +202,15 @@ class OSWValidation:
|
|
|
202
202
|
continue
|
|
203
203
|
is_valid, duplicates = self.are_ids_unique(gdf)
|
|
204
204
|
if not is_valid:
|
|
205
|
+
total_duplicates = len(duplicates)
|
|
206
|
+
displayed = ', '.join(map(str, duplicates[:max_errors]))
|
|
207
|
+
if total_duplicates > max_errors:
|
|
208
|
+
message = (f"Duplicate _id's found in {osw_file}: showing first {max_errors} "
|
|
209
|
+
f"of {total_duplicates} duplicates: {displayed}")
|
|
210
|
+
else:
|
|
211
|
+
message = f"Duplicate _id's found in {osw_file}: {displayed}"
|
|
205
212
|
self.log_errors(
|
|
206
|
-
message=
|
|
213
|
+
message=message,
|
|
207
214
|
filename=osw_file,
|
|
208
215
|
feature_index=None
|
|
209
216
|
)
|
|
@@ -238,11 +245,11 @@ class OSWValidation:
|
|
|
238
245
|
if unmatched:
|
|
239
246
|
unmatched_list = list(unmatched)
|
|
240
247
|
num_unmatched = len(unmatched_list)
|
|
241
|
-
limit = min(num_unmatched,
|
|
248
|
+
limit = min(num_unmatched, max_errors)
|
|
242
249
|
displayed_unmatched = ', '.join(map(str, unmatched_list[:limit]))
|
|
243
250
|
self.log_errors(
|
|
244
251
|
message=(f"All _u_id's in edges should be part of _id's mentioned in nodes. "
|
|
245
|
-
f"Showing {
|
|
252
|
+
f"Showing {max_errors if num_unmatched > max_errors else 'all'} out of {num_unmatched} "
|
|
246
253
|
f"unmatched _u_id's: {displayed_unmatched}"),
|
|
247
254
|
filename='All',
|
|
248
255
|
feature_index=None
|
|
@@ -253,11 +260,11 @@ class OSWValidation:
|
|
|
253
260
|
if unmatched:
|
|
254
261
|
unmatched_list = list(unmatched)
|
|
255
262
|
num_unmatched = len(unmatched_list)
|
|
256
|
-
limit = min(num_unmatched,
|
|
263
|
+
limit = min(num_unmatched, max_errors)
|
|
257
264
|
displayed_unmatched = ', '.join(map(str, unmatched_list[:limit]))
|
|
258
265
|
self.log_errors(
|
|
259
266
|
message=(f"All _v_id's in edges should be part of _id's mentioned in nodes. "
|
|
260
|
-
f"Showing {
|
|
267
|
+
f"Showing {max_errors if num_unmatched > max_errors else 'all'} out of {num_unmatched} "
|
|
261
268
|
f"unmatched _v_id's: {displayed_unmatched}"),
|
|
262
269
|
filename='All',
|
|
263
270
|
feature_index=None
|
|
@@ -268,11 +275,11 @@ class OSWValidation:
|
|
|
268
275
|
if unmatched:
|
|
269
276
|
unmatched_list = list(unmatched)
|
|
270
277
|
num_unmatched = len(unmatched_list)
|
|
271
|
-
limit = min(num_unmatched,
|
|
278
|
+
limit = min(num_unmatched, max_errors)
|
|
272
279
|
displayed_unmatched = ', '.join(map(str, unmatched_list[:limit]))
|
|
273
280
|
self.log_errors(
|
|
274
281
|
message=(f"All _w_id's in zones should be part of _id's mentioned in nodes. "
|
|
275
|
-
f"Showing {
|
|
282
|
+
f"Showing {max_errors if num_unmatched > max_errors else 'all'} out of {num_unmatched} "
|
|
276
283
|
f"unmatched _w_id's: {displayed_unmatched}"),
|
|
277
284
|
filename='All',
|
|
278
285
|
feature_index=None
|
|
@@ -295,10 +302,10 @@ class OSWValidation:
|
|
|
295
302
|
ids_series = invalid_geojson['_id'] if '_id' in invalid_geojson.columns else invalid_geojson.index
|
|
296
303
|
invalid_ids = list(set(ids_series))
|
|
297
304
|
num_invalid = len(invalid_ids)
|
|
298
|
-
limit = min(num_invalid,
|
|
305
|
+
limit = min(num_invalid, max_errors)
|
|
299
306
|
displayed_invalid = ', '.join(map(str, invalid_ids[:limit]))
|
|
300
307
|
self.log_errors(
|
|
301
|
-
message=(f"Showing {
|
|
308
|
+
message=(f"Showing {max_errors if num_invalid > max_errors else 'all'} out of {num_invalid} "
|
|
302
309
|
f"invalid {osw_file} geometries, id's of invalid geometries: {displayed_invalid}"),
|
|
303
310
|
filename='All',
|
|
304
311
|
feature_index=None
|
|
@@ -323,11 +330,11 @@ class OSWValidation:
|
|
|
323
330
|
try:
|
|
324
331
|
invalid_ids = list(set(invalid_geojson.get('_id', invalid_geojson.index)))
|
|
325
332
|
num_invalid = len(invalid_ids)
|
|
326
|
-
limit = min(num_invalid,
|
|
333
|
+
limit = min(num_invalid, max_errors)
|
|
327
334
|
displayed_invalid = ', '.join(map(str, invalid_ids[:limit]))
|
|
328
335
|
self.log_errors(
|
|
329
336
|
message=(f"Invalid geometries found in extension file `{file_name}`. "
|
|
330
|
-
f"Showing {
|
|
337
|
+
f"Showing {max_errors if num_invalid > max_errors else 'all'} of {num_invalid} "
|
|
331
338
|
f"invalid geometry IDs: {displayed_invalid}"),
|
|
332
339
|
filename=file_name,
|
|
333
340
|
feature_index=None
|
|
@@ -388,8 +395,28 @@ class OSWValidation:
|
|
|
388
395
|
gc.collect()
|
|
389
396
|
|
|
390
397
|
def load_osw_file(self, graph_geojson_path: str) -> Dict[str, Any]:
|
|
391
|
-
|
|
392
|
-
|
|
398
|
+
try:
|
|
399
|
+
with open(graph_geojson_path, 'r') as file:
|
|
400
|
+
return json.load(file)
|
|
401
|
+
except json.JSONDecodeError as e:
|
|
402
|
+
filename = os.path.basename(graph_geojson_path)
|
|
403
|
+
self.log_errors(
|
|
404
|
+
message=(
|
|
405
|
+
f"Failed to parse '{filename}' as valid JSON. "
|
|
406
|
+
f"{e.msg} (line {e.lineno}, column {e.colno}, char {e.pos})."
|
|
407
|
+
),
|
|
408
|
+
filename=filename,
|
|
409
|
+
feature_index=None,
|
|
410
|
+
)
|
|
411
|
+
raise
|
|
412
|
+
except OSError as e:
|
|
413
|
+
filename = os.path.basename(graph_geojson_path)
|
|
414
|
+
self.log_errors(
|
|
415
|
+
message=f"Unable to read file '{filename}': {e.strerror or e}",
|
|
416
|
+
filename=filename,
|
|
417
|
+
feature_index=None,
|
|
418
|
+
)
|
|
419
|
+
raise
|
|
393
420
|
|
|
394
421
|
def validate_osw_errors(self, file_path: str, max_errors: int) -> bool:
|
|
395
422
|
"""Validate one OSW GeoJSON against the appropriate schema (streaming).
|
|
@@ -399,7 +426,12 @@ class OSWValidation:
|
|
|
399
426
|
before returning, pushes a single human-friendly message per feature
|
|
400
427
|
into `self.issues` (like your sample: "must include one of: ...").
|
|
401
428
|
"""
|
|
402
|
-
|
|
429
|
+
try:
|
|
430
|
+
geojson_data = self.load_osw_file(file_path)
|
|
431
|
+
except json.JSONDecodeError:
|
|
432
|
+
return False
|
|
433
|
+
except OSError:
|
|
434
|
+
return False
|
|
403
435
|
schema_path = self.pick_schema_for_file(file_path, geojson_data)
|
|
404
436
|
schema = self.load_osw_schema(schema_path)
|
|
405
437
|
validator = jsonschema_rs.Draft7Validator(schema)
|
|
@@ -23,6 +23,59 @@
|
|
|
23
23
|
"format": "date-time",
|
|
24
24
|
"type": "string"
|
|
25
25
|
},
|
|
26
|
+
"pipelineVersion": {
|
|
27
|
+
"additionalProperties": true,
|
|
28
|
+
"properties": {},
|
|
29
|
+
"type": "object"
|
|
30
|
+
},
|
|
31
|
+
"region": {
|
|
32
|
+
"title": "geometryObject",
|
|
33
|
+
"type": "object",
|
|
34
|
+
"required": [
|
|
35
|
+
"type",
|
|
36
|
+
"coordinates"
|
|
37
|
+
],
|
|
38
|
+
"additionalProperties": false,
|
|
39
|
+
"properties": {
|
|
40
|
+
"type": {
|
|
41
|
+
"title": "GeometryType",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"default": "MultiPolygon",
|
|
44
|
+
"enum": [
|
|
45
|
+
"MultiPolygon"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"coordinates": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"minItems": 1,
|
|
51
|
+
"items": {
|
|
52
|
+
"type": "array",
|
|
53
|
+
"minItems": 1,
|
|
54
|
+
"items": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"minItems": 4,
|
|
57
|
+
"items": {
|
|
58
|
+
"type": "array",
|
|
59
|
+
"additionalItems": false,
|
|
60
|
+
"items": [
|
|
61
|
+
{
|
|
62
|
+
"type": "number",
|
|
63
|
+
"minimum": -180,
|
|
64
|
+
"maximum": 180
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "number",
|
|
68
|
+
"minimum": -90,
|
|
69
|
+
"maximum": 90
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"description": "MultiPolygon geometry object."
|
|
78
|
+
},
|
|
26
79
|
"type": {
|
|
27
80
|
"title": "Feature Collection",
|
|
28
81
|
"type": "string",
|
|
@@ -23,6 +23,59 @@
|
|
|
23
23
|
"format": "date-time",
|
|
24
24
|
"type": "string"
|
|
25
25
|
},
|
|
26
|
+
"pipelineVersion": {
|
|
27
|
+
"additionalProperties": true,
|
|
28
|
+
"properties": {},
|
|
29
|
+
"type": "object"
|
|
30
|
+
},
|
|
31
|
+
"region": {
|
|
32
|
+
"title": "geometryObject",
|
|
33
|
+
"type": "object",
|
|
34
|
+
"required": [
|
|
35
|
+
"type",
|
|
36
|
+
"coordinates"
|
|
37
|
+
],
|
|
38
|
+
"additionalProperties": false,
|
|
39
|
+
"properties": {
|
|
40
|
+
"type": {
|
|
41
|
+
"title": "GeometryType",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"default": "MultiPolygon",
|
|
44
|
+
"enum": [
|
|
45
|
+
"MultiPolygon"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"coordinates": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"minItems": 1,
|
|
51
|
+
"items": {
|
|
52
|
+
"type": "array",
|
|
53
|
+
"minItems": 1,
|
|
54
|
+
"items": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"minItems": 4,
|
|
57
|
+
"items": {
|
|
58
|
+
"type": "array",
|
|
59
|
+
"additionalItems": false,
|
|
60
|
+
"items": [
|
|
61
|
+
{
|
|
62
|
+
"type": "number",
|
|
63
|
+
"minimum": -180,
|
|
64
|
+
"maximum": 180
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "number",
|
|
68
|
+
"minimum": -90,
|
|
69
|
+
"maximum": 90
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"description": "MultiPolygon geometry object."
|
|
78
|
+
},
|
|
26
79
|
"type": {
|
|
27
80
|
"title": "Feature Collection",
|
|
28
81
|
"type": "string",
|
|
@@ -23,6 +23,59 @@
|
|
|
23
23
|
"format": "date-time",
|
|
24
24
|
"type": "string"
|
|
25
25
|
},
|
|
26
|
+
"pipelineVersion": {
|
|
27
|
+
"additionalProperties": true,
|
|
28
|
+
"properties": {},
|
|
29
|
+
"type": "object"
|
|
30
|
+
},
|
|
31
|
+
"region": {
|
|
32
|
+
"title": "geometryObject",
|
|
33
|
+
"type": "object",
|
|
34
|
+
"required": [
|
|
35
|
+
"type",
|
|
36
|
+
"coordinates"
|
|
37
|
+
],
|
|
38
|
+
"additionalProperties": false,
|
|
39
|
+
"properties": {
|
|
40
|
+
"type": {
|
|
41
|
+
"title": "GeometryType",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"default": "MultiPolygon",
|
|
44
|
+
"enum": [
|
|
45
|
+
"MultiPolygon"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"coordinates": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"minItems": 1,
|
|
51
|
+
"items": {
|
|
52
|
+
"type": "array",
|
|
53
|
+
"minItems": 1,
|
|
54
|
+
"items": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"minItems": 4,
|
|
57
|
+
"items": {
|
|
58
|
+
"type": "array",
|
|
59
|
+
"additionalItems": false,
|
|
60
|
+
"items": [
|
|
61
|
+
{
|
|
62
|
+
"type": "number",
|
|
63
|
+
"minimum": -180,
|
|
64
|
+
"maximum": 180
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "number",
|
|
68
|
+
"minimum": -90,
|
|
69
|
+
"maximum": 90
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"description": "MultiPolygon geometry object."
|
|
78
|
+
},
|
|
26
79
|
"type": {
|
|
27
80
|
"title": "Feature Collection",
|
|
28
81
|
"type": "string",
|
python_osw_validation/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.2.
|
|
1
|
+
__version__ = '0.2.14'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
python_osw_validation/__init__.py,sha256=_OtFJzHGX3kzomOdnywHE4-6WrGjcyT43ida-xX4JKc,21091
|
|
2
|
+
python_osw_validation/extracted_data_validator.py,sha256=wZyCk8NlJv10cj_GrRTAiwm4cBhTAeDethjzJU-amoI,3877
|
|
3
|
+
python_osw_validation/helpers.py,sha256=afTFF7J14QBWqhxy1pO20Db_EQeWSO2Br5eteiy7xNg,3160
|
|
4
|
+
python_osw_validation/version.py,sha256=r8iWhYU-gaJ9WVJc_-ZLY8sK6iebY4JbvDv_kfd67iA,22
|
|
5
|
+
python_osw_validation/zipfile_handler.py,sha256=jXnP-8O5AAOBapuNF3-XdFVM1MHiPaWpl_wlbX-aqhY,2631
|
|
6
|
+
python_osw_validation/schema/Linestring_schema.json,sha256=prQqlQo78HSN0EVKHQBuv2PYKKVbcAwK6FXkHlVx8h0,73712
|
|
7
|
+
python_osw_validation/schema/Point_schema.json,sha256=2U5A9eUKqfdBj1NP0IqCYAR_dVpfRP_LPWBd6mTH2Ns,6764
|
|
8
|
+
python_osw_validation/schema/Polygon_schema.json,sha256=ACjnP3vSsqAEz5-iFuo7LqTodoNe14hwgvZ5KJiYFRc,11071
|
|
9
|
+
python_osw_validation/schema/opensidewalks.schema.json,sha256=i0iJwb_4Tq20BVUpkpgyM_7fm4SW_d_HNXKw0xul7OA,240987
|
|
10
|
+
python_osw_validation-0.2.14.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
11
|
+
python_osw_validation-0.2.14.dist-info/METADATA,sha256=sABTIhSz5cYzJYjgSMET8B6lSDD-HFNbsVpXMOdLM14,7232
|
|
12
|
+
python_osw_validation-0.2.14.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
13
|
+
python_osw_validation-0.2.14.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
|
|
14
|
+
python_osw_validation-0.2.14.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
python_osw_validation/__init__.py,sha256=07DnRGgPYKLUYzrLVY67FtKzWxmFiP9GRBNRTBtbY-Q,19663
|
|
2
|
-
python_osw_validation/extracted_data_validator.py,sha256=wZyCk8NlJv10cj_GrRTAiwm4cBhTAeDethjzJU-amoI,3877
|
|
3
|
-
python_osw_validation/helpers.py,sha256=afTFF7J14QBWqhxy1pO20Db_EQeWSO2Br5eteiy7xNg,3160
|
|
4
|
-
python_osw_validation/version.py,sha256=W9XM0mJRQGP61BM5IqZCUyRVhoppIU84BvoWmWAj_So,22
|
|
5
|
-
python_osw_validation/zipfile_handler.py,sha256=jXnP-8O5AAOBapuNF3-XdFVM1MHiPaWpl_wlbX-aqhY,2631
|
|
6
|
-
python_osw_validation/schema/Linestring_schema.json,sha256=U7JGf6OIy4WGcGICsVzYNiC_4p_sa3W3czSCc5Mked4,72408
|
|
7
|
-
python_osw_validation/schema/Point_schema.json,sha256=pYWVNzkJ6T4IQyoX0ogFrFxPkkJej5ftYpP70HKwKLY,5460
|
|
8
|
-
python_osw_validation/schema/Polygon_schema.json,sha256=szwsTrjZb5tnmQKdipQAOp5yU5V35rUZZrAtRxw7Fp4,9767
|
|
9
|
-
python_osw_validation/schema/opensidewalks.schema.json,sha256=i0iJwb_4Tq20BVUpkpgyM_7fm4SW_d_HNXKw0xul7OA,240987
|
|
10
|
-
python_osw_validation-0.2.12.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
11
|
-
python_osw_validation-0.2.12.dist-info/METADATA,sha256=GGDeRrQjagv2wfH4roQzdsB8icrx0Ptf6mfQToPtySk,7232
|
|
12
|
-
python_osw_validation-0.2.12.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
13
|
-
python_osw_validation-0.2.12.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
|
|
14
|
-
python_osw_validation-0.2.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{python_osw_validation-0.2.12.dist-info → python_osw_validation-0.2.14.dist-info}/top_level.txt
RENAMED
|
File without changes
|