python-osw-validation 0.3.0__py3-none-any.whl → 0.3.2__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.
@@ -124,15 +124,24 @@ class OSWValidation:
124
124
  return key
125
125
  return None
126
126
 
127
- def _contains_disallowed_features_for_02(self, geojson_data: Dict[str, Any]) -> bool:
128
- """Detect Tree coverage or Custom Point/Line/Polygon in legacy 0.2 datasets."""
127
+ def _contains_disallowed_features_for_02(self, geojson_data: Dict[str, Any]) -> set:
128
+ """Detect Tree coverage or Custom content in legacy 0.2 datasets.
129
+
130
+ Returns a set of reason tags, e.g. {"tree", "custom_ext", "custom_token"}.
131
+ Empty set means no 0.2-only violations detected.
132
+ """
133
+ reasons = set()
129
134
  for feat in geojson_data.get("features", []):
130
135
  props = feat.get("properties") or {}
136
+ geom = feat.get("geometry") or {}
137
+ geom_type = geom.get("type") if isinstance(geom, dict) else None
138
+ is_point = isinstance(geom_type, str) and geom_type.lower() == "point"
139
+
131
140
  val = props.get("natural")
132
141
  if isinstance(val, str) and val.strip().lower() in {"tree", "wood"}:
133
- return True
142
+ reasons.add("tree")
134
143
  if any(k in props for k in ("leaf_cycle", "leaf_type")):
135
- return True
144
+ reasons.add("tree")
136
145
  for k, v in props.items():
137
146
  target = ""
138
147
  if isinstance(v, str):
@@ -142,8 +151,8 @@ class OSWValidation:
142
151
  if any(tok in target for tok in ["custom point", "custom_point", "custompoint",
143
152
  "custom line", "custom_line", "customline",
144
153
  "custom polygon", "custom_polygon", "custompolygon"]):
145
- return True
146
- return False
154
+ reasons.add("custom_token")
155
+ return reasons
147
156
 
148
157
  # ----------------------------
149
158
  # Schema selection
@@ -475,9 +484,25 @@ class OSWValidation:
475
484
 
476
485
  schema_url = geojson_data.get('$schema')
477
486
  if isinstance(schema_url, str) and '0.2/schema.json' in schema_url:
478
- if self._contains_disallowed_features_for_02(geojson_data):
487
+ reasons = self._contains_disallowed_features_for_02(geojson_data)
488
+ if reasons:
489
+ dataset_key = self._schema_key_from_text(file_path) or "data"
490
+ custom_label_map = {
491
+ "edges": "Custom Edge",
492
+ "lines": "Custom Line",
493
+ "polygons": "Custom Polygon",
494
+ "zones": "Custom Polygon/Zone",
495
+ "points": "Custom Point",
496
+ "nodes": "Custom Node",
497
+ }
498
+ parts = []
499
+ if "tree" in reasons:
500
+ parts.append("Tree coverage")
501
+ if "custom_ext" in reasons or "custom_token" in reasons:
502
+ parts.append(custom_label_map.get(dataset_key, "Custom content"))
503
+ msg = f"0.2 schema does not support " + " and ".join(parts)
479
504
  self.log_errors(
480
- message="0.2 schema does not support Tree coverage, Custom Point, Custom Line, and Custom Polygon",
505
+ message=msg,
481
506
  filename=os.path.basename(file_path),
482
507
  feature_index=None,
483
508
  )
@@ -98,6 +98,16 @@ class ExtractedDataValidator:
98
98
  gc.collect()
99
99
  return True
100
100
 
101
+ allowed_keys = tuple(OSW_DATASET_FILES.keys())
102
+ unsupported_files = sorted(
103
+ {bn for bn in basenames if not any(key in bn for key in allowed_keys)}
104
+ )
105
+ if unsupported_files:
106
+ allowed_fmt = ", ".join(allowed_keys)
107
+ self.error = (f"Unsupported .geojson files present: {', '.join(unsupported_files)}. "
108
+ f"Allowed file types are {{{allowed_fmt}}}")
109
+ return False
110
+
101
111
  required_files = [key for key, value in OSW_DATASET_FILES.items() if value['required']]
