OSW Sanitizer
osw-sanitizer is a Python package for sanitizing OpenSidewalks (OSW)
dataset ZIP files. It is designed to be consumed by the TDEI sanitization
service and by other Python workflows that need the same deterministic cleanup
behavior.
Features
- Removes JSON
nulland numericNaNproperty values. - Preserves string values such as
"None","null","nan","n/a", and"na". - Truncates geometry coordinates to a configurable precision.
- Removes unsupported non-OSW files from sanitized output.
- Removes zero-length edge
LineStringfeatures unless explicitly allowed. - Splits edge
LineStringfeatures that exceed the configured geometry vertex limit. - Generates intermediate split nodes and rewires
_u_id/_v_idreferences when needed. - Writes a
fixes.jsonartifact describing every applied change.
Polygon splitting is intentionally out of scope.
Installation
pip install osw-sanitizer
For local development:
python -m pip install -e .
python -m pip install pytest coverage
Quick Start
from osw_sanitizer import OSWSanitization, SanitizationConfig
config = SanitizationConfig(
coordinate_precision=7,
max_geometry_vertices=2000,
allow_zero_length_lines=False,
)
sanitizer = OSWSanitization(
input_path="/path/to/input.zip",
output_dir="/path/to/output",
config=config,
)
result = sanitizer.sanitize()
if result.success:
print(result.updated_dataset_zip)
print(result.fixes_json)
else:
print(result.message)
Service-Compatible API
OSWSanitization.sanitize_dataset(...) returns a dictionary with the same keys
used by TDEI-sanitization-service:
from osw_sanitizer import OSWSanitization
result = OSWSanitization.sanitize_dataset(
input_zip_path="/path/to/input.zip",
output_dir="/path/to/output",
)
print(result["success"])
print(result["updated_dataset_zip"])
print(result["fixes_json"])
Configuration
| Option | Default | Description |
|---|---|---|
coordinate_precision |
7 |
Maximum decimal places retained for coordinate values. |
max_geometry_vertices |
2000 |
Splits edge LineString features with more vertices than this value. |
allow_zero_length_lines |
False |
Preserves zero-length edge LineString features when True; otherwise they are removed. |
The configuration names match the OSW formatter and validator packages where applicable.
Output Artifacts
The sanitizer writes two artifacts into output_dir:
- A sanitized dataset ZIP using the same filename as the input ZIP.
fixes.json, containing structured details about applied fixes.
The result object exposes both paths:
result.updated_dataset_zip
result.fixes_json
fixes.json
fixes.json includes:
removedTagsprecisionUpdatesremovedEdgessplitEdgesaddedNodesremovedFiles
Example:
{
"jobId": "",
"files": [
{
"filename": "edges.geojson",
"removedTags": [
{
"featureIndex": 0,
"tag": "width",
"value": null
}
],
"precisionUpdates": [
{
"featureIndex": 0,
"coordinatePath": "coordinates[0]",
"original": "-122.123456789",
"updated": "-122.1234567",
"precision": 7
}
]
}
],
"removedFiles": []
}
Supported Dataset Files
The sanitizer keeps OSW dataset files matching these dataset keys:
edgeslinesnodespointspolygonszones
Supported filename forms include:
<dataset>.geojson<dataset>.OSW.geojson*.<dataset>.geojson*.<dataset>.OSW.geojson
Unsupported files are omitted from sanitized output and recorded in
fixes.json.
Testing
Install the package and test dependencies:
python -m pip install -e .
python -m pip install pytest coverage
Run the unit tests:
python -m pytest
Run the unit tests with coverage enforcement:
coverage run -m pytest
coverage report --fail-under=90
The GitHub Actions unit test workflow writes timestamped test and coverage
logs into test_results/ and uploads them to Azure Blob Storage using the
AZURE_STORAGE_CONNECTION_STRING secret.
Package metadata is defined in pyproject.toml. setup.py is retained as a
compatibility shim for legacy packaging workflows.
Release Pipelines
GitHub Actions includes package publishing workflows:
.github/workflows/deploy_to_test.ymlpublishes to TestPyPI fromdevelop..github/workflows/publish_to_pypi.ymlpublishes to PyPI from semver tags or manual dispatch.
Both workflows build the package from pyproject.toml and use
PYPI_API_TOKEN for authentication.
Test Datasets
Sample dataset ZIPs are checked in under tests/assets and are used by the
unit tests:
precision_and_null_tags.zipzero_length_edge.zipoversized_edge.zipunsupported_files.zipnested_dataset.zip
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file osw_sanitizer-0.1.1.tar.gz.
File metadata
- Download URL: osw_sanitizer-0.1.1.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79e3afc511ddaa26b195a58d106a2e605081b58565f3b607bd30a17ce35b8c00
|
|
| MD5 |
c3efb0343411deae5fbf73126240a1b3
|
|
| BLAKE2b-256 |
46402a9e9e09d3125bf9a5e74bc1134205057f5eff592b469a48603df146c8b7
|
File details
Details for the file osw_sanitizer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: osw_sanitizer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5c93246e3449d072d4ca503cc52dd2d0954e2b0a9ef6eded5742d02b319a9d9
|
|
| MD5 |
78475eb7586d36627019d78e259f8906
|
|
| BLAKE2b-256 |
35a12d2fda360b186159eceafbf7eee6d624e8e54849fcf8227dcac16ab32650
|