bstroebl / DigitizingTools

A QGIS plugin, that subsumes different tools useful during digitizing sessions
GNU General Public License v2.0
22 stars 9 forks source link

Split Features problem when editing the same polygon twice #43

Closed andywicht closed 5 years ago

andywicht commented 5 years ago

Hi Bernhard,

A new issue emerged concerning the Split Features tool. When splitting off one part of a polygon and e.g. merging it to another polygon and then splitting off another part of either of those 2 polygons without saving the edits inbetween, the dialogue which is asking which part should be inserted as a new feature is suppressed. When you then undo the edit (because you don't have control which part gets a new id from the sequence in the db) and save the layer the Split Features icon is greyed out and not available anymore until you restart QGIS. This behavior applies only after the second split. That happens with QGIS 3.4 and 3.6.

I hope I could make the problem clear to you. If not I can provide a gif to show the steps in a better way.

Cheers

bstroebl commented 5 years ago

Hi Andy, sorry I cannot confirm any issue. Question: Which tool are you using Split Features or split off one part...? From what you describe I assume you are using Split Features. What I did:

  1. Split part of multi feature A with Split Features => Dialog appears
  2. Merge split-off part of A with another feature B using DigitizingTools Merge selectes features
  3. Split new part of B with Split Features => Dialog appears

Tested with DigitizingTools 1.2.0, QGIS 3.4.4 on Ubuntu and QGIS 3.5.0 on Win7

andywicht commented 5 years ago

Hi Bernhard, I think I got a bit closer. First of all I am using the dtsplitfeature.pyfrom master branch to have the topological editing working for the splits. That does not seem to influence the outcome here, I tested both.

The issue seems to be the case that there can be single part polygons casted as multi part polygons in a MultiPolygon geometry column in PostGIS (also tested geopackage).

I always tested this issue here with 2 adjacent rectangles. Once I add another part to both polygons I can reproduce the behavior you described above.

Please try to confirm the case of 2 adjacent rectangles with number of parts = 1.

bstroebl commented 5 years ago

Ok, I understand and can reproduce this now. When splitting features of single-part layers no dialog is shown at all because it is not necessary then. I suspect this is the same behaviour in your case because the features are in fact single part and will only become multi part when being written back into the DB. I would think the dialog should not be shown in the first place if a feature is in fact single part no matter that it is part of a multi-part layer. What do you think?

andywicht commented 5 years ago

In my opinion the dialogue can always be shown because then the user has control over the fact which feature is inserted and therefore generates a new unique id in the DB. Depending if other processes, relations, trigger are involved that is useful to be able to choose.

Can you also reproduce now the fact that the tool gets greyed out and is not available anymore until you restart QGIS? Sometimes there is also a python stacktrace connected to this as I just found out:

AttributeError: 'NoneType' object has no attribute 'selectedFeatureIds' 
Traceback (most recent call last):
  File "C:\Users\XXX\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\DigitizingTools\tools\dtsplitfeature.py", line 50, in digitizingFinished
    selIds = self.editLayer.selectedFeatureIds()
AttributeError: 'NoneType' object has no attribute 'selectedFeatureIds'

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] 
QGIS version: 3.4.3-Madeira Madeira, 2f64a3c4e7
bstroebl commented 5 years ago

In my opinion the dialogue can always be shown because then the user has control over the fact which feature is inserted and therefore generates a new unique id in the DB. Depending if other processes, relations, trigger are involved that is useful to be able to choose.

I admit this may be useful to choose if a user works in a DB that has all this fancy stuff but if a user is not or does not care it poses an extra click. If one needs to make sure a certain geometry is linked to a certain feature you may use Exchange attributes between selected features which was exactly made for this rather special case.

Can you also reproduce now the fact that the tool gets greyed out and is not available anymore until you restart QGIS? Sometimes there is also a python stacktrace connected to this as I just found out:

no, sorry I cannot. I did some undoes and redoes and finally saved the layer (some changes done) but the tool is still active and working. The Python run-time error indicates that somehow the editLayer is not set anymore. I would need steps to reproduce the behaviour in order to debug.

andywicht commented 5 years ago

I admit this may be useful to choose if a user works in a DB that has all this fancy stuff but if a user is not or does not care it poses an extra click. If one needs to make sure a certain geometry is linked to a certain feature you may use Exchange attributes between selected features which was exactly made for this rather special case.

Agreed.

no, sorry I cannot. I did some undoes and redoes and finally saved the layer (some changes done) but the tool is still active and working. The Python run-time error indicates that somehow the editLayer is not set anymore. I would need steps to reproduce the behaviour in order to debug.

I attached a gif showing the exact way to reproduce.

splitfeature

bstroebl commented 5 years ago

Seems to be only the case if you save (and stay editable). Please try to stop editing (+ commit changes) and restart editing.

andywicht commented 5 years ago

Yes, I also found that out. Is that a plugin issue or is QGIS the culprit here? Either way the outcome should be the same no matter which button you press. If necessary we should raise the topic in a QGIS issue.

bstroebl commented 5 years ago

I need to examine that. Clicking on the save button used to be the same signals as clicking on the pen button + click on save + click on the pen button again. Maybe that changed (but other tools are enabled, so I am not convinced) BTW it is sufficient to change the active layer and then change back to your editing layer to reenable the tool, so I suspect it is more an issue of the plugin.

andywicht commented 5 years ago

OK. Took me a while to understand that the behavior of the buttons is not the same in that case.

BTW it is sufficient to change the active layer and then change back to your editing layer to reenable the tool, so I suspect it is more an issue of the plugin.

Great, thanks for the hint! I was always testing this stuff on a single layer. That saves the QGIS restart :)

bstroebl commented 5 years ago

Hi Andy, could you please test the develop branch (exchange dtsplitfeature.py and dttools.py)? I think I fixed it now.

andywicht commented 5 years ago

Hi Bernhard, finally got to test it, seems fixed to me now. But I did not yet get a chance to do a thorough test. Thank you!

bstroebl commented 5 years ago

I will release a new version of the plugin