Using turf 6.5.0 I get an odd error in a very specific case and I cannot understand why.
import { difference, Polygon } from "@turf/turf";
const area1 = {
type: "Polygon",
coordinates: [
[
[
11.79926,
59.307999
],
[
18.80383,
60.15596
],
[
18.73765340635914,
60.23951348693759
],
[
18.58133,
60.34301
],
[
11.79926,
59.307999
]
]
]
};
const area1_subtract = {
type: "Polygon",
coordinates: [
[
[
11.79926,
59.307999
],
[
18.80383,
60.15596
],
[
18.73765340635913, // Subtract 1 to final digit
60.23951348693759
],
[
18.58133,
60.34301
],
[
11.79926,
59.307999
]
]
]
};
const area1_add = {
type: "Polygon",
coordinates: [
[
[
11.79926,
59.307999
],
[
18.80383,
60.15596
],
[
18.73765340635915, // Add 1 to final digit
60.23951348693759
],
[
18.58133,
60.34301
],
[
11.79926,
59.307999
]
]
]
};
const area2 = {
type: "Polygon",
coordinates: [
[
[
18.35554,
60.35768
],
[
18.58133,
60.34301
],
[
18.75959,
60.22499
],
[
18.80383,
60.15596
],
[
18.35554,
60.35768
]
]
]
};
describe('Turfjs bug?', () => {
it('difference broken', () => {
difference(area1 as Polygon, area2 as Polygon)
});
it('works', () => {
difference(area1_subtract as Polygon, area2 as Polygon)
});
it('works', () => {
difference(area1_add as Polygon, area2 as Polygon)
});
});
Providing a minimal test case to illustrate the extremely specific error I'm getting.
"Error: Unable to complete output ring starting at [18.58133, 60.34301]. Last matching segment found ends at [18.737653406359147, 60.23951348693759]."
Typescript version: 4.9.5
Node version: v16.17.1
NPM version: 8.15.0
Using turf 6.5.0 I get an odd error in a very specific case and I cannot understand why.
Providing a minimal test case to illustrate the extremely specific error I'm getting.
Typescript version: 4.9.5
Node version: v16.17.1
NPM version: 8.15.0