Skip to content
Permalink
Browse files
Fix Z/M dimension URI via DB Manager. Fixes #34894
  • Loading branch information
lbartoletti authored and nyalldawson committed Nov 1, 2021
1 parent 7f154ec commit b084b39e930f5324793bfbddf0383cf50c4a6a50
Showing with 19 additions and 1 deletion.
  1. +18 −0 python/plugins/db_manager/db_plugins/postgis/plugin.py
  2. +1 −1 python/plugins/db_manager/db_tree.py
@@ -308,6 +308,24 @@ def runAction(self, action):
return True
return VectorTable.runAction(self, action)

def geometryType(self):
""" Returns the proper WKT type.
PostGIS records type like this:
| WKT Type | geomType | geomDim |
|--------------|-------------|---------|
| LineString | LineString | 2 |
| LineStringZ | LineString | 3 |
| LineStringM | LineStringM | 3 |
| LineStringZM | LineString | 4 |
"""
geometryType = self.geomType
if self.geomDim == 3 and not self.geomType[-1] == "M":
geometryType += "Z"
elif self.geomDim == 4:
geometryType += "ZM"

return geometryType


class PGRasterTable(PGTable, RasterTable):

@@ -159,7 +159,7 @@ def delete(self):
def addLayer(self):
table = self.currentTable()
if table is not None:
layer = table.toMapLayer()
layer = table.toMapLayer(table.geometryType())
layers = QgsProject.instance().addMapLayers([layer])
if len(layers) != 1:
QgsMessageLog.logMessage(

0 comments on commit b084b39

Please sign in to comment.