Bug: turf/difference removes arrays of MultiPolygon Input
See original GitHub issueHi all! Great work again on the removal of jsts, it made leaflet.pm so much smaller and better š. Iāve tried to track down an issue in the plugin and I think it might be the output of difference.
Hereās a gif showing a test of cutting an additional hole in a MultiPolygon:
Hereās the data for testing Input 1:
{
type: 'Feature',
properties: {
name: 'Original Viereck',
category: 'default',
id: '6BA2d7Kdsr7ytyhERLcB',
},
geometry: {
type: 'MultiPolygon',
coordinates: [
[
[
[-74.007991, 40.712882],
[-74.002844, 40.710215],
[-73.995466, 40.714509],
[-74.002983, 40.716637],
[-74.003519, 40.71568],
[-74.005797, 40.715789],
[-74.007991, 40.712882],
],
],
[
[
[-74.005369, 40.716355],
[-74.003402, 40.716756],
[-74.004774, 40.717144],
[-74.005369, 40.716355],
],
[
[-74.003605, 40.713988],
[-74.002854, 40.714769],
[-74.001266, 40.714167],
[-74.001609, 40.713289],
[-74.003605, 40.713988],
],
],
],
},
};
Input 2:
{
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [
[
[-74.005558, 40.713403],
[-74.005558, 40.712573],
[-74.003949, 40.712573],
[-74.003949, 40.713517],
[-74.005558, 40.713403],
],
],
},
};
Using difference 6.0.2 like this:
JSON.stringify(difference(g1, g2))
gives the result:
{
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [
[
[-74.005558, 40.713403],
[-74.005558, 40.712573],
[-74.003949, 40.712573],
[-74.003949, 40.713517],
[-74.005558, 40.713403],
],
],
},
};
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Advanced geospatial analysis - Turf.js
Takes a set of features, calculates the bbox of all input features, and returns a bounding box. ... Removes redundant coordinates from any...
Read more >@turf/difference | Yarn - Package Manager
Most Turf functions work with GeoJSON features. These are pieces of data that represent a collection of properties (ie: population, elevation, zipcode, etc.)Ā ......
Read more >Input geometry is not a valid Polygon in turf.js - Stack Overflow
I try to use turf.js and its function intersect in my Leaflet project. My original question can be found here. The problem is...
Read more >api documentation for turf (v3.0.14)
multiPolygon (coordinates, properties); function turf.nearest (targetPoint, ... else throw new Error('input must be a LineString Feature or Geometry');Ā ...
Read more >Turf difference function and coincident polygon boundaries
What are the dimension of your "error" GeoJSON? Is it line string or polygon? How does it's coordinates match with coordinates of polygons...
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
Hi @codeofsumit
Thanks for the bug report - Iāll take a look at whatās going
Not sure itās caused by martinez, please, look at this codepen https://codepen.io/w8r/pen/LJyOmP