python-osw-validation 0.4.0__py3-none-any.whl → 0.4.1__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.
@@ -14,6 +14,7 @@ from .helpers import (
14
14
  _err_kind,
15
15
  _feature_index_from_error,
16
16
  _pretty_message,
17
+ _read_geojson_without_ext,
17
18
  )
18
19
 
19
20
  SCHEMA_PATH = os.path.join(os.path.dirname(__file__), 'schema')
@@ -419,7 +420,7 @@ class OSWValidation:
419
420
  osw_file = next((osw_key for osw_key in OSW_DATASET_FILES.keys()
420
421
  if osw_key in os.path.basename(file_path)), '')
421
422
  try:
422
- gdf = gpd.read_file(file_path)
423
+ gdf = _read_geojson_without_ext(file_path)
423
424
  except Exception as e:
424
425
  self.log_errors(
425
426
  message=f"Failed to read '{os.path.basename(file_path)}' as GeoJSON: {e}",
@@ -557,7 +558,7 @@ class OSWValidation:
557
558
  file_path = os.path.join(file)
558
559
  file_name = os.path.basename(file)
559
560
  try:
560
- extensionFile = gpd.read_file(file_path)
561
+ extensionFile = _read_geojson_without_ext(file_path)
561
562
  except Exception as e:
562
563
  self.log_errors(
563
564
  message=f"Failed to read extension '{file_name}' as GeoJSON: {e}",
@@ -1,6 +1,30 @@
1
1
  from typing import Optional
2
+ import json
2
3
  import re
3
4
 
5
+ import geopandas as gpd
6
+
7
+
8
+ def _read_geojson_without_ext(file_path: str) -> gpd.GeoDataFrame:
9
+ """Load a GeoJSON file into a GeoDataFrame with ext:* properties removed.
10
+
11
+ Why: pyogrio/GDAL infers a single dtype per property column when reading
12
+ GeoJSON. Extension tags (ext:*) are free-form by spec and may legitimately
13
+ mix numbers and strings across features, which breaks that inference and
14
+ surfaces as a confusing JSON parse error. Schema validation has already
15
+ accepted these properties; the GeoDataFrame is only used for geometry and
16
+ _id-based integrity checks, so dropping ext:* here is safe.
17
+ """
18
+ with open(file_path, 'r') as f:
19
+ data = json.load(f)
20
+ for feature in data.get('features', []):
21
+ props = feature.get('properties')
22
+ if isinstance(props, dict):
23
+ for key in [k for k in props if isinstance(k, str) and k.startswith('ext:')]:
24
+ del props[key]
25
+ crs = (data.get('crs') or {}).get('properties', {}).get('name')
26
+ return gpd.GeoDataFrame.from_features(data.get('features', []), crs=crs)
27
+
4
28
  _ADDITIONAL_PROPERTIES_RE = re.compile(
5
29
  r"Additional properties are not allowed \('(?P<tag>[^']+)' was unexpected\)"
6
30
  )
@@ -1 +1 @@
1
- __version__ = '0.4.0'
1
+ __version__ = '0.4.1'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_osw_validation
3
- Version: 0.4.0
3
+ Version: 0.4.1
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
@@ -31,6 +31,10 @@ Dynamic: summary
31
31
 
32
32
  # TDEI python lib OSW validation package
33
33
 
34
+ [![PyPI version](https://img.shields.io/pypi/v/python-osw-validation.svg)](https://pypi.org/project/python-osw-validation/)
35
+ [![Tests](https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/actions/workflows/unit_tests.yml)
36
+ [![Coverage](https://img.shields.io/badge/coverage-92%25-brightgreen)](#)
37
+
34
38
  This package validates OSW GeoJSON datasets packaged as a ZIP file.
35
39
 
36
40
  ## System requirements
@@ -1,8 +1,8 @@
1
- python_osw_validation/__init__.py,sha256=GQX6EdJxaYkMVZv0dGjhT1rJgX7FYyR6ksAi-UYayEs,33246
1
+ python_osw_validation/__init__.py,sha256=jmTokejVzcwWwuQRgwIjCEH9KDhkJqp1a-e4ubVgOOU,33301
2
2
  python_osw_validation/extracted_data_validator.py,sha256=gEGYLaM_QkK6NrrhVYmNx-jMaNHXC4PbDGf1zKwJre4,6605
3
3
  python_osw_validation/geometry_mapping_validator.py,sha256=KscmfgSwTiXbf8IPx-RXuTIXPYY4PHDwvBeb2WmhpVA,14137
4
- python_osw_validation/helpers.py,sha256=_LgtNoFTjJLqg64zxJLO1Q4dPpui_lWNPNDMnqN8Qck,8106
5
- python_osw_validation/version.py,sha256=2eiWQI55fd-roDdkt4Hvl9WzrTJ4xQo33VzFud6D03U,22
4
+ python_osw_validation/helpers.py,sha256=iLVJZS1-AaLsbP0ngHZLW208dKSnM2k52JFal4Nuxcg,9203
5
+ python_osw_validation/version.py,sha256=qBs4HqYsPn6yUHWEuCN4rGUC05gABbl800d8LBd8h9w,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=Egp--i6ahiUDKY55g_fuv71HkVPtnQN5OW8L_okRa8o,79638
8
8
  python_osw_validation/schema/opensidewalks.lines.schema-0.3.json,sha256=3s-VXiMPv0_wv3yU2iGw8iKjE3Ec1w6QKkUsQURp2II,9470
@@ -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.0.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
15
- python_osw_validation-0.4.0.dist-info/METADATA,sha256=fIdNFivsf7gvoWIVNtL11MtQ0yzoScgYS1XzHeLRp_o,6080
16
- python_osw_validation-0.4.0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
17
- python_osw_validation-0.4.0.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
18
- python_osw_validation-0.4.0.dist-info/RECORD,,
14
+ python_osw_validation-0.4.1.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
15
+ python_osw_validation-0.4.1.dist-info/METADATA,sha256=NytFX-HWBMVtDbxB8PD_Ba4eHr2AoEUaIA2K19vxlR8,6502
16
+ python_osw_validation-0.4.1.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
17
+ python_osw_validation-0.4.1.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
18
+ python_osw_validation-0.4.1.dist-info/RECORD,,