Tide: Anzeige erster Testdaten

This commit is contained in:
2025-10-05 12:04:19 +02:00
parent e9d473fd10
commit e7a2f4bb54
6 changed files with 91 additions and 24 deletions

View File

@@ -1,8 +1,7 @@
"""
NAVTEX
- Meldungen anzeigen
Tide Vorausschau
"""
import cairo
@@ -25,6 +24,9 @@ class Tide(Page):
ctx.set_font_size(16)
ctx.set_line_width(2)
ctx.move_to(220, 40)
ctx.show_text("Schulau, Elbe")
x0 = 40 # links unten
y0 = 250
x1 = 380 # rechts oben
@@ -48,3 +50,28 @@ class Tide(Page):
self.draw_text_center(ctx, x0 + (x1 - x0) / 2, y0 + 12, "Zeit, h")
ctx.stroke()
ymin, ymax = self.app.web.get_tide_minmax()
rawdata = self.app.web.get_tide()
ctx.move_to(x0 - 32, y0 + 8)
ctx.show_text(str(ymin))
ctx.move_to(x0 - 32, y1 + 8)
ctx.show_text(str(ymax))
ctx.move_to(x0 + 16, y0 + 16)
ctx.show_text(f"n = {len(rawdata)}")
dx = (x1 - x0) / len(rawdata)
x = x0
while rawdata[0][0] is None:
x += dx
del rawdata[0]
y = (rawdata[0][0] - ymin) / (ymax - ymin) * (y0 - y1)
ctx.move_to(x, y0 - (rawdata[0][0] - ymin))
del rawdata[0]
x += dx
for val in rawdata:
y = (val[0] - ymin) / (ymax - ymin) * (y0 - y1)
ctx.line_to(x, y0 - y)
x += dx