question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Bug: turf/difference removes arrays of MultiPolygon Input

See original GitHub issue

Hi 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: cutproblem

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:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rowanwinscommented, Sep 4, 2018

Hi @codeofsumit

Thanks for the bug report - Iā€™ll take a look at whatā€™s going

1reaction
w8rcommented, Sep 3, 2018

Not sure itā€™s caused by martinez, please, look at this codepen https://codepen.io/w8r/pen/LJyOmP

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found