-
Notifications
You must be signed in to change notification settings - Fork 371
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
Fix bug causing interior polygons to be ignored (clean) #1326
base: main
Are you sure you want to change the base?
Conversation
8a52fc5
to
35a0048
Compare
35a0048
to
6039b9d
Compare
16b4bec
to
860c9c0
Compare
Can you post some sort of before/after images? |
@QuLogic here's an example. |
Is The problem with this specific path is that the 79 code means go-to-first-point, and |
For example, what if we did this? for path_verts, path_codes in zip(verts_split, codes_split):
if len(path_verts) == 0:
continue
+ if path_codes[-1] == Path.CLOSEPOLY:
+ path_verts[-1, :] = path_verts[0, :]
+
verts_same_as_first = np.all(path_verts[0, :] == path_verts[1:, :],
axis=1)
if all(verts_same_as_first):
geom = sgeom.Point(path_verts[0, :]) I think this fixes your test (other than a type change, which is arguably more correct), but does it fix the above image? |
@QuLogic I've tried the above piece of code and it doesn't seem to fix the plot. I believe the path in the test is a simplification. I may not have entirely captured the nature of the path causing the bug in the plot (beyond the fact that it was length 3 and contained not all the same points). I'll dig back into the code and try and find what the exact path looked like. |
@QuLogic The exact values of path_verts are |
The following code, placed just before
Would this also be a preferable solution? |
I'm not sure about that, something like Going back to your example, I think we should tweak the check for a I do think we're handling |
I can confirm that #1456 also fixes the plot, looks promising. |
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.
Since #1456 fixes your plot and is now merged, I'm going to block this. This PR may no longer be needed for you, but I also think some of it might still be applicable. I will need to think about it a bit more though.
Hi @QuLogic please may i ask for a status update w.r.t. your comment:
Do you still think it worthwhile keeping this open as a PR, or is it reasonable to close this now? thank you |
When path_to_geos read a path with the codes ...,1,2,79,... it would create a LineString which would be appended to collection. This would cause further path_codes to be ignored. This was causing a bug with contourf where occasionally these codes will be passed. This fix would cause these LineStrings to be added to other_result_geoms instead. I have not yet explored the possible consequences of passing LineStrings to other_result_geoms.
(This pull request is essentially the same as #1314 but with a cleaner commit history since it got muddled with my other branch at some point)