[hamradio-commits] [dump1090] 39/389: Google map view enhanced: color by altitude and more.

Matthew Ernisse mernisse-guest at moszumanska.debian.org
Wed Nov 5 00:19:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

mernisse-guest pushed a commit to branch master
in repository dump1090.

commit 03759a3eb01f41f322e393f358ef82430857ff3d
Author: antirez <antirez at gmail.com>
Date:   Wed Jan 16 20:25:28 2013 +0100

    Google map view enhanced: color by altitude and more.
---
 dump1090.c |  5 +++--
 gmap.html  | 27 +++++++++++++++++++--------
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/dump1090.c b/dump1090.c
index d895cb7..7bb23a3 100644
--- a/dump1090.c
+++ b/dump1090.c
@@ -1872,8 +1872,9 @@ char *aircraftsToJson(int *len) {
 
         if (a->lat != 0 && a->lon != 0) {
             l = snprintf(p,buflen,
-                "{\"hex\":\"%s\", \"lat\":%f, \"lon\":%f, \"track\":%d},\n",
-                a->hexaddr, a->lat, a->lon, a->track);
+                "{\"hex\":\"%s\", \"flight\":\"%s\", \"lat\":%f, "
+                "\"lon\":%f, \"altitude\":%d, \"track\":%d},\n",
+                a->hexaddr, a->flight, a->lat, a->lon, a->altitude, a->track);
             p += l; buflen -= l;
             /* Resize if needed. */
             if (buflen < 256) {
diff --git a/gmap.html b/gmap.html
index a5b4a01..a1c9d38 100644
--- a/gmap.html
+++ b/gmap.html
@@ -15,17 +15,23 @@
     </script>
     <script type="text/javascript">
     Map=null;
-    CenterLat=50.0;
+    CenterLat=45.0;
     CenterLon=9.0;
     Planes={};
 
     function getIconForPlane(plane) {
+        var r = 255, g = 255, b = 0;
+        var maxalt = 40000; /* Max altitude in the average case */
+        var invalt = maxalt-plane.altitude;
+
+        if (invalt < 0) invalt = 0;
+        b = parseInt(255/maxalt*invalt);
         return {
-            strokeWeight: 2,
+            strokeWeight: 1,
             path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
             scale: 5,
-            fillColor: 'yellow',
-            fillOpacity: 0.8,
+            fillColor: 'rgb('+r+','+g+','+b+')',
+            fillOpacity: 0.9,
             rotation: plane.track
         };
     }
@@ -35,25 +41,30 @@
             var stillhere = {}
             for (var j=0; j < data.length; j++) {
                 var plane = data[j];
+                var marker = null;
                 stillhere[plane.hex] = true;
+                plane.flight = $.trim(plane.flight);
 
                 if (Planes[plane.hex]) {
                     var myplane = Planes[plane.hex];
-                    var marker = myplane.marker;
+                    marker = myplane.marker;
                     var icon = marker.getIcon();
                     var newpos = new google.maps.LatLng(plane.lat, plane.lon);
                     marker.setPosition(newpos);
                     marker.setIcon(getIconForPlane(plane));
                 } else {
-                    var marker = new google.maps.Marker({
+                    marker = new google.maps.Marker({
                         position: new google.maps.LatLng(plane.lat, plane.lon),
                         map: Map,
-                        title: plane.hex,
                         icon: getIconForPlane(plane)
                     });
                     plane.marker = marker;
                     Planes[plane.hex] = plane;
                 }
+                if (plane.flight.length == 0)
+                    marker.setTitle(plane.hex)
+                else
+                    marker.setTitle(plane.flight+' ('+plane.hex+')')
             }
 
             /* Remove idle planes. */
@@ -70,7 +81,7 @@
     function initialize() {
         var mapOptions = {
             center: new google.maps.LatLng(CenterLat, CenterLon),
-            zoom: 8,
+            zoom: 5,
             mapTypeId: google.maps.MapTypeId.ROADMAP
         };
         Map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git



More information about the pkg-hamradio-commits mailing list