102
112
  optional_files = [key for key, value in OSW_DATASET_FILES.items() if not value['required']]
103
113
  missing_files = []
@@ -308,10 +308,49 @@
308
308
  "required": [
309
309
  "_id",
310
310
  "_u_id",
311
- "_v_id",
312
- "highway"
311
+ "_v_id"
313
312
  ],
314
313
  "anyOf": [
314
+ {
315
+ "title": "CustomEdgeFields",
316
+ "type": "object",
317
+ "additionalProperties": false,
318
+ "properties": {
319
+ "_id": {
320
+ "minLength": 1,
321
+ "type": "string"
322
+ },
323
+ "_u_id": {
324
+ "minLength": 1,
325
+ "type": "string"
326
+ },
327
+ "_v_id": {
328
+ "minLength": 1,
329
+ "type": "string"
330
+ },
331
+ "foot": {
332
+ "description": "A field that indicates whether an edge can be used by pedestrians.",
333
+ "enum": [
334
+ "designated",
335
+ "destination",
336
+ "no",
337
+ "permissive",
338
+ "private",
339
+ "use_sidepath",
340
+ "yes"
341
+ ],
342
+ "type": "string"
343
+ }
344
+ },
345
+ "required": [
346
+ "_id",
347
+ "_u_id",
348
+ "_v_id"
349
+ ],
350
+ "patternProperties": {
351
+ "^ext:.*$": {}
352
+ }
353
+ },
315
354
  {
316
355
  "title": "AlleyFields",
317
356
  "type": "object",
@@ -1895,4 +1934,4 @@
1895
1934
  }
1896
1935
  }
1897
1936
  }
1898
- }
1937
+ }
@@ -196,6 +196,23 @@
196
196
  "_id"
197
197
  ],
198
198
  "anyOf": [
199
+ {
200
+ "title": "CustomNodeFields",
201
+ "type": "object",
202
+ "additionalProperties": false,
203
+ "properties": {
204
+ "_id": {
205
+ "minLength": 1,
206
+ "type": "string"
207
+ }
208
+ },
209
+ "required": [
210
+ "_id"
211
+ ],
212
+ "patternProperties": {
213
+ "^ext:.*$": {}
214
+ }
215
+ },
199
216
  {
200
217
  "title": "BareNodeFields",
201
218
  "type": "object",
@@ -417,4 +434,4 @@
417
434
  }
418
435
  }
419
436
  }
420
- }
437
+ }
@@ -225,10 +225,65 @@
225
225
  },
226
226
  "required": [
227
227
  "_id",
228
- "_w_id",
229
- "highway"
228
+ "_w_id"
230
229
  ],
231
230
  "anyOf": [
231
+ {
232
+ "title": "CustomZoneFields",
233
+ "type": "object",
234
+ "additionalProperties": false,
235
+ "properties": {
236
+ "_id": {
237
+ "minLength": 1,
238
+ "type": "string"
239
+ },
240
+ "_w_id": {
241
+ "items": {
242
+ "type": "string"
243
+ },
244
+ "type": "array"
245
+ },
246
+ "foot": {
247
+ "description": "A field that indicates whether an edge can be used by pedestrians.",
248
+ "enum": [
249
+ "designated",
250
+ "destination",
251
+ "no",
252
+ "permissive",
253
+ "private",
254
+ "use_sidepath",
255
+ "yes"
256
+ ],
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
+ }
278
+ },
279
+ "required": [
280
+ "_id",
281
+ "_w_id"
282
+ ],
283
+ "patternProperties": {
284
+ "^ext:.*$": {}
285
+ }
286
+ },
232
287
  {
233
288
  "title": "PedestrianZoneFields",
234
289
  "type": "object",
@@ -302,4 +357,4 @@
302
357
  }
303
358
  }
304
359
  }
