Skip to content
Permalink
Browse files

Allow loading GPKG layers with GEOMETRY type (#42253)

  • Loading branch information
mbernasocchi authored and github-actions committed Mar 16, 2021
1 parent f4e4d88 commit fbecae12b06906327d8be20b9240fb74541e87b7
Showing with 10 additions and 1 deletion.
  1. +10 −1 python/plugins/db_manager/db_plugins/gpkg/plugin.py
@@ -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):

0 comments on commit fbecae1

Please sign in to comment.