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

error intersecting polygons #37

Closed
jomel opened this issue Oct 2, 2018 · 2 comments
Closed

error intersecting polygons #37

jomel opened this issue Oct 2, 2018 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jomel
Copy link

jomel commented Oct 2, 2018

see gist for polygons in question:
https://gist.github.com/jomel/45d2c23bc7d3b83143af18fb8ce1312a

when trying to run intersection()
I get :

Error: Unable to complete output ring starting at [0.523657, 51.281218]. Last matching segment found ends at  [0.5239850000000017, 51.281651].
    at Function.factory (webpack://polygon-clipping/./src/geom-out.js?:52:21)
    at doIt (webpack://polygon-clipping/./src/index.js?:81:34)
    at intersection (webpack://polygon-clipping/./main.js?:30:28)
...

I don't see anything odd about my geometries...

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

mfogel commented Oct 3, 2018

Thanks for the bug report @jomel

This is a simplified version of that geometry that still triggers the bug (by performing an intersection() on the Features in the FeatureCollection below):

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [0.5242, 51.2815],
            [0.52406, 51.281726],
            [0.523787, 51.281453],
            [0.5242, 51.2815]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [0.5241, 51.2816],
            [0.52401, 51.2817],
            [0.523985, 51.281651],
            [0.5241, 51.2816]
          ]
        ]
      }
    }
  ]
}
Loading

In this simplified geometry it looks like the problem is occurring because one vertex [0.523985, 51.281651] is almost-just-barely-not-quite on the line segment [0.523787, 51.281453] <-> [0.52406, 51.281726]. Basically sometimes the algorithm thinks the vertex intersects that line segment, and sometimes it thinks it doesn't. That inconsistency leads to the error.

I'll see if I can figure out a fix.

@mfogel mfogel self-assigned this Oct 3, 2018
@mfogel mfogel added this to the v0.11 milestone Jan 7, 2019
@mfogel mfogel closed this as completed in 88cbda7 Jan 8, 2019
@mfogel
Copy link
Owner

mfogel commented Jan 8, 2019

I've verified that the latest on master now successfully processes the coordinates linked to and quoted in this bug.

mfogel added a commit that referenced this issue Jan 13, 2019
Fixes #60. Going to re-investigate #37
mfogel added a commit that referenced this issue Jan 13, 2019
mfogel added a commit that referenced this issue Jan 13, 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

2 participants