union_ of two valid polygons sharing an edge returns empty (argument order dependent)
Maintainers usually reply within 2 days
Assessment
This issue has not been assessed yet.
Description
Two valid, non-overlapping cartesian polygons that share one edge. union_(a, b) and union_(b, a) should both return one polygon with area(a) + area(b). With union_(b, a) the result is empty on all versions I tried, including develop.
The vertices of a along the shared side are nearly collinear (the shared edge lies on a line through three of them). The data comes from a land cover coverage after ST_CoverageSimplify (GEOS); GEOS computes the union correctly.
#include <boost/geometry.hpp>
#include <iostream>
namespace bg = boost::geometry;
typedef bg::model::d2::point_xy<double> Point;
typedef bg::model::polygon<Point> Polygon;
typedef bg::model::multi_polygon<Polygon> MultiPolygon;
int main() {
MultiPolygon a, b, u1, u2;
bg::read_wkt("MULTIPOLYGON(((7.5766965679702691 55.1955384390566266,7.5769710638206007 55.1955418668735760,"
"7.5776907371234223 55.1955508539257096,7.5777041477885838 55.1955510213938609,"
"7.5724506758568699 55.1833987553893692,7.5766965679702691 55.1955384390566266)))", a);
bg::read_wkt("MULTIPOLYGON(((7.5776907371234223 55.1955508539257096,7.5769710638206007 55.1955418668735760,"
"7.5786734102424926 55.1979584470965179,7.5776907371234223 55.1955508539257096)))", b);
bg::correct(a); bg::correct(b);
bg::union_(a, b, u1);
bg::union_(b, a, u2);
std::cout << "valid " << bg::is_valid(a) << bg::is_valid(b)
<< ", area a+b " << bg::area(a) + bg::area(b)
<< ", union(a,b) " << u1.size() << " polygon(s) area " << bg::area(u1)
<< ", union(b,a) " << u2.size() << " polygon(s) area " << bg::area(u2) << "\n";
}
| Boost.Geometry | union(a, b) | union(b, a) |
|---|---|---|
| 1.83 | 1 polygon, area of a only (b dropped) |
empty |
1.83 with BOOST_GEOMETRY_USE_RESCALING |
correct | correct |
| 1.87 | b dropped |
empty |
| 1.89, 1.92 | correct | empty |
| develop (fd21a751b2, 2026-11-04) | correct | empty |
Expected area: 6.951063106e-06 (a: 6.089138509e-06, b: 8.619245973e-07, intersection area 0).
Compiled with g++ 14.2, -O2 -std=c++17 (newer versions: Boost.Geometry and Boost.Core headers of that tag, rest of Boost 1.83).
Context: tilemaker combines adjacent polygons of the same class with union_ (binary reduction). On a land cover coverage this drops whole polygons; on OpenStreetMap land use data it happens rarely (2 cases in an extract of Denmark).
- Dominant language
- C++
- Stars
- 519
- Forks
- 241
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/geometry
-
Difficulty 4/5 3-5 days Newbie friendliness 57/100
boostorg/geometry#1523 · 3 comments ·
Maintainers usually reply within 2 days
-
LLM generated regression case in differencePossibly taken @barendgehrels claimed this 14 days ago. Openbug
boostorg/geometry#1511 · 1 reaction · 1 assignee ·
Maintainers usually reply within 2 days
-
difference() produces invalid (self-intersecting) result for valid polygon-with-hole inputMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 70/100
boostorg/geometry#1490 · 1 comment · 1 reaction ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
boostorg/geometry#1476 · 6 comments ·
Maintainers usually reply within 2 days
-
I cannot get Dissolve to compile in version 1.91May be free again @barendgehrels claimed this 162 days ago, and no pull request is open. Open
boostorg/geometry#1472 · 8 comments · 1 assignee ·
Maintainers usually reply within 2 days
All issues in boostorg/geometry
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
uxlfoundation/oneDNN#6604 · 1 comment ·
Maintainers usually reply within 2 days
-
[Bug]: RoundToNearest truncates in plugins compiled with spcomp 1.13Possibly taken @fmu1337 claimed this today. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
alliedmodders/sourcemod#2627 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
lballabio/QuantLib#3134 · 1 comment ·
Maintainers usually reply within 3 days
-
new issue
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
llvm/llvm-project#245835 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 72/100
EchoTools/nevr-runtime#2823 ·
Maintainers usually reply within 1 day