Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Allow loading GPKG layers with GEOMETRY type (#42253)
- Loading branch information
Showing
with
10 additions
and
1 deletion.
-
+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): |
|
|