mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-19 00:02:48 -04:00
Make algorithm recursive
When a new color is required, repeat the color assignment process. This is the fastest part of the algorithm, so there's no noticable speed drop. Repeating the whole coloring ensures that newly added colors are properly balanced with respect to other colors, and avoids the situation where one of the last features to be colored requires a whole new class to be created, which will only have a few possible members. Overall this results in more balanced color assignment.
This commit is contained in:
parent
ff10cf48f4
commit
2fd78b85bd
@ -203,9 +203,9 @@ class ColoringAlgorithm:
|
||||
|
||||
feature_color=-1
|
||||
if len(available_colors) == 0:
|
||||
# no existing colors available for this feature, so add new color to pool
|
||||
feature_color = len(color_pool) + 1
|
||||
color_pool.add(feature_color)
|
||||
# no existing colors available for this feature, so add new color to pool and repeat
|
||||
min_colors += 1
|
||||
return ColoringAlgorithm.balanced(features,graph,feedback,balance,min_colors)
|
||||
else:
|
||||
if balance==BalanceMethod.BY_COUNT:
|
||||
# choose least used available color
|
||||
|
Loading…
x
Reference in New Issue
Block a user