[FEATURE] Remove Singleparts to Multiparts algorithm

This algorithm is no longer required - it's been replaced by
the 'Promote to multipart' and 'Collect geometries" algorithms.

Tagged as feature to remember to include in release notes
This commit is contained in:
Nyall Dawson 2017-09-05 11:31:14 +10:00
parent 16c4f830b3
commit a55fbd8ef3
4 changed files with 1 additions and 129 deletions

View File

@ -544,9 +544,6 @@ qgis:simplifygeometries: >
The algorithm gives a choice of simplification methods, including distance based (the "Douglas-Peucker" algorithm), area based ("Visvalingam" algorithm) and snapping geometries to grid.
qgis:singlepartstomultipart:
qgis:singlesidedbuffer: >
This algorithm buffers lines by a specified distance on one side of the line only.

View File

@ -144,7 +144,6 @@ from .ShortestPathLayerToPoint import ShortestPathLayerToPoint
from .ShortestPathPointToLayer import ShortestPathPointToLayer
from .ShortestPathPointToPoint import ShortestPathPointToPoint
from .SimplifyGeometries import SimplifyGeometries
from .SinglePartsToMultiparts import SinglePartsToMultiparts
from .SingleSidedBuffer import SingleSidedBuffer
from .Slope import Slope
from .Smooth import Smooth
@ -292,7 +291,6 @@ class QGISAlgorithmProvider(QgsProcessingProvider):
ShortestPathPointToLayer(),
ShortestPathPointToPoint(),
SimplifyGeometries(),
SinglePartsToMultiparts(),
SingleSidedBuffer(),
Slope(),
Smooth(),

View File

@ -1,123 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
SinglePartsToMultiparts.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
from builtins import str
__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
from qgis.PyQt.QtGui import QIcon
from qgis.core import (QgsFeature,
QgsFeatureSink,
QgsGeometry,
QgsWkbTypes,
QgsProcessingUtils,
NULL,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterField,
QgsProcessingParameterFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
class SinglePartsToMultiparts(QgisAlgorithm):
INPUT = 'INPUT'
FIELD = 'FIELD'
OUTPUT = 'OUTPUT'
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'single_to_multi.png'))
def group(self):
return self.tr('Vector geometry')
def __init__(self):
super().__init__()
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer')))
self.addParameter(QgsProcessingParameterField(self.FIELD,
self.tr('Unique ID field'), parentLayerParameterName=self.INPUT))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Multipart')))
def name(self):
return 'singlepartstomultipart'
def displayName(self):
return self.tr('Singleparts to multipart')
def processAlgorithm(self, parameters, context, feedback):
source = self.parameterAsSource(parameters, self.INPUT, context)
field_name = self.parameterAsString(parameters, self.FIELD, context)
geom_type = QgsWkbTypes.multiType(source.wkbType())
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
source.fields(), geom_type, source.sourceCrs())
index = source.fields().lookupField(field_name)
collection_geom = {}
collection_attrs = {}
features = source.getFeatures()
total = 100.0 / source.featureCount() if source.featureCount() else 0
for current, feature in enumerate(features):
if feedback.isCanceled():
break
atMap = feature.attributes()
idVar = atMap[index]
if idVar in [None, NULL] or not feature.hasGeometry():
sink.addFeature(feature, QgsFeatureSink.FastInsert)
feedback.setProgress(int(current * total))
continue
key = str(idVar).strip()
if key not in collection_geom:
collection_geom[key] = []
collection_attrs[key] = atMap
inGeom = feature.geometry()
collection_geom[key].append(inGeom)
feedback.setProgress(int(current * total))
for key, geoms in collection_geom.items():
if feedback.isCanceled():
break
feature = QgsFeature()
feature.setAttributes(collection_attrs[key])
feature.setGeometry(QgsGeometry.collectGeometry(geoms))
sink.addFeature(feature, QgsFeatureSink.FastInsert)
return {self.OUTPUT: dest_id}

View File

@ -2683,7 +2683,7 @@ tests:
name: expected/mean_coordinates.gml
type: vector
- algorithm: qgis:singlepartstomultipart
- algorithm: native:collect
name: single part to multipart
params:
FIELD: id