Bug report #16870

copy/paste/save fails ("geometry type is not compatible with the current layer") for a specific point dataset in qgis master (on Windows)

Added by Giovanni Manghi over 7 years ago. Updated over 7 years ago.

Status:Closed
Priority:High
Assignee:Luigi Pirelli
Category:Digitising
Affected QGIS version:master Regression?:Yes
Operating System:Windows Easy fix?:Yes
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:24769

Description

Was all ok until 2.18.10 included.

To test just make a copy of the attached shapefile.

points.zip (28.8 KB) Giovanni Manghi, 2017-07-14 04:33 PM

Recording #2.mp4 (2.97 MB) Giovanni Manghi, 2017-07-14 11:17 PM

BOUNDLESS-WIN-1.LOG Magnifier (258 KB) Luigi Pirelli, 2017-07-19 04:05 PM

punkte.shp - point layer with multipoints (1.85 KB) A E, 2017-08-10 12:31 PM

Associated revisions

Revision 2712f669
Added by Alessandro Pasotti over 7 years ago

Merge pull request #4980 from boundlessgeo/Win_CutAndPaste_issue16870

From Clipboard Cut&Paste fix when attached special field values. Fixes #16870

Revision f464aebf
Added by Alessandro Pasotti over 7 years ago

Merge pull request #5030 from boundlessgeo/Win_CutAndPaste_2-18_issue16870

Clipboard Cut&Paste fix when attached special field values. Fixes #16870

History

#1 Updated by Richard Duivenvoorde over 7 years ago

I cannot reproduce this?

In current master I:
- open your attached zip (without unzipping)
- select a bunch of points
- Paste as New Vector layer (in Edit menu)
- then I can save it both as shape file or geopackage without problem...

#2 Updated by Giovanni Manghi over 7 years ago

Richard Duivenvoorde wrote:

I cannot reproduce this?

In current master I:
- open your attached zip (without unzipping)
- select a bunch of points
- Paste as New Vector layer (in Edit menu)
- then I can save it both as shape file or geopackage without problem...

no, that is not the right workflow.

Open the shapefile > save as (shapefile) to make a clone of it > copy features from original shape > paste into copy > try save edits in copy

#3 Updated by Jürgen Fischer over 7 years ago

Not reproducable in master (insert above point layer, copy features from layer, save as other file, start editing saved layer, paste features to layer, commit changes, voila)

#4 Updated by Giovanni Manghi over 7 years ago

Jürgen Fischer wrote:

Not reproducable in master (insert above point layer, copy features from layer, save as other file, start editing saved layer, paste features to layer, commit changes, voila)

will post screencasts from both 2.18.10 nightly and master from clean testing environments.

#5 Updated by Jürgen Fischer over 7 years ago

Jürgen Fischer wrote:

Not reproducable in master (insert above point layer, copy features from layer, save as other file, start editing saved layer, paste features to layer, commit changes, voila)

and not with 2.18.10 (same procedure; both on Linux)

#6 Updated by Jürgen Fischer over 7 years ago

Jürgen Fischer wrote:

and not with 2.18.10 (same procedure; both on Linux)

but with master on windows (with GDAL 2.2 vs. GDAL 2.1.2 on Linux)

#7 Updated by Giovanni Manghi over 7 years ago

Jürgen Fischer wrote:

Jürgen Fischer wrote:

and not with 2.18.10 (same procedure; both on Linux)

but with master on windows (with GDAL 2.2 vs. GDAL 2.1.2 on Linux)

test in clean env (Linux and Win) + screencast is coming (if confirmed)... just a few more minutes.

#8 Updated by Giovanni Manghi over 7 years ago

  • Operating System set to Windows
  • File Recording #2.mp4 added
  • Subject changed from copy/paste/save fails ("geometry type is not compatible with the current layer") for a specific point dataset in qgis 2.18.10-nightly and master to copy/paste/save fails ("geometry type is not compatible with the current layer") for a specific point dataset in qgis master (on Windows)
  • Affected QGIS version changed from 2.18.10 to master

I tried again on clean testing environments both linux and windows, with 2.18.10-nightly and master. And despite not confirming again on 2.18.10-nightly and master on linux, I still see it on master Windows. That is on a clean Win7 VM, with qgis master just installed from osgeo4w. Screencast attached.

#9 Updated by Luigi Pirelli over 7 years ago

confirmed on master(d70f53c)/win10

#10 Updated by Jürgen Fischer over 7 years ago

  • Assignee set to Luigi Pirelli

#11 Updated by Luigi Pirelli over 7 years ago

related log

#12 Updated by Luigi Pirelli over 7 years ago

independent by provider type (tested on spatialite)
the check is done because it is wkbPoint or wkbPoint25D as in:
https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L3445

#13 Updated by Luigi Pirelli over 7 years ago

btw on Linux (compild master) the line:
https://github.com/qgis/QGIS/blob/master/src/core/qgsvectorlayereditbuffer.cpp#L329
that generate the erro ris never reached because the pasted geometry has the same type of destination layer.

