Bug report #7244

Split multipolygon geometry fails

Added by Csaba Sandor over 6 years ago. Updated about 6 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Vincent Mora
Category:Digitising
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:16271

Description

Hi,

Splitting multipolygon spatialite geometries does not work as expected.

I try to split a geometry with 2 patches using edit/split features around the middle. (see attachment for cut line direction)

I get: Cut edges detected. Make sure the line splits features into multiple parts.

If I convert the Multi to simple geometries it splits the geoms happily with the previous cutline.

It also works on geometries that are Multi in type but not Multi really.

With MultiLine geoms it also works although converts the split results to simple geoms which is still better than not doing it. :)

First tried on stable 1.8 then on 1.9 master.

Thanks for any views on this.
Csaba

splitpoly.jpg (229 KB) Csaba Sandor, 2013-02-27 08:18 AM

test_qgsissue7244.py Magnifier (3.38 KB) Vincent Mora, 2013-07-11 07:07 AM


Related issues

Related to QGIS Application - Bug report #7550: Split feature on spatialite layers with primary key error Closed 2013-04-08

Associated revisions

Revision 6272274f
Added by Jürgen Fischer about 6 years ago

Merge pull request #717 from Oslandia/issue7244

geometry: don't check for cut edges and validate the split geometries instead (fixes #7244)

History

#1 Updated by Giovanni Manghi over 6 years ago

  • Subject changed from Split multipolygon spatialite geometry fails to Split multipolygon spatialite geometry fails/errors
  • Category set to Vectors
  • Priority changed from Normal to High
  • Operating System deleted (Windows 7)
  • OS version deleted (Osgeo4W)
  • Crashes QGIS or corrupts data changed from No to Yes

The split works fine for me on a newly created DB and vector on qgis master.

On the other hand if the vector was created with an autoincremental id (as qgis allows from the GUI), I get the following when trying committing the changes

Could not commit changes to layer teste1

Errors: ERROR: 2 feature(s) not added.
  SUCCESS: 2 geometries were changed.

  Provider errors:
  SQLite error: PRIMARY KEY must be unique
SQL: INSERT INTO "teste1"("geometry","pkuid","nome") VALUES (GeomFromWKB(?, 3003),?,?)

more over if the user discard the changes part of the "splitted" polygons do disappear.

#2 Updated by Olivier Dalang over 6 years ago

@Giovanni Manghi : doesn't this deserve a specific issue thread ? (it's not clear if the two bugs are linked )
Also it should be fixed for 2.0 since it leads to data loss...

#3 Updated by Giovanni Manghi over 6 years ago

Olivier Dalang wrote:

@Giovanni Manghi : doesn't this deserve a specific issue thread ? (it's not clear if the two bugs are linked )
Also it should be fixed for 2.0 since it leads to data loss...

I agree, would you mind file a ticket? thanks.

#4 Updated by Olivier Dalang over 6 years ago

Ok here it is: #7550

#5 Updated by Giovanni Manghi over 6 years ago

  • Priority changed from High to Severe/Regression
  • Subject changed from Split multipolygon spatialite geometry fails/errors to Split multipolygon spatialite/postgis geometry fails

The original issue is still true, and I raise the priority because the tool is broken for multi part geometries.

#6 Updated by Salvatore Larosa about 6 years ago

I cannot reproduce with PostGIS layer ! (spatialite not tested yet)
I tried it with a multipolygon features.

My testcase: http://lrssvt.ns0.it/img/multipolygon_postgis.sql

#7 Updated by Giovanni Manghi about 6 years ago

  • Target version set to Version 2.0.0
  • Crashes QGIS or corrupts data changed from Yes to No
  • Category changed from Vectors to Digitising

Salvatore Larosa wrote:

I cannot reproduce with PostGIS layer ! (spatialite not tested yet)
I tried it with a multipolygon features.

My testcase: http://lrssvt.ns0.it/img/multipolygon_postgis.sql

it is still true, you must try split both parts of a multipart feature. Splitting of SL layers is broken see #7550

