Bug report #12799

QgsFeatureRequest iterator using filterRect (spatial index) lose some feature with invalid geometries which have one segment in common.

Added by Roy Roge over 4 years ago. Updated over 2 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Digitising
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:Yes Copied to github as #:20895

Description

new description:
#12799-9

old:

Draw a polygon and use the "Split parts" advanced digitizing tool on it.
Save the shapefile.

Only one part of the split feature is selectable, also it is an invalid geometry.

thanks, Roy.

split_test.zip - sample data (1.37 KB) Roy Roge, 2015-05-21 05:18 AM

split_parts_sample.jpeg (68.7 KB) Roy Roge, 2015-05-23 03:01 AM

Associated revisions

Revision 5b2b3a45
Added by Jürgen Fischer over 4 years ago

allow adding polygons to multipolygons. fixes split part tool (refs #12799)

Revision df31fc0f
Added by Jürgen Fischer over 4 years ago

digitizing: disable split parts on single part geometries and allow adding and removing only part of single part features (fixes #12886, refs #12799)

History

#1 Updated by Saber Razmjooei over 4 years ago

  • Status changed from Open to Feedback
  • Priority changed from High to Normal

Tried in 2.8.2 and get proper results. Could you confirm QGIS version?
A sample data will help too.

#2 Updated by Roy Roge over 4 years ago

I'm using QGIS 2.8.2 64bit on windows.

Step to reproduce:
  1. Create a new polygon shapefile
  2. draw a rectangle
  3. cut the rectangle in two parts using the "Split parts" tool
  4. save the shapefile and toggle editing off

try selecting, clicking into both parts with the select tool (select feature by single click) one of the two parts is not selectable.

Sample data added,

thanks, Roy.

#3 Updated by Saber Razmjooei over 4 years ago

I can't reproduce with your file. It is a multipart polygon. Is that result of the split or is the original file?

#4 Updated by Roy Roge over 4 years ago

It is the result of the "split parts", can you select the feature clicking in the upper "half" rectangle?
i can not...

#5 Updated by Giovanni Manghi over 4 years ago

  • Affected QGIS version changed from 2.8.2 to master
  • Category set to Digitising
  • Status changed from Feedback to Open
  • Priority changed from Normal to High
  • Target version set to Future Release - High Priority

The issue here is that the "split parts" tool should not be active/usable to split (main) geometries, that are not "parts".

To split (main) geometries the user must use the "split features" tool.

This of course can be really confusing and, as shown by this example, it can lead to data corruption.

#6 Updated by Roy Roge over 4 years ago

I noted that the "split parts" tool is not working properly also using multipart geometries:

step to reproduce the issue:
  1. Create a new polygon shapefile,
  2. draw a polygon (id 1),
  3. draw a second polygon (id 2) totally outside the first one,
  4. select both polygons,
  5. merge the two polygons with the "merge selected features" tool, now we have a multipart geometry,
  6. split one of the two polygons with the split parts tool -> at this point you get an invalid geometry
  7. save and toggle edit off

you can verify that you get an invalid geometry (e.g. with the QGIS topology checker)

thanks, Roy.

#7 Updated by Arnaud Morvan over 4 years ago

6 - split one of the two polygons with the split parts tool -> at this point you get an invalid geometry

At this point, the splitted parts have at least one segment in common, so it's effectively an invalid geometry.

#8 Updated by Giovanni Manghi over 4 years ago

  • Subject changed from Advanced editing tool "Split parts" generates corrupted geometry to Advanced editing tool "Split parts" generates corrupted geometry (disable the split parts tool if the geometry is not multipart)

#9 Updated by Arnaud Morvan over 4 years ago

The geometries are effectively invalid, this is not a bug, split parts makes invalid geometries, it is a logical consequence.

For the selection problem, I suspect that this is due to OGR.
The selection tool use a QgsFeatureRequest with a filterRect using the spatial index.
The QgsFeatureRequest iterator do not return the invalid feature for one of its parts.
If I'm not mistaken, the spatial index is applied by OGR.

@Giovanni: Can you update the title:
QgsFeatureRequest iterator using filterRect (spatial index) lose some feature with invalid geometries which have one segment in common.

#10 Updated by Giovanni Manghi over 4 years ago

  • Subject changed from Advanced editing tool "Split parts" generates corrupted geometry (disable the split parts tool if the geometry is not multipart) to QgsFeatureRequest iterator using filterRect (spatial index) lose some feature with invalid geometries which have one segement in common.

#11 Updated by Arnaud Morvan over 4 years ago

Ticket created on GDAL #5974

#12 Updated by Roy Roge over 4 years ago

Arnaud Morvan wrote:

The geometries are effectively invalid, this is not a bug, split parts makes invalid geometries, it is a logical consequence.

Hi Arnaud,

I think that Split Parts tool is quite pointless if this is the case, and not a bug, what is the the point of using it then, to make an invalid geometry?

I can think of sensible use cases for the split part tool if it would generate two geometries after applying it to a multipart feature of two separated polygons, differently from the "Split Features" tool that generates three geoms from the same initial multipart feature (example image attached); i mean i'm expecting that the "split tool" actually split the feature in two.

It may well be that there indeed are sensible use cases that i cannot think of, and i'm honestly curious to understand in this case when i'm supposed to use the "split parts" tool.

I agree with Giovanni however that split parts tool should be disabled if a non multipart feature is selected.

thanks, Roy.

#13 Updated by Jürgen Fischer over 4 years ago

  • Subject changed from QgsFeatureRequest iterator using filterRect (spatial index) lose some feature with invalid geometries which have one segement in common. to QgsFeatureRequest iterator using filterRect (spatial index) lose some feature with invalid geometries which have one segment in common.

#14 Updated by Jürgen Fischer over 4 years ago

Did this change after merging of the new geometry classes? Apparently split parts is not generating invalid geometry anymore - it's now not splitting, but cutting - leaving only one part of the split geometry. So now it's worse.

I understand that it was producing invalid geometries before - which it actually must - polygons are not allowed to have common edges, which the initial cut edges have to be. The geometries must be edited afterwards. Eg. the initial corn polygon could be a result of splitting an earlier single part polygon, that was covering both parts and the space in between, twice and removing the middle part. So for that you even need to have the split parts tool available for single part geometries.

#15 Updated by Roy Roge over 4 years ago

Jürgen Fischer wrote:

Did this change after merging of the new geometry classes? Apparently split parts is not generating invalid geometry anymore - it's now not splitting, but cutting - leaving only one part of the split geometry. So now it's worse.

yes something changed, but i need to do some tests to understand the new behaviour ...

The geometries must be edited afterwards.

you cannot edit invalid geometries in fact, QGIS properly complains that the geometry is invalid.

Eg. the initial corn polygon could be a result of splitting an earlier single part polygon, that was covering both parts and the space in between, twice and removing the middle part.

nope, the initial corn polygon could not be a result of splitting an earlier single part polygon twice,
because at the first go you produce an invalid geometry and you are stuck with that , with QGIS complaining
that the geometry is invalid (as it should indeed)... i hope the issue is more clear now.

#16 Updated by Jürgen Fischer over 4 years ago

Roy Roge wrote:

you cannot edit invalid geometries in fact, QGIS properly complains that the geometry is invalid.

Generally you can edit invalid geometries - maybe not this one. And that's the bug. I doubt that it's even generally true for any split parts, as it would render the split part tool completely useless.

Eg. the initial corn polygon could be a result of splitting an earlier single part polygon, that was covering both parts and the space in between, twice and removing the middle part.

nope, the initial corn polygon could not be a result of splitting an earlier single part polygon twice,
because at the first go you produce an invalid geometry and you are stuck with that , with QGIS complaining
that the geometry is invalid (as it should indeed)... i hope the issue is more clear now.

I was describing how it's intended to work. Splitting a part without further editing doesn't make sense as polygons describe a set of points and on split that set doesn't change. That probably also why it is considered invalid - it's not the simplest way to describe that set.

The split tool is just a shortcut - if it wasn't there, you would have to manually edit the original part to form one part and add the other one by digitizing.

#17 Updated by Jürgen Fischer over 4 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

upsteam issue was closed. other issues should be fixed by the referenced commits.

#18 Updated by Jürgen Fischer over 2 years ago

  • Description updated (diff)

Also available in: Atom PDF