Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/geometry/polygon_assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,39 +384,6 @@ mod tests {
}
}

/// An inner ring that touches the outer ring at exactly two points
/// (not along an overlapping edge, not crossing) so removing it splits
/// the outer into two disjoint pieces rather than leaving one polygon
/// with a hole. Mirrors `geometry_multipolygon/8` from `nimix/osm_conv_tests`
/// (2012, unlicensed, not vendored here -- we only inspected it to see
/// whether it had any test cases `osm-testdata`'s vendored `grid`
/// fixtures lack). `grid` covers a single-point inner/outer touch
/// (`7/754`-`7/758`) and touching along a shared line (`7/756`,
/// `7/757`), but not this two-point-touch-splits-the-outer-in-two
/// case, so this test closes that one gap directly in our own suite.
#[test]
fn inner_touching_outer_at_two_points_splits_it_into_two_pieces() {
let mut a = PolygonAssembler::new();
// Outer: a rectangle with redundant midpoints on its top and
// bottom edges -- the exact points the inner ring below touches.
a.add_ring(&ring(&[
(0.0, 0.0),
(2.0, 0.0), // bottom midpoint, shared with the inner ring
(4.0, 0.0),
(4.0, 2.0),
(2.0, 2.0), // top midpoint, shared with the inner ring
(0.0, 2.0),
]));
// Inner: a diamond whose top and bottom vertices land exactly on
// the outer's midpoints above, touching but never crossing.
a.add_ring(&ring(&[(2.0, 2.0), (1.0, 1.0), (2.0, 0.0), (3.0, 1.0)]));

match a.finish() {
Some(Geometry::MultiPolygon(mp)) => assert_eq!(mp.0.len(), 2),
other => panic!("expected the outer split into two pieces, got {other:?}"),
}
}