#8 Updated by Salvatore Larosa about 6 years ago

Giovanni Manghi wrote:

it is still true, you must try split both parts of a multipart feature. Splitting of SL layers is broken see #7550

ah, I only see the following message:

Cut edges detected. Make sure the line splits features into multiple parts.

is that what do you refer to ?

#9 Updated by Giovanni Manghi about 6 years ago

ah, I only see the following message:

yes, this message is about this ticket (splitting the parts of a multipart geometry).

On the other hand when splitting a SL geometry you always get a message like

Could not commit changes to layer utm10

Errors: ERROR: 1 feature(s) not added.
  SUCCESS: 1 geometries were changed.

  Provider errors:
  SQLite error: PRIMARY KEY must be unique
SQL: INSERT INTO "utm10"("geom","pk","grel_","grel_id","id","amostra") VALUES (ST_Multi(GeomFromWKB(?, 32629)),?,?,?,?,?)

#10 Updated by Salvatore Larosa about 6 years ago

well, but I still don't understand the reason why this issue is a blocker for PostGIS provider too.
Also on 1.8 I get the same message and I think it is working as expected, or isn't ?

should not it be better to have two separate tickets ?

#11 Updated by Giovanni Manghi about 6 years ago

Salvatore Larosa wrote:

well, but I still don't understand the reason why this issue is a blocker for PostGIS provider too.

because it happens also for postgis :)

Also on 1.8 I get the same message

it is the same on 1.8? if yes you can downgrade this, but I really think that all the (core) digitizing issue should be fixed for qgis 2.0

and I think it is working as expected, or isn't ?

no it isn't: while maybe is not a common operation a user could be very well need to split at the same time two parts of the same feature.

The issues are already in two different tickets:

this one is about splitting the parts of a multipart feature: the resulting message is at least misleading, but the optimal solution would be obviously allow shuch operation.

There is another ticket about the impossibility of splitting any SL feature, because of the error already reported.

Cheers!

#12 Updated by Jürgen Fischer about 6 years ago

  • Subject changed from Split multipolygon spatialite/postgis geometry fails to Split multipolygon geometry fails

Should be provider independant and is reproduceable with a multipolygon shape here too.

#13 Updated by Jürgen Fischer about 6 years ago

Jürgen Fischer wrote:

Should be provider independant and is reproduceable with a multipolygon shape here too.

The cut edge is the line between the part of the split line between the two polygons. Apparently that's ok in this case. So the pure existance of cut edges isn't a clear indication that the GEOSPolygonize() will produce something ugly. May be should just check the validity of resulting polygon instead.

See alse http://lists.osgeo.org/pipermail/qgis-developer/2008-August/004549.html

#14 Updated by Vincent Mora about 6 years ago

Here is a minimal test case for the issue.

Note that the split of one of the polygons in a multipolygon works and produces 2 new features (both parts of the split polygon).

Splitting at least two polygons of the polygons in a multipolygon produces the error.

#15 Updated by Vincent Mora about 6 years ago

Jürgen Fischer wrote:

The cut edge is the line between the part of the split line between the two polygons. Apparently that's ok in this case. So the pure existance of cut edges isn't a clear indication that the GEOSPolygonize() will produce something ugly. May be should just check the validity of resulting polygon instead.

See alse http://lists.osgeo.org/pipermail/qgis-developer/2008-August/004549.html

I removed the check for cut edge and added a validity check as proposed. Works like a charm.

Note that I tried to create an invalid geometry (cut edge) by releasing the split tool inside the interior ring of a polygon and wasn't able to cut it.

#16 Updated by Vincent Mora about 6 years ago

  • Pull Request or Patch supplied changed from No to Yes

#17 Updated by Jürgen Fischer about 6 years ago

  • Status changed from Open to Closed

#18 Updated by Vincent Mora about 6 years ago

Bug fixed thanks to fundings from Agence de l'Eau Adour-Garonne.

Also available in: Atom PDF