python-osw-validation 0.4.4__py3-none-any.whl → 0.4.5__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 +181 -5
- python_osw_validation/config.py +31 -0
- python_osw_validation/helpers.py +45 -1
- python_osw_validation/schema/opensidewalks.points.schema-0.3.json +0 -1
- python_osw_validation/schema/opensidewalks.zones.schema-0.3.json +0 -19
- python_osw_validation/version.py +1 -1
- {python_osw_validation-0.4.4.dist-info → python_osw_validation-0.4.5.dist-info}/METADATA +33 -1
- {python_osw_validation-0.4.4.dist-info → python_osw_validation-0.4.5.dist-info}/RECORD +11 -10
- {python_osw_validation-0.4.4.dist-info → python_osw_validation-0.4.5.dist-info}/WHEEL +0 -0
- {python_osw_validation-0.4.4.dist-info → python_osw_validation-0.4.5.dist-info}/licenses/LICENSE +0 -0
- {python_osw_validation-0.4.4.dist-info → python_osw_validation-0.4.5.dist-info}/top_level.txt +0 -0
|
@@ -8,6 +8,11 @@ import geopandas as gpd
|
|
|
8
8
|
import jsonschema_rs
|
|
9
9
|
|
|
10
10
|
from .zipfile_handler import ZipFileHandler
|
|
11
|
+
from .config import (
|
|
12
|
+
DEFAULT_COORDINATE_PRECISION,
|
|
13
|
+
DEFAULT_MAX_GEOMETRY_VERTICES,
|
|
14
|
+
ValidationConfig,
|
|
15
|
+
)
|
|
11
16
|
from .extracted_data_validator import ExtractedDataValidator, OSW_DATASET_FILES, dataset_key_for_filename
|
|
12
17
|
from .version import __version__
|
|
13
18
|
from .helpers import (
|
|
@@ -16,6 +21,7 @@ from .helpers import (
|
|
|
16
21
|
_feature_index_from_error,
|
|
17
22
|
_pretty_message,
|
|
18
23
|
_read_geojson_without_ext,
|
|
24
|
+
_geojson_file_has_excess_coordinate_precision,
|
|
19
25
|
)
|
|
20
26
|
|
|
21
27
|
SCHEMA_PATH = os.path.join(os.path.dirname(__file__), 'schema')
|
|
@@ -28,6 +34,13 @@ DEFAULT_DATASET_SCHEMAS = {
|
|
|
28
34
|
"zones": os.path.join(SCHEMA_PATH, 'opensidewalks.zones.schema-0.3.json'),
|
|
29
35
|
}
|
|
30
36
|
|
|
37
|
+
COORDINATE_PRECISION_WARNING = (
|
|
38
|
+
"Input dataset contains coordinates with more than "
|
|
39
|
+
f"{DEFAULT_COORDINATE_PRECISION} decimal places."
|
|
40
|
+
)
|
|
41
|
+
MAX_GEOMETRY_VERTICES = DEFAULT_MAX_GEOMETRY_VERTICES
|
|
42
|
+
VERTEX_LIMIT_DATASETS = frozenset({"edges", "lines", "polygons", "zones"})
|
|
43
|
+
|
|
31
44
|
|
|
32
45
|
class ValidationResult:
|
|
33
46
|
"""Container for validation outcome.
|
|
@@ -35,16 +48,18 @@ class ValidationResult:
|
|
|
35
48
|
* `errors`: high-level, human-readable strings (legacy behavior).
|
|
36
49
|
* `issues`: per-feature schema problems (former `fixme`), each item:
|
|
37
50
|
{ 'filename': str, 'feature_index': Optional[int], 'error_message': List[str] }
|
|
51
|
+
* `warnings`: non-blocking validation warning string.
|
|
38
52
|
"""
|
|
39
53
|
|
|
40
54
|
def __init__(self, is_valid: bool, errors: Optional[List[str]] = None,
|
|
41
|
-
issues: Optional[List[Dict[str, Any]]] = None):
|
|
55
|
+
issues: Optional[List[Dict[str, Any]]] = None, warnings: str = ""):
|
|
42
56
|
self.is_valid = is_valid
|
|
43
57
|
if len(errors) == 0:
|
|
44
58
|
self.errors = None
|
|
45
59
|
else:
|
|
46
60
|
self.errors = errors
|
|
47
61
|
self.issues = issues
|
|
62
|
+
self.warnings = warnings
|
|
48
63
|
|
|
49
64
|
|
|
50
65
|
class OSWValidation:
|
|
@@ -63,12 +78,17 @@ class OSWValidation:
|
|
|
63
78
|
point_schema_path: Optional[str] = None,
|
|
64
79
|
line_schema_path: Optional[str] = None,
|
|
65
80
|
polygon_schema_path: Optional[str] = None,
|
|
81
|
+
config: Optional[ValidationConfig] = None,
|
|
66
82
|
):
|
|
67
83
|
self.zipfile_path = zipfile_path
|
|
68
84
|
self.extracted_dir: Optional[str] = None
|
|
69
85
|
self.errors: List[str] = []
|
|
70
86
|
# per-feature schema issues (formerly `fixme`)
|
|
71
87
|
self.issues: List[Dict[str, Any]] = []
|
|
88
|
+
self.warnings = ""
|
|
89
|
+
if config is not None and not isinstance(config, ValidationConfig):
|
|
90
|
+
raise TypeError("config must be a ValidationConfig instance.")
|
|
91
|
+
self.config = config or ValidationConfig()
|
|
72
92
|
|
|
73
93
|
# Legacy single schema (if set, used for all)
|
|
74
94
|
self.schema_file_path = schema_file_path # may be None
|
|
@@ -95,6 +115,23 @@ class OSWValidation:
|
|
|
95
115
|
'error_message': message,
|
|
96
116
|
})
|
|
97
117
|
|
|
118
|
+
def _check_coordinate_precision(self, file_paths) -> None:
|
|
119
|
+
"""Set one aggregate warning without affecting validation state."""
|
|
120
|
+
for file_path in file_paths:
|
|
121
|
+
try:
|
|
122
|
+
if _geojson_file_has_excess_coordinate_precision(
|
|
123
|
+
str(file_path),
|
|
124
|
+
self.config.coordinate_precision,
|
|
125
|
+
):
|
|
126
|
+
self.warnings = (
|
|
127
|
+
"Input dataset contains coordinates with more than "
|
|
128
|
+
f"{self.config.coordinate_precision} decimal places."
|
|
129
|
+
)
|
|
130
|
+
return
|
|
131
|
+
except (OSError, json.JSONDecodeError, TypeError, ValueError):
|
|
132
|
+
# Existing parsing and schema validation own all functional errors.
|
|
133
|
+
continue
|
|
134
|
+
|
|
98
135
|
# add this small helper inside OSWValidation (near other helpers)
|
|
99
136
|
def _get_colset(self, gdf: Optional[gpd.GeoDataFrame], col: str, filekey: str) -> set:
|
|
100
137
|
"""Return set of a column if present; else log and return empty set."""
|
|
@@ -117,10 +154,8 @@ class OSWValidation:
|
|
|
117
154
|
# Geometry mapping helpers
|
|
118
155
|
# ----------------------------
|
|
119
156
|
|
|
120
|
-
_COORD_TOLERANCE = 1e-7 # ~1 cm at equator
|
|
121
|
-
|
|
122
157
|
def _coords_match(self, c1: tuple, c2: tuple) -> bool:
|
|
123
|
-
return
|
|
158
|
+
return c1 == c2
|
|
124
159
|
|
|
125
160
|
def _build_node_coord_map(self, nodes_df: gpd.GeoDataFrame) -> Dict[Any, tuple]:
|
|
126
161
|
"""Return {node_id: (lon, lat)} from a nodes GeoDataFrame."""
|
|
@@ -263,6 +298,125 @@ class OSWValidation:
|
|
|
263
298
|
feature_index=feat_idx,
|
|
264
299
|
)
|
|
265
300
|
|
|
301
|
+
@staticmethod
|
|
302
|
+
def _ring_vertex_count(ring) -> int:
|
|
303
|
+
coords = list(ring.coords)
|
|
304
|
+
if len(coords) > 1 and coords[0] == coords[-1]:
|
|
305
|
+
return len(coords) - 1
|
|
306
|
+
return len(coords)
|
|
307
|
+
|
|
308
|
+
def _geometry_vertex_count(self, geom) -> int:
|
|
309
|
+
"""Count line and polygon vertices, excluding polygon ring closure coordinates."""
|
|
310
|
+
if geom is None:
|
|
311
|
+
return 0
|
|
312
|
+
if geom.geom_type == 'LineString':
|
|
313
|
+
return len(geom.coords)
|
|
314
|
+
if geom.geom_type == 'Polygon':
|
|
315
|
+
return self._ring_vertex_count(geom.exterior) + sum(
|
|
316
|
+
self._ring_vertex_count(ring) for ring in geom.interiors
|
|
317
|
+
)
|
|
318
|
+
if geom.geom_type in {'MultiLineString', 'MultiPolygon', 'GeometryCollection'}:
|
|
319
|
+
return sum(self._geometry_vertex_count(part) for part in geom.geoms)
|
|
320
|
+
return 0
|
|
321
|
+
|
|
322
|
+
def _validate_geometry_vertex_limit(
|
|
323
|
+
self,
|
|
324
|
+
gdf: Optional[gpd.GeoDataFrame],
|
|
325
|
+
dataset_name: str,
|
|
326
|
+
max_errors: int,
|
|
327
|
+
) -> None:
|
|
328
|
+
"""Report line or polygon features exceeding the configured vertex limit."""
|
|
329
|
+
if gdf is None:
|
|
330
|
+
return
|
|
331
|
+
|
|
332
|
+
for feature_index, row in gdf.iterrows():
|
|
333
|
+
if len(self.errors) >= max_errors:
|
|
334
|
+
break
|
|
335
|
+
|
|
336
|
+
vertex_count = self._geometry_vertex_count(row.geometry)
|
|
337
|
+
if vertex_count <= self.config.max_geometry_vertices:
|
|
338
|
+
continue
|
|
339
|
+
|
|
340
|
+
feature_id = row.get('_id', feature_index)
|
|
341
|
+
if self._is_nullish_value(feature_id):
|
|
342
|
+
feature_id = feature_index
|
|
343
|
+
self.log_errors(
|
|
344
|
+
message=(
|
|
345
|
+
f"Feature '{feature_id}' in '{dataset_name}' contains {vertex_count} geometry vertices. "
|
|
346
|
+
f"Maximum allowed is {self.config.max_geometry_vertices}."
|
|
347
|
+
),
|
|
348
|
+
filename=dataset_name,
|
|
349
|
+
feature_index=feature_index,
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
def _geometry_coordinate_pairs(self, geometry) -> List[tuple]:
|
|
353
|
+
"""Return two-dimensional coordinate pairs from line and polygon geometries."""
|
|
354
|
+
if geometry is None or geometry.is_empty:
|
|
355
|
+
return []
|
|
356
|
+
if geometry.geom_type in {'LineString', 'LinearRing'}:
|
|
357
|
+
return [(coordinate[0], coordinate[1]) for coordinate in geometry.coords]
|
|
358
|
+
if geometry.geom_type == 'Polygon':
|
|
359
|
+
coordinates = self._geometry_coordinate_pairs(geometry.exterior)
|
|
360
|
+
for ring in geometry.interiors:
|
|
361
|
+
coordinates.extend(self._geometry_coordinate_pairs(ring))
|
|
362
|
+
return coordinates
|
|
363
|
+
if geometry.geom_type in {'MultiLineString', 'MultiPolygon', 'GeometryCollection'}:
|
|
364
|
+
return [
|
|
365
|
+
coordinate
|
|
366
|
+
for part in geometry.geoms
|
|
367
|
+
for coordinate in self._geometry_coordinate_pairs(part)
|
|
368
|
+
]
|
|
369
|
+
return []
|
|
370
|
+
|
|
371
|
+
def _validate_collapsed_geometries(
|
|
372
|
+
self,
|
|
373
|
+
gdf: Optional[gpd.GeoDataFrame],
|
|
374
|
+
dataset_name: str,
|
|
375
|
+
max_errors: int,
|
|
376
|
+
) -> set:
|
|
377
|
+
"""Report line or polygon features whose coordinates all share one location."""
|
|
378
|
+
collapsed_indexes = set()
|
|
379
|
+
if gdf is None:
|
|
380
|
+
return collapsed_indexes
|
|
381
|
+
|
|
382
|
+
for feature_index, row in gdf.iterrows():
|
|
383
|
+
geometry = row.geometry
|
|
384
|
+
coordinates = self._geometry_coordinate_pairs(geometry)
|
|
385
|
+
if len(coordinates) < 2 or len(set(coordinates)) != 1:
|
|
386
|
+
continue
|
|
387
|
+
|
|
388
|
+
if geometry.geom_type in {'LineString', 'MultiLineString'}:
|
|
389
|
+
geometry_problem = 'zero-length'
|
|
390
|
+
elif geometry.geom_type in {'Polygon', 'MultiPolygon'}:
|
|
391
|
+
geometry_problem = 'zero-area'
|
|
392
|
+
else:
|
|
393
|
+
continue
|
|
394
|
+
|
|
395
|
+
collapsed_indexes.add(feature_index)
|
|
396
|
+
allow_zero_length_line = (
|
|
397
|
+
self.config.allow_zero_length_lines
|
|
398
|
+
and geometry.geom_type == 'LineString'
|
|
399
|
+
and dataset_name not in {"nodes", "points", "polygons", "zones"}
|
|
400
|
+
)
|
|
401
|
+
if allow_zero_length_line:
|
|
402
|
+
continue
|
|
403
|
+
if len(self.errors) >= max_errors:
|
|
404
|
+
continue
|
|
405
|
+
|
|
406
|
+
feature_id = row.get('_id', feature_index)
|
|
407
|
+
if self._is_nullish_value(feature_id):
|
|
408
|
+
feature_id = feature_index
|
|
409
|
+
self.log_errors(
|
|
410
|
+
message=(
|
|
411
|
+
f"Feature '{feature_id}' in '{dataset_name}' has {geometry_problem} geometry "
|
|
412
|
+
"because all coordinates are identical."
|
|
413
|
+
),
|
|
414
|
+
filename=dataset_name,
|
|
415
|
+
feature_index=feature_index,
|
|
416
|
+
)
|
|
417
|
+
|
|
418
|
+
return collapsed_indexes
|
|
419
|
+
|
|
266
420
|
def _schema_key_from_text(self, text: Optional[str]) -> Optional[str]:
|
|
267
421
|
"""Return dataset key from exact filename suffixes only."""
|
|
268
422
|
if not text:
|
|
@@ -394,7 +548,7 @@ class OSWValidation:
|
|
|
394
548
|
final_errors = self.errors if errors is None else errors
|
|
395
549
|
final_errors = (final_errors or [])[:max_errors]
|
|
396
550
|
final_issues = (self.issues or [])[:max_errors]
|
|
397
|
-
return ValidationResult(is_valid, final_errors, final_issues)
|
|
551
|
+
return ValidationResult(is_valid, final_errors, final_issues, self.warnings)
|
|
398
552
|
|
|
399
553
|
zip_handler = None
|
|
400
554
|
OSW_DATASET: Dict[str, Optional[gpd.GeoDataFrame]] = {}
|
|
@@ -423,6 +577,11 @@ class OSWValidation:
|
|
|
423
577
|
)
|
|
424
578
|
return _finalize(False)
|
|
425
579
|
|
|
580
|
+
self._check_coordinate_precision(
|
|
581
|
+
list(getattr(validator, 'files', []) or [])
|
|
582
|
+
+ list(getattr(validator, 'externalExtensions', []) or [])
|
|
583
|
+
)
|
|
584
|
+
|
|
426
585
|
# Per-file schema validation → populate self.issues (fixme-like)
|
|
427
586
|
for file in validator.files:
|
|
428
587
|
file_path = os.path.join(file)
|
|
@@ -549,6 +708,9 @@ class OSWValidation:
|
|
|
549
708
|
for osw_file, gdf in OSW_DATASET.items():
|
|
550
709
|
if gdf is None:
|
|
551
710
|
continue
|
|
711
|
+
collapsed_indexes = self._validate_collapsed_geometries(gdf, osw_file, max_errors)
|
|
712
|
+
if osw_file in VERTEX_LIMIT_DATASETS and len(self.errors) < max_errors:
|
|
713
|
+
self._validate_geometry_vertex_limit(gdf, osw_file, max_errors)
|
|
552
714
|
expected_geom = OSW_DATASET_FILES.get(osw_file, {}).get('geometry')
|
|
553
715
|
if expected_geom:
|
|
554
716
|
invalid_geojson = gdf[
|
|
@@ -557,6 +719,9 @@ class OSWValidation:
|
|
|
557
719
|
else:
|
|
558
720
|
invalid_geojson = gdf[gdf.is_valid == False]
|
|
559
721
|
|
|
722
|
+
if collapsed_indexes:
|
|
723
|
+
invalid_geojson = invalid_geojson.drop(index=collapsed_indexes, errors='ignore')
|
|
724
|
+
|
|
560
725
|
if len(invalid_geojson) > 0:
|
|
561
726
|
# Extract IDs if present, else fallback to index
|
|
562
727
|
ids_series = invalid_geojson['_id'] if '_id' in invalid_geojson.columns else invalid_geojson.index
|
|
@@ -585,7 +750,18 @@ class OSWValidation:
|
|
|
585
750
|
)
|
|
586
751
|
continue
|
|
587
752
|
|
|
753
|
+
if len(self.errors) < max_errors:
|
|
754
|
+
self._validate_geometry_vertex_limit(extensionFile, file_name, max_errors)
|
|
755
|
+
|
|
756
|
+
collapsed_indexes = self._validate_collapsed_geometries(
|
|
757
|
+
extensionFile,
|
|
758
|
+
file_name,
|
|
759
|
+
max_errors,
|
|
760
|
+
)
|
|
761
|
+
|
|
588
762
|
invalid_geojson = extensionFile[extensionFile.is_valid == False]
|
|
763
|
+
if collapsed_indexes:
|
|
764
|
+
invalid_geojson = invalid_geojson.drop(index=collapsed_indexes, errors='ignore')
|
|
589
765
|
if len(invalid_geojson) > 0:
|
|
590
766
|
try:
|
|
591
767
|
invalid_ids = list(set(invalid_geojson.get('_id', invalid_geojson.index)))
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
DEFAULT_MAX_GEOMETRY_VERTICES = 2000
|
|
5
|
+
DEFAULT_COORDINATE_PRECISION = 7
|
|
6
|
+
DEFAULT_ALLOW_ZERO_LENGTH_LINES = False
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class ValidationConfig:
|
|
11
|
+
"""User-configurable validation behavior."""
|
|
12
|
+
|
|
13
|
+
max_geometry_vertices: int = DEFAULT_MAX_GEOMETRY_VERTICES
|
|
14
|
+
coordinate_precision: int = DEFAULT_COORDINATE_PRECISION
|
|
15
|
+
allow_zero_length_lines: bool = DEFAULT_ALLOW_ZERO_LENGTH_LINES
|
|
16
|
+
|
|
17
|
+
def __post_init__(self) -> None:
|
|
18
|
+
if isinstance(self.max_geometry_vertices, bool) or not isinstance(
|
|
19
|
+
self.max_geometry_vertices, int
|
|
20
|
+
):
|
|
21
|
+
raise TypeError("max_geometry_vertices must be an integer.")
|
|
22
|
+
if self.max_geometry_vertices <= 0:
|
|
23
|
+
raise ValueError("max_geometry_vertices must be greater than zero.")
|
|
24
|
+
if isinstance(self.coordinate_precision, bool) or not isinstance(
|
|
25
|
+
self.coordinate_precision, int
|
|
26
|
+
):
|
|
27
|
+
raise TypeError("coordinate_precision must be an integer.")
|
|
28
|
+
if self.coordinate_precision < 0:
|
|
29
|
+
raise ValueError("coordinate_precision must be zero or greater.")
|
|
30
|
+
if not isinstance(self.allow_zero_length_lines, bool):
|
|
31
|
+
raise TypeError("allow_zero_length_lines must be a boolean.")
|
python_osw_validation/helpers.py
CHANGED
|
@@ -1,10 +1,54 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
1
|
import json
|
|
3
2
|
import re
|
|
3
|
+
from decimal import Decimal
|
|
4
|
+
from typing import Any, Optional
|
|
4
5
|
|
|
5
6
|
import geopandas as gpd
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
def _coordinate_values_exceed_decimal_places(values: Any, max_decimal_places: int) -> bool:
|
|
10
|
+
if isinstance(values, Decimal):
|
|
11
|
+
return values.is_finite() and max(0, -values.as_tuple().exponent) > max_decimal_places
|
|
12
|
+
if isinstance(values, list):
|
|
13
|
+
return any(_coordinate_values_exceed_decimal_places(value, max_decimal_places) for value in values)
|
|
14
|
+
return False
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _geometry_exceeds_coordinate_precision(geometry: Any, max_decimal_places: int) -> bool:
|
|
18
|
+
if not isinstance(geometry, dict):
|
|
19
|
+
return False
|
|
20
|
+
if _coordinate_values_exceed_decimal_places(geometry.get("coordinates"), max_decimal_places):
|
|
21
|
+
return True
|
|
22
|
+
geometries = geometry.get("geometries", [])
|
|
23
|
+
if not isinstance(geometries, list):
|
|
24
|
+
return False
|
|
25
|
+
return any(
|
|
26
|
+
_geometry_exceeds_coordinate_precision(child, max_decimal_places)
|
|
27
|
+
for child in geometries
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _geojson_file_has_excess_coordinate_precision(file_path: str, max_decimal_places: int = 7) -> bool:
|
|
32
|
+
"""Return whether serialized GeoJSON coordinates exceed the decimal-place limit."""
|
|
33
|
+
with open(file_path, 'r', encoding='utf-8') as file:
|
|
34
|
+
data = json.load(file, parse_float=Decimal)
|
|
35
|
+
|
|
36
|
+
if not isinstance(data, dict):
|
|
37
|
+
return False
|
|
38
|
+
if data.get("type") == "FeatureCollection":
|
|
39
|
+
features = data.get("features", [])
|
|
40
|
+
if not isinstance(features, list):
|
|
41
|
+
return False
|
|
42
|
+
return any(
|
|
43
|
+
isinstance(feature, dict)
|
|
44
|
+
and _geometry_exceeds_coordinate_precision(feature.get("geometry"), max_decimal_places)
|
|
45
|
+
for feature in features
|
|
46
|
+
)
|
|
47
|
+
if data.get("type") == "Feature":
|
|
48
|
+
return _geometry_exceeds_coordinate_precision(data.get("geometry"), max_decimal_places)
|
|
49
|
+
return _geometry_exceeds_coordinate_precision(data, max_decimal_places)
|
|
50
|
+
|
|
51
|
+
|
|
8
52
|
def _read_geojson_without_ext(file_path: str) -> gpd.GeoDataFrame:
|
|
9
53
|
"""Load a GeoJSON file into a GeoDataFrame with ext:* properties removed.
|
|
10
54
|
|
|
@@ -255,25 +255,6 @@
|
|
|
255
255
|
"yes"
|
|
256
256
|
],
|
|
257
257
|
"type": "string"
|
|
258
|
-
},
|
|
259
|
-
"name": {
|
|
260
|
-
"description": "A field for a designated name for an entity. Example: an official name for a trail.",
|
|
261
|
-
"type": "string"
|
|
262
|
-
},
|
|
263
|
-
"surface": {
|
|
264
|
-
"description": "A field for the surface material of the path.",
|
|
265
|
-
"enum": [
|
|
266
|
-
"asphalt",
|
|
267
|
-
"concrete",
|
|
268
|
-
"dirt",
|
|
269
|
-
"grass",
|
|
270
|
-
"grass_paver",
|
|
271
|
-
"gravel",
|
|
272
|
-
"paved",
|
|
273
|
-
"paving_stones",
|
|
274
|
-
"unpaved"
|
|
275
|
-
],
|
|
276
|
-
"type": "string"
|
|
277
258
|
}
|
|
278
259
|
},
|
|
279
260
|
"required": [
|
python_osw_validation/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.4.
|
|
1
|
+
__version__ = '0.4.5'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python_osw_validation
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.5
|
|
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
|
|
@@ -70,6 +70,7 @@ result = validator.validate()
|
|
|
70
70
|
print(result.is_valid)
|
|
71
71
|
print(result.errors) # returns up to the first 20 high-level errors by default
|
|
72
72
|
print(result.issues) # detailed per-feature issues, capped to first 20 by default
|
|
73
|
+
print(result.warnings) # non-blocking coordinate precision warning, or an empty string
|
|
73
74
|
|
|
74
75
|
result = validator.validate(max_errors=10)
|
|
75
76
|
print(result.is_valid)
|
|
@@ -77,6 +78,37 @@ print(result.errors) # returns up to the first 10 high-level errors
|
|
|
77
78
|
print(result.issues) # capped by the same max_errors limit
|
|
78
79
|
```
|
|
79
80
|
|
|
81
|
+
### Validation configuration
|
|
82
|
+
|
|
83
|
+
Use `ValidationConfig` to override validation behavior for one validator instance.
|
|
84
|
+
When no configuration is supplied, the documented defaults are used.
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from python_osw_validation import OSWValidation, ValidationConfig
|
|
88
|
+
|
|
89
|
+
config = ValidationConfig(
|
|
90
|
+
max_geometry_vertices=3000,
|
|
91
|
+
coordinate_precision=8,
|
|
92
|
+
allow_zero_length_lines=True,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
validator = OSWValidation(
|
|
96
|
+
zipfile_path="dataset.zip",
|
|
97
|
+
config=config,
|
|
98
|
+
)
|
|
99
|
+
result = validator.validate()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
| Setting | Default | Meaning |
|
|
103
|
+
|---------|---------|---------|
|
|
104
|
+
| `max_geometry_vertices` | `2000` | Maximum allowed vertices for edges, lines, polygons, and zones. Must be an integer greater than zero. |
|
|
105
|
+
| `coordinate_precision` | `7` | Maximum coordinate decimal places before a non-blocking warning is reported. Must be a non-negative integer. |
|
|
106
|
+
| `allow_zero_length_lines` | `False` | Rejects collapsed `LineString` geometries by default. Set to `True` to allow them in edges, lines, and external line data. |
|
|
107
|
+
|
|
108
|
+
Allowing zero-length lines does not bypass `_u_id`/`_v_id` existence or exact
|
|
109
|
+
node-coordinate checks. Zero-area polygons and zones, collapsed `MultiLineString`
|
|
110
|
+
geometries, and line geometries in point datasets remain invalid.
|
|
111
|
+
|
|
80
112
|
## Error behavior
|
|
81
113
|
|
|
82
114
|
- `errors`: high-level validation messages, capped by `max_errors` (default `20`).
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
python_osw_validation/__init__.py,sha256=
|
|
1
|
+
python_osw_validation/__init__.py,sha256=KNwyU9LEePS81WHZvdXi5sMGWHpQsgvMH_abp4RKBFg,41363
|
|
2
|
+
python_osw_validation/config.py,sha256=v1KuNsJofrTCi50iaS3I9Ik5o8jmVe9idgbkJDP0uXc,1261
|
|
2
3
|
python_osw_validation/extracted_data_validator.py,sha256=ry5M6XO-fwijVc1XCIAMmfeR3n45V-NkSWPuJNF6vJ4,6949
|
|
3
4
|
python_osw_validation/geometry_mapping_validator.py,sha256=KscmfgSwTiXbf8IPx-RXuTIXPYY4PHDwvBeb2WmhpVA,14137
|
|
4
|
-
python_osw_validation/helpers.py,sha256=
|
|
5
|
-
python_osw_validation/version.py,sha256=
|
|
5
|
+
python_osw_validation/helpers.py,sha256=uXJuexsxALuhC05uhH8f1p1Sd5A7xfIhJY3X97BDdJE,11063
|
|
6
|
+
python_osw_validation/version.py,sha256=jMc7UM2pASY9F8z0XMALQbSXxGCAxWPyeXQlarwD0VI,22
|
|
6
7
|
python_osw_validation/zipfile_handler.py,sha256=jXnP-8O5AAOBapuNF3-XdFVM1MHiPaWpl_wlbX-aqhY,2631
|
|
7
8
|
python_osw_validation/schema/opensidewalks.edges.schema-0.3.json,sha256=yE4K97WEdQBMHlVo5k9uheJ8TzHE6Tfupekxq_uv5Bk,78976
|
|
8
9
|
python_osw_validation/schema/opensidewalks.lines.schema-0.3.json,sha256=AlZuNu4dxEvnnqamHoogg9Y0yZMEyUtB0r854SF0xYo,9326
|
|
9
10
|
python_osw_validation/schema/opensidewalks.nodes.schema-0.3.json,sha256=yEv4pIY69YvPHhSiQmvU21HeI426V-Z4j2K7ONQAwLM,14445
|
|
10
|
-
python_osw_validation/schema/opensidewalks.points.schema-0.3.json,sha256=
|
|
11
|
+
python_osw_validation/schema/opensidewalks.points.schema-0.3.json,sha256=hx5L1FvlvYTtBwpzaMAwCEl4T4MX7fdnABcNR7aFqAk,13004
|
|
11
12
|
python_osw_validation/schema/opensidewalks.polygons.schema-0.3.json,sha256=VzDpHv1ZVT42cAk9n3gsFZjS7WcflQzSbjN-aNIVTYM,16286
|
|
12
13
|
python_osw_validation/schema/opensidewalks.schema-0.3.json,sha256=vyyGzPpqLxr1e5wFfNKzlA1sr6tmhHKM7ntaTk8z5k8,278489
|
|
13
|
-
python_osw_validation/schema/opensidewalks.zones.schema-0.3.json,sha256=
|
|
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/schema/opensidewalks.zones.schema-0.3.json,sha256=j4vjO5JR5LrRieEhoqOl1ftqwEiU7xggAz__s6LQI38,10548
|
|
15
|
+
python_osw_validation-0.4.5.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
16
|
+
python_osw_validation-0.4.5.dist-info/METADATA,sha256=5lE5rGOHWKb62He6gN9v8tNR1EqByNHhpvFG6GpPS3c,8111
|
|
17
|
+
python_osw_validation-0.4.5.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
18
|
+
python_osw_validation-0.4.5.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
|
|
19
|
+
python_osw_validation-0.4.5.dist-info/RECORD,,
|
|
File without changes
|
{python_osw_validation-0.4.4.dist-info → python_osw_validation-0.4.5.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{python_osw_validation-0.4.4.dist-info → python_osw_validation-0.4.5.dist-info}/top_level.txt
RENAMED
|
File without changes
|