Conversation
## Changes Adds `max_geometry_vertices` to `FormatterConfig`, defaulting to 2000 to match `python-osw-validation`. One setting drives both places the limit matters. **Validation.** The limit reaches the validator for OSW input and for the OSW generated by OSM → OSW, so a line or polygon feature carrying more vertices is reported with the validator's own message: ``` Feature 'e1' in 'edges.geojson' contains 2001 geometry vertices. Maximum allowed is 2000. ``` Scope and counting are the validator's: `edges`, `lines`, `polygons` and `zones`; points and nodes unaffected; polygon vertices summed across exterior and interior rings with the closing coordinate excluded. **Way splitting.** The same setting is passed to `ogr2osm` as `max_points_in_way`, raising its split point from the 1800 default. A run of coordinates too long for a single OSM way becomes several ways sharing a node, so the pieces stay joined. Splitting still applies to input the validator accepts, because the two count different things: the validator counts unique vertices and ignores a ring's closing coordinate, while an OSM way counts every node reference. A ring of exactly 2000 unique vertices is valid, yet needs 2001 references and cannot be one way. `max_vertices_ok.zip` is exactly this case — valid input that still splits. Lowering the limit tightens both at once: input validation gets stricter and ways split sooner. ## Notes for review Two things were already implemented and are not reimplemented here: - `python-osw-validation` already enforces the whole rule — counting, ring-closure exclusion, multipart summation, dataset scope, message text, `errors` + `issues`, `max_errors`. All of it already held at the default; the only gap was that it was not reachable from `FormatterConfig`. - `ogr2osm` already splits long ways with the same shared-node algorithm, and handles ways inside relations. An earlier hand-rolled splitter was removed in favour of configuring the library. ## Behaviour change Ways now split at 2000 nodes rather than ogr2osm's 1800, so conversions produce slightly fewer, longer ways than before. No API removed. ## Testing 340 tests pass. 24 new tests cover the boundary (1999 / 2000 / 2001), lines, polygons, interior rings, closing-coordinate exclusion, point datasets being unaffected, issue contents, `max_errors`, configurability, and splitting. End-to-end, with every conversion output handed back to the validator: - All 19 fixtures round-tripped; every one that converts produces **valid** OSW, and the five intended-failure fixtures are rejected as expected. - The split round trip preserves the data — 1 edge, 1 line, 1 zone, 1 polygon in and out, validator clean. - Real datasets validate: `wa.microsoft.osm.pbf` (4369 edges), `test_roundtrip.zip` (451 edges), `osw.zip` (4407 edges), `dataset_with_incline.zip`. Four fixtures added — `max_vertices_ok.zip`, `max_vertices_exceeded.zip`, `max_vertices_way_ok.xml`, `max_vertices_way_exceeded.xml`.
MashB
approved these changes
Aug 12, 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.
Changes
Adds
max_geometry_verticestoFormatterConfig, defaulting to 2000 to matchpython-osw-validation. One setting drives both places the limit matters.Validation. The limit reaches the validator for OSW input and for the OSW generated by OSM → OSW, so a line or polygon feature carrying more vertices is reported with the validator's own message:
Scope and counting are the validator's:
edges,lines,polygonsandzones; points and nodes unaffected; polygon vertices summed across exterior and interior rings with the closing coordinate excluded.Way splitting. The same setting is passed to
ogr2osmasmax_points_in_way, raising its split point from the 1800 default. A run of coordinates too long for a single OSM way becomes several ways sharing a node, so the pieces stay joined.Splitting still applies to input the validator accepts, because the two count different things: the validator counts unique vertices and ignores a ring's closing coordinate, while an OSM way counts every node reference. A ring of exactly 2000 unique vertices is valid, yet needs 2001 references and cannot be one way.
max_vertices_ok.zipis exactly this case — valid input that still splits.Lowering the limit tightens both at once: input validation gets stricter and ways split sooner.
Notes for review
Two things were already implemented and are not reimplemented here:
python-osw-validationalready enforces the whole rule — counting, ring-closure exclusion, multipart summation, dataset scope, message text,errors+issues,max_errors. All of it already held at the default; the only gap was that it was not reachable fromFormatterConfig.ogr2osmalready splits long ways with the same shared-node algorithm, and handles ways inside relations. An earlier hand-rolled splitter was removed in favour of configuring the library.Behaviour change
Ways now split at 2000 nodes rather than ogr2osm's 1800, so conversions produce slightly fewer, longer ways than before. No API removed.
Testing
340 tests pass. 24 new tests cover the boundary (1999 / 2000 / 2001), lines, polygons, interior rings, closing-coordinate exclusion, point datasets being unaffected, issue contents,
max_errors, configurability, and splitting.End-to-end, with every conversion output handed back to the validator:
wa.microsoft.osm.pbf(4369 edges),test_roundtrip.zip(451 edges),osw.zip(4407 edges),dataset_with_incline.zip.Four fixtures added —
max_vertices_ok.zip,max_vertices_exceeded.zip,max_vertices_way_ok.xml,max_vertices_way_exceeded.xml.