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

Unable to complete output ring starting at ... #101

Open
Tracked by #1
cmonacaps opened this issue Jul 17, 2020 · 4 comments
Open
Tracked by #1

Unable to complete output ring starting at ... #101

cmonacaps opened this issue Jul 17, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@cmonacaps
Copy link

cmonacaps commented Jul 17, 2020

geojsons referred to can be found at this gist

A production issue was reproduced by trying to union source_1.geojson and source_2.geojson.

$ geo-cli union -i source_1.geojson -i source_2.geojson
ℹ start union
◰ [Error] Unable to complete output ring starting at [-77.31806300030723, 38.975023999757816]. Last matching segment found ends at [-77.112505, 38.855774].

    at factory   polygon-clipping/dist/polygon-clipping.cjs.js:1266  throw new Error("Unable to complete output ring starting at [".concat(firstPt.x…
    at run       polygon-clipping/dist/polygon-clipping.cjs.js:1781  var ringsOut = RingOut.factory(sweepLine.segments);                             
    at union     polygon-clipping/dist/polygon-clipping.cjs.js:1797  return operation.run('union', geom, moreGeoms);                                 
    at union     lib/geo.js:43                                       coordinates: _polygonClipping.default.union((0, _geoUtil.featureToCoordinates)(…

We found we could do the union with a Python lib.

I looked at the data and it seems like there may be some rounding noise since most of the numbers have a sequence of decimal digits 999 or 000 at the 6th decimal place.

I tried rounding the numbers to the 6th dec place and this could union with polygon-clipping.

These 2 successful union results are also at the gist linked above.

Using polygon-clipping version 0.14.3 throughout this sequence of events.

I saw there is already an issue open on this error diagnostic and I honestly wasn't sure whether to post this in that thread or open a new one.

@mfogel mfogel added the bug Something isn't working label Aug 29, 2020
@mcdenhoed
Copy link

I have a similar simple case happening trying to union 4 squares. Code to reproduce is below:

const polygonClipping = require('polygon-clipping')

const poly1 = [[
    [1553.481712766874, 1494.8225115579035],
    [1553.481712766874, 80.60894918480847],
    [139.26815039377902, 80.60894918480824],
    [139.2681503937788, 1494.8225115579032]]]

const poly2 = [[
    [2130.363837219598, 1505.3523513000096],
    [2130.363837219598, 91.13878892691457],
    [716.1502748465028, 91.13878892691434],
    [716.1502748465026, 1505.3523513000093]
]]
const poly3 = [[
    [2162.7561633766086, 1808.0852438855597],
    [2162.7561633766086, 393.87168151246476],
    [748.5426010035136, 393.87168151246453],
    [748.5426010035134, 1808.0852438855595]
]]
const poly4 = [[
    [1522.2282522557293, 1767.4968190640373],
    [1522.2282522557293, 353.28325669094227],
    [108.01468988263434, 353.28325669094204],
    [108.01468988263412, 1767.496819064037]
]]

// This succeeds
const union = polygonClipping.union(poly1, poly2, poly3)

// This fails
const union2 = polygonClipping.union(poly1, poly2, poly3, poly4)

@mcdenhoed
Copy link

Actually in that example calling union on poly1 and poly4 is sufficient to get a crash.

@mcdenhoed
Copy link

Rounding also seems to avoid this in my case, so I guess I'll just make sure I'm rounding all inputs to polygon-clipping.

@852Kerfunkle
Copy link

I'm guessing most of these issues are related to comparing floats directly. Probably should be doing epsEqual with a sufficiently large epsilon.

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

4 participants