Something different happend in Windows... could be a erroneous geometry due to cut&paste, or some missing gemetry type. More investigation. The hard is to have a debug setup on win.

#14 Updated by jd lom over 7 years ago

Seems to be fixed with 2.18.11. Can anyone confirm this ?

#15 Updated by Luigi Pirelli over 7 years ago

I hadn't test yet... did you try with test data attached to this issue?

#16 Updated by Gerhard Spieles over 7 years ago

I test it with 2.18.11 under win10 and win7.
Copy and paste between shape/shape and shape/spatialite is ok.
I haven`t test it with dxf/geopackage.

#17 Updated by Giovanni Manghi over 7 years ago

Gerhard Spieles wrote:

I test it with 2.18.11 under win10 and win7.
Copy and paste between shape/shape and shape/spatialite is ok.
I haven`t test it with dxf/geopackage.

the question is if you tested the point layer attached to this ticket. In general it works, but there are datasets where it does not.

#18 Updated by Gerhard Spieles over 7 years ago

Sorry Giovanni,
I was in the wrong ticket. Right ticket is #16770.
I'll report it there.

#19 Updated by Luigi Pirelli over 7 years ago

one of the pasted feature in mFeatureAdded has wrong values... investigating the cut&paste mechanism
.
.
2017-08-04T05:25:39 WARNING ID -574
2017-08-04T05:25:39 WARNING ID -573
2017-08-04T05:25:39 WARNING is ¢঎ɾ୸֟ޙ has geom %2 of type %3

#20 Updated by Luigi Pirelli over 7 years ago

new debug message... for some reason one geometry pasted has been converted to PointZM (3001) instead of Point (1)

2017-08-05T04:13:22 WARNING ID -2906 has geom 1 of type 1
2017-08-05T04:13:22 WARNING ID -2905 has geom 1 of type 1
2017-08-05T04:13:22 WARNING ID -2904 has geom 1 of type 3001

#21 Updated by Luigi Pirelli over 7 years ago

the PointZM geometry is already present during paste (not only at commit) => investigating if:
1) data are wrong mixing Point and PointZM
2) if copy or paste has modified a geometry type

#22 Updated by Luigi Pirelli over 7 years ago

the erro is derived from the fact that in: https://github.com/qgis/QGIS/blob/master/src/app/qgsclipboard.cpp#L194 to the generator is passed a record with WKT + all attached params.
If a params has a value with "( ... )" the QgsGeometry::fromWkt(string) return a wrong geometry

#23 Updated by Luigi Pirelli over 7 years ago

it's still not clear why this happend only on win

#24 Updated by Luigi Pirelli over 7 years ago

in windows for a not clear to me combination setting value of mUseSystemClipboard enter in:
https://github.com/qgis/QGIS/blob/master/src/app/qgsclipboard.cpp#L194
where the geometry os build getting the WKT string + fields values.
If a field value has (something) e.g. "POINT value1 value2 aaa(something) value3"
then the geometry is PointZM generated by QgsGeometry::fromWkt.

the error is that row have to be cleaned from fields values... that is the object of the patch I'm preparing.

#25 Updated by Luigi Pirelli over 7 years ago

  • Easy fix? changed from No to Yes

#26 Updated by Luigi Pirelli over 7 years ago

  • Pull Request or Patch supplied changed from No to Yes

#27 Updated by Anonymous over 7 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

#28 Updated by A E over 7 years ago

Still an issue under Win7 running 2.18.11: multi-point features are not pasted into other layers. Error warning informs simply that not all features could be pasted.

#29 Updated by Giovanni Manghi over 7 years ago

A E wrote:

Still an issue under Win7 running 2.18.11: multi-point features are not pasted into other layers. Error warning informs simply that not all features could be pasted.

can you add the other layers of the shapefile?: shx, dbf and prj, thanks.

#30 Updated by Luigi Pirelli over 7 years ago

reading the code probably the issue would affect also 2.18 in case of cut&paste from outside qgis, e.g. passsing from a dump of the layer in textual from from clipboard (in case of inter layer cut&paste, qgis use directly the features without text conversion). The fix is identical of the master code. I will backport to 2.18 as soon as possibile. BTW, please attache the complete layer to reproduce the issue.
In the description pelase also give the followiong informations:

1) configuration value of Option->settings-Zdata source->Copy feature as
2) detailed and reproducible sequence of steps to replicate the issue on 2.18.11

thanks

#31 Updated by Luigi Pirelli over 7 years ago

backported to 2.18 with PR:
https://github.com/qgis/QGIS/pull/5030

#32 Updated by Luigi Pirelli over 7 years ago

Anonymous wrote:

Applied in changeset qgis|2712f66938546f7423bc46a9376fe4c7a02c0505.

dbf file is especially important because the error was due to parse QgsGeometry::fromWkt from a WKT with attached all attributes and where an attribute has "(some value) inside.

btw https://github.com/qgis/QGIS/pull/5030 should have fixed it

Also available in: Atom PDF