@@ -354,8 +354,9 @@ def multi_to_single( self ):
354
354
allAttrs = vprovider .attributeIndexes ()
355
355
vprovider .select ( allAttrs )
356
356
fields = vprovider .fields ()
357
+ geomType = self .multiToSingleGeom (vprovider .geometryType ())
357
358
writer = QgsVectorFileWriter ( self .myName , self .myEncoding ,
358
- fields , vprovider . geometryType () - 3 , vprovider .crs () )
359
+ fields , geomType , vprovider .crs () )
359
360
inFeat = QgsFeature ()
360
361
outFeat = QgsFeature ()
361
362
inGeom = QgsGeometry ()
@@ -901,6 +902,22 @@ def singleToMultiGeom(self, wkbType):
901
902
except Exception , err :
902
903
print str (err )
903
904
905
+ def multiToSingleGeom (self , wkbType ):
906
+ try :
907
+ if wkbType in (QGis .WKBPoint , QGis .WKBMultiPoint ,
908
+ QGis .WKBPoint25D , QGis .WKBMultiPoint25D ):
909
+ return QGis .WKBPoint
910
+ elif wkbType in (QGis .WKBLineString , QGis .WKBMultiLineString ,
911
+ QGis .WKBMultiLineString25D , QGis .WKBLineString25D ):
912
+ return QGis .WKBLineString
913
+ elif wkbType in (QGis .WKBPolygon , QGis .WKBMultiPolygon ,
914
+ QGis .WKBMultiPolygon25D , QGis .WKBPolygon25D ):
915
+ return QGis .WKBPolygon
916
+ else :
917
+ return QGis .WKBUnknown
918
+ except Exception , err :
919
+ print str (err )
920
+
904
921
def extractAsSingle ( self , geom ):
905
922
multi_geom = QgsGeometry ()
906
923
temp_geom = []
0 commit comments