Skip to content
Permalink
Browse files

Fix some possible exceptions in topocolor alg

  • Loading branch information
nyalldawson committed Aug 13, 2017
1 parent a056e24 commit 913bf64e6573c8a4a3a8fb12071023c15dfdee3a
Showing with 5 additions and 2 deletions.
  1. +5 −2 python/plugins/processing/algs/qgis/TopoColors.py
@@ -112,6 +112,9 @@ def processAlgorithm(self, parameters, context, feedback):
feedback=feedback,
min_colors=min_colors)

if len(feature_colors) == 0:
return {self.OUTPUT: dest_id}

max_colors = max(feature_colors.values())
feedback.pushInfo(self.tr('{} colors required').format(max_colors))

@@ -146,7 +149,7 @@ def compute_graph(features, feedback, create_id_graph=False, min_distance=0):
# skip features without geometry
features_with_geometry = {f_id: f for (f_id, f) in features.items() if f.hasGeometry()}

total = 70.0 / len(features_with_geometry)
total = 70.0 / len(features_with_geometry) if features_with_geometry else 1
index = QgsSpatialIndex()

i = 0
@@ -211,7 +214,7 @@ def balanced(features, graph, feedback, balance=0, min_colors=4):
color_counts[c] = 0
color_areas[c] = 0

total = 10.0 / len(sorted_by_count)
total = 10.0 / len(sorted_by_count) if sorted_by_count else 1
i = 0

for (feature_id, n) in sorted_by_count:

0 comments on commit 913bf64

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