aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2026-10-16 00:19:33 +0200
committerDaniel Schadt <kingdread@gmx.de>2026-10-16 00:19:33 +0200
commitbe568d5386e550f2b2ba4fbfc73cb7a45f605506 (patch)
tree1b1c40dacc4b5dd81d725f203f2e342b8dfcf247
parentb98b74cbe4efafbe22aa7db759c1b95f89b7f7a3 (diff)
downloadfietsboek-be568d5386e550f2b2ba4fbfc73cb7a45f605506.tar.gz
fietsboek-be568d5386e550f2b2ba4fbfc73cb7a45f605506.tar.bz2
fietsboek-be568d5386e550f2b2ba4fbfc73cb7a45f605506.zip
add a small comment explaining the colorization
-rw-r--r--fietsboek/trackmap.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/fietsboek/trackmap.py b/fietsboek/trackmap.py
index d2f16e0..cb64893 100644
--- a/fietsboek/trackmap.py
+++ b/fietsboek/trackmap.py
@@ -212,6 +212,14 @@ def height_profile(track: geo.Path, size: tuple[int, int] = (300, 300), simplify
polyline.append((cur_x, cur_y, dist, point.elevation))
last = point
+ # If simplification is enabled, we do the following:
+ # 1. We use the Visvalignam-Whyatt algorithm to simplify the height profile
+ # to the given number of points.
+ # 2. We colorize the simplified profile.
+ # 3. We draw the actual profile using the original data, only using the
+ # simplified color profile for the colors.
+ # This gives the best of both worlds: An accurately drawn profile, but no
+ # color "overload".
if simplify:
simplified = _visvalignam_whyatt(polyline, simplify)
else:
@@ -253,6 +261,7 @@ def _visvalignam_whyatt(
polyline: list[tuple[float, float, float, float]],
target: int,
) -> list[tuple[float, float, float, float]]:
+ # See https://en.wikipedia.org/wiki/Visvalingam%E2%80%93Whyatt_algorithm
polyline = polyline[:]
while len(polyline) > target:
areas = (