qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.62k stars 3.01k forks source link

Unable to paste from one PostGIS layer to another #32445

Closed CoryAlbrecht closed 4 years ago

CoryAlbrecht commented 5 years ago

When trying to pas a feature into a PostGIS layer that was copied from another PostGIS layer, the pasting fails.

First, a message banner pops up on top of the map canvas saying that pasting 1 feature was successful. When that disappears, an error message appears saying:

Layer timeline_level1: PostGIS error while adding features: ERROR: null value in column "geom" violates not-null constraint DETAIL: Failing row contains (null, null, f3aecfe1-f0b5-4e62-acbd-a88c9191f2d7, 0a1afc2c-5498-4625-bdf4-ac5a5d9d9733, {}, {}, null, null, null, null, null, 0.085, null, null, {}, {}, {}, {}, t).

However, Menu→Vector→Geometry Tools→Check Validity… finds no errors. Neither does the Processing Tools Check validity. Using Processing Tools Fix geometry and copying the feature from the scratch layer created still has the same problem when pasting, and is identical to the original (when pasting as GeoJSON from QGIS to Vim and using diff -u).

The feature being pasted is attached in geojson format feature.zip

In the console output there's one line that says: Paste features : 1 features were successfully pasted. Geometry collapsed due to intersection avoidance.

Except the geometry has been validated as good, it's not over top of any other feature or even near anything else on teh canvas. There's no clipping layers or anything like that.

QGIS console output when doing Ctrl+V


../../src/providers/postgres/qgspostgrestransaction.cpp:73 : (executeSql) [9640ms] Transaction sql: SAVEPOINT "{db38eb3b-8685-4c45-82d2-c93c79f7325b}"
../../src/providers/postgres/qgspostgrestransaction.cpp:95 : (executeSql) [0ms] Status 1 (OK)
../../src/app/qgsclipboard.cpp:300 : (copyOf) [0ms] returning clipboard.
../../src/app/qgsclipboard.cpp:350 : (transformedCopyOf) [0ms] transforming clipboard.
../../src/providers/postgres/qgspostgresfeatureiterator.cpp:313 : (fetchFeature) [6ms] Finished after 2 features
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [68ms] Checking field against: name
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: admin1_uuid
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: full_name
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: alternate_name
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: start_date
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: end_date
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: main_rgb
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: stripe_rgb
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: border_rgb
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: border_shade
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [1ms] Checking field against: sovereign
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: type
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: info_url
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: flag_url
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: predecessors
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: successors
../../src/providers/postgres/qgspostgresprovider.cpp:2167 : (addFeatures) [0ms] Checking field against: visible
../../src/providers/postgres/qgspostgresprovider.cpp:2280 : (addFeatures) [0ms] prepare addfeatures: INSERT INTO "Balance of Power"."timeline_level1"("geom","feature_uuid","name","admin1_uuid","full_name","alternate_name","start_date","end_date","main_rgb","stripe_rgb","border_rgb","border_shade","sovereign","type","info_url","flag_url","predecessors","successors","visible") VALUES (st_multi(st_geomfromwkb($1::bytea,4326)),$2,'Cape Breton','cd2f4921-bfff-4e8d-ae98-0254dfe7f66d',E'{}',E'{}','1784-08-16','1867-06-30','F99F9F',NULL,'F67676',0.085,NULL,'colony',E'{}',E'{}',E'{}',E'{}',TRUE) RETURNING "feature_uuid"
../../src/core/qgsvectordataprovider.cpp:712 : (pushError) [2ms] PostGIS error while adding features: ERROR:  Geometry type (GeometryCollection) does not match column type (MultiPolygon)

../../src/core/qgsmessagelog.cpp:29 : (logMessage) [6ms] 2019-10-27T14:07:25 Messages[2] Layer timeline_level1 : PostGIS error while adding features: ERROR:  Geometry type (GeometryCollection) does not match column type (MultiPolygon)

../../src/gui/qgsmapcanvas.cpp:512 : (refresh) [2ms] CANVAS refresh scheduling
../../src/providers/postgres/qgspostgresprovider.cpp:572 : (whereClause) [1ms] FAILURE: Key values for feature 0 not found.
../../src/providers/postgres/qgspostgresfeatureiterator.cpp:313 : (fetchFeature) [1ms] Finished after 0 features
../../src/gui/qgsmapcanvas.cpp:506 : (refresh) [2ms] CANVAS refresh already scheduled
../../src/providers/postgres/qgspostgresprovider.cpp:572 : (whereClause) [2ms] FAILURE: Key values for feature 0 not found.
../../src/providers/postgres/qgspostgresfeatureiterator.cpp:313 : (fetchFeature) [1ms] Finished after 0 features
../../src/core/qgsmessagelog.cpp:29 : (logMessage) [27ms] 2019-10-27T14:07:25 Messages[1] Paste features : 1 features were successfully pasted. Geometry collapsed due to intersection avoidance.
../../src/gui/qgsmapcanvas.cpp:506 : (refresh) [1ms] CANVAS refresh already scheduled
../../src/core/qgsmaprendererparalleljob.cpp:64 : (start) [19ms] QThreadPool max thread count is 8
../../src/providers/postgres/qgspostgresfeatureiterator.cpp:313 : (fetchFeature) [36ms] [thread:0x7f46000067e0] Finished after 2 features
../../src/core/qgsmaprendererparalleljob.cpp:210 : (renderLayersFinished) [97ms] PARALLEL layers finished
../../src/core/qgsmaprenderercustompainterjob.cpp:338 : (drawLabeling) [19ms] [thread:0x7f46000026b0] Draw labeling took (seconds): 0.019
../../src/core/qgsmaprendererparalleljob.cpp:231 : (renderingFinished) [0ms] PARALLEL finished
../../src/gui/qgsmapcanvas.cpp:598 : (rendererJobFinished) [1ms] CANVAS finish! 1
gioman commented 5 years ago

@CoryAlbrecht using your sample data worked without issues with qgis master/linux and pgsql 10 and postgis 2.4.

Geometry collapsed due to intersection avoidance.

are you sure you are not pasting into a layer that has the (advanced) snapping option "avoid intersection" active and by chance the pasted polygon is overlapped to an existing one?

CoryAlbrecht commented 5 years ago

@gioman Like I said, it is not over top of anything else in the same layer. This what my advanced snapping options kook like image.

I upped the snapping from 15 pixels to 30 when I got 4K monitors to work with, but that was a year ago and this is a recent problem.

gioman commented 5 years ago

@gioman Like I said, it is not over top of anything else in the same layer. This what my advanced snapping options kook like

please attach a dump of your postgis table from where the feature is being copied and the sql to recreate the target table. The json you posted here is not enough to replicate the issue.

gioman commented 4 years ago

Closing for lack of feedback. Please reopen if necessary.