Skip to content

Commit

Permalink
fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Sep 14, 2016
1 parent acc108a commit d2189ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/gdal/GdalAlgorithm.py
Expand Up @@ -59,9 +59,9 @@ def processAlgorithm(self, progress):
c = c.replace(layer.source(), exported)
if os.path.isfile(layer.source()):
fileName = os.path.splitext(os.path.split(layer.source())[1])[0]
c = re.sub('[\s]{}[\s]'.format(fileName), ' ' + exportedFileName + ' ', c)
c = re.sub('[\s]{}'.format(fileName), ' ' + exportedFileName, c)
c = re.sub('["\']{}["\']'.format(fileName), "'" + exportedFileName + "'", c)
c = re.sub('[\s]{}[\s]'.format(fileName), ' ' + exportedFileName + ' ', c)
c = re.sub('[\s]{}'.format(fileName), ' ' + exportedFileName, c)
c = re.sub('["\']{}["\']'.format(fileName), "'" + exportedFileName + "'", c)

commands[i] = c
GdalUtils.runGdal(commands, progress)
Expand Down
43 changes: 22 additions & 21 deletions python/plugins/processing/algs/qgis/SinglePartsToMultiparts.py
Expand Up @@ -29,7 +29,7 @@

from qgis.PyQt.QtGui import QIcon

from qgis.core import QGis, QgsFeature, QgsGeometry
from qgis.core import Qgis, QgsFeature, QgsGeometry, QgsWkbTypes

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
Expand Down Expand Up @@ -67,7 +67,7 @@ def processAlgorithm(self, progress):
geomType = self.singleToMultiGeom(layer.wkbType())

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
layer.pendingFields().toList(), geomType, layer.crs())
layer.fields().toList(), geomType, layer.crs())

inFeat = QgsFeature()
outFeat = QgsFeature()
Expand All @@ -92,7 +92,7 @@ def processAlgorithm(self, progress):
if first:
attrs = atMap
first = False
inGeom = QgsGeometry(inFeat.geometry())
inGeom = inFeat.geometry()
vType = inGeom.type()
feature_list = self.extractAsMulti(inGeom)
multi_feature.extend(feature_list)
Expand All @@ -108,34 +108,35 @@ def processAlgorithm(self, progress):

del writer
else:
raise GeoAlgorithmExecutionException(self.tr('Invalid unique ID field'))
raise GeoAlgorithmExecutionException(
self.tr('At least two features must have same attribute value! Please choose another field...'))

def singleToMultiGeom(self, wkbType):
try:
if wkbType in (QGis.WKBPoint, QGis.WKBMultiPoint,
QGis.WKBPoint25D, QGis.WKBMultiPoint25D):
return QGis.WKBMultiPoint
elif wkbType in (QGis.WKBLineString, QGis.WKBMultiLineString,
QGis.WKBMultiLineString25D,
QGis.WKBLineString25D):

return QGis.WKBMultiLineString
elif wkbType in (QGis.WKBPolygon, QGis.WKBMultiPolygon,
QGis.WKBMultiPolygon25D, QGis.WKBPolygon25D):

return QGis.WKBMultiPolygon
if wkbType in (QgsWkbTypes.Point, QgsWkbTypes.MultiPoint,
QgsWkbTypes.Point25D, QgsWkbTypes.MultiPoint25D):
return QgsWkbTypes.MultiPoint
elif wkbType in (QgsWkbTypes.LineString, QgsWkbTypes.MultiLineString,
QgsWkbTypes.MultiLineString25D,
QgsWkbTypes.LineString25D):

return QgsWkbTypes.MultiLineString
elif wkbType in (QgsWkbTypes.Polygon, QgsWkbTypes.MultiPolygon,
QgsWkbTypes.MultiPolygon25D, QgsWkbTypes.Polygon25D):

return QgsWkbTypes.MultiPolygon
else:
return QGis.WKBUnknown
return QgsWkbTypes.Unknown
except Exception:
pass

def extractAsMulti(self, geom):
if geom.type() == QGis.Point:
if geom.type() == QgsWkbTypes.PointGeometry:
if geom.isMultipart():
return geom.asMultiPoint()
else:
return [geom.asPoint()]
elif geom.type() == QGis.Line:
elif geom.type() == QgsWkbTypes.LineGeometry:
if geom.isMultipart():
return geom.asMultiPolyline()
else:
Expand All @@ -147,9 +148,9 @@ def extractAsMulti(self, geom):
return [geom.asPolygon()]

def convertGeometry(self, geom_list, vType):
if vType == QGis.Point:
if vType == QgsWkbTypes.PointGeometry:
return QgsGeometry().fromMultiPoint(geom_list)
elif vType == QGis.Line:
elif vType == QgsWkbTypes.LineGeometry:
return QgsGeometry().fromMultiPolyline(geom_list)
else:
return QgsGeometry().fromMultiPolygon(geom_list)

0 comments on commit d2189ac

Please sign in to comment.