Skip to content
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

Misattributed hole with intersection #96

Closed
davebrent opened this issue Jan 2, 2019 · 5 comments
Closed

Misattributed hole with intersection #96

davebrent opened this issue Jan 2, 2019 · 5 comments

Comments

@davebrent
Copy link

Ive put together a little gist of the issue here. It seems that the hole in this case is being assigned to the split polygon above rather than the polygon it belonged to.

I think this may be similar to #38?

The problem
actual

Expected result
expected

@jakeNiemiec
Copy link

I think when polygons have holes, you need to use the MultiPolygon format http://geojson.org/geojson-spec.html#id7 instead of polygon: https://gist.github.com/davebrent/28a686e7555f0e65f0859a6994bce5c0#file-index-js-L21

In my usage, martinez.intersection should return a MultiPolygon in this case.

@davebrent
Copy link
Author

davebrent commented Jan 2, 2019

I think when polygons have holes, you need to use the MultiPolygon format http://geojson.org/geojson-spec.html#id7 instead of polygon: https://gist.github.com/davebrent/28a686e7555f0e65f0859a6994bce5c0#file-index-js-L21

In my usage, martinez.intersection should return a MultiPolygon in this case.

Hi Jake thanks but that's not my understanding. A MultiPolygon is just an array of Polygon coordinate arrays, which are arrays of rings, the first being the exterior the rest being the interior holes. source

What I think is happening here is that the ring representing the hole in one polygon is being assigned to a different one on output

@jakeNiemiec
Copy link

A MultiPolygon is just an array of Polygon coordinate arrays, which are arrays of rings, the first being the exterior the rest being the interior holes.

Right, my point was that you will always get a MultiPolygon as an output, but as far as I can tell that does not influence the original problem 🙃.

What I think is happening here is that the ring representing the hole in one polygon is being assigned to a different one on output

You are right, the intersection is dividing the input (a poly with a hole) into 2. You can see from the expected.json->actual.json diff that the hole is indeed misattributed to the poly furthest from the origin. (or the last poly in a multipoly?)

image

I made a similar gist with the example from #38 by @joelgallant: https://gist.github.com/jakeNiemiec/7d75093e5e8d9fe52008871c109bb855#file-actual-json (I was unable to get the codepen example by @w8r to load)

This example shows the same problem, but with martinez.diff:

image

With this, you can see that the holes are, again, misattributed to the poly that is the furthest from the origin. These problems seem reflected in another popular issue by @erikh2000 from nearly a year ago.

TL;DR: When a subject is divided into 2 polys via diff or intersection clipping, all of the subjects holes seem to be misattributed to the poly furthest from the origin. (or the last poly in a multipoly?)

@rowanwins
Copy link
Collaborator

Think this is all resolved now from #113

@w8r
Copy link
Owner

w8r commented Apr 4, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants