leaflet-geoman icon indicating copy to clipboard operation
leaflet-geoman copied to clipboard

Deleting all points in a MultiPolygon or Polygon corrupting coordinates

Open maxmorgan opened this issue 3 years ago β€’ 1 comments

You can use the hosted geoman for this.

Polygon Use Case

Steps to Reproduce:

  1. Create a new shape
  2. Right click to remove all points

Expected results:

  • Coordinates set to [] (same as LineString behavior)
  • OR event fired to denote that this shape should be deleted (same as deleting Point behavior)

Actual results:

  • A shape with a single ring containing null:
{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "properties": {
            "shape": "Polygon",
            "name": "Unnamed Layer",
            "category": "default"
        },
        "geometry": {
            "type": "Polygon",
            "coordinates": [
                [null]
            ]
        }
    }]
}

MultiPolygon Use Case

Steps to Reproduce:

  1. Create a new shape
  2. Use eraser tool to split shape into two
  3. Right click to remove all points of one of the resulting polygons

Expected results:

  • A valid polygon comprised of the remaining shell

Actual results:

  • A multi polygon with all null points.
{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [
                [null],
                [
                    [null, null],
                    [null, null]
                ]
            ]
        },
        "properties": {
            "shape": "Polygon",
            "name": "Unnamed Layer",
            "category": "default"
        }
    }]
}

maxmorgan avatar Apr 25 '22 23:04 maxmorgan

Thank you for reporting. It sounds like a Leaflet Core issue https://github.com/Leaflet/Leaflet/issues/7627

Falke-Design avatar Apr 26 '22 05:04 Falke-Design

Fixed in Leaflet Core

Falke-Design avatar Oct 16 '22 18:10 Falke-Design

@Falke-Design Is an updated version of geoman required for this to work? I've updated my app to Leaflet 1.9.2 but am still getting an error when I try to remove all points after cutting a polygon in half. Trying to figure out whether the issue is on my side or whether I should be patient for an updated version of geoman.

image

msereda avatar Oct 19 '22 19:10 msereda

@msereda can you please create a video what are you doing. And it would be very helpful, if you can create a demo: https://jsfiddle.net/o1dwu2vg/

Falke-Design avatar Oct 19 '22 19:10 Falke-Design

@Falke-Design I can get it via the fiddle if I update leaflet to 1.9.2 (the version in that linked fiddle is 1.6.0).

Will attempt to capture it if I can get the windows tool working, but the steps are pretty simple - create a polygon, cut the polygon in half, then edit & remove all points from one of the resulting two polygons (then 'finish' the edit). You actually get a different error depending on which of the two you remove all points from. https://jsfiddle.net/ja4zy3op/1/

msereda avatar Oct 19 '22 19:10 msereda

@Falke-Design Video: https://user-images.githubusercontent.com/5561775/196789826-c14dafeb-e3eb-41dc-9c2c-7a632a535e38.mp4

msereda avatar Oct 19 '22 19:10 msereda

Thank you, I think I found already a solution for this bug

Falke-Design avatar Oct 19 '22 21:10 Falke-Design