Bug: turf/difference fails on a shared edge
See original GitHub issueIt appears difference is failing due to a bug in a supporting library: https://github.com/w8r/martinez/issues/35
Here is a runnable test that exhibits the behavior
const difference = require('@turf/difference');
tape('Difference failure', (t) => {
const polygon1 = {
'type': 'Polygon',
'coordinates': [
[[ 10, 10 ], [ 80, 10 ], [ 80, 80 ], [ 10, 80 ], [ 10, 10 ]]
]
};
const polygon2 = {
'type': 'Polygon',
'coordinates': [
[[ 20, 10 ], [ 30, 10 ], [ 30, 80 ], [ 20, 80 ], [ 20, 10 ]]
]
};
const result = difference(polygon1, polygon2);
});
// Expected result to be a multi-polygon
// Actual fails with exception `Each LinearRing of a Polygon must have 4 or more Positions.`
This failure happens since martinez
returns a malformed polygon when two edges overlap. It returns a “good” difference and as well as a two- or three-point polygon. Could this be detected and handled prior to handing off to helper.polygon
, which is where the exception occurs?
(Hoping creating a tracking issue between the two libraries helps find a common solution faster.)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
TopologyException error when finding difference from polygon ...
I'm trying to use the turf.js 'difference' tool on a polygon and a multipolygon - the multipolygon areas are to be subtracted from...
Read more >Turf difference function and coincident polygon boundaries
I've been wrestling with this issue for a few days. The tool I'm creating takes one polygon and essentially minuses/subtracts another from ...
Read more >Advanced geospatial analysis - Turf.js
May result in degenerate edges when clipping Polygons. ... npm install @turf/difference ... Error - if it encounters an unknown geometry type.
Read more >Cache Bug in Edge Version 95.0.1020.53
1. Open a InPrivate Window and visit the problematic website, now Edge performs as expected. 2. Clear the cache, go into Developer Mode...
Read more >Edge 106.0.1370.37 with bug fixes; failed start issue not fixed
[German]Short addendum: Microsoft has updated the Edge browser in the stable channel to version 106.0.1370.37 on October 6, 2022. Is a bug ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
linking the issue here w8r/martinez#81
Resolved in v6.2.0 onwards