mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Allow loading GPKG layers with GEOMETRY type (#42253)
This commit is contained in:
parent
8731c7e60a
commit
60f788c91d
@ -209,12 +209,21 @@ class GPKGTable(Table):
|
||||
# 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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user