Merged
Conversation
… co-located nodes, remove warnings ## PR summary ## What Adds validation at both ends of conversion, fixes how degenerate and co-located geometry is carried between formats, and removes the warning subsystem. ### Validation - **OSW input** is validated with `python-osw-validation` before OSW→OSM starts. Rejected input returns `status=False` with the validator's per-feature `issues`, each naming the file and feature index; repeated messages are collapsed. - **OSW output** is validated before OSM→OSW reports success, using the same settings that produced it. - **OSM input** is rejected when any node coordinate carries more decimal places than `coordinate_precision`, for both XML and PBF. No tolerance: one digit over the limit is rejected. Coordinates are read as exact decimal strings, never floats. - `coordinate_precision` and `allow_zero_length_lines` are passed to the validator, so input, output and conversion are judged by one set of rules. ### Error messages - A corrupt OSM file returns `invalid input file, the OSM file is corrupted and could not be read. The problem is at line N, column M.` instead of printing a traceback and surfacing raw parser text. Reads identically whether the failure surfaces during validation or during conversion. - Unreadable OSW archives (missing, not a zip, no `.geojson` inside) are reported in plain language rather than OS error numbers, and echo only the file name — previously the caller's absolute path leaked into the message. ### Geometry - **Zero-length edges** survive both directions when `allow_zero_length_lines` is set: OSW `e1 = (n0, n0)` becomes OSM `w1 = [n0, n0]`, and back again. With the setting off they collapse to a single point. Required two fixes — restoring the `nd` ref ogr2osm drops from a single-node way, and a self-loop guard in `OSMGraph.simplify()` that was splicing the node into its own way and deleting both. - **Co-located points are no longer merged.** Two OSW point features at one coordinate stay two OSM nodes even with identical tags. Way vertices still merge onto node features, so edges stay connected and kerb nodes stay attached. - **Edge endpoints are restored from `_u_id`/`_v_id`.** ogr2osm resolves way vertices by coordinate, so an edge between two co-located nodes collapsed onto whichever node was created first. The references are recorded while features are read and applied before renumbering. ## Breaking changes - `Response.warnings` and `helpers/warnings.py` are removed. Callers reading `response.warnings` will get an `AttributeError`. Coordinate precision is now enforced at the input gate rather than reported after the fact. - `allow_zero_length_lines` now defaults to `True`, matching the validator default. Set it to `False` for the previous behaviour. New config: `validate_input` and `validate_output`, both defaulting to `True`, each with a `Formatter(...)` kwarg to opt out. ## Testing 311 tests pass. Every OSM fixture in the repo was run through conversion and its output validated before enabling output validation by default — all compliant, so no existing test needed changing. 15 fixtures added, tracked under `tests/unit_tests/test_files/input_validation/`, covering valid and invalid OSW and OSM input, corrupt XML, non-standard tags, duplicate points, and six zero-length scenarios across both directions.
[0.4.0] validate OSW input and output, preserve zero-length edges and co-located nodes, remove warnings
shweta2101
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
Adds validation at both ends of conversion, fixes how degenerate and co-located geometry is carried between formats, and removes the warning subsystem.
Validation
python-osw-validationbefore OSW→OSM starts. Rejected input returnsstatus=Falsewith the validator's per-featureissues, each naming the file and feature index; repeated messages are collapsed.coordinate_precision, for both XML and PBF. No tolerance: one digit over the limit is rejected. Coordinates are read as exact decimal strings, never floats.coordinate_precisionandallow_zero_length_linesare passed to the validator, so input, output and conversion are judged by one set of rules.Error messages
invalid input file, the OSM file is corrupted and could not be read. The problem is at line N, column M.instead of printing a traceback and surfacing raw parser text. Reads identically whether the failure surfaces during validation or during conversion..geojsoninside) are reported in plain language rather than OS error numbers, and echo only the file name — previously the caller's absolute path leaked into the message.Geometry
allow_zero_length_linesis set: OSWe1 = (n0, n0)becomes OSMw1 = [n0, n0], and back again. With the setting off they collapse to a single point. Required two fixes — restoring thendref ogr2osm drops from a single-node way, and a self-loop guard inOSMGraph.simplify()that was splicing the node into its own way and deleting both._u_id/_v_id. ogr2osm resolves way vertices by coordinate, so an edge between two co-located nodes collapsed onto whichever node was created first. The references are recorded while features are read and applied before renumbering.Breaking changes
Response.warningsandhelpers/warnings.pyare removed. Callers readingresponse.warningswill get anAttributeError. Coordinate precision is now enforced at the input gate rather than reported after the fact.allow_zero_length_linesnow defaults toTrue, matching the validator default. Set it toFalsefor the previous behaviour.New config:
validate_inputandvalidate_output, both defaulting toTrue, each with aFormatter(...)kwarg to opt out.Testing
311 tests pass. Every OSM fixture in the repo was run through conversion and its output validated before enabling output validation by default — all compliant, so no existing test needed changing.