From a4cd8d88d94cea759ac955b41350d10e0323349b Mon Sep 17 00:00:00 2001
From: unknown
Date: Wed, 16 Dec 2020 12:18:50 +0100
Subject: [PATCH] ignore 0 Values in Orientation and Position data
---
static/scripts/hike.geo.json | 737 ----------------------------------
static/scripts/map.js | 18 +-
static/scripts/speedometer.js | 0
static/scripts/websocket.js | 44 +-
templates/index.html | 1 +
5 files changed, 48 insertions(+), 752 deletions(-)
delete mode 100644 static/scripts/hike.geo.json
create mode 100644 static/scripts/speedometer.js
diff --git a/static/scripts/hike.geo.json b/static/scripts/hike.geo.json
deleted file mode 100644
index fb2388e..0000000
--- a/static/scripts/hike.geo.json
+++ /dev/null
@@ -1,737 +0,0 @@
-{
- "type": "FeatureCollection",
- "features": [
- {
- "type": "Feature",
- "geometry": {
- "type": "LineString",
- "coordinates": [
- [
- 9.196275472640991,
- 49.12280972701122
- ],
- [
- 9.19629693031311,
- 49.122757066649065
- ],
- [
- 9.196267426013947,
- 49.1227219597099
- ],
- [
- 9.196237921714783,
- 49.12268685274588
- ],
- [
- 9.196205735206604,
- 49.122642969005895
- ],
- [
- 9.196168184280396,
- 49.12259908522708
- ],
- [
- 9.196090400218964,
- 49.122556956762885
- ],
- [
- 9.196015298366547,
- 49.12252536039125
- ],
- [
- 9.195816814899445,
- 49.122421794365344
- ],
- [
- 9.19578731060028,
- 49.12246041223081
- ],
- [
- 9.195752441883085,
- 49.122495519355134
- ],
- [
- 9.195720255374908,
- 49.1225306264546
- ],
- [
- 9.195685386657715,
- 49.12257099958827
- ],
- [
- 9.195658564567566,
- 49.122602595930815
- ],
- [
- 9.195634424686432,
- 49.12263419225324
- ],
- [
- 9.195604920387268,
- 49.12266052250654
- ],
- [
- 9.19557273387909,
- 49.12268334204809
- ],
- [
- 9.195548593997955,
- 49.12271318297122
- ],
- [
- 9.195532500743866,
- 49.12273951318259
- ],
- [
- 9.195497632026672,
- 49.12276057734161
- ],
- [
- 9.19557273387909,
- 49.12281850373281
- ],
- [
- 9.195524454116821,
- 49.12285712128936
- ],
- [
- 9.195497632026672,
- 49.12287818539843
- ],
- [
- 9.195476174354553,
- 49.122904515522194
- ],
- [
- 9.195586144924162,
- 49.12300983587742
- ],
- [
- 9.195840954780579,
- 49.1232152099268
- ],
- [
- 9.19605016708374,
- 49.1233942532759
- ],
- [
- 9.196152091026306,
- 49.1235346789797
- ],
- [
- 9.196280837059021,
- 49.12368212554077
- ],
- [
- 9.196393489837646,
- 49.12382606104651
- ],
- [
- 9.196511507034302,
- 49.123924358225025
- ],
- [
- 9.196581244468689,
- 49.12404371882266
- ],
- [
- 9.196720719337463,
- 49.124173610911306
- ],
- [
- 9.196838736534119,
- 49.12435967195905
- ],
- [
- 9.196951389312744,
- 49.124501850213676
- ],
- [
- 9.197013080120087,
- 49.1245896143649
- ],
- [
- 9.19705867767334,
- 49.12465280445759
- ],
- [
- 9.19714719057083,
- 49.12476865275172
- ],
- [
- 9.197292029857635,
- 49.12495120102961
- ],
- [
- 9.197361767292023,
- 49.12506529336202
- ],
- [
- 9.197455644607544,
- 49.125175874910624
- ],
- [
- 9.197522699832916,
- 49.12529347723932
- ],
- [
- 9.197605848312378,
- 49.12543565281655
- ],
- [
- 9.197745323181152,
- 49.125690163634275
- ],
- [
- 9.197841882705688,
- 49.12584989044582
- ],
- [
- 9.19790893793106,
- 49.12598328826778
- ],
- [
- 9.197978675365448,
- 49.12612195141281
- ],
- [
- 9.198064506053925,
- 49.12627290072483
- ],
- [
- 9.19819325208664,
- 49.126525652032335
- ],
- [
- 9.198254942893982,
- 49.12668011053043
- ],
- [
- 9.198305904865265,
- 49.12679770929164
- ],
- [
- 9.198405146598816,
- 49.12695743253551
- ],
- [
- 9.198488295078278,
- 49.12716981099699
- ],
- [
- 9.198619723320007,
- 49.12720315959838
- ],
- [
- 9.198799431324005,
- 49.127229487425765
- ],
- [
- 9.199027419090271,
- 49.12716630061657
- ],
- [
- 9.19931173324585,
- 49.127129441607394
- ],
- [
- 9.199504852294922,
- 49.12708556179883
- ],
- [
- 9.19965773820877,
- 49.12704870272959
- ],
- [
- 9.199883043766022,
- 49.12700482284956
- ],
- [
- 9.200116395950317,
- 49.1269732293119
- ],
- [
- 9.200357794761658,
- 49.12690653177737
- ],
- [
- 9.200548231601715,
- 49.12688546937944
- ],
- [
- 9.20065551996231,
- 49.126911797375485
- ],
- [
- 9.200770854949951,
- 49.12695743253551
- ],
- [
- 9.200899600982666,
- 49.12702061961085
- ],
- [
- 9.20103371143341,
- 49.12706800986451
- ],
- [
- 9.201240241527557,
- 49.12711891045688
- ],
- [
- 9.20141190290451,
- 49.12714874871086
- ],
- [
- 9.2015540599823,
- 49.127191750868846
- ],
- [
- 9.201587587594986,
- 49.127187362895256
- ],
- [
- 9.201736450195312,
- 49.1271601574503
- ],
- [
- 9.201810210943222,
- 49.127157524664504
- ],
- [
- 9.201871901750565,
- 49.12715313668789
- ],
- [
- 9.201933592557907,
- 49.12710925690026
- ],
- [
- 9.202055633068085,
- 49.12697498450896
- ],
- [
- 9.20224204659462,
- 49.12691530777389
- ],
- [
- 9.20237347483635,
- 49.126887224579605
- ],
- [
- 9.202480763196945,
- 49.126842466955814
- ],
- [
- 9.20254647731781,
- 49.12681613892294
- ],
- [
- 9.202671200037003,
- 49.126769626030736
- ],
- [
- 9.202869683504105,
- 49.126692396981234
- ],
- [
- 9.202970266342163,
- 49.12665729282806
- ],
- [
- 9.203054755926132,
- 49.12662218865002
- ],
- [
- 9.203156679868698,
- 49.12659147247387
- ],
- [
- 9.203227758407593,
- 49.126569532336404
- ],
- [
- 9.203289449214935,
- 49.126551980219446
- ],
- [
- 9.203341752290726,
- 49.12653179527724
- ],
- [
- 9.203158020973206,
- 49.126483526903876
- ],
- [
- 9.203088283538818,
- 49.12646334193381
- ],
- [
- 9.203002452850342,
- 49.12644140173965
- ],
- [
- 9.202857613563538,
- 49.12640278697433
- ],
- [
- 9.202712774276733,
- 49.126357151303814
- ],
- [
- 9.202632308006287,
- 49.126325557353475
- ],
- [
- 9.202412366867065,
- 49.12626236939239
- ],
- [
- 9.202256798744202,
- 49.126213223144774
- ],
- [
- 9.202122688293455,
- 49.12616758729978
- ],
- [
- 9.201961755752563,
- 49.12612546186714
- ],
- [
- 9.2018061876297,
- 49.12607982594142
- ],
- [
- 9.201698899269104,
- 49.126037700434225
- ],
- [
- 9.201596975326538,
- 49.125999085354515
- ],
- [
- 9.20129120349884,
- 49.125883239934964
- ],
- [
- 9.201119542121887,
- 49.125827072361396
- ],
- [
- 9.200921058654785,
- 49.12578143616102
- ],
- [
- 9.200685024261473,
- 49.125676121692166
- ],
- [
- 9.200513362884521,
- 49.12560591192202
- ],
- [
- 9.200336337089539,
- 49.12554623353922
- ],
- [
- 9.199842810630798,
- 49.125360176943595
- ],
- [
- 9.199681878089905,
- 49.12527592467067
- ],
- [
- 9.1995370388031,
- 49.12522677744532
- ],
- [
- 9.199456572532654,
- 49.12518816173411
- ],
- [
- 9.19932246208191,
- 49.12513199337321
- ],
- [
- 9.199220538139343,
- 49.12508635653314
- ],
- [
- 9.199113249778748,
- 49.125023166992925
- ],
- [
- 9.199016690254211,
- 49.12496699844514
- ],
- [
- 9.198925495147705,
- 49.1248932771296
- ],
- [
- 9.198732376098633,
- 49.12480551351584
- ],
- [
- 9.198582172393799,
- 49.124721260300475
- ],
- [
- 9.198474884033203,
- 49.124647538619605
- ],
- [
- 9.198367595672607,
- 49.12459839077146
- ],
- [
- 9.198265671730042,
- 49.12455626400573
- ],
- [
- 9.198126196861267,
- 49.124542221742516
- ],
- [
- 9.198099374771118,
- 49.12450360549822
- ],
- [
- 9.198126196861267,
- 49.12441584119478
- ],
- [
- 9.198174476623533,
- 49.12433509789843
- ],
- [
- 9.19828176498413,
- 49.12430701324279
- ],
- [
- 9.19831931591034,
- 49.12427190740087
- ],
- [
- 9.198254942893982,
- 49.12420871682283
- ],
- [
- 9.198115468025208,
- 49.124149036758475
- ],
- [
- 9.197981357574463,
- 49.124085846023824
- ],
- [
- 9.197836518287659,
- 49.124026165811614
- ],
- [
- 9.197707772254944,
- 49.12395595370529
- ],
- [
- 9.197557568550108,
- 49.12386467781845
- ],
- [
- 9.197487831115723,
- 49.12381201857656
- ],
- [
- 9.197385907173157,
- 49.123717231800214
- ],
- [
- 9.197214245796204,
- 49.12367510428589
- ],
- [
- 9.197010397911072,
- 49.123566274708274
- ],
- [
- 9.196908473968506,
- 49.123474998104186
- ],
- [
- 9.196704626083374,
- 49.123401274570526
- ],
- [
- 9.196602702140808,
- 49.123348614836544
- ],
- [
- 9.196484684944153,
- 49.123260848488954
- ],
- [
- 9.196339845657349,
- 49.12319414596088
- ],
- [
- 9.196216464042664,
- 49.12313095400942
- ],
- [
- 9.196135997772217,
- 49.12306776197748
- ],
- [
- 9.19607162475586,
- 49.12299754851418
- ],
- [
- 9.195937514305115,
- 49.12295893106699
- ],
- [
- 9.195835590362549,
- 49.12289222813283
- ],
- [
- 9.195733666419983,
- 49.12282903579667
- ],
- [
- 9.195638447999954,
- 49.122754433629495
- ],
- [
- 9.195600226521492,
- 49.12273293063105
- ],
- [
- 9.195574074983597,
- 49.122708355764296
- ],
- [
- 9.195574074983597,
- 49.12269431297779
- ],
- [
- 9.195623695850372,
- 49.1226412136555
- ],
- [
- 9.195666611194609,
- 49.12260961733753
- ],
- [
- 9.195688739418983,
- 49.12258021519025
- ],
- [
- 9.195733666419983,
- 49.12253106529318
- ],
- [
- 9.19575646519661,
- 49.12250034658276
- ],
- [
- 9.195783287286758,
- 49.12247269972715
- ],
- [
- 9.195801392197609,
- 49.12244988008865
- ],
- [
- 9.195815473794937,
- 49.122438470265486
- ],
- [
- 9.195830225944519,
- 49.12242047784666
- ],
- [
- 9.195859730243683,
- 49.122431887674
- ],
- [
- 9.195901304483414,
- 49.122448563570735
- ],
- [
- 9.195931479334831,
- 49.12246787249679
- ],
- [
- 9.195965006947517,
- 49.12248367070343
- ],
- [
- 9.195998534560204,
- 49.122498152388445
- ],
- [
- 9.19603407382965,
- 49.12251307290797
- ],
- [
- 9.196063578128815,
- 49.12253501484029
- ],
- [
- 9.196093752980232,
- 49.122546424641236
- ],
- [
- 9.196127280592918,
- 49.1225600286313
- ],
- [
- 9.19615812599659,
- 49.12258109286655
- ],
- [
- 9.196201711893082,
- 49.12261927177015
- ],
- [
- 9.196238592267036,
- 49.12267237111598
- ],
- [
- 9.196262061595917,
- 49.12270045669739
- ],
- [
- 9.196281507611275,
- 49.122722837383684
- ],
- [
- 9.196305647492409,
- 49.122746534569934
- ],
- [
- 9.196302965283394,
- 49.1227693540719
- ],
- [
- 9.196292236447334,
- 49.12279392890845
- ],
- [
- 9.196286201477049,
- 49.122811482355665
- ],
- [
- 9.19628955423832,
- 49.12282815812477
- ],
- [
- 9.196309000253677,
- 49.1228479057388
- ]
- ]
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/static/scripts/map.js b/static/scripts/map.js
index 8385575..4be6b78 100644
--- a/static/scripts/map.js
+++ b/static/scripts/map.js
@@ -62,14 +62,14 @@ map.on('load', function () {
});
- map.jumpTo({ 'center': [9.19640999, 49.12283027], 'zoom': 6 });
+ map.jumpTo({ 'center': [9.19640999, 49.12283027], 'zoom': 17 });
map.setPitch(30);
var stateLegendEl = document.getElementById('state-legend');
stateLegendEl.style.display = 'block';
})
-function updateMap (TCPlong, TCPlat, SERIALlong, SERIALlat) {
+/*function updateMap (TCPlong, TCPlat, SERIALlong, SERIALlat) {
emptyTCP.features[0].geometry.coordinates.push([TCPlong, TCPlat]);
map.getSource('routeTCP').setData(emptyTCP);
emptySERIAL.features[0].geometry.coordinates.push([SERIALlong, SERIALlat]);
@@ -80,8 +80,16 @@ function updateMap (TCPlong, TCPlat, SERIALlong, SERIALlat) {
else if (!([SERIALlong, SERIALlat] = [0,0])) {
map.panTo({ 'center': [SERIALlong, SERIALlat], 'zoom': 17 });
}
- else {
- map.jumpTo({ 'center': [9.19640999, 49.12283027], 'zoom': 6 });
- }
+}*/
+function updateMapTCP (TCPlong, TCPlat) {
+ emptyTCP.features[0].geometry.coordinates.push([TCPlong, TCPlat]);
+ map.getSource('routeTCP').setData(emptyTCP);
+ //map.panTo([TCPlong, TCPlat]);
+}
+
+function updateMapSERIAL (SERIALlong, SERIALlat) {
+ emptySERIAL.features[0].geometry.coordinates.push([SERIALlong, SERIALlat]);
+ map.getSource('routeTCP').setData(emptySERIAL);
+ map.panTo([SERIALlong, SERIALlat]);
}
\ No newline at end of file
diff --git a/static/scripts/speedometer.js b/static/scripts/speedometer.js
new file mode 100644
index 0000000..e69de29
diff --git a/static/scripts/websocket.js b/static/scripts/websocket.js
index 0577c3d..0ac5c04 100644
--- a/static/scripts/websocket.js
+++ b/static/scripts/websocket.js
@@ -19,7 +19,7 @@ window.addEventListener("load", function(evt) {
};
document.getElementById("open").onclick = function(evt) {
if (ws && ws.OPEN) {
- print("Websocket already open")
+ print2("Websocket already open")
return false;
}
ws = new WebSocket("ws://localhost:3011/ws");
@@ -40,16 +40,23 @@ window.addEventListener("load", function(evt) {
//console.log(evt.data)
console.log("JSON geparsed onmessage", dat)
//console.log(dat.SOURCE_TCP.Orientation)
- document.getElementById("gyroscopeTCP").style.transform = `rotateX(${dat.SOURCE_TCP.Orientation[0]}deg) rotateY(${dat.SOURCE_TCP.Orientation[1]}deg) rotateZ(${dat.SOURCE_TCP.Orientation[2]}deg)`
- document.getElementById("gyroscopeSERIAL").style.transform = `rotateX(${dat.SOURCE_SERIAL.Orientation[0]}deg) rotateY(${dat.SOURCE_SERIAL.Orientation[1]}deg) rotateZ(${dat.SOURCE_SERIAL.Orientation[2]}deg)`
+ if(!(dat.SOURCE_TCP.Orientation[0] === 0) && !(dat.SOURCE_TCP.Orientation[1] === 0) && !(dat.SOURCE_TCP.Orientation[2] === 0)){
+ document.getElementById("gyroscopeTCP").style.transform = `rotateX(${dat.SOURCE_TCP.Orientation[0]}deg) rotateY(${dat.SOURCE_TCP.Orientation[1]}deg) rotateZ(${dat.SOURCE_TCP.Orientation[2]}deg)`
+ }
+ if(!(dat.SOURCE_SERIAL.Orientation[0] === 0) || !(dat.SOURCE_SERIAL.Orientation[1] === 0) || !(dat.SOURCE_SERIAL.Orientation[2] === 0)){
+ document.getElementById("gyroscopeSERIAL").style.transform = `rotateX(${dat.SOURCE_SERIAL.Orientation[0]}deg) rotateY(${dat.SOURCE_SERIAL.Orientation[1]}deg) rotateZ(${dat.SOURCE_SERIAL.Orientation[2]}deg)`
+ }
- document.getElementById("TCPlong").innerHTML = "Smartphone long: " + dat.SOURCE_TCP.Position[1]
- document.getElementById("TCPlat").innerHTML = "Smartphone lat: " + dat.SOURCE_TCP.Position[0]
- document.getElementById("SERIALlong").innerHTML = "Ublox long: " + dat.SOURCE_SERIAL.Position[1]
- document.getElementById("SERIALlat").innerHTML = "Ublox lat: " + dat.SOURCE_SERIAL.Position[0]
+ if((!(dat.SOURCE_TCP.Position[0] === 0) && !(dat.SOURCE_TCP.Position[1] === 0)) || (!(dat.SOURCE_SERIAL.Position[0] === 0) && !(dat.SOURCE_SERIAL.Position[1] === 0))){
+ document.getElementById("TCPlong").innerHTML = "Smartphone long: " + dat.SOURCE_TCP.Position[1]
+ document.getElementById("TCPlat").innerHTML = "Smartphone lat: " + dat.SOURCE_TCP.Position[0]
+ document.getElementById("SERIALlong").innerHTML = "Ublox long: " + dat.SOURCE_SERIAL.Position[1]
+ document.getElementById("SERIALlat").innerHTML = "Ublox lat: " + dat.SOURCE_SERIAL.Position[0]
+
+ document.getElementById("diffLong").innerHTML = "Differenz long: " + Math.abs(dat.SOURCE_TCP.Position[1] - dat.SOURCE_SERIAL.Position[1])
+ document.getElementById("diffLat").innerHTML = "Differenz lat: " + Math.abs(dat.SOURCE_TCP.Position[0] - dat.SOURCE_SERIAL.Position[0])
+ }
- document.getElementById("diffLong").innerHTML = "Differenz long: " + Math.abs(dat.SOURCE_TCP.Position[1] - dat.SOURCE_SERIAL.Position[1])
- document.getElementById("diffLat").innerHTML = "Differenz lat: " + Math.abs(dat.SOURCE_TCP.Position[0] - dat.SOURCE_SERIAL.Position[0])
/*
console.log(dat)
orientation[0] += dat[0] * multiplier
@@ -62,7 +69,15 @@ window.addEventListener("load", function(evt) {
// addData(orientation[0] / multiplier)
*/
addData(dat.SOURCE_TCP.Orientation[0])
- updateMap(dat.SOURCE_TCP.Position[1], dat.SOURCE_TCP.Position[0], dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0])
+
+ //updateMap(dat.SOURCE_TCP.Position[1], dat.SOURCE_TCP.Position[0], dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0])
+
+ if(!(dat.SOURCE_TCP.Position[1] === 0) && !(dat.SOURCE_TCP.Position[0] === 0)){
+ updateMapTCP(dat.SOURCE_TCP.Position[1], dat.SOURCE_TCP.Position[0])
+ }
+ if(!(dat.SOURCE_SERIAL.Position[1] === 0) && !(dat.SOURCE_SERIAL.Position[0] === 0)){
+ updateMapSERIAL(dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0])
+ }
// addData(dat[0])
//document.getElementById("gyroscope").style.transform = `rotateX(${-orientation[0]}deg) rotateY(${orientation[1]}deg) rotateZ(${-orientation[2]}deg) translateZ(50px)`
@@ -87,4 +102,13 @@ window.addEventListener("load", function(evt) {
ws.close();
return false;
};
+
+ //------------------------Buttons------------------------------
+
+ document.getElementById("livetracking").onclick = function(evt) {
+ if (ws) {
+ print2("LIVETRACKING");
+ }
+ return false;
+ };
});
\ No newline at end of file
diff --git a/templates/index.html b/templates/index.html
index a889fa6..05514ba 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -113,6 +113,7 @@
+