From 81f9d53da2fb4c7f1fafb92d3d7bc7c19476b4af Mon Sep 17 00:00:00 2001 From: PCigales <58741513+PCigales@users.noreply.github.com> Date: Thu, 16 Sep 2021 22:31:02 +0200 Subject: [PATCH] Implementation of timestamp completion by interpolation --- GPXTweaker.py | 117 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 6 deletions(-) diff --git a/GPXTweaker.py b/GPXTweaker.py index ff89d49..6d6747c 100644 --- a/GPXTweaker.py +++ b/GPXTweaker.py @@ -115,6 +115,7 @@ 'jelevationsadd': 'ajouter élévations', 'jelevationsreplace': 'remplacer élévations', 'jaltitudesjoin': 'joindre altitudes', + 'jdatetime': 'compléter l\'horodatage par interpolation', 'jsave': 'sauvegarder', 'jswitchpoints': 'afficher/cacher points', 'jgraph': 'afficher/cacher graphique', @@ -249,6 +250,7 @@ 'jelevationsadd': 'add elevations', 'jelevationsreplace': 'replace elevations', 'jaltitudesjoin': 'join altitudes', + 'jdatetime': 'complete timestamps by interpolation', 'jsave': 'backup', 'jswitchpoints': 'show/hide points', 'jgraph': 'show/hide graph', @@ -2761,7 +2763,7 @@ class GPXTweakerWebInterfaceServer(): ' --zoom:1;\r\n' \ ' }\r\n' \ ' input[id=name_track] {\r\n' \ - ' width:calc(97vw - 55em);\r\n' \ + ' width:calc(97vw - 57em);\r\n' \ ' font-size:70%;\r\n' \ ' background-color:inherit;\r\n' \ ' color:inherit;\r\n' \ @@ -3976,7 +3978,11 @@ class GPXTweakerWebInterfaceServer(): ' }\r\n' \ ' if (seg != null) {segment_recalc(seg);}\r\n' \ ' if (ex_foc && ex_foc != focused) {element_click(null, document.getElementById(ex_foc + "desc"));}\r\n' \ - ' if (! ex_foc && focused) {element_click(null, document.getElementById(focused + "desc"));}\r\n' \ + ' if (! ex_foc && focused) {\r\n' \ + ' ex_foc = focused;\r\n' \ + ' element_click(null, document.getElementById(focused + "desc"));\r\n' \ + ' dot_style(ex_foc, false);\r\n' \ + ' }\r\n' \ ' if (seg != null) {whole_calc();}\r\n' \ ' if (gr) {refresh_graph(true);}\r\n' \ ' }\r\n' \ @@ -4095,6 +4101,97 @@ class GPXTweakerWebInterfaceServer(): ' element_click(null, document.getElementById(seg_foc.id.replace("cont", "desc")));\r\n' \ ' }\r\n' \ ' }\r\n' \ + ' function datetime_interpolate() {\r\n' \ + ' let segs = [];\r\n' \ + ' let seg_foc = null;\r\n' \ + ' let pt_foc = null;\r\n' \ + ' if (focused == "") {\r\n' \ + ' segms = document.getElementById("pointsform").children;\r\n' \ + ' for (let s=0; s 0) {\r\n' \ + ' dist += distance(document.getElementById(spans[pp].id.replace("focus", "lat")).value, document.getElementById(spans[pp].id.replace("focus", "lon")).value, pele==null?0:pele, document.getElementById(spans[p].id.replace("focus", "lat")).value, document.getElementById(spans[p].id.replace("focus", "lon")).value, pele==null?0:ele);\r\n' \ + ' if (etime >= stime && dist > 0) {\r\n' \ + ' for (let i=0; i=0; p--) {\r\n' \ ' [lat, lon] = path[p].split(",").map(Number);\r\n' \ ' point_insert("b", lat, lon);\r\n' \ @@ -4420,12 +4520,14 @@ class GPXTweakerWebInterfaceServer(): ' document.getElementById(focused + "lon").value = lon.toFixed(6);\r\n' \ ' document.getElementById(focused + "alt").value = "";\r\n' \ ' document.getElementById(focused + "ele").value = "";\r\n' \ + ' document.getElementById(focused + "time").value = "";\r\n' \ ' point_edit(false, false, false);\r\n' \ ' save_old();\r\n' \ ' }\r\n' \ ' if (focused != foc) {element_click(null, document.getElementById(foc + "desc"));}\r\n' \ ' document.getElementById(foc).scrollIntoView({block:"center"});\r\n' \ ' segment_recalc(document.getElementById(foc).parentNode.parentNode);\r\n' \ + ' if (gr) {refresh_graph(true);}\r\n' \ ' } \r\n' \ ' function build_path() {\r\n' \ ' if (focused.substring(0, 5) != "point") {return;}\r\n' \ @@ -4573,7 +4675,7 @@ class GPXTweakerWebInterfaceServer(): ' }\r\n' \ ' if (this.status != 204) {\r\n' \ ' window.alert("{#jserror#}" + this.status + " " + this.statusText);\r\n' \ - ' } else {\r\n' \ + ' } else if (this.responseURL.indexOf("?") > 0) {\r\n' \ ' window.open("http://" + location.hostname + ":" + location.port + "/3D/viewer.html");\r\n' \ ' }\r\n' \ ' }\r\n' \ @@ -4642,7 +4744,7 @@ class GPXTweakerWebInterfaceServer(): ' \r\n' \ ' \r\n' \ ' \r\n' \ - '                                    1\r\n' \ + '                                     1\r\n' \ ' \r\n' \ ' \r\n' \ ' \r\n' \ @@ -4748,8 +4850,11 @@ class GPXTweakerWebInterfaceServer(): ' point_insert("a", lat, lon);\r\n' \ ' document.getElementById(focused + "lat").value = lat.toFixed(6);\r\n' \ ' document.getElementById(focused + "lon").value = lon.toFixed(6);\r\n' \ - ' document.getElementById(focused + "alt").value = "";\r\n' \ - ' document.getElementById(focused + "ele").value = "";\r\n' \ + ' if (focused.substring(0, 3) != "way") {\r\n' \ + ' document.getElementById(focused + "alt").value = "";\r\n' \ + ' document.getElementById(focused + "ele").value = "";\r\n' \ + ' document.getElementById(focused + "time").value = "";\r\n' \ + ' }\r\n' \ ' point_edit(false, false, false);\r\n' \ ' save_old();\r\n' \ ' hand = document.getElementById(focused.replace("point", "dot"));\r\n' \