[fix] avoid current get_distance_measure which can make sides indistinguishable

This commit is contained in:
Barend Gehrels
2023-08-30 17:46:27 +02:00
parent fd209ffbf5
commit eb879fe621
3 changed files with 55 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Boost.Geometry
// Copyright (c) 2007-2021 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2007-2023 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2015-2022.
@@ -852,24 +852,15 @@ struct equal : public base_turn_handler
int const side_pk_p = has_pk ? side.pk_wrt_p1() : 0;
int const side_qk_p = has_qk ? side.qk_wrt_p1() : 0;
if (BOOST_GEOMETRY_CONDITION(VerifyPolicy::use_side_verification)
&& has_pk && has_qk && side_pk_p == side_qk_p)
if (has_pk && has_qk && side_pk_p == side_qk_p)
{
// They turn to the same side, or continue both collinearly
// Without rescaling, to check for union/intersection,
// try to check side values (without any thresholds)
auto const dm_pk_q2
= get_distance_measure(range_q.at(1), range_q.at(2), range_p.at(2),
umbrella_strategy);
auto const dm_qk_p2
= get_distance_measure(range_p.at(1), range_p.at(2), range_q.at(2),
umbrella_strategy);
// To check for union/intersection, try to check side values
int const side_qk_p2 = side.qk_wrt_p2();
if (dm_qk_p2.measure != dm_pk_q2.measure)
if (opposite(side_qk_p2, side_pk_q2))
{
// A (possibly very small) difference is detected, which
// can be used to distinguish between union/intersection
ui_else_iu(dm_qk_p2.measure < dm_pk_q2.measure, ti);
ui_else_iu(side_pk_q2 == 1, ti);
return;
}
}

View File

@@ -1113,6 +1113,51 @@ static std::string issue_1108[2] =
"POLYGON((22 1,22 0,14 0,18 -1.2696790939262529996,12 0,22 1))"
};
static std::string issue_1183[2] =
{
"POLYGON((\
-38880.685990792437 6721344.0451435195,\
-38902.349206128216 6721371.1493254723,\
-38937.993505971914 6721407.9151819283,\
-38925.264019448201 6721389.3887558663,\
-38925.240186032526 6721389.3524003429,\
-38903.891993208345 6721355.1907963008,\
-38909.181455691403 6721352.2237809654,\
-38926.953387540903 6721388.3157829558,\
-38940.906008282145 6721408.6223519640,\
-38961.796165266409 6721432.5740491701,\
-38961.819650679929 6721432.6019898951,\
-38977.627018370375 6721452.1204930553,\
-38977.724235665897 6721452.2645238554,\
-38997.157657657241 6721487.2743892670,\
-38997.156729985494 6721487.2749042027,\
-38997.205159411656 6721487.3621566473,\
-38995.456469315024 6721488.3327662209,\
-38976.018586129794 6721453.3126770724,\
-38959.181300235970 6721432.6429256191,\
-38900.879954713615 6721372.5071140006,\
-38900.816775977277 6721372.4353842726,\
-38879.096795985606 6721345.2601805655,\
-38879.046005852288 6721345.1907021403,\
-38880.685990792437 6721344.0451435195,\
))",
"POLYGON((\
-38880.685990792437 6721344.0451435195,\
-38902.349206128216 6721371.1493254723,\
-38960.647313876834 6721431.2817974398,\
-38960.704662809898 6721431.3463021647,\
-38977.625225408119 6721452.1182855805,\
-38977.724248525541 6721452.2645470239,\
-38997.205159411656 6721487.3621566473,\
-38995.456469315024 6721488.3327662209,\
-38976.018586130762 6721453.3126770733,\
-38959.181300235970 6721432.6429256191,\
-38900.879954713615 6721372.5071140006,\
-38879.046005852288 6721345.1907021403,\
-38880.685990792437 6721344.0451435195,\
))"
};
static std::string issue_1184[2] =
{
"POLYGON((1169 177,2004 177,2004 1977,1262 1977,1169 177))",

View File

@@ -465,6 +465,9 @@ void test_areal()
TEST_UNION(issue_1108, 1, 0, -1, 12.1742);
TEST_UNION_REV(issue_1108, 1, 0, -1, 12.1742);
TEST_UNION(issue_1183, 1, 0, -1, 607.6507);
TEST_UNION_REV(issue_1183, 1, 0, -1, 607.6507);
TEST_UNION(issue_1186, 1, 1, -1, 21.6189);
TEST_UNION_REV(issue_1186, 1, 1, -1, 21.6189);