polygon-clipping: "Unable to complete output ring staring at"
I am getting the following error:
polygon-clipping.umd.js:2181 Uncaught Error: Unable to complete output ring starting at [-91.86961961111155, 42.61062747659163]. Last matching segment found ends at [-91.8660566, 42.6108961].
at Function.factory (polygon-clipping.umd.js:2181)
at Operation.run (polygon-clipping.umd.js:2715)
at union (polygon-clipping.umd.js:2731)
at Object.run [as callback] (index.js:215)
at NewClass.eval (index.js:59)
at HTMLFormElement.handler (leaflet-src.js:2660)
Here are the arguments:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-91.8681381296294, 42.610082377777616],
[-91.8680455370368, 42.610082377777616],
[-91.8680455370368, 42.60980459999983],
[-91.8681381296294, 42.60980459999983],
[-91.8681381296294, 42.60971200740724],
[-91.868230722222, 42.60971200740724],
[-91.868230722222, 42.60961941481465],
[-91.86832331481459, 42.60961941481465],
[-91.86841590740718, 42.60961941481465],
[-91.86850849999978, 42.60961941481464],
[-91.86850849999978, 42.60971200740725],
[-91.86860109259237, 42.60971200740724],
[-91.86860109259237, 42.60980459999983],
[-91.86850849999978, 42.60980459999983],
[-91.86841590740718, 42.60980459999983],
[-91.86832331481459, 42.60980459999983],
[-91.868230722222, 42.60980459999983],
[-91.868230722222, 42.609989785185],
[-91.8681381296294, 42.609989785185],
[-91.8681381296294, 42.610082377777616]
]
],
[
[
[-91.86961961111155, 42.61062747659163],
[-91.86961961111089, 42.610267562962804],
[-91.8695270185183, 42.610267562962804],
[-91.8695270185183, 42.61054534074058],
[-91.8694344259257, 42.61054534074058],
[-91.8694344259257, 42.61063793333317],
[-91.86915664814792, 42.61063793333317],
[-91.86915664814792, 42.61073052592577],
[-91.8669344259257, 42.61073052592577],
[-91.8669344259257, 42.61082311851836],
[-91.86647146296275, 42.61082311851836],
[-91.86647146296275, 42.61045274814798],
[-91.86637887037016, 42.61045274814798],
[-91.86637887037016, 42.61036015555539],
[-91.86628627777756, 42.61036015555539],
[-91.86624536562047, 42.61036015556462],
[-91.8659157103266, 42.610545340740664],
[-91.86610109259237, 42.61054534074058],
[-91.86610109259237, 42.61073052592577],
[-91.86600849999978, 42.61073052592577],
[-91.86600849999978, 42.610742638821925],
[-91.86583199305461, 42.61076086072423],
[-91.86601542361976, 42.61092414665349],
[-91.8660566, 42.6108961],
[-91.86610109259263, 42.610894865817954],
[-91.86610109259263, 42.610894866465976],
[-91.86702701851864, 42.61086919171867],
[-91.86702701851829, 42.61082311851836],
[-91.8686879090433, 42.61082311852055],
[-91.86934183333335, 42.61080497199335],
[-91.86934183333311, 42.61073052592577],
[-91.8694344259257, 42.61073052592577],
[-91.86950644804213, 42.61073052593223],
[-91.86952701851854, 42.610711793936204],
[-91.8695270185183, 42.61063793333317],
[-91.86960812811655, 42.61063793333722],
[-91.86961961111155, 42.61062747659163]
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-91.8681381296294, 42.610082377777616],
[-91.8680455370368, 42.610082377777616],
[-91.8680455370368, 42.60980459999983],
[-91.8681381296294, 42.60980459999983],
[-91.8681381296294, 42.60971200740724],
[-91.868230722222, 42.60971200740724],
[-91.868230722222, 42.60961941481465],
[-91.86832331481459, 42.60961941481465],
[-91.86841590740718, 42.60961941481465],
[-91.86850849999978, 42.60961941481464],
[-91.86850849999978, 42.60971200740725],
[-91.86860109259237, 42.60971200740724],
[-91.86860109259237, 42.60980459999983],
[-91.86850849999978, 42.60980459999983],
[-91.86841590740718, 42.60980459999983],
[-91.86832331481459, 42.60980459999983],
[-91.868230722222, 42.60980459999983],
[-91.868230722222, 42.609989785185],
[-91.8681381296294, 42.609989785185],
[-91.8681381296294, 42.610082377777616]
]
],
[
[
[-91.8686879090433, 42.61082311852055],
[-91.86860109259237, 42.61082311851836],
[-91.86850849999978, 42.61082311851836],
[-91.86841590740718, 42.61082311851836],
[-91.86832331481459, 42.61082311851836],
[-91.868230722222, 42.61082311851836],
[-91.8681381296294, 42.61082311851836],
[-91.8680455370368, 42.61082311851836],
[-91.86795294444421, 42.61082311851836],
[-91.86786035185165, 42.61082311851836],
[-91.86776775925905, 42.61082311851836],
[-91.86767516666646, 42.61082311851835],
[-91.86758257407384, 42.61082311851836],
[-91.86748998148126, 42.61082311851836],
[-91.86739738888866, 42.61082311851836],
[-91.86730479629607, 42.61082311851836],
[-91.86721220370347, 42.61082311851836],
[-91.86711961111088, 42.61082311851836],
[-91.86702701851829, 42.61082311851836],
[-91.86702701851864, 42.61086919171867],
[-91.86610109259263, 42.610894866465976],
[-91.86610109259237, 42.61082311851836],
[-91.86600849999978, 42.61082311851835],
[-91.86600849999978, 42.61073052592577],
[-91.86610109259237, 42.61073052592577],
[-91.86610109259237, 42.61054534074058],
[-91.86600849999978, 42.61054534074057],
[-91.86591590740719, 42.61054534074058],
[-91.8659157103266, 42.610545340740664],
[-91.86624536562047, 42.61036015556462],
[-91.86628627777756, 42.61036015555539],
[-91.86637887037016, 42.61036015555539],
[-91.86637887037016, 42.61045274814798],
[-91.86647146296275, 42.61045274814798],
[-91.86647146296275, 42.61082311851836],
[-91.86656405555534, 42.61082311851836],
[-91.86665664814792, 42.61082311851835],
[-91.86674924074052, 42.61082311851835],
[-91.86684183333311, 42.61082311851836],
[-91.8669344259257, 42.61082311851836],
[-91.8669344259257, 42.61073052592577],
[-91.86702701851829, 42.61073052592577],
[-91.86711961111088, 42.61073052592576],
[-91.86721220370347, 42.610730525925774],
[-91.86730479629607, 42.610730525925774],
[-91.86739738888866, 42.61073052592576],
[-91.86748998148126, 42.61073052592577],
[-91.86758257407384, 42.610730525925774],
[-91.86767516666646, 42.61073052592576],
[-91.86776775925905, 42.610730525925774],
[-91.86786035185165, 42.610730525925774],
[-91.86795294444421, 42.61073052592577],
[-91.8680455370368, 42.61073052592577],
[-91.8681381296294, 42.61073052592577],
[-91.868230722222, 42.61073052592577],
[-91.86832331481459, 42.610730525925774],
[-91.86841590740718, 42.61073052592577],
[-91.86850849999978, 42.610730525925774],
[-91.86860109259237, 42.61073052592577],
[-91.86869368518497, 42.61073052592577],
[-91.86878627777756, 42.610730525925774],
[-91.86887887037014, 42.610730525925774],
[-91.86897146296273, 42.610730525925774],
[-91.86906405555533, 42.61073052592577],
[-91.86915664814792, 42.610730525925774],
[-91.86915664814792, 42.61063793333317],
[-91.86924924074052, 42.61063793333317],
[-91.86934183333311, 42.61063793333317],
[-91.8694344259257, 42.61063793333317],
[-91.8694344259257, 42.61054534074058],
[-91.8695270185183, 42.61054534074058],
[-91.8695270185183, 42.610267562962804],
[-91.86961961111089, 42.610267562962804],
[-91.86961961111155, 42.61062747659163],
[-91.86960812811655, 42.61063793333722],
[-91.8695270185183, 42.61063793333318],
[-91.86952701851854, 42.610711793936204],
[-91.86950644804213, 42.61073052593223],
[-91.8694344259257, 42.61073052592577],
[-91.86934183333311, 42.610730525925774],
[-91.86934183333335, 42.61080497199335],
[-91.8686879090433, 42.61082311852055]
]
]
]
}
}
]
}
This is how it looks:
Any idea why this might be happening?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 19 (1 by maintainers)
@andrewharvey I went ahead released v0.14.3 just now with the latest on master
@betovelandia thanks for the failing coordinates. If you want a quick fix, I would try trimming the number of digits after the decimal place before running the coords through the library.
Unfortunately, that doesn’t resolve the issue =/ At first I thought it was possibly my implementation but even moving the numbers to just ints or shifting the decimal continues to encounter the issue:
In case anyone would like the code for scaling, here’s what I was working on – but it’s more likely rounding is still the workaround for now =/
My suggestion, given the issues with floating point issues, is scale those number by 1000. That might work.
I am running into this error as well, using turf’s difference function (which uses polygon-clipping’s difference function) to get the difference between a polygon and a multipolygon