-
Notifications
You must be signed in to change notification settings - Fork 28
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
Incorrect union on small example #12
Comments
Hi @agersant , I'm currently working on making the algorithm more robust, so further test cases are more than welcome. I was running this example through the test case plotting: So it looks like there is already a coordinate hiccup in the input. Comparing to the numbers in the screenshot I noticed that there is one y value of 280 which probably should be 208. Changing it gives: If you have trouble isolating your error, feel free to post the coordinates of the full problem, preferably just as list of coordinates or GeoJSON. I'm currently working on further fixes e.g. for w8r/martinez#110 and w8r/martinez#114, maybe that also helps in your case. Test case GeoJSON{
"features": [
{
"geometry": {
"coordinates": [
[
[416, 256],
[432, 240],
[432, 224],
[448, 208],
[480, 208],
[480, 256],
[416, 256]
]
],
"type": "Polygon"
},
"properties": {},
"type": "Feature"
},
{
"geometry": {
"coordinates": [
[
[400, 272],
[416, 256],
[480, 256],
[480, 272],
[400, 272]
]
],
"type": "Polygon"
},
"properties": {},
"type": "Feature"
},
{
"geometry": {
"coordinates": [
[
[
[400, 272],
[416, 256],
[432, 240],
[432, 224],
[448, 208],
[480, 208],
[480, 256],
[480, 272],
[400, 272]
]
]
],
"type": "MultiPolygon"
},
"properties": {
"operation": "union"
},
"type": "Feature"
}
],
"type": "FeatureCollection"
} |
Sorry about that, I'm a potato and I shouldn't write bug reports late at night. It is difficult to post my entire dataset as the issue arise within a iterative process which merges and simplifies a large number of polygons into gradually bigger chunks. I did take a closer look and I am confident that the union() I see are correct - I believe simplify() is where problems are. I will open an issue over there (after carefully proof reading it). |
Sorry for all the flip flopping on this. I think I finally cornered it. Here is a zip file with two serialized MultiPolygons ( The zip file also contains Some pictures: (there is also a strange doodad near the top-right corner which appears earlier in the calculations of these shapes but that's a problem for another day) |
No problem at all, and thanks again for investigating. I can reproduce the issue now: Also, the problem seems to be independent of the issues I'm currently fixing, so it is quite a valuable test case. I'll probably do some deeper debugging on the weekend.
Actually this kind of self-overlap might be the cause of the issue. Note that the x-coordinate of the self-overlap goes from 400 to 416. The start x of the segment that disappears is 400. Setting it to <400 or >=416 avoids the problem. As a temporary work-around you could try adding a polygon simplification to the intermediate results in your incremental logic. |
I think you are correct. I do run a simplification step on the intermediate results for performance benefits, and I only run into all these issues when using I also isolated the union operation which creates the overlapping edge in the first place (in earlier iterations), this might be a useful test case too. Here is another zip file with Picture of the resulting union w/ self-overlapping edge: |
Okay this is "almost" fixed by #13: The original test case works now, and also the doodad case (I had almost the same on my branch already ;)). The thing that doesn't work is to swap the roles of the subject and clipping polygon in your main example. Will have to look into that in the next bug fixing round. |
Fantastic news, thank you so much!! |
Hi and thanks for maintaining this very useful library.
I ran into some incorrect results while computing the union of a large number of polygons, and I think I managed to isolate a simple example out of my larger data set.
This is the two polygons (blue and green) being merged. Note the shared horizontal edge in the middle.
Here is the resulting union:
Repro code:
The text was updated successfully, but these errors were encountered: