From 530835067e0b3157b363e500425f8c298505d68a Mon Sep 17 00:00:00 2001 From: drowe67 Date: Wed, 8 Dec 2010 06:35:53 +0000 Subject: [PATCH] added distance calculator git-svn-id: https://svn.code.sf.net/p/freetel/code@265 01035d8c-6547-0410-b346-abe4f91aad63 --- dilimesh/README.txt | 16 ++++++--- dilimesh/dilimesh/dilimesh.html | 63 +++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/dilimesh/README.txt b/dilimesh/README.txt index 622edba6..9a057bd6 100644 --- a/dilimesh/README.txt +++ b/dilimesh/README.txt @@ -213,7 +213,7 @@ Tests $ cat /var/www/dilimesh/nodes.txt (empty file) -7/ Test signal strength daemon: +7/ Test signal strength daemon on each node: $ telnet 10.130.1.1 4950 Trying 10.130.1.36... @@ -223,6 +223,7 @@ Tests 10.130.1.1 10.130.1.56 10.130.1.14 -64 -90 -75 + Using Dilimesh -------------- @@ -233,14 +234,19 @@ Using Dilimesh 3/ Dilimesh will find new nodes automatically. Drag bouncing nodes to the correct position on map. -4/ Mouse over or click to get node IP and packet loss. Right click to - delete node. Colours: +4/ Mouse over or click on a node to get IP and packet loss. If nodes + are running signal strength daemon signal strengths of adjacent + nodes will also be displayed. + +5/ Click on links to get "Distance" stats on lower right hand side. + +5/ Node colours: * blue - packet loss < 10% * red - packet loss between 10% and 90% * black - packet loss > 90% -5/ "Update Enable" will update packet loss and network links - automatically. +5/ "Update Enable" will update packet loss, network links and signal + strength automatically. Debugging diff --git a/dilimesh/dilimesh/dilimesh.html b/dilimesh/dilimesh/dilimesh.html index 9f1bcb84..8a2d7246 100644 --- a/dilimesh/dilimesh/dilimesh.html +++ b/dilimesh/dilimesh/dilimesh.html @@ -440,6 +440,24 @@ } + // calculate distance between two points + + rad = function(x) {return x*Math.PI/180;} + + distHaversine = function(p1, p2) { + var R = 6371; // earth's mean radius in km + var dLat = rad(p2.lat() - p1.lat()); + var dLong = rad(p2.lng() - p1.lng()); + + var a = Math.sin(dLat/2) * Math.sin(dLat/2) + + Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) * Math.sin(dLong/2) * Math.sin(dLong/2); + var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); + var d = R * c; + + return d.toFixed(3); + } + + // draw lines indicating links between nodes function drawPathesBetweenNodes() { @@ -486,7 +504,8 @@ } if ((router_location != undefined) && (neighbour_location != undefined)) { - // draw polyline between locations + + // draw polyline between locations var coords = [ router_location, @@ -495,11 +514,30 @@ var path = new google.maps.Polyline({ path: coords, strokeColor: "#008000", - strokeOpacity: 1.0, - strokeWeight: 2 + strokeOpacity: 0.5, + strokeWeight: 5 }); path.setMap(map); + // click on line to get distance and path loss estimates + + google.maps.event.addListener(path, "click", function() { + var path = this.getPath(); + var dist = distHaversine(path.b[0], path.b[1]) * 1000; + var path_loss = 100.0 + 20*Math.log(dist/1000)/Math.log(10); + path_loss = Math.round(path_loss); + + // est rx power: + // MP tx pwr between 15 and 20dB depending on rate + // roughly 2dB antennas + + var est_rx_sig = 17 + 2 + 2 - path_loss; + + document.getElementById('distance').innerHTML = dist + ' m'; + document.getElementById('path_loss').innerHTML = -path_loss + ' dBm'; + document.getElementById('est_rx_sig').innerHTML = est_rx_sig + ' dBm'; + }); + pathes.push(path); } } @@ -858,6 +896,25 @@
+ +

Distance

+ + + + + + + + + + + + + + + + +
Distance
Path Loss
Est Rx Signal
-- 2.25.1