python-osw-validation 0.2.9__py3-none-any.whl → 0.2.11__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 +48 -6
- python_osw_validation/version.py +1 -1
- {python_osw_validation-0.2.9.dist-info → python_osw_validation-0.2.11.dist-info}/METADATA +22 -1
- python_osw_validation-0.2.11.dist-info/RECORD +10 -0
- python_osw_validation-0.2.9.dist-info/RECORD +0 -10
- {python_osw_validation-0.2.9.dist-info → python_osw_validation-0.2.11.dist-info}/LICENSE +0 -0
- {python_osw_validation-0.2.9.dist-info → python_osw_validation-0.2.11.dist-info}/WHEEL +0 -0
- {python_osw_validation-0.2.9.dist-info → python_osw_validation-0.2.11.dist-info}/top_level.txt +0 -0
|
@@ -107,22 +107,40 @@ class OSWValidation:
|
|
|
107
107
|
unmatched = node_ids_edges_u - node_ids
|
|
108
108
|
is_valid = len(unmatched) == 0
|
|
109
109
|
if not is_valid:
|
|
110
|
+
unmatched_list = list(unmatched)
|
|
111
|
+
num_unmatched = len(unmatched_list)
|
|
112
|
+
limit = min(num_unmatched, 20)
|
|
113
|
+
displayed_unmatched = ', '.join(map(str, unmatched_list[:limit]))
|
|
110
114
|
self.errors.append(
|
|
111
|
-
f"All _u_id's in edges should be part of _id's mentioned in nodes
|
|
115
|
+
f"All _u_id's in edges should be part of _id's mentioned in nodes. "
|
|
116
|
+
f"Showing {'20' if num_unmatched > 20 else 'all'} out of {len(unmatched)} unmatched _u_id's: {displayed_unmatched}"
|
|
117
|
+
)
|
|
112
118
|
|
|
113
119
|
# Do all node references in _v_id exist in nodes?
|
|
114
120
|
unmatched = node_ids_edges_v - node_ids
|
|
115
121
|
is_valid = len(unmatched) == 0
|
|
116
122
|
if not is_valid:
|
|
123
|
+
unmatched_list = list(unmatched)
|
|
124
|
+
num_unmatched = len(unmatched_list)
|
|
125
|
+
limit = min(num_unmatched, 20)
|
|
126
|
+
displayed_unmatched = ', '.join(map(str, unmatched_list[:limit]))
|
|
117
127
|
self.errors.append(
|
|
118
|
-
f"All _v_id's in edges should be part of _id's mentioned in nodes
|
|
128
|
+
f"All _v_id's in edges should be part of _id's mentioned in nodes. "
|
|
129
|
+
f"Showing {'20' if num_unmatched > 20 else 'all'} out of {len(unmatched)} unmatched _v_id's: {displayed_unmatched}"
|
|
130
|
+
)
|
|
119
131
|
|
|
120
132
|
# Do all node references in _w_id exist in nodes?
|
|
121
133
|
unmatched = node_ids_zones_w - node_ids
|
|
122
134
|
is_valid = len(unmatched) == 0
|
|
123
135
|
if not is_valid:
|
|
136
|
+
unmatched_list = list(unmatched)
|
|
137
|
+
num_unmatched = len(unmatched_list)
|
|
138
|
+
limit = min(num_unmatched, 20)
|
|
139
|
+
displayed_unmatched = ', '.join(map(str, unmatched_list[:limit]))
|
|
124
140
|
self.errors.append(
|
|
125
|
-
f"All _w_id's in zones should be part of _id's mentioned in nodes
|
|
141
|
+
f"All _w_id's in zones should be part of _id's mentioned in nodes. "
|
|
142
|
+
f"Showing {'20' if num_unmatched > 20 else 'all'} out of {len(unmatched)} unmatched _w_id's: {displayed_unmatched}"
|
|
143
|
+
)
|
|
126
144
|
|
|
127
145
|
# Geometry validation: check geometry type in each file and test if coordinates make a shape that is reasonable geometric shape according to the Simple Feature Access standard
|
|
128
146
|
for osw_file in OSW_DATASET:
|
|
@@ -131,18 +149,42 @@ class OSWValidation:
|
|
|
131
149
|
OSW_DATASET[osw_file].is_valid == False)]
|
|
132
150
|
is_valid = len(invalid_geojson) == 0
|
|
133
151
|
if not is_valid:
|
|
152
|
+
invalid_ids = list(set(invalid_geojson['_id']))
|
|
153
|
+
num_invalid = len(invalid_ids)
|
|
154
|
+
limit = min(num_invalid, 20)
|
|
155
|
+
displayed_invalid = ', '.join(map(str, invalid_ids[:min(num_invalid, limit)]))
|
|
134
156
|
self.errors.append(
|
|
135
|
-
f"
|
|
157
|
+
f"Showing {'20' if num_invalid > 20 else 'all'} out of {num_invalid} invalid {osw_file} geometries, "
|
|
158
|
+
f"id's of invalid geometries: {displayed_invalid}"
|
|
159
|
+
)
|
|
136
160
|
|
|
137
161
|
# Validate OSW external extensions
|
|
138
162
|
for file in validator.externalExtensions:
|
|
139
163
|
file_path = os.path.join(file)
|
|
164
|
+
file_name = os.path.basename(file)
|
|
140
165
|
extensionFile = gpd.read_file(file_path)
|
|
141
166
|
invalid_geojson = extensionFile[extensionFile.is_valid == False]
|
|
142
167
|
is_valid = len(invalid_geojson) == 0
|
|
143
168
|
if not is_valid:
|
|
144
|
-
|
|
145
|
-
|
|
169
|
+
try:
|
|
170
|
+
# Safely extract invalid _id or fallback to index if _id is missing
|
|
171
|
+
invalid_ids = list(set(invalid_geojson.get('_id', invalid_geojson.index)))
|
|
172
|
+
num_invalid = len(invalid_ids)
|
|
173
|
+
limit = min(num_invalid, 20)
|
|
174
|
+
displayed_invalid = ', '.join(map(str, invalid_ids[:limit]))
|
|
175
|
+
self.errors.append(
|
|
176
|
+
f"Invalid geometries found in extension file `{file_name}`. Showing {limit if num_invalid > 20 else 'all'} of {num_invalid} invalid geometry IDs: {displayed_invalid}"
|
|
177
|
+
)
|
|
178
|
+
except Exception as e:
|
|
179
|
+
self.errors.append(f"Invalid features found in `{file_name}`, but failed to extract IDs: {e}")
|
|
180
|
+
|
|
181
|
+
# Optional: Test serializability of extension file
|
|
182
|
+
try:
|
|
183
|
+
for idx, row in extensionFile.drop(columns='geometry').iterrows():
|
|
184
|
+
json.dumps(row.to_dict())
|
|
185
|
+
except Exception as e:
|
|
186
|
+
self.errors.append(f"Extension file `{file_name}` has non-serializable properties: {e}")
|
|
187
|
+
break
|
|
146
188
|
|
|
147
189
|
if self.errors:
|
|
148
190
|
return ValidationResult(False, self.errors)
|
python_osw_validation/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.2.
|
|
1
|
+
__version__ = '0.2.11'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-osw-validation
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.11
|
|
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
|
|
@@ -127,3 +127,24 @@ Ran 37 tests in 1284.068s
|
|
|
127
127
|
|
|
128
128
|
OK
|
|
129
129
|
```
|
|
130
|
+
|
|
131
|
+
## Use locally:
|
|
132
|
+
To use the library locally, use the [example.py](./src/example.py) code
|
|
133
|
+
|
|
134
|
+
## Deployment:
|
|
135
|
+
|
|
136
|
+
- The library can be pushed to [TestPy](https://test.pypi.org/project/python-osw-validation/) or [PYPI](https://pypi.org/project/python-osw-validation/)
|
|
137
|
+
### Deploy to TestPy
|
|
138
|
+
- On every push to `dev` branch, a workflow is triggered which publishes the updated version to TestPy
|
|
139
|
+
|
|
140
|
+
### Deploy to PyPI
|
|
141
|
+
- This happens whenever a tag/release is created with `*.*.*` notation (eg. 0.0.8)
|
|
142
|
+
- To change the version, change the version at [version.py](./src/python_osw_validation/version.py)
|
|
143
|
+
- To release a new version:
|
|
144
|
+
- Go to Github link of this repository
|
|
145
|
+
- Under [releases](https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/releases), click on `Draft a new release`
|
|
146
|
+
- Under `choose a new tag`, add a new tag `v*.*.*` , Generate Release notes
|
|
147
|
+
- Choose `main` branch for release
|
|
148
|
+
- Publish the release.
|
|
149
|
+
- This release triggers a workflow to generate the new version of the Package.
|
|
150
|
+
- The new package will be available at https://pypi.org/project/python-osw-validation/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
python_osw_validation/__init__.py,sha256=eMf_TBIaQWFmQelG1lZkvDpwaW0JjIJNiDEFKx4bHe8,10467
|
|
2
|
+
python_osw_validation/extracted_data_validator.py,sha256=wZyCk8NlJv10cj_GrRTAiwm4cBhTAeDethjzJU-amoI,3877
|
|
3
|
+
python_osw_validation/version.py,sha256=MDWVRBs0IWHig-yP3jl_AM0VvBpaMmDN0nBK4Hl8Idk,22
|
|
4
|
+
python_osw_validation/zipfile_handler.py,sha256=jXnP-8O5AAOBapuNF3-XdFVM1MHiPaWpl_wlbX-aqhY,2631
|
|
5
|
+
python_osw_validation/schema/opensidewalks.schema.json,sha256=i0iJwb_4Tq20BVUpkpgyM_7fm4SW_d_HNXKw0xul7OA,240987
|
|
6
|
+
python_osw_validation-0.2.11.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
7
|
+
python_osw_validation-0.2.11.dist-info/METADATA,sha256=pmboxEjaNs3SxMNlnh-L-zsnPFbSjvJF6Vezkuz25fc,7232
|
|
8
|
+
python_osw_validation-0.2.11.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
9
|
+
python_osw_validation-0.2.11.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
|
|
10
|
+
python_osw_validation-0.2.11.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
python_osw_validation/__init__.py,sha256=BrVyTquf9n4-US7d_FZBNEjyh24LaucSz4Zd65v2tfw,7946
|
|
2
|
-
python_osw_validation/extracted_data_validator.py,sha256=wZyCk8NlJv10cj_GrRTAiwm4cBhTAeDethjzJU-amoI,3877
|
|
3
|
-
python_osw_validation/version.py,sha256=e5Klz6yLU-4Ub9zxGUBo9wADAYsST38ZylTv9ze4i60,21
|
|
4
|
-
python_osw_validation/zipfile_handler.py,sha256=jXnP-8O5AAOBapuNF3-XdFVM1MHiPaWpl_wlbX-aqhY,2631
|
|
5
|
-
python_osw_validation/schema/opensidewalks.schema.json,sha256=i0iJwb_4Tq20BVUpkpgyM_7fm4SW_d_HNXKw0xul7OA,240987
|
|
6
|
-
python_osw_validation-0.2.9.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
7
|
-
python_osw_validation-0.2.9.dist-info/METADATA,sha256=dOSaEqE-VEW2iqhkzSb27T2A72Y31AfRyuGnDlI3aqE,6140
|
|
8
|
-
python_osw_validation-0.2.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
9
|
-
python_osw_validation-0.2.9.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
|
|
10
|
-
python_osw_validation-0.2.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{python_osw_validation-0.2.9.dist-info → python_osw_validation-0.2.11.dist-info}/top_level.txt
RENAMED
|
File without changes
|