|
52 | 52 | from processing.tools import dataobjects, spatialite, postgis |
53 | 53 |
|
54 | 54 |
|
55 | | -GEOM_TYPE_MAP = { |
56 | | - QgsWkbTypes.NullGeometry: 'none', |
57 | | - QgsWkbTypes.Point: 'Point', |
58 | | - QgsWkbTypes.LineString: 'LineString', |
59 | | - QgsWkbTypes.Polygon: 'Polygon', |
60 | | - QgsWkbTypes.MultiPoint: 'MultiPoint', |
61 | | - QgsWkbTypes.MultiLineString: 'MultiLineString', |
62 | | - QgsWkbTypes.MultiPolygon: 'MultiPolygon', |
63 | | - QgsWkbTypes.Point25D: 'Point25D', |
64 | | - QgsWkbTypes.LineString25D: 'LineString25D', |
65 | | - QgsWkbTypes.Polygon25D: 'Polygon25D', |
66 | | - QgsWkbTypes.MultiPoint25D: 'MultiPoint25D', |
67 | | - QgsWkbTypes.MultiLineString25D: 'MultiLineString25D', |
68 | | - QgsWkbTypes.MultiPolygon25D: 'MultiPolygon25D', |
69 | | -} |
70 | | - |
71 | | - |
72 | 55 | TYPE_MAP = { |
73 | 56 | str: QVariant.String, |
74 | 57 | float: QVariant.Double, |
@@ -567,7 +550,7 @@ def __init__(self, destination, encoding, fields, geometryType, |
567 | 550 | if self.destination.startswith(self.MEMORY_LAYER_PREFIX): |
568 | 551 | self.isNotFileBased = True |
569 | 552 |
|
570 | | - uri = GEOM_TYPE_MAP[geometryType] + "?uuid=" + str(uuid.uuid4()) |
| 553 | + uri = QgsWkbTypes.displayString(geometryType) + "?uuid=" + str(uuid.uuid4()) |
571 | 554 | if crs.isValid(): |
572 | 555 | uri += '&crs=' + crs.authid() |
573 | 556 | fieldsdesc = [] |
@@ -614,7 +597,7 @@ def _runSQL(sql): |
614 | 597 | if geometryType != QgsWkbTypes.NullGeometry: |
615 | 598 | _runSQL("SELECT AddGeometryColumn('{schema}', '{table}', 'the_geom', {srid}, '{typmod}', 2)".format( |
616 | 599 | table=uri.table().lower(), schema=uri.schema(), srid=crs.authid().split(":")[-1], |
617 | | - typmod=GEOM_TYPE_MAP[geometryType].upper())) |
| 600 | + typmod=QgsWkbTypes.displayString(geometryType).upper())) |
618 | 601 |
|
619 | 602 | self.layer = QgsVectorLayer(uri.uri(), uri.table(), "postgres") |
620 | 603 | self.writer = self.layer.dataProvider() |
@@ -646,7 +629,7 @@ def _runSQL(sql): |
646 | 629 | if geometryType != QgsWkbTypes.NullGeometry: |
647 | 630 | _runSQL("SELECT AddGeometryColumn('{table}', 'the_geom', {srid}, '{typmod}', 2)".format( |
648 | 631 | table=uri.table().lower(), srid=crs.authid().split(":")[-1], |
649 | | - typmod=GEOM_TYPE_MAP[geometryType].upper())) |
| 632 | + typmod=QgsWkbTypes.displayString(geometryType).upper())) |
650 | 633 |
|
651 | 634 | self.layer = QgsVectorLayer(uri.uri(), uri.table(), "spatialite") |
652 | 635 | self.writer = self.layer.dataProvider() |
|
0 commit comments