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

Bugs caused by similar or identical input geometries #41

Closed
rf- opened this issue Oct 15, 2018 · 5 comments
Closed

Bugs caused by similar or identical input geometries #41

rf- opened this issue Oct 15, 2018 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@rf-
Copy link

rf- commented Oct 15, 2018

I've been seeing some crashing bugs caused by specific inputs to union with version 0.8.0.

For example:

var coords1 = [
  [
    [
      [-118.49128246307373, 34.019483292435396],
      [-118.49096059799194, 34.019203176094535],
      [-118.49094450473785, 34.01912758898703],
      [-118.48823547363281, 34.016802140968366],
      [-118.487548828125, 34.017371278141994],
      [-118.487548828125, 34.01735794217727],
      [-118.48639011383057, 34.01833169712249],
      [-118.48449110984802, 34.019892349558305],
      [-118.487548828125, 34.022524496063156],
      [-118.487548828125, 34.02252330890177],
      [-118.48758637905121, 34.02255561892879],
      [-118.48968923091888, 34.02087941406322],
      [-118.490429520607, 34.020261388532035],
      [-118.49038660526276, 34.02022581858034],
      [-118.49128246307373, 34.019483292435396]
    ]
  ]
];

var coords2 = [
  [
    [-118.48639011383057, 34.01833169712249],
    [-118.48823547363281, 34.016802140968366],
    [-118.49094450473785, 34.01912758898703],
    [-118.49096059799194, 34.019203176094535],
    [-118.49128246307373, 34.019483292435396],
    [-118.49038660526276, 34.02022581858034],
    [-118.490429520607, 34.020261388532035],
    [-118.48968923091888, 34.02087941406322],
    [-118.48758637905121, 34.02255561892879],
    [-118.48449110984802, 34.019892349558305],
    [-118.48639011383057, 34.01833169712249]
  ]
];

var results = polygonClipping.union(coords1, coords2);

This seems to cause an infinite loop.

I thought the issue could be related to overly-precise coordinates, but I also see issues sometimes with rounded coordinates. For example, this input causes a SweepEvent comparison failed error:

var coords = [
  [
    [-118.46571, 34.025348],
    [-118.465871, 34.025308],
    [-118.465936, 34.025348],
    [-118.467899, 34.025348],
    [-118.468194, 34.025197],
    [-118.468983, 34.025174],
    [-118.469245, 34.025348],
    [-118.46571, 34.025348]
  ]
];

polygonClipping.union(
  JSON.parse(JSON.stringify(coords)),
  JSON.parse(JSON.stringify(coords))
); // or `polygonClipping.union(coords, coords)`
@rf-
Copy link
Author

rf- commented Oct 15, 2018

Here's another SweepEvent comparison failed case where the inputs are less similar, although one of them has a weird shape:

polygonClipping.union(
  [
    [
      [-118.46571, 34.025348],
      [-118.465871, 34.025308],
      [-118.465936, 34.025348],
      [-118.467899, 34.025348],
      [-118.468194, 34.025197],
      [-118.468983, 34.025174],
      [-118.469245, 34.025348],
      [-118.46571, 34.025348]
    ]
  ],
  [
    [
      [-118.464605, 34.02561],
      [-118.465871, 34.025308],
      [-118.466413, 34.02565],
      [-118.467722, 34.025468],
      [-118.468194, 34.025197],
      [-118.468983, 34.025174],
      [-118.469433, 34.025494],
      [-118.470297, 34.025512],
      [-118.472282, 34.027219],
      [-118.464605, 34.02561]
    ]
  ]
);

@mfogel mfogel added the bug Something isn't working label Oct 17, 2018
@mfogel
Copy link
Owner

mfogel commented Oct 18, 2018

Thanks for the bug(s) @rf-

@mfogel mfogel added this to the v0.10 milestone Oct 18, 2018
@mfogel mfogel removed this from the v0.9.1 milestone Oct 27, 2018
@mfogel
Copy link
Owner

mfogel commented Nov 14, 2018

The two sets of coordinates above for which polygon-clipping is throwing a SweepEvent comparison failed error I think are a subcase of #48 (which I just opened). I'll move those coordinates over to that issue and follow up with them there.

The first set of coordinates above (the one that results in the infinite loop) I think is a different error, this issue will track the problem with that first set of coordinates.

@rowanwins
Copy link
Contributor

rowanwins commented Jan 2, 2019

Both the bugs above are resolved by this commit

@mfogel mfogel added this to the v0.10 milestone Jan 7, 2019
@mfogel
Copy link
Owner

mfogel commented Jan 7, 2019

Verified all these coordinates now work. Fix will be included in next release to NPM.

@mfogel mfogel closed this as completed Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants