From c79802acda75e5e7e26c45a3a4d9da6b51da9215 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 15 Feb 2023 23:08:16 +0100 Subject: implement null-elevation-fix transformer --- fietsboek/locale/de/LC_MESSAGES/messages.mo | Bin 11757 -> 12059 bytes fietsboek/locale/de/LC_MESSAGES/messages.po | 80 +++++++++++++++----------- fietsboek/locale/en/LC_MESSAGES/messages.mo | Bin 11069 -> 11347 bytes fietsboek/locale/en/LC_MESSAGES/messages.po | 80 +++++++++++++++----------- fietsboek/locale/fietslog.pot | 84 ++++++++++++++++------------ fietsboek/transformers/__init__.py | 21 ++++++- 6 files changed, 160 insertions(+), 105 deletions(-) diff --git a/fietsboek/locale/de/LC_MESSAGES/messages.mo b/fietsboek/locale/de/LC_MESSAGES/messages.mo index 7092994..6043d8e 100644 Binary files a/fietsboek/locale/de/LC_MESSAGES/messages.mo and b/fietsboek/locale/de/LC_MESSAGES/messages.mo differ diff --git a/fietsboek/locale/de/LC_MESSAGES/messages.po b/fietsboek/locale/de/LC_MESSAGES/messages.po index dfa2bed..8787ec2 100644 --- a/fietsboek/locale/de/LC_MESSAGES/messages.po +++ b/fietsboek/locale/de/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2022-12-10 17:37+0100\n" +"POT-Creation-Date: 2023-02-15 23:01+0100\n" "PO-Revision-Date: 2022-07-02 17:35+0200\n" "Last-Translator: FULL NAME \n" "Language: de\n" @@ -18,39 +18,39 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.11.0\n" -#: fietsboek/util.py:274 +#: fietsboek/util.py:273 msgid "password_constraint.mismatch" msgstr "Passwörter stimmen nicht überein" -#: fietsboek/util.py:276 +#: fietsboek/util.py:275 msgid "password_constraint.length" msgstr "Passwort zu kurz" -#: fietsboek/models/track.py:543 +#: fietsboek/models/track.py:565 msgid "tooltip.table.length" msgstr "Länge" -#: fietsboek/models/track.py:544 +#: fietsboek/models/track.py:566 msgid "tooltip.table.uphill" msgstr "Bergauf" -#: fietsboek/models/track.py:545 +#: fietsboek/models/track.py:567 msgid "tooltip.table.downhill" msgstr "Bergab" -#: fietsboek/models/track.py:546 +#: fietsboek/models/track.py:568 msgid "tooltip.table.moving_time" msgstr "Fahrzeit" -#: fietsboek/models/track.py:547 +#: fietsboek/models/track.py:569 msgid "tooltip.table.stopped_time" msgstr "Haltezeit" -#: fietsboek/models/track.py:549 +#: fietsboek/models/track.py:571 msgid "tooltip.table.max_speed" msgstr "Maximalgeschwindigkeit" -#: fietsboek/models/track.py:553 +#: fietsboek/models/track.py:575 msgid "tooltip.table.avg_speed" msgstr "Durchschnittsgeschwindigkeit" @@ -438,6 +438,10 @@ msgstr "Bildbeschreibung" msgid "page.track.form.image_description_modal.save" msgstr "Übernehmen" +#: fietsboek/templates/edit_form.jinja2:166 +msgid "page.track.form.transformer.enable" +msgstr "Transformation anwenden" + #: fietsboek/templates/finish_upload.jinja2:8 #: fietsboek/templates/upload.jinja2:6 msgid "page.upload.title" @@ -460,47 +464,47 @@ msgstr "Startseite" msgid "page.home.total" msgstr "Gesamt" -#: fietsboek/templates/layout.jinja2:35 +#: fietsboek/templates/layout.jinja2:36 msgid "page.navbar.toggle" msgstr "Navigation umschalten" -#: fietsboek/templates/layout.jinja2:46 +#: fietsboek/templates/layout.jinja2:47 msgid "page.navbar.home" msgstr "Startseite" -#: fietsboek/templates/layout.jinja2:49 +#: fietsboek/templates/layout.jinja2:50 msgid "page.navbar.browse" msgstr "Stöbern" -#: fietsboek/templates/layout.jinja2:53 +#: fietsboek/templates/layout.jinja2:54 msgid "page.navbar.upload" msgstr "Hochladen" -#: fietsboek/templates/layout.jinja2:62 +#: fietsboek/templates/layout.jinja2:63 msgid "page.navbar.user" msgstr "Nutzer" -#: fietsboek/templates/layout.jinja2:66 +#: fietsboek/templates/layout.jinja2:67 msgid "page.navbar.welcome_user" msgstr "Willkommen, {}!" -#: fietsboek/templates/layout.jinja2:69 +#: fietsboek/templates/layout.jinja2:70 msgid "page.navbar.logout" msgstr "Abmelden" -#: fietsboek/templates/layout.jinja2:72 +#: fietsboek/templates/layout.jinja2:73 msgid "page.navbar.profile" msgstr "Profil" -#: fietsboek/templates/layout.jinja2:76 +#: fietsboek/templates/layout.jinja2:77 msgid "page.navbar.admin" msgstr "Admin" -#: fietsboek/templates/layout.jinja2:82 +#: fietsboek/templates/layout.jinja2:83 msgid "page.navbar.login" msgstr "Anmelden" -#: fietsboek/templates/layout.jinja2:86 +#: fietsboek/templates/layout.jinja2:87 msgid "page.navbar.create_account" msgstr "Konto Erstellen" @@ -626,6 +630,14 @@ msgstr "Anfrage senden" msgid "page.upload.form.gpx" msgstr "GPX Datei" +#: fietsboek/transformers/__init__.py:130 +msgid "transformers.fix-null-elevation.title" +msgstr "Nullhöhen beheben" + +#: fietsboek/transformers/__init__.py:134 +msgid "transformers.fix-null-elevation.description" +msgstr "Diese Transformation passt die Höhenangabe für Punkte an, bei denen die Höhenangabe fehlt." + #: fietsboek/views/account.py:54 msgid "flash.invalid_name" msgstr "Ungültiger Name" @@ -649,15 +661,15 @@ msgstr "" msgid "flash.a_confirmation_link_has_been_sent" msgstr "Ein Bestätigungslink wurde versandt" -#: fietsboek/views/admin.py:49 +#: fietsboek/views/admin.py:48 msgid "flash.badge_added" msgstr "Wappen hinzugefügt" -#: fietsboek/views/admin.py:73 +#: fietsboek/views/admin.py:72 msgid "flash.badge_modified" msgstr "Wappen bearbeitet" -#: fietsboek/views/admin.py:93 +#: fietsboek/views/admin.py:92 msgid "flash.badge_deleted" msgstr "Wappen gelöscht" @@ -705,43 +717,43 @@ msgstr "E-Mail-Adresse bestätigt" msgid "flash.password_updated" msgstr "Passwort aktualisiert" -#: fietsboek/views/detail.py:101 +#: fietsboek/views/detail.py:140 msgid "flash.track_deleted" msgstr "Strecke gelöscht" -#: fietsboek/views/profile.py:61 +#: fietsboek/views/profile.py:60 msgid "flash.personal_data_updated" msgstr "Persönliche Daten wurden gespeichert" -#: fietsboek/views/profile.py:79 +#: fietsboek/views/profile.py:78 msgid "flash.friend_not_found" msgstr "Das angegebene Konto wurde nicht gefunden" -#: fietsboek/views/profile.py:85 +#: fietsboek/views/profile.py:84 msgid "flash.friend_already_exists" msgstr "Dieser Freund existiert bereits" -#: fietsboek/views/profile.py:93 +#: fietsboek/views/profile.py:92 msgid "flash.friend_added" msgstr "Freund hinzugefügt" -#: fietsboek/views/profile.py:103 +#: fietsboek/views/profile.py:102 msgid "flash.friend_request_sent" msgstr "Freundschaftsanfrage gesendet" -#: fietsboek/views/upload.py:56 +#: fietsboek/views/upload.py:52 msgid "flash.no_file_selected" msgstr "Keine Datei ausgewählt" -#: fietsboek/views/upload.py:66 +#: fietsboek/views/upload.py:62 msgid "flash.invalid_file" msgstr "Ungültige GPX-Datei gesendet" -#: fietsboek/views/upload.py:189 +#: fietsboek/views/upload.py:182 msgid "flash.upload_success" msgstr "Hochladen erfolgreich" -#: fietsboek/views/upload.py:205 +#: fietsboek/views/upload.py:198 msgid "flash.upload_cancelled" msgstr "Hochladen abgebrochen" diff --git a/fietsboek/locale/en/LC_MESSAGES/messages.mo b/fietsboek/locale/en/LC_MESSAGES/messages.mo index 7827a62..4f35491 100644 Binary files a/fietsboek/locale/en/LC_MESSAGES/messages.mo and b/fietsboek/locale/en/LC_MESSAGES/messages.mo differ diff --git a/fietsboek/locale/en/LC_MESSAGES/messages.po b/fietsboek/locale/en/LC_MESSAGES/messages.po index f4b0239..5f3ab68 100644 --- a/fietsboek/locale/en/LC_MESSAGES/messages.po +++ b/fietsboek/locale/en/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2022-12-10 17:37+0100\n" +"POT-Creation-Date: 2023-02-15 23:01+0100\n" "PO-Revision-Date: 2022-06-28 13:11+0200\n" "Last-Translator: \n" "Language: en\n" @@ -18,39 +18,39 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.11.0\n" -#: fietsboek/util.py:274 +#: fietsboek/util.py:273 msgid "password_constraint.mismatch" msgstr "Passwords don't match" -#: fietsboek/util.py:276 +#: fietsboek/util.py:275 msgid "password_constraint.length" msgstr "Password not long enough" -#: fietsboek/models/track.py:543 +#: fietsboek/models/track.py:565 msgid "tooltip.table.length" msgstr "Length" -#: fietsboek/models/track.py:544 +#: fietsboek/models/track.py:566 msgid "tooltip.table.uphill" msgstr "Uphill" -#: fietsboek/models/track.py:545 +#: fietsboek/models/track.py:567 msgid "tooltip.table.downhill" msgstr "Downhill" -#: fietsboek/models/track.py:546 +#: fietsboek/models/track.py:568 msgid "tooltip.table.moving_time" msgstr "Moving Time" -#: fietsboek/models/track.py:547 +#: fietsboek/models/track.py:569 msgid "tooltip.table.stopped_time" msgstr "Stopped Time" -#: fietsboek/models/track.py:549 +#: fietsboek/models/track.py:571 msgid "tooltip.table.max_speed" msgstr "Max Speed" -#: fietsboek/models/track.py:553 +#: fietsboek/models/track.py:575 msgid "tooltip.table.avg_speed" msgstr "Average Speed" @@ -434,6 +434,10 @@ msgstr "Image description" msgid "page.track.form.image_description_modal.save" msgstr "Apply" +#: fietsboek/templates/edit_form.jinja2:166 +msgid "page.track.form.transformer.enable" +msgstr "Apply transformation" + #: fietsboek/templates/finish_upload.jinja2:8 #: fietsboek/templates/upload.jinja2:6 msgid "page.upload.title" @@ -456,47 +460,47 @@ msgstr "Home" msgid "page.home.total" msgstr "Total" -#: fietsboek/templates/layout.jinja2:35 +#: fietsboek/templates/layout.jinja2:36 msgid "page.navbar.toggle" msgstr "Toggle navigation" -#: fietsboek/templates/layout.jinja2:46 +#: fietsboek/templates/layout.jinja2:47 msgid "page.navbar.home" msgstr "Home" -#: fietsboek/templates/layout.jinja2:49 +#: fietsboek/templates/layout.jinja2:50 msgid "page.navbar.browse" msgstr "Browse" -#: fietsboek/templates/layout.jinja2:53 +#: fietsboek/templates/layout.jinja2:54 msgid "page.navbar.upload" msgstr "Upload" -#: fietsboek/templates/layout.jinja2:62 +#: fietsboek/templates/layout.jinja2:63 msgid "page.navbar.user" msgstr "User" -#: fietsboek/templates/layout.jinja2:66 +#: fietsboek/templates/layout.jinja2:67 msgid "page.navbar.welcome_user" msgstr "Welcome, {}!" -#: fietsboek/templates/layout.jinja2:69 +#: fietsboek/templates/layout.jinja2:70 msgid "page.navbar.logout" msgstr "Logout" -#: fietsboek/templates/layout.jinja2:72 +#: fietsboek/templates/layout.jinja2:73 msgid "page.navbar.profile" msgstr "Profile" -#: fietsboek/templates/layout.jinja2:76 +#: fietsboek/templates/layout.jinja2:77 msgid "page.navbar.admin" msgstr "Admin" -#: fietsboek/templates/layout.jinja2:82 +#: fietsboek/templates/layout.jinja2:83 msgid "page.navbar.login" msgstr "Login" -#: fietsboek/templates/layout.jinja2:86 +#: fietsboek/templates/layout.jinja2:87 msgid "page.navbar.create_account" msgstr "Create Account" @@ -622,6 +626,14 @@ msgstr "Send request" msgid "page.upload.form.gpx" msgstr "GPX file" +#: fietsboek/transformers/__init__.py:130 +msgid "transformers.fix-null-elevation.title" +msgstr "Fix null elevation" + +#: fietsboek/transformers/__init__.py:134 +msgid "transformers.fix-null-elevation.description" +msgstr "This transformer fixes the elevation of points whose elevation is unset." + #: fietsboek/views/account.py:54 msgid "flash.invalid_name" msgstr "Invalid name" @@ -645,15 +657,15 @@ msgstr "" msgid "flash.a_confirmation_link_has_been_sent" msgstr "A confirmation link has been sent" -#: fietsboek/views/admin.py:49 +#: fietsboek/views/admin.py:48 msgid "flash.badge_added" msgstr "Badge has been added" -#: fietsboek/views/admin.py:73 +#: fietsboek/views/admin.py:72 msgid "flash.badge_modified" msgstr "Badge has been modified" -#: fietsboek/views/admin.py:93 +#: fietsboek/views/admin.py:92 msgid "flash.badge_deleted" msgstr "Badge has been deleted" @@ -700,43 +712,43 @@ msgstr "Your email address has been verified" msgid "flash.password_updated" msgstr "Password has been updated" -#: fietsboek/views/detail.py:101 +#: fietsboek/views/detail.py:140 msgid "flash.track_deleted" msgstr "Track has been deleted" -#: fietsboek/views/profile.py:61 +#: fietsboek/views/profile.py:60 msgid "flash.personal_data_updated" msgstr "Personal data has been updated" -#: fietsboek/views/profile.py:79 +#: fietsboek/views/profile.py:78 msgid "flash.friend_not_found" msgstr "The friend was not found" -#: fietsboek/views/profile.py:85 +#: fietsboek/views/profile.py:84 msgid "flash.friend_already_exists" msgstr "Friend already exists" -#: fietsboek/views/profile.py:93 +#: fietsboek/views/profile.py:92 msgid "flash.friend_added" msgstr "Friend has been added" -#: fietsboek/views/profile.py:103 +#: fietsboek/views/profile.py:102 msgid "flash.friend_request_sent" msgstr "Friend request sent" -#: fietsboek/views/upload.py:56 +#: fietsboek/views/upload.py:52 msgid "flash.no_file_selected" msgstr "No file selected" -#: fietsboek/views/upload.py:66 +#: fietsboek/views/upload.py:62 msgid "flash.invalid_file" msgstr "Invalid GPX file selected" -#: fietsboek/views/upload.py:189 +#: fietsboek/views/upload.py:182 msgid "flash.upload_success" msgstr "Upload successful" -#: fietsboek/views/upload.py:205 +#: fietsboek/views/upload.py:198 msgid "flash.upload_cancelled" msgstr "Upload cancelled" diff --git a/fietsboek/locale/fietslog.pot b/fietsboek/locale/fietslog.pot index a86c43b..05bc70a 100644 --- a/fietsboek/locale/fietslog.pot +++ b/fietsboek/locale/fietslog.pot @@ -1,14 +1,14 @@ # Translations template for PROJECT. -# Copyright (C) 2022 ORGANIZATION +# Copyright (C) 2023 ORGANIZATION # This file is distributed under the same license as the PROJECT project. -# FIRST AUTHOR , 2022. +# FIRST AUTHOR , 2023. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2022-12-10 17:37+0100\n" +"POT-Creation-Date: 2023-02-15 23:01+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,39 +17,39 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.11.0\n" -#: fietsboek/util.py:274 +#: fietsboek/util.py:273 msgid "password_constraint.mismatch" msgstr "" -#: fietsboek/util.py:276 +#: fietsboek/util.py:275 msgid "password_constraint.length" msgstr "" -#: fietsboek/models/track.py:543 +#: fietsboek/models/track.py:565 msgid "tooltip.table.length" msgstr "" -#: fietsboek/models/track.py:544 +#: fietsboek/models/track.py:566 msgid "tooltip.table.uphill" msgstr "" -#: fietsboek/models/track.py:545 +#: fietsboek/models/track.py:567 msgid "tooltip.table.downhill" msgstr "" -#: fietsboek/models/track.py:546 +#: fietsboek/models/track.py:568 msgid "tooltip.table.moving_time" msgstr "" -#: fietsboek/models/track.py:547 +#: fietsboek/models/track.py:569 msgid "tooltip.table.stopped_time" msgstr "" -#: fietsboek/models/track.py:549 +#: fietsboek/models/track.py:571 msgid "tooltip.table.max_speed" msgstr "" -#: fietsboek/models/track.py:553 +#: fietsboek/models/track.py:575 msgid "tooltip.table.avg_speed" msgstr "" @@ -431,6 +431,10 @@ msgstr "" msgid "page.track.form.image_description_modal.save" msgstr "" +#: fietsboek/templates/edit_form.jinja2:166 +msgid "page.track.form.transformer.enable" +msgstr "" + #: fietsboek/templates/finish_upload.jinja2:8 #: fietsboek/templates/upload.jinja2:6 msgid "page.upload.title" @@ -453,47 +457,47 @@ msgstr "" msgid "page.home.total" msgstr "" -#: fietsboek/templates/layout.jinja2:35 +#: fietsboek/templates/layout.jinja2:36 msgid "page.navbar.toggle" msgstr "" -#: fietsboek/templates/layout.jinja2:46 +#: fietsboek/templates/layout.jinja2:47 msgid "page.navbar.home" msgstr "" -#: fietsboek/templates/layout.jinja2:49 +#: fietsboek/templates/layout.jinja2:50 msgid "page.navbar.browse" msgstr "" -#: fietsboek/templates/layout.jinja2:53 +#: fietsboek/templates/layout.jinja2:54 msgid "page.navbar.upload" msgstr "" -#: fietsboek/templates/layout.jinja2:62 +#: fietsboek/templates/layout.jinja2:63 msgid "page.navbar.user" msgstr "" -#: fietsboek/templates/layout.jinja2:66 +#: fietsboek/templates/layout.jinja2:67 msgid "page.navbar.welcome_user" msgstr "" -#: fietsboek/templates/layout.jinja2:69 +#: fietsboek/templates/layout.jinja2:70 msgid "page.navbar.logout" msgstr "" -#: fietsboek/templates/layout.jinja2:72 +#: fietsboek/templates/layout.jinja2:73 msgid "page.navbar.profile" msgstr "" -#: fietsboek/templates/layout.jinja2:76 +#: fietsboek/templates/layout.jinja2:77 msgid "page.navbar.admin" msgstr "" -#: fietsboek/templates/layout.jinja2:82 +#: fietsboek/templates/layout.jinja2:83 msgid "page.navbar.login" msgstr "" -#: fietsboek/templates/layout.jinja2:86 +#: fietsboek/templates/layout.jinja2:87 msgid "page.navbar.create_account" msgstr "" @@ -617,6 +621,14 @@ msgstr "" msgid "page.upload.form.gpx" msgstr "" +#: fietsboek/transformers/__init__.py:130 +msgid "transformers.fix-null-elevation.title" +msgstr "" + +#: fietsboek/transformers/__init__.py:134 +msgid "transformers.fix-null-elevation.description" +msgstr "" + #: fietsboek/views/account.py:54 msgid "flash.invalid_name" msgstr "" @@ -637,15 +649,15 @@ msgstr "" msgid "flash.a_confirmation_link_has_been_sent" msgstr "" -#: fietsboek/views/admin.py:49 +#: fietsboek/views/admin.py:48 msgid "flash.badge_added" msgstr "" -#: fietsboek/views/admin.py:73 +#: fietsboek/views/admin.py:72 msgid "flash.badge_modified" msgstr "" -#: fietsboek/views/admin.py:93 +#: fietsboek/views/admin.py:92 msgid "flash.badge_deleted" msgstr "" @@ -689,43 +701,43 @@ msgstr "" msgid "flash.password_updated" msgstr "" -#: fietsboek/views/detail.py:101 +#: fietsboek/views/detail.py:140 msgid "flash.track_deleted" msgstr "" -#: fietsboek/views/profile.py:61 +#: fietsboek/views/profile.py:60 msgid "flash.personal_data_updated" msgstr "" -#: fietsboek/views/profile.py:79 +#: fietsboek/views/profile.py:78 msgid "flash.friend_not_found" msgstr "" -#: fietsboek/views/profile.py:85 +#: fietsboek/views/profile.py:84 msgid "flash.friend_already_exists" msgstr "" -#: fietsboek/views/profile.py:93 +#: fietsboek/views/profile.py:92 msgid "flash.friend_added" msgstr "" -#: fietsboek/views/profile.py:103 +#: fietsboek/views/profile.py:102 msgid "flash.friend_request_sent" msgstr "" -#: fietsboek/views/upload.py:56 +#: fietsboek/views/upload.py:52 msgid "flash.no_file_selected" msgstr "" -#: fietsboek/views/upload.py:66 +#: fietsboek/views/upload.py:62 msgid "flash.invalid_file" msgstr "" -#: fietsboek/views/upload.py:189 +#: fietsboek/views/upload.py:182 msgid "flash.upload_success" msgstr "" -#: fietsboek/views/upload.py:205 +#: fietsboek/views/upload.py:198 msgid "flash.upload_cancelled" msgstr "" diff --git a/fietsboek/transformers/__init__.py b/fietsboek/transformers/__init__.py index b22c492..1f084a0 100644 --- a/fietsboek/transformers/__init__.py +++ b/fietsboek/transformers/__init__.py @@ -11,6 +11,7 @@ function to load and apply transformers. from abc import ABC, abstractmethod from collections.abc import Mapping +from itertools import chain, islice from typing import TypeVar from gpxpy.gpx import GPX @@ -145,7 +146,25 @@ class FixNullElevation(Transformer): pass def execute(self, gpx): - print("YALLA YALLA") + def all_points(): + return ( + point + for track in gpx.tracks + for segment in track.segments + for point in segment.points + ) + + points = all_points() + previous_points = chain([None], all_points()) + next_points = chain(islice(all_points(), 1, None), [None]) + + for previous_point, point, next_point in zip(previous_points, points, next_points): + if point.elevation == 0.0: + if previous_point: + point.elevation += previous_point.elevation + if next_point: + point.elevation += next_point.elevation + point.elevation /= sum(1 for pt in [previous_point, next_point] if pt) def list_transformers() -> list[type[Transformer]]: -- cgit v1.2.3