Skip to content
Permalink
Browse files

[processing] Throw error when attempting to use Distance Matrix with

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

(cherry picked from commit 5c2f68e)
  • Loading branch information
nyalldawson committed Dec 14, 2018
1 parent 3169977 commit 489f32d8a4608b9bbf0ad9a9233a6d28d473177d
Showing with 6 additions and 0 deletions.
  1. +6 −0 python/plugins/processing/algs/qgis/PointDistance.py
@@ -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)

0 comments on commit 489f32d

Please sign in to comment.
You can’t perform that action at this time.