[union] fix missing interior ring and double traversed exterior ring - #1113
Conversation
vissarion
left a comment
There was a problem hiding this comment.
Thanks, I am OK with merging!
| #else | ||
| using point_t = decltype(turns[*indices.begin()].point); | ||
| using coor_t = typename coordinate_type<point_t>::type; | ||
| coor_t centroid_0{}; |
There was a problem hiding this comment.
I do not remember using this initialization in boost geometry. I am not against though, just to check.
There was a problem hiding this comment.
I'd prefer to assign 0 explicitly because for user-defined numerical type this could result in default ctor call which could initialize variable to something different than 0.
There was a problem hiding this comment.
I will update it. Thanks.
| // The coordinates are averaged. | ||
| // It is necessary to avoid artefacts and invalidities. | ||
| template <typename Turns, typename Clusters> | ||
| inline void colocate_clusters(Turns& turns, Clusters const& clusters) |
There was a problem hiding this comment.
Shouldn't the order be the other way around? Such that the output is after then input?
There was a problem hiding this comment.
You are right will fix it.
| test_one<multi_polygon_type, polygon_type>("rt_p11", rt_p11, join_miter, end_flat, 28.7426, 1.0); | ||
| test_one<multi_polygon_type, polygon_type>("rt_p12", rt_p12, join_miter, end_flat, 22.5711, 1.0); | ||
|
|
||
| // Needs centroid of cluster turn points |
There was a problem hiding this comment.
this is related to flag BOOST_GEOMETRY_USE_FIRST_POINT_AT_CLUSTER
There was a problem hiding this comment.
This define is now gone.
✔️
| // which is now return T(1) (earlier it was 1000) | ||
| double const multiplier = 1.0 / 1000.0; | ||
| // which is now return T(100) (earlier it was 1000) | ||
| double const multiplier = 1.0 / 10.0; |
There was a problem hiding this comment.
does it hold multiplier = T / 1000.0; ?
There was a problem hiding this comment.
I don't understand. Maybe the comment needs to point to the source in get_clusters.hpp
There was a problem hiding this comment.
My question is: "should multiplier be a function of T e.g. multiplier = T / 1000.0; instead of manually update the fraction every time you change the threshold?" Am I missing something in the context here?
There was a problem hiding this comment.
Changed these lines a bit, avoiding the multiplier and enhancing the comment
✔️
There was a problem hiding this comment.
My question is: "should
multiplierbe a function ofTe.g.multiplier = T / 1000.0;instead of manually update the fraction every time you change the threshold?" Am I missing something in the context here?
Sorry, I noticed this answer only after my own reply.
But I changed it, without multiplier now. I hope the threshold won't change again. Is it fine like this?
| for (const auto& index : indices) | ||
| { | ||
| centroid_0 += geometry::get<0>(turns[index].point); | ||
| centroid_1 += geometry::get<1>(turns[index].point); | ||
| } | ||
| centroid_0 /= indices.size(); | ||
| centroid_1 /= indices.size(); |
There was a problem hiding this comment.
AFAIU this is only correct for cartesian. Can this be a problem?
Another issue is that for integral coordinates this could result in overflow.
There was a problem hiding this comment.
Good points.
Happening on the dateline would be a rare case... but, see below.
Integral coordinates: if they are clustered, they are (by definition) on the same location. So they don't need this, the first point is fine.
I'll update the implementation to cover these two situations (which means: for geographic or integer coordinates take the first).
There was a problem hiding this comment.
So indeed it was a problem, reported as #1116 which was found on this branch.
Good catch!
My updated implementation solved that already, but I will create a testcase.
That will be done in a separate PR. If you approve, this can be merged now.
7f75e4f to
51fa43c
Compare
| for (++it; it != indices.end(); ++it) | ||
| { | ||
| turns[*it].point = first_point; | ||
| } |
There was a problem hiding this comment.
Because all implementation is here, I removed the define, better like this.
Thanks for the comments.
| } | ||
|
|
||
| remove_clusters(turns, clusters); | ||
| colocate_clusters(clusters, turns); |
There was a problem hiding this comment.
This now looks a bit weird (by the order change).
I will change it in a later PR but I didn't want to do it in this one, to keep the size smaller.
51fa43c to
ec7f9c9
Compare
|
@barendgehrels do you want to have this PR in 1.82 beta? Deadline 8/3 Side note: there is an error in buffer tests https://app.circleci.com/pipelines/github/boostorg/geometry/374/workflows/e4f969a0-4b45-4af2-8316-328437fde513/jobs/19175 probably not related to this PR. |
fixes: #1109 and #1108
keeps fixed: #1081