Skip to content

Commit

Permalink
[processing] Throw error when attempting to use Distance Matrix with
Browse files Browse the repository at this point in the history
multipoint datasets

There's no single approach to use for multi-point inputs, so instead
of overloading this algorithm with extra options to control how these
are handled, we raise a helpful error and push the reponsibility back
to the user to get the data into the right format before running the
tool.

Fixes #20799
  • Loading branch information
nyalldawson committed Dec 15, 2018
1 parent 1285a01 commit 5c2f68e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/plugins/processing/algs/qgis/PointDistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ def processAlgorithm(self, parameters, context, feedback):
if source is None:
raise QgsProcessingException(self.invalidSourceError(parameters, self.INPUT))

if QgsWkbTypes.isMultiType(source.wkbType()):
raise QgsProcessingException(self.tr('Input point layer is a MultiPoint layer - first convert to single points before using this algorithm.'))

source_field = self.parameterAsString(parameters, self.INPUT_FIELD, context)
target_source = self.parameterAsSource(parameters, self.TARGET, context)
if target_source is None:
raise QgsProcessingException(self.invalidSourceError(parameters, self.TARGET))

if QgsWkbTypes.isMultiType(target_source.wkbType()):
raise QgsProcessingException(self.tr('Target point layer is a MultiPoint layer - first convert to single points before using this algorithm.'))

target_field = self.parameterAsString(parameters, self.TARGET_FIELD, context)
same_source_and_target = parameters[self.INPUT] == parameters[self.TARGET]
matType = self.parameterAsEnum(parameters, self.MATRIX_TYPE, context)
Expand Down

0 comments on commit 5c2f68e

Please sign in to comment.