-
Notifications
You must be signed in to change notification settings - Fork 108
Symmetric difference does not create a hole #281
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
Comments
See also newly documented example. |
Ok, I have spent a bit of time with this today and it might be a bit shifty of a fix. The general strategy that I have been relying on in the pre-processing is that, when a hole is created, it is fully enclosed in a shapely Polygon and the hole is present in the Example where symmetric difference is "manually" performed: int_geom = circ1 & circ2
geom = (circ1 | circ2) - int_geom
geom.plot_geometry() Shapely does not recognize a hole here because the resulting MultiPolygons are valid shapely Polygons that only touch at points. Therefore, when I perform the To come up with a more robust algorithm, I would need to have some way of getting this MultiPolygon "converted" to a Polygon. One possibilityI can change line no. 2387 to add a unionized_poly = unary_union([geom.geom for geom in self.geoms]).buffer(1e-6) This succeeds in converting the MultiPolygon into a Polygon and the hole is then recognized: This could work because I am only performing the
For the first question: Perhaps the scale could be based on the resulting area of the unary union: say, if the area was in the For the second question: Well, all the tests pass ¯_(ツ)_/¯ So, without thinking of a specific scenario where the buffer could cause unwanted holes, then maybe that is good enough? I tested this FYI: At scales of ConclusionI think this could work well as a solution to this problem. However, @robbievanleeuwen brings up a good point that this kind of operation may be moot anyway since it leaves the modeller with a model with singularities and is not actually useful. I see this symmetric difference as possibly being an operation on the way to a final geometry but not necessarily the final geometry. Additionally, the result of the symmetric difference can be achieved with intersection and difference so I don't think that removing the functionality of symmetric difference will solve this problem. So, I have included this proposed fix in #297 for review! |
Performing a symmetric difference operation does not create a hole where regions have been differenced away.
To reproduce:
Generates the following:
Expected behaviour:
There should be a hole in the centre region - note the coarser mesh indicating the lack of a control point here.
Discussion:
If this is too difficult I wouldn't be against removing this functionality. I am having a hard time trying to come up with a real-life use case for this operation, but perhaps more creative minds can find a use!
The text was updated successfully, but these errors were encountered: