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

outer ring added to wrong polygon in diff() result. #68

Open
erikh2000 opened this issue Feb 15, 2018 · 0 comments · May be fixed by #149
Open

outer ring added to wrong polygon in diff() result. #68

erikh2000 opened this issue Feb 15, 2018 · 0 comments · May be fixed by #149

Comments

@erikh2000
Copy link

erikh2000 commented Feb 15, 2018

This is in a local build with latest master branch and then pr #58, #60, #64, #66, and #67 merged in. (Should be reproducible without #66 and #67 and maybe others--I'm just being complete.)

The key factors of the case seem to be:

EDIT Feb-16: Widened the repro case above after some more testing.

The return from diff() calculates a new inner ring for the return shape that would be correct except that the outer ring is added to the first polygon of the return shape instead of the second.

var param1 = [
    [[[-89.489886, 40.482217],[-89.489714, 40.482022],[-89.489836, 40.482146],[-89.489886, 40.482217]]], // polygon #1
    [[[-89.491551, 40.483208],[-89.486778, 40.487262],[-89.487045, 40.485142],[-89.491551, 40.483208]]] // polygon #2
];
var param2 = [[[-89.48925, 40.484891],[-89.488996, 40.484309],[-89.48821, 40.484919],[-89.48925, 40.484891]]]; // A triangle that is contained by polygon #1 and has no intersection with polygon #2.
var d = diff(param1, param2);
console.log(JSON.stringify(d));

Console output from above with my added comments:

[
  [  (polygon #1)
    [[-89.491551,40.483208],[-89.487045,40.485142],[-89.486778,40.487262],[-89.491551,40.483208]]
  ],[ (polygon #2)
    [[-89.489886,40.482217],[-89.489836,40.482146],[-89.489714,40.482022],[-89.489886,40.482217]],

    (inner ring that is not contained by the outer ring. If this inner ring were under polygon #1 instead of the polygon #2, it would be correct.)
    [[-89.48925,40.484891],[-89.488996,40.484309],[-89.48821,40.484919],[-89.48925,40.484891]] 
  ]
]

image
The rendered output of the return shape. It's a little weird-looking because it's simplified points from a real-world set of shapes. But the big triangle is polygon #1. The tiny line at the bottom (actually a triangle) is the outer ring of polygon #2. And the dark triangle is the inner ring of the polygon #2 which you can see is not inside of the outer ring of polygon #2.

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

Successfully merging a pull request may close this issue.

2 participants