This package validates OSW GeoJSON datasets packaged as a ZIP file.
| Software | Version |
|---|---|
| Python | >= 3.10 |
- Extracts the provided ZIP file
- Finds supported OSW dataset files inside the extracted directory
- Validates each file (
edges,lines,nodes,points,polygons, andzones) against the matching schema - Runs cross-file integrity checks such as duplicate
_iddetection and edge or zone references back to nodes - Returns a
ValidationResultobject withis_valid,errors, andissues
Any subset of the six supported dataset files may be present. By default, no individual dataset file is required.
- Add
python-osw-validationpackage as dependency in yourrequirements.txt - or
pip install python-osw-validation - Start using the packages in your code.
from python_osw_validation import OSWValidation
validator = OSWValidation(zipfile_path='<Zip file path>')
result = validator.validate()
print(result.is_valid)
print(result.errors) # returns up to the first 20 high-level errors by default
print(result.issues) # per-file or per-feature issues
result = validator.validate(max_errors=10)
print(result.is_valid)
print(result.errors) # returns up to the first 10 high-level errorsYou can also override schemas:
from python_osw_validation import OSWValidation
validator = OSWValidation(
zipfile_path='<Zip file path>',
schema_paths={
'nodes': 'path/to/opensidewalks.nodes.schema-0.3.json',
'edges': 'path/to/opensidewalks.edges.schema-0.3.json',
},
)The validator accepts dataset files whose names end with one of these exact suffixes:
.edges.geojson.lines.geojson.nodes.geojson.points.geojson.polygons.geojson.zones.geojson
It also accepts the legacy form:
.edges.OSW.geojson.lines.OSW.geojson.nodes.OSW.geojson.points.OSW.geojson.polygons.OSW.geojson.zones.OSW.geojson
Examples:
gs_metaline_falls_uga.nodes.geojsonis validgs_yarrow_point.edges.geojsonis validroadEdges.geojsonis invalid
If a dataset uses canonical OSW 0.3 names that start with opensidewalks., then only these exact names are allowed:
opensidewalks.edges.geojsonopensidewalks.lines.geojsonopensidewalks.nodes.geojsonopensidewalks.points.geojsonopensidewalks.polygons.geojsonopensidewalks.zones.geojson
All unit tests are under tests/unit_tests.
-
To execute the tests:
pip install -r requirements.txtpython -m unittest discover -v tests/unit_tests -
To execute code coverage:
coverage run --source=src/python_osw_validation -m unittest discover -v tests/unit_testscoverage htmlcoverage report
After running coverage, open htmlcov/index.html to inspect the report in a browser.
To use the library locally, use the example.py code
- On every push to
devbranch, a workflow is triggered which publishes the updated version to TestPyPI
- This happens whenever a tag or release is created with
*.*.*notation, for example0.0.8 - To change the version, update version.py
- To release a new version:
- Go to the GitHub repository
- Under releases, click on
Draft a new release - Under
choose a new tag, add a new tagv*.*.*, then generate release notes - Choose
mainbranch for release - Publish the release.
- This release triggers a workflow to generate the new package version.
- The new package will be available at https://pypi.org/project/python-osw-validation/