-
Notifications
You must be signed in to change notification settings - Fork 222
Fix/buffer use cluster for within piece #1404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ template | |
< | ||
typename CsTag, | ||
typename Turns, | ||
typename Clusters, | ||
typename Pieces, | ||
typename DistanceStrategy, | ||
typename UmbrellaStrategy | ||
|
@@ -46,6 +47,7 @@ template | |
class turn_in_piece_visitor | ||
{ | ||
Turns& m_turns; // because partition is currently operating on const input only | ||
Clusters const& m_clusters; | ||
Pieces const& m_pieces; // to check for piece-type | ||
DistanceStrategy const& m_distance_strategy; // to check if point is on original or one_sided | ||
UmbrellaStrategy const& m_umbrella_strategy; | ||
|
@@ -77,6 +79,44 @@ class turn_in_piece_visitor | |
return false; | ||
} | ||
|
||
// Returns true if the turn is part of a cluster, and one of the other turns in the same | ||
// cluster is involved in the same piece as the operations in the turn. | ||
template <typename Turn, typename Piece> | ||
inline bool skip_by_same_cluster(Turn const& turn, Piece const& piece) const | ||
{ | ||
if (turn.cluster_id <= 0) | ||
{ | ||
return false; | ||
} | ||
|
||
auto it = m_clusters.find(turn.cluster_id); | ||
if (it == m_clusters.end()) | ||
{ | ||
return false; | ||
} | ||
|
||
for (auto const& index : it->second.turn_indices) | ||
{ | ||
if (index == turn.turn_index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This produces a comparison of integers of different signedness (long int and size_t) warning in algorithms_buffer_linestring_aimes.test and other tests. |
||
{ | ||
continue; | ||
} | ||
auto const& other_turn = m_turns[index]; | ||
auto const& seg_id0 = other_turn.operations[0].seg_id; | ||
auto const& seg_id1 = other_turn.operations[1].seg_id; | ||
|
||
if (seg_id0.piece_index == piece.index | ||
|| seg_id1.piece_index == piece.index) | ||
{ | ||
// One of the other turns in the same cluster is an intersection | ||
// with the same piece. | ||
// Therefore, the turn under inspection cannot be within that piece. | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
template <typename NumericType> | ||
inline bool is_one_sided(NumericType const& left, NumericType const& right) const | ||
{ | ||
|
@@ -96,10 +136,11 @@ class turn_in_piece_visitor | |
|
||
public: | ||
|
||
inline turn_in_piece_visitor(Turns& turns, Pieces const& pieces, | ||
inline turn_in_piece_visitor(Turns& turns, Clusters const& clusters, Pieces const& pieces, | ||
DistanceStrategy const& distance_strategy, | ||
UmbrellaStrategy const& umbrella_strategy) | ||
: m_turns(turns) | ||
, m_clusters(clusters) | ||
, m_pieces(pieces) | ||
, m_distance_strategy(distance_strategy) | ||
, m_umbrella_strategy(umbrella_strategy) | ||
|
@@ -140,7 +181,12 @@ class turn_in_piece_visitor | |
|
||
if (piece.type == geometry::strategy::buffer::buffered_empty_side) | ||
{ | ||
return false; | ||
return true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not make any difference - but it should have been There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that this case was not covered by a unit test? Could we add one? |
||
} | ||
|
||
if (skip_by_same_cluster(turn, piece)) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the fix |
||
return true; | ||
} | ||
|
||
if (piece.type == geometry::strategy::buffer::buffered_point) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -625,10 +625,7 @@ void test_all() | |
TEST_BUFFER(rt_w15, join_miter, end_flat, 80.1348, 1.0); | ||
TEST_BUFFER(rt_w16, join_miter, end_flat, 31.6495, 1.0); | ||
TEST_BUFFER(rt_w17, join_miter, end_flat, 33.74264, 1.0); | ||
|
||
#if defined(BOOST_GEOMETRY_TEST_FAILURES) | ||
TEST_BUFFER(rt_w18, join_miter, end_flat, 82.4779, 1.0); | ||
#endif | ||
TEST_BUFFER(rt_w18, join_miter, end_flat, 83.4779, 1.0); | ||
|
||
#if defined(BOOST_GEOMETRY_TEST_FAILURES) || defined(BOOST_GEOMETRY_CONCEPT_FIX_ARRIVAL) | ||
// See comments at issue issue_1262 | ||
|
@@ -637,10 +634,7 @@ void test_all() | |
|
||
TEST_BUFFER(rt_w20, join_miter, end_flat, 63.0269, 1.0); | ||
TEST_BUFFER(rt_w21, join_miter, end_flat, 26.3137, 1.0); | ||
|
||
#if defined(BOOST_GEOMETRY_TEST_FAILURES) | ||
TEST_BUFFER(rt_w22, join_miter, end_flat, 86.0416, 1.0); | ||
#endif | ||
TEST_BUFFER(rt_w22, join_miter, end_flat, 86.1274, 1.0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a change in area here. Did the expected result changed? |
||
|
||
TEST_BUFFER(rt_w23, join_miter, end_flat, 59.5711, 1.0); | ||
|
||
|
@@ -672,6 +666,11 @@ void test_all() | |
TEST_BUFFER_VALIDITY_FALSE_NEGATIVE(rt_w35, join_round32, end_flat, 51.63174, 1.0); | ||
|
||
TEST_BUFFER(rt_w35, join_miter, end_flat, 57.6569, 1.0); | ||
TEST_BUFFER(rt_w36, join_miter, end_flat, 60.1274, 1.0); | ||
TEST_BUFFER(rt_w37, join_miter, end_flat, 30.6569, 1.0); | ||
TEST_BUFFER(rt_w38, join_miter, end_flat, 68.2279, 1.0); | ||
TEST_BUFFER(rt_w39, join_miter, end_flat, 46.2279, 1.0); | ||
TEST_BUFFER(rt_w40, join_miter, end_flat, 49.0490, 1.0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These new 5 all fail in |
||
|
||
test_one<multi_polygon_type, polygon_type>("nores_mt_1", nores_mt_1, join_round32, end_flat, 13.4113, 1.0); | ||
test_one<multi_polygon_type, polygon_type>("nores_mt_2", nores_mt_2, join_round32, end_flat, 17.5265, 1.0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does a negative cluster_id means and why we are not searching for it? It is the case that m_clusters does not contain negative values so this condition speeds up the search?