/// https://github.com/alltheplaces/osm-diffs/issues/532, mirroring
/// grid fixture `7/790`: a ring added twice (the same OSM way listed
/// twice as a member) must not cancel itself out under the even-odd
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data/osm-testdata-grid/VENDORED.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Source: https://github.com/osmcode/osm-testdata
Path: grid/data/
Commit: ecfdeb0d5ffcfcb60939651d517d5d7d1bb041a3
Vendored on: 2026-08-06
Commit: 98a9b32aafe8798523d8b3819c33199eee6d5687
Vendored on: 2026-08-29
License: Public domain (per upstream README: "All files are released
into the public domain.")
Used only for tests; not part of any shipped artifact.
39 changes: 39 additions & 0 deletions tests/test_data/osm-testdata-grid/data/7/769/data.osm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version='1.0' encoding='UTF-8'?>
<osm version="0.6" generator="testdata" upload="false">
<node id="769000" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.92" lat="1.62"/>
<node id="769001" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.95" lat="1.62"/>
<node id="769002" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.98" lat="1.62"/>
<node id="769003" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.98" lat="1.68"/>
<node id="769004" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.95" lat="1.68"/>
<node id="769005" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.92" lat="1.68"/>
<node id="769006" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.93" lat="1.65"/>
<node id="769007" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.97" lat="1.65"/>
<way id="769800" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1">
<nd ref="769000"/>
<nd ref="769001"/>
<nd ref="769002"/>
<nd ref="769003"/>
<nd ref="769004"/>
<nd ref="769005"/>
<nd ref="769000"/>
<tag k="test:section" v="mp-geom"/>
<tag k="test:id" v="769"/>
</way>
<way id="769801" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1">
<nd ref="769004"/>
<nd ref="769006"/>
<nd ref="769001"/>
<nd ref="769007"/>
<nd ref="769004"/>
<tag k="test:section" v="mp-geom"/>
<tag k="test:id" v="769"/>
</way>
<relation id="769900" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1">
<member type="way" ref="769801" role="inner"/>
<member type="way" ref="769800" role="outer"/>
<tag k="type" v="multipolygon"/>
<tag k="test:section" v="mp-geom"/>
<tag k="test:id" v="769"/>
<tag k="landuse" v="forest"/>
</relation>
</osm>
8 changes: 8 additions & 0 deletions tests/test_data/osm-testdata-grid/data/7/769/nodes.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
769000 POINT(7.92 1.62)
769001 POINT(7.95 1.62)
769002 POINT(7.98 1.62)
769003 POINT(7.98 1.68)
769004 POINT(7.95 1.68)
769005 POINT(7.92 1.68)
769006 POINT(7.93 1.65)
769007 POINT(7.97 1.65)
1 change: 1 addition & 0 deletions tests/test_data/osm-testdata-grid/data/7/769/result
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
valid
18 changes: 18 additions & 0 deletions tests/test_data/osm-testdata-grid/data/7/769/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"test_id": 769,
"description": "Multipolygon with one outer and one inner ring, inner touching outer in two nodes, splitting the outer into two components.",
"areas": {
"default": [
{
"from_id": 769900,
"from_type": "relation",
"wkt": "MULTIPOLYGON(((7.92 1.62,7.95 1.62,7.93 1.65,7.95 1.68,7.92 1.68,7.92 1.62)),((7.95 1.62,7.98 1.62,7.98 1.68,7.95 1.68,7.97 1.65,7.95 1.62)))",
"tags": {
"landuse": "forest",
"test:section": "mp-geom",
"test:id": "769"
}
}
]
}
}
2 changes: 2 additions & 0 deletions tests/test_data/osm-testdata-grid/data/7/769/ways.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
769800 LINESTRING(7.92 1.62,7.95 1.62,7.98 1.62,7.98 1.68,7.95 1.68,7.92 1.68,7.92 1.62)
769801 LINESTRING(7.95 1.68,7.93 1.65,7.95 1.62,7.97 1.65,7.95 1.68)
36 changes: 36 additions & 0 deletions tests/test_data/osm-testdata-grid/data/all.osm
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,14 @@
<node id="768004" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.87" lat="1.64"/>
<node id="768005" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.87" lat="1.61"/>
<node id="768006" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.84" lat="1.62"/>
<node id="769000" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.92" lat="1.62"/>
<node id="769001" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.95" lat="1.62"/>
<node id="769002" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.98" lat="1.62"/>
<node id="769003" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.98" lat="1.68"/>
<node id="769004" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.95" lat="1.68"/>
<node id="769005" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.92" lat="1.68"/>
<node id="769006" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.93" lat="1.65"/>
<node id="769007" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.97" lat="1.65"/>
<node id="770000" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.06" lat="1.72"/>
<node id="770001" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.02" lat="1.72"/>
<node id="770002" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1" lon="7.02" lat="1.74"/>
Expand Down Expand Up @@ -2367,6 +2375,26 @@
<tag k="test:id" v="768"/>
<tag k="area" v="yes"/>
</way>
<way id="769800" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1">
<nd ref="769000"/>
<nd ref="769001"/>
<nd ref="769002"/>
<nd ref="769003"/>
<nd ref="769004"/>
<nd ref="769005"/>
<nd ref="769000"/>
<tag k="test:section" v="mp-geom"/>
<tag k="test:id" v="769"/>
</way>
<way id="769801" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1">
<nd ref="769004"/>
<nd ref="769006"/>
<nd ref="769001"/>
<nd ref="769007"/>
<nd ref="769004"/>
<tag k="test:section" v="mp-geom"/>
<tag k="test:id" v="769"/>
</way>
<way id="770800" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1">
<nd ref="770000"/>
<nd ref="770001"/>
Expand Down Expand Up @@ -3755,6 +3783,14 @@
<tag k="test:id" v="768"/>
<tag k="landuse" v="forest"/>
</relation>
<relation id="769900" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1">
<member type="way" ref="769801" role="inner"/>
<member type="way" ref="769800" role="outer"/>
<tag k="type" v="multipolygon"/>
<tag k="test:section" v="mp-geom"/>
<tag k="test:id" v="769"/>
<tag k="landuse" v="forest"/>
</relation>
<relation id="770900" version="1" timestamp="2014-01-01T00:00:00Z" uid="1" user="test" changeset="1">
<member type="way" ref="770800" role="outer"/>
<member type="way" ref="770801" role="outer"/>
Expand Down
18 changes: 18 additions & 0 deletions tests/test_data/osm-testdata-grid/data/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,24 @@
]
}
},
{
"test_id": 769,
"description": "Multipolygon with one outer and one inner ring, inner touching outer in two nodes, splitting the outer into two components.",
"areas": {
"default": [
{
"from_id": 769900,
"from_type": "relation",
"wkt": "MULTIPOLYGON(((7.92 1.62,7.95 1.62,7.93 1.65,7.95 1.68,7.92 1.68,7.92 1.62)),((7.95 1.62,7.98 1.62,7.98 1.68,7.95 1.68,7.97 1.65,7.95 1.62)))",
"tags": {
"landuse": "forest",
"test:section": "mp-geom",
"test:id": "769"
}
}
]
}
},
{
"test_id": 770,
"description": "Multipolygon with two outer rings touching in single node.",
Expand Down
Loading