Bug report #17814
Postgres provider retrieves 4D geometries as 2D
|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:||No||Copied to github as #:||25710|
For some reason PostgreSQL provider retrieves 4-dimensional geometries (e.g. POINT ZM) as 2D geometries: the Z and M values are skipped.
To replicate, create a simple view:
CREATE VIEW multipoint_zm_test AS SELECT 1 AS id, ST_GeomFromText('MULTIPOINT', 25832) AS geom;
In identify results, in derived section the "closest vertex z/m" entries are missing. Another way to confirm the bug is to open 3D view and enable 3D renderer for the layer - points are shown at zero elevation.
Postgres provider uses ST_Force2D() when retrieving 4D geometries - looks like it was a fix for an earlier bug #9748. Not sure if the forcing to 2D still makes sense. When "force2d" feature is disabled, things still seem to work.
Here is the place where force2d is turned on for 4D geometries: https://github.com/qgis/QGIS/blob/master/src/providers/postgres/qgspostgresconn.cpp#L1491