From 9e05dd1aba034edab12f1b19d1c5ee1071314b22 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jan 2021 14:50:48 +0100 Subject: [PATCH] fix distVincenty() to using var instead of let again --- static/scripts/accChart.js | 49 +++++++++++++++++++++----------------- static/scripts/refull.js | 4 ---- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/static/scripts/accChart.js b/static/scripts/accChart.js index e31f5ad..bf75587 100644 --- a/static/scripts/accChart.js +++ b/static/scripts/accChart.js @@ -6,9 +6,14 @@ * @authors Timo Volkmann, Frank Herkommer. */ +//list of all horizontal accuracies sent in by the Ublox +let allAccSerial = [] +//list of all coordinates sent in by the Ublox +let allSerialCoords = [] + //Defines the chart and its properties -let ctx = document.getElementById('accChart').getContext('2d'); -let accChart = new Chart(ctx, { +let ctx1 = document.getElementById('accChart').getContext('2d'); +let accChart = new Chart(ctx1, { type: 'line', data: { labels: [], @@ -140,26 +145,26 @@ function distVincenty(coord1, coord2) { const lat1 = coord1[1] const lon2 = coord2[0] const lat2 = coord2[1] - const a = 6378137, b = 6356752.314245, f = 1/298.257223563; // WGS-84 ellipsoid params - let L = (lon2-lon1).toRad() - let U1 = Math.atan((1-f) * Math.tan(lat1.toRad())); - let U2 = Math.atan((1-f) * Math.tan(lat2.toRad())); - let sinU1 = Math.sin(U1), cosU1 = Math.cos(U1); - let sinU2 = Math.sin(U2), cosU2 = Math.cos(U2); + var a = 6378137, b = 6356752.314245, f = 1/298.257223563; // WGS-84 ellipsoid params + var L = (lon2-lon1).toRad() + var U1 = Math.atan((1-f) * Math.tan(lat1.toRad())); + var U2 = Math.atan((1-f) * Math.tan(lat2.toRad())); + var sinU1 = Math.sin(U1), cosU1 = Math.cos(U1); + var sinU2 = Math.sin(U2), cosU2 = Math.cos(U2); - let lambda = L, lambdaP, iterLimit = 100; + var lambda = L, lambdaP, iterLimit = 100; do { - let sinLambda = Math.sin(lambda), cosLambda = Math.cos(lambda); - let sinSigma = Math.sqrt((cosU2*sinLambda) * (cosU2*sinLambda) + + var sinLambda = Math.sin(lambda), cosLambda = Math.cos(lambda); + var sinSigma = Math.sqrt((cosU2*sinLambda) * (cosU2*sinLambda) + (cosU1*sinU2-sinU1*cosU2*cosLambda) * (cosU1*sinU2-sinU1*cosU2*cosLambda)); if (sinSigma===0) return 0; // co-incident points - let cosSigma = sinU1*sinU2 + cosU1*cosU2*cosLambda; - let sigma = Math.atan2(sinSigma, cosSigma); - let sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma; - let cosSqAlpha = 1 - sinAlpha*sinAlpha; - let cos2SigmaM = cosSigma - 2*sinU1*sinU2/cosSqAlpha; + var cosSigma = sinU1*sinU2 + cosU1*cosU2*cosLambda; + var sigma = Math.atan2(sinSigma, cosSigma); + var sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma; + var cosSqAlpha = 1 - sinAlpha*sinAlpha; + var cos2SigmaM = cosSigma - 2*sinU1*sinU2/cosSqAlpha; if (isNaN(cos2SigmaM)) cos2SigmaM = 0; // equatorial line: cosSqAlpha=0 (ยง6) - let C = f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha)); + var C = f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha)); lambdaP = lambda; lambda = L + (1-C) * f * sinAlpha * (sigma + C*sinSigma*(cos2SigmaM+C*cosSigma*(-1+2*cos2SigmaM*cos2SigmaM))); @@ -167,12 +172,12 @@ function distVincenty(coord1, coord2) { if (iterLimit===0) return NaN // formula failed to converge - let uSq = cosSqAlpha * (a*a - b*b) / (b*b); - let A = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq))); - let B = uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq))); - let deltaSigma = B*sinSigma*(cos2SigmaM+B/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)- + var uSq = cosSqAlpha * (a*a - b*b) / (b*b); + var A = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq))); + var B = uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq))); + var deltaSigma = B*sinSigma*(cos2SigmaM+B/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)- B/6*cos2SigmaM*(-3+4*sinSigma*sinSigma)*(-3+4*cos2SigmaM*cos2SigmaM))); - let s = b*A*(sigma-deltaSigma); + var s = b*A*(sigma-deltaSigma); s = s.toFixed(3); // round to 1mm precision return s; diff --git a/static/scripts/refull.js b/static/scripts/refull.js index 61c7e2f..38cd459 100644 --- a/static/scripts/refull.js +++ b/static/scripts/refull.js @@ -5,10 +5,6 @@ */ let indexes -//list of all horizontal accuracies sent in by the Ublox -let allAccSerial = [] -//list of all coordinates sent in by the Ublox -let allSerialCoords = [] function composeTimestamp(servertime){ let composed;