Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow loading GPKG layers with GEOMETRY type (#42253)
  • Loading branch information
mbernasocchi committed Mar 16, 2021
1 parent 8731c7e commit 60f788c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/plugins/db_manager/db_plugins/gpkg/plugin.py
Expand Up @@ -209,12 +209,21 @@ def mimeUri(self):
# QGIS has no provider to load Geopackage vectors, let's use OGR
return u"vector:ogr:%s:%s" % (self.name, self.ogrUri())

def toMapLayer(self):
def toMapLayer(self, geometryType=None, crs=None):
from qgis.core import QgsVectorLayer

provider = "ogr"
uri = self.ogrUri()

if geometryType:
geom_mapping = {
'POINT': 'Point',
'LINESTRING': 'LineString',
'POLYGON': 'Polygon',
}
geometryType = geom_mapping[geometryType]
uri = "{}|geometrytype={}".format(uri, geometryType)

return QgsVectorLayer(uri, self.name, provider)

def tableFieldsFactory(self, row, table):
Expand Down

0 comments on commit 60f788c

Please sign in to comment.