Skip to content
Permalink
Browse files
Merge pull request #42924 from agiudiceandrea/fix-42918-42919-dbmanager
[DB Manager] Fix layers with Z/M or with CurvePolygon/MultyCurve/... geometry types and No Geometry tables.
  • Loading branch information
nyalldawson committed Apr 27, 2021
2 parents 3ecfd14 + 828638f commit 746495f8faab435efa083195a3ba30c90c78e7bd
Showing with 16 additions and 40 deletions.
  1. +16 −40 python/plugins/db_manager/db_plugins/vlayers/connector.py
@@ -215,45 +215,20 @@ def getVectorTables(self, schema=None):

geomType = None
dim = None
g = l.dataProvider().wkbType()
if g == QgsWkbTypes.Point:
geomType = 'POINT'
dim = 'XY'
elif g == QgsWkbTypes.LineString:
geomType = 'LINESTRING'
dim = 'XY'
elif g == QgsWkbTypes.Polygon:
geomType = 'POLYGON'
dim = 'XY'
elif g == QgsWkbTypes.MultiPoint:
geomType = 'MULTIPOINT'
dim = 'XY'
elif g == QgsWkbTypes.MultiLineString:
geomType = 'MULTILINESTRING'
dim = 'XY'
elif g == QgsWkbTypes.MultiPolygon:
geomType = 'MULTIPOLYGON'
dim = 'XY'
elif g == QgsWkbTypes.Point25D:
geomType = 'POINT'
dim = 'XYZ'
elif g == QgsWkbTypes.LineString25D:
geomType = 'LINESTRING'
dim = 'XYZ'
elif g == QgsWkbTypes.Polygon25D:
geomType = 'POLYGON'
dim = 'XYZ'
elif g == QgsWkbTypes.MultiPoint25D:
geomType = 'MULTIPOINT'
dim = 'XYZ'
elif g == QgsWkbTypes.MultiLineString25D:
geomType = 'MULTILINESTRING'
dim = 'XYZ'
elif g == QgsWkbTypes.MultiPolygon25D:
geomType = 'MULTIPOLYGON'
dim = 'XYZ'
lst.append(
(Table.VectorType, lname, False, False, l.id(), 'geometry', geomType, dim, l.crs().postgisSrid()))
if l.isSpatial():
g = l.dataProvider().wkbType()
g_flat = QgsWkbTypes.flatType(g)
geomType = QgsWkbTypes.displayString(g_flat).upper()
if geomType:
dim = 'XY'
if QgsWkbTypes.hasZ(g):
dim += 'Z'
if QgsWkbTypes.hasM(g):
dim += 'M'
lst.append(
(Table.VectorType, lname, False, False, l.id(), 'geometry', geomType, dim, l.crs().postgisSrid()))
else:
lst.append((Table.TableType, lname, False, False))
return lst

def getRasterTables(self, schema=None):
@@ -276,7 +251,8 @@ def getTableFields(self, table):
n = l.dataProvider().fields().size()
f = [(i, f.name(), f.typeName(), False, None, False)
for i, f in enumerate(l.dataProvider().fields())]
f += [(n, "geometry", "geometry", False, None, False)]
if l.isSpatial():
f += [(n, "geometry", "geometry", False, None, False)]
return f

def getTableIndexes(self, table):

0 comments on commit 746495f

Please sign in to comment.