Skip to content

Commit b1bebca

Browse files
committed
[union] fix issue 1100
1 parent 94f5c0e commit b1bebca

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

doc/release_notes.qbk

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919

2020
[section:release_notes Release Notes]
2121

22+
[/=================]
23+
[heading Boost 1.83]
24+
[/=================]
25+
26+
[*Major improvements]
27+
28+
[*Improvements]
29+
30+
[*Solved issues]
31+
32+
* [@https://github.com/boostorg/geometry/issues/1100 1100] Fix for union
33+
34+
[*Breaking changes]
35+
2236
[/=================]
2337
[heading Boost 1.82]
2438
[/=================]

include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ struct touch : public base_turn_handler
557557
>
558558
static inline bool handle_imperfect_touch(UniqueSubRange1 const& range_p,
559559
UniqueSubRange2 const& range_q,
560+
int side_pk_q2,
560561
UmbrellaStrategy const& umbrella_strategy,
561562
TurnInfo& ti)
562563
{
@@ -595,10 +596,11 @@ struct touch : public base_turn_handler
595596
return d1.measure > 0 && d2.measure > 0;
596597
};
597598

598-
if (has_distance(range_p, range_q))
599+
if (side_pk_q2 == -1 && has_distance(range_p, range_q))
599600
{
600601
// Even though there is a touch, Q(j) is left of P1
601602
// and P(i) is still left from Q2.
603+
// Q continues to the right.
602604
// It can continue.
603605
ti.operations[0].operation = operation_blocked;
604606
// Q turns right -> union (both independent),
@@ -608,14 +610,11 @@ struct touch : public base_turn_handler
608610
return true;
609611
}
610612

611-
if (has_distance(range_q, range_p))
613+
if (side_pk_q2 == 1 && has_distance(range_q, range_p))
612614
{
613-
// Even though there is a touch, Q(j) is left of P1
614-
// and P(i) is still left from Q2.
615-
// It can continue.
615+
// Similarly, but the other way round.
616+
// Q continues to the left.
616617
ti.operations[0].operation = operation_union;
617-
// Q turns right -> union (both independent),
618-
// Q turns left -> intersection
619618
ti.operations[1].operation = operation_blocked;
620619
ti.touch_only = true;
621620
return true;
@@ -676,8 +675,8 @@ struct touch : public base_turn_handler
676675
|| (side_qi_p1 == 0 && side_qk_p1 == 0 && side_pk_p != -1))
677676
{
678677
if (side_qk_p1 == 0 && side_pk_q1 == 0
679-
&& has_qk && has_qk
680-
&& handle_imperfect_touch(range_p, range_q, umbrella_strategy, ti))
678+
&& has_pk && has_qk
679+
&& handle_imperfect_touch(range_p, range_q, side_pk_q2, umbrella_strategy, ti))
681680
{
682681
// If q continues collinearly (opposite) with p, it should be blocked
683682
// but (FP) not if there is just a tiny space in between

test/algorithms/overlay/overlay_cases.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,12 @@ static std::string issue_1081c[2] =
11011101
"POLYGON((423.217316892426425 67.5751428875900331,414.40388971336813 96.7777620478938587,410.429206867910466 100.02249750988706,412.848579034710781 101.010025694314706,412.502954439453561 102.98508206238165,416.996074177797027 109.05132662251431,427.364812035512671 72.6538592632950468,423.217316892426425 67.5751428875900331))"
11021102
};
11031103

1104+
static std::string issue_1100[2] =
1105+
{
1106+
"POLYGON((1.5300545419548890819e-16 2101,1 2101,1 2100,1.1102230246251565404e-16 2100,1.5300545419548890819e-16 2101))",
1107+
"POLYGON((-0.19761611601674899941 2101,0 2100.6135231738085167,0 2100,-0.5 2100,-0.5 2101,-0.19761611601674899941 2101))"
1108+
};
1109+
11041110
static std::string issue_1108[2] =
11051111
{
11061112
"POLYGON((17 -2,18 -1.269679093926235014,12 0,22 0,17 -2))",

test/algorithms/set_operations/union/union.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ void test_areal()
459459
TEST_UNION(issue_1081c, 1, 1, -1, 2338.08);
460460
TEST_UNION_REV(issue_1081c, 1, 1, -1, 2338.08);
461461

462+
TEST_UNION(issue_1100, BG_IF_RESCALED(2, 1), 0, -1, 1.46181);
463+
TEST_UNION_REV(issue_1100, BG_IF_RESCALED(2, 1), 0, -1, 1.46181);
464+
462465
TEST_UNION(issue_1108, 1, 0, -1, 12.1742);
463466
TEST_UNION_REV(issue_1108, 1, 0, -1, 12.1742);
464467

0 commit comments

Comments
 (0)