This project provides utilities for working with the OpenSidewalks (OSW) schema:
- Parsing the canonical
opensidewalks.schema.jsoninto grouped definitions. - Building specialized JSON Schemas for LineString, Point, and Polygon/MultiPolygon features.
- Generating valid and invalid sample GeoJSON files from the schema.
- Validating GeoJSON feature collections against the generated schemas.
Node.js (Schema & Sample Generation)
# Install dependencies
npm installPython (Validation)
# Create venv (recommended)
python3 -m venv .venv
source .venv/bin/activate
# Install requirements
pip install -r requirements.txtParses opensidewalks.schema.json into grouped schemas and writes results into output/.
node scripts/parse-osw-schema.jsThis produces:
output/results.json(expanded schema entries)output/lineSchema.jsonoutput/pointsSchema.jsonoutput/PolygonSchema.json
example.js demonstrates creating valid and invalid sample files:
node example.jsOutputs:
my_valid.geojsonmy_invalid.geojson
You can adjust:
- Number of features (
numFeatures) - Output filenames (
validOut,invalidOut) - Random seed (
seed) - Feature types (
Line,Point,Polygonarrays)
Validate a file against a schema using the high-performance Rust-backed jsonschema-rs:
python test.py- By default, uses
output/lineSchema.jsonandmy_valid.geojson. - Edit
test.pyto switch toPOINT_SCHEMA,POLY_SCHEMA, orINVALID_FILE.
The output is a JSON array of errors:
[
{ "featureIndex": 0, "error": "missing '_id'" },
{ "featureIndex": 2, "error": "\"bench\" is not one of \"lamp\", \"hydrant\"" }
]RENAME_MAPin JS scripts allows renaming schema keys (e.g.,_id → id).DISCRIMINATORSdefines tags (highway,amenity,building, etc.) used for property dependencies.META_KEYSlists common fields (e.g.,name) that skip dependency checks.test.pyprefers root-cause errors (enum,type,required) and collapses noisy cascades.
-
Parse the OSW schema:
node scripts/parse-osw-schema.js
-
Generate sample GeoJSON files:
node example.js
-
Validate the generated files:
python test.py