Skip to content

Commit

Permalink
Merge pull request #45304 from qgis/backport-45223-to-queued_ltr_back…
Browse files Browse the repository at this point in the history
…ports

[Backport queued_ltr_backports] Fix Z/M dimension URI via DB Manager. Fixes #34894
  • Loading branch information
lbartoletti committed Sep 30, 2021
2 parents 0b1ccc6 + 6430269 commit 12be3a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions python/plugins/db_manager/db_plugins/postgis/plugin.py
Expand Up @@ -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 self.geomType[-1] != "M":
geometryType += "Z"
elif self.geomDim == 4:
geometryType += "ZM"

return geometryType


class PGRasterTable(PGTable, RasterTable):

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_tree.py
Expand Up @@ -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(
Expand Down

0 comments on commit 12be3a6

Please sign in to comment.