305
- }
360
+ }
@@ -1 +1 @@
1
- __version__ = '0.3.0'
1
+ __version__ = '0.3.2'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_osw_validation
3
- Version: 0.3.0
3
+ Version: 0.3.2
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
@@ -1,17 +1,17 @@
1
- python_osw_validation/__init__.py,sha256=O9APke7GKtH9eg1_v22KIDu3MfR3wspNCg0aoSQCPjM,23599
2
- python_osw_validation/extracted_data_validator.py,sha256=7xy4EGNJvh1zsqOP84tPBV4-ffD9AVzRGIhU_W0SkVE,5690
1
+ python_osw_validation/__init__.py,sha256=qVfuBSSOAKgCzoc5QxNX4sMBKgXda6YPr9kPg0OgdEQ,24708
2
+ python_osw_validation/extracted_data_validator.py,sha256=isTMONOiMHW2sOcNqCOnJETL0g_dd0nHl_yVO2Imc9E,6149
3
3
  python_osw_validation/helpers.py,sha256=afTFF7J14QBWqhxy1pO20Db_EQeWSO2Br5eteiy7xNg,3160
4
- python_osw_validation/version.py,sha256=3wVEs2QD_7OcTlD97cZdCeizd2hUbJJ0GeIO8wQIjrk,22
4
+ python_osw_validation/version.py,sha256=bqu4G7Is-8Were-hMi-SthEalL7QW-PAbKWGZ9pVB6U,22
5
5
  python_osw_validation/zipfile_handler.py,sha256=jXnP-8O5AAOBapuNF3-XdFVM1MHiPaWpl_wlbX-aqhY,2631
6
- python_osw_validation/schema/opensidewalks.edges.schema-0.3.json,sha256=KxxbJy9r8tkeq8VdMBXWXnGzozt-HzgEKCjLxz3po9g,78389
6
+ python_osw_validation/schema/opensidewalks.edges.schema-0.3.json,sha256=Egp--i6ahiUDKY55g_fuv71HkVPtnQN5OW8L_okRa8o,79638
7
7
  python_osw_validation/schema/opensidewalks.lines.schema-0.3.json,sha256=MLfoELBR3DC5Zv7Pa5waoCUCqUBGK7LaX7kcOXJ3DmA,9622
8
- python_osw_validation/schema/opensidewalks.nodes.schema-0.3.json,sha256=KgErEpfJXnrsf4cRiSu-ZT1HU0ivTKjroY_GSPkkWnw,13951
8
+ python_osw_validation/schema/opensidewalks.nodes.schema-0.3.json,sha256=yEv4pIY69YvPHhSiQmvU21HeI426V-Z4j2K7ONQAwLM,14445
9
9
  python_osw_validation/schema/opensidewalks.points.schema-0.3.json,sha256=dIvItG6JbwWnNZCPNYZBblgVmkPfW79KArL3gZsfjZc,13245
10
10
  python_osw_validation/schema/opensidewalks.polygons.schema-0.3.json,sha256=K8KmsXze39hukqWfFYFBMncRNwVo95_xJo1v6IWUk-M,16438
11
11
  python_osw_validation/schema/opensidewalks.schema-0.3.json,sha256=Yq8WyvUEr_0nxfSSLFlGYc7vMQeKL6yS1qjltq-5JPk,204728
12
- python_osw_validation/schema/opensidewalks.zones.schema-0.3.json,sha256=4mPMegZhQv9iyQqeylSqI4Z06o3W3mpl3Gn62_Kwy_4,9393
13
- python_osw_validation-0.3.0.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
14
- python_osw_validation-0.3.0.dist-info/METADATA,sha256=R2YMkn9q7KVberUcYKs5ubHqnm4sfePAZW-iWTf3f5c,7540
15
- python_osw_validation-0.3.0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
16
- python_osw_validation-0.3.0.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
17
- python_osw_validation-0.3.0.dist-info/RECORD,,
12
+ python_osw_validation/schema/opensidewalks.zones.schema-0.3.json,sha256=JCqoCJj-dCuPVPHWSUQhRJMebaJ9IrzHWwTVAC6j7dY,11281
13
+ python_osw_validation-0.3.2.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
14
+ python_osw_validation-0.3.2.dist-info/METADATA,sha256=gKRCQhhKS03o43bkVvTrgThAn4g0nir2lpNLgvHGMQo,7540
15
+ python_osw_validation-0.3.2.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
16
+ python_osw_validation-0.3.2.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
17
+ python_osw_validation-0.3.2.dist-info/RECORD,,