diff --git a/css/main.css b/css/main.css index 28ef1da..c0de689 100644 --- a/css/main.css +++ b/css/main.css @@ -1,4 +1,4 @@ -/* Habitat Mobile Tracker +/* SondeHub Mobile Tracker * Main style sheet * */ diff --git a/img/sondehub_logo.png b/img/sondehub_logo.png index ad0d901..8593f55 100644 Binary files a/img/sondehub_logo.png and b/img/sondehub_logo.png differ diff --git a/js/app.js b/js/app.js index 30bb1a6..885d302 100644 --- a/js/app.js +++ b/js/app.js @@ -201,31 +201,6 @@ var loadComplete = function(e) { $('#loading .complete').stop(true,true).animate({width: 200}, {complete: trackerInit }); }; -var hysplit = {}; -var hysplit_data = {}; -var refresh_hysplit = function() { - $.getJSON("//spacenear.us/tracker/datanew.php?type=hysplit&format=json", function(data) { - var refresh = false; - - for(var k in data) { - if(k in hysplit_data) { - // if the jobid is the same, skip to next one - if(hysplit_data[k].jobid == data[k].jobid) continue; - - // otherwise update the url - hysplit_data[k] = data[k]; - hysplit[k].setUrl(hysplit_data[k].url_kmz); - } else { - hysplit_data[k] = data[k]; - hysplit[k] = new google.maps.KmlLayer({url: hysplit_data[k].url_kmz, preserveViewport:true }); - refresh = true; - } - } - - if(refresh) refreshUI(); - }); -}; - // loads the tracker interface function trackerInit() { $('#loading,#settingsbox,#aboutbox,#chasebox').hide(); // welcome screen @@ -240,10 +215,6 @@ function trackerInit() { $.getScript("js/init_plot.js", function() { checkSize(); if(!map) load(); }); if(wvar.graph) $('#telemetry_graph').attr('style',''); - // fetch hysplit jobs - // setInterval(refresh_hysplit, 60 * 1000); - // refresh_hysplit(); - return; } if(!map) load(); @@ -480,7 +451,7 @@ var updateTimebox = function(date) { }; var format_time_friendly = function(start, end) { - var dt = Math.floor((end - start) / 1000); + var dt = Math.floor((end - start) / 1000);; if(dt < 0) return null; if(dt < 60) return dt + 's'; @@ -566,23 +537,6 @@ $(window).ready(function() { // expand graph on startup, if nessary if(wvar.graph_expanded) $('#telemetry_graph .graph_label').click(); - // hysplit button - $("#main").on('click','.row .data .vbutton.hysplit', function(event) { - event.stopPropagation(); - - var elm = $(this); - var name = elm.attr('data-vcallsign'); - - if(elm.hasClass("active")) { - elm.removeClass('active'); - map.removeLayer(hysplit[name]); - } - else { - elm.addClass('active'); - map.addLayer(hysplit[name]); - } - }); - $("#main").on('click','.row .data .vbutton.path', function(event) { event.stopPropagation(); @@ -721,7 +675,7 @@ $(window).ready(function() { field.attr('disabled','disabled'); e.removeClass('off').addClass('on'); - // push listener doc to habitat + // push listener doc to SondeHub // this gets a station on the map, under the car marker // im still not sure its nessesary if(!CHASE_listenerSent) { @@ -730,7 +684,7 @@ $(window).ready(function() { CHASE_listenerSent = true; } } - // if already have a position push it to habitat + // if already have a position push it to SondeHub if(GPS_ts) { ChaseCar.updatePosition(callsign, { coords: { latitude: GPS_lat, longitude: GPS_lon, altitude: GPS_alt, speed: GPS_speed }}); } diff --git a/js/chasecar.lib.js b/js/chasecar.lib.js index 0c7f62f..43321ca 100644 --- a/js/chasecar.lib.js +++ b/js/chasecar.lib.js @@ -1,5 +1,5 @@ -/* Habitat ChaseCar lib - * Uploads geolocation for chase cars to habitat +/* SondeHub ChaseCar lib + * Uploads geolocation for chase cars to SondeHub * * Author: Rossen Gerogiev * Requires: jQuery diff --git a/js/tracker.js b/js/tracker.js index 518d351..dee29cb 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -1,15 +1,10 @@ var mission_id = 0; var position_id = 0; var data_url = "https://api.v2.sondehub.org/datanew"; -var receivers_url = "https://api.v2.sondehub.org/listeners"; +var receivers_url = "https://api.v2.sondehub.org/listeners/telemetry"; var predictions_url = "https://api.v2.sondehub.org/predictions?vehicles="; var recovered_sondes_url = "https://api.v2.sondehub.org/recovered"; -var habitat_max = 400; -//var habitat_url = "//habitat.habhub.org/habitat/"; -var habitat_url = "/habitat/"; -var habitat_url_payload_telemetry = habitat_url + "_design/payload_telemetry/_view/payload_time?startkey=[%22{ID}%22,{START}]&endkey=[%22{ID}%22,{END}]&include_docs=true&limit=" + habitat_max + "&skip="; - var host_url = ""; var markers_url = "img/markers/"; var vehicles = {}; @@ -354,11 +349,6 @@ function clean_refresh(text, force, history_step) { vehicles[callsign].kill(); } - // clear hysplit - for(callsign in hysplit) { - map.removeLayer(hysplit[callsign]); - } - car_index = 0; balloon_index = 0; nyan_color_index = 0; @@ -1238,6 +1228,8 @@ function updateVehicleInfo(vcallsign, newPosition) { callsign_list = callsign_list.join(", "); } + var timeNow = new Date(); + //desktop var a = '
' + '' + sonde_type + vcallsign + ' ' + @@ -1266,7 +1258,7 @@ function updateVehicleInfo(vcallsign, newPosition) { '
' + // right '' + // data ''; - var c = '
Received via:
' + + var c = '
Received via:
' + callsign_list + '
'; if(!newPosition.callsign) c = ''; @@ -1616,25 +1608,9 @@ function mapInfoBox_handle_path(event) { }; function mapInfoBox_handle_path_fetch(id,vehicle) { - var ishabitat = id.length == 64 - - if(ishabitat) { - var url = habitat_url + id; - } else { - var url = data_url + "?mode=single&format=json&position_id=" + id; - } + var url = data_url + "?mode=single&format=json&position_id=" + id; $.getJSON(url, function(data) { - if(ishabitat) { - var encap = {positions: { position: [] }}; - - if(!data.hasOwnProperty('error')) { - data._id = data._id.substring(58); - encap.positions.position.push(habitat_doc_to_snus(data)); - data = encap; - } - } - if('positions' in data && data.positions.position.length === 0) { mapInfoBox.setContent("not found"); mapInfoBox.openOn(map); @@ -2230,7 +2206,7 @@ function addPosition(position) { // calculate vertical rate // TODO - Make this average over more points rather than use a FIR. var rate = (position.gps_alt - vehicle.curr_position.gps_alt) / dt; - if (!isNaN(rate)) { + if (!isNaN(rate) && dt != 0) { vehicle.ascent_rate = 0.7 * rate + 0.3 * vehicle.ascent_rate; } @@ -2717,6 +2693,7 @@ var ajax_positions_old = null; var ajax_inprogress = false; var ajax_inprogress_single = false; var ajax_inprogress_old = "none"; +var ajax_single_serial = null; function refresh() { if(ajax_inprogress) { @@ -2763,7 +2740,7 @@ function refresh() { } } else { ajax_inprogress_old = "none"; - update(response); + update(response); } $("#stText").text(""); $("#stTimer").attr("data-timestamp", response.fetch_timestamp); @@ -2809,6 +2786,7 @@ function refreshSingle(serial, first) { } ajax_inprogress_single = true; + ajax_single_serial = serial; var mode = wvar.mode.toLowerCase(); mode = (mode == "position") ? "latest" : mode.replace(/ /g,""); @@ -2866,21 +2844,21 @@ function refreshSingleOld(serial) { } function refreshReceivers() { - // if options to hide receivers is selected do nothing if(offline.get('opt_hide_receivers')) return; + var mode = wvar.mode.toLowerCase(); + mode = (mode == "position") ? "latest" : mode.replace(/ /g,""); + + data_str = "duration=3h"; + $.ajax({ type: "GET", url: receivers_url, - data: "", + data: data_str, dataType: "json", success: function(response, textStatus) { - offline.set('receivers', response); updateReceivers(response); }, - error: function() { - if(!ls_receivers && offline.get('opt_offline')) updateReceivers(offline.get('receivers')); - }, complete: function(request, textStatus) { periodical_listeners = setTimeout(refreshReceivers, 60 * 1000); } @@ -2888,7 +2866,6 @@ function refreshReceivers() { } function refreshRecoveries() { - // TODO: Option to hide recoveries if(offline.get('opt_hide_recoveries')) return; $.ajax({ @@ -2897,8 +2874,6 @@ function refreshRecoveries() { data: "", dataType: "json", success: function(response, textStatus) { - // TODO: Offline stuff. (Or don't bother?) - //offline.set('recoveries', response); updateRecoveries(response); }, error: function() { @@ -2957,107 +2932,6 @@ function refreshPredictions() { }); } -function habitat_translation_layer(json_result, prefix) { - if(json_result.rows.length === 0) { - habitat_payload_step(true); - return; - } - - json_result = json_result.rows; - - var result = {positions: { position: [] }}; - result.fetch_timestamp = Date.now(); - $("#stTimer").attr("data-timestamp", result.fetch_timestamp); - - for(var i in json_result) { - var doc = json_result[i].doc; - - if(doc.data.latitude === 0 && doc.data.longitude === 0) continue; - - var row = habitat_doc_to_snus(doc, prefix); - - result.positions.position.push(row); - } - - if(result.positions.position.length) update(result); - - // next step - periodical = setTimeout(function() { - habitat_payload_step(); - }, 500); -} - -var habitat_field_blacklist = { - altitude: 1, - date: 1, - latitude: 1, - longitude: 1, - payload: 1, - sentence_id: 1, - time: 1, -}; - -function habitat_doc_to_snus(doc, prefix) { - prefix = prefix || ''; - - var row = { - 'position_id': doc._id, - 'vehicle': prefix + doc.data.payload, - 'server_time': doc.data._parsed.time_parsed, - 'sequence': doc.data.sentence_id, - 'gps_lat': doc.data.latitude, - 'gps_lon': doc.data.longitude, - 'gps_alt': doc.data.altitude, - 'callsign': "HABITAT ARCHIVE", - 'data': {} - }; - - try { - row.gps_time = "20" + doc.data.date.replace(/([0-9]{2})/g, "$1-") + doc.data.time; - } catch (e) { - row.gps_time = row.server_time; - } - - // move all other properties as data - for(var x in doc.data) { - // skip internal and reserved vars - if(x[0] == '_' || habitat_field_blacklist.hasOwnProperty(x)) continue; - - row.data[x] = doc.data[x]; - } - row.data = JSON.stringify(row.data); - - return row; -} - -var habitat_payload_step_data; - -function habitat_payload_step(remove_current) { - remove_current = !!remove_current; - - if(remove_current) { - habitat_payload_step_data.payloads.splice(habitat_payload_step_data.idx, 1); - } - - if(habitat_payload_step_data.payloads.length === 0) { - $("#stText").text(""); - $("#main .header.empty").html("No vehicles :("); - return; - } - - habitat_payload_step_data.idx += 1; - habitat_payload_step_data.idx = habitat_payload_step_data.idx % habitat_payload_step_data.payloads.length; - - var prefix = habitat_payload_step_data.payloads[habitat_payload_step_data.idx].prefix; - var url = habitat_payload_step_data.payloads[habitat_payload_step_data.idx].url; - url += habitat_payload_step_data.payloads[habitat_payload_step_data.idx].skip; - habitat_payload_step_data.payloads[habitat_payload_step_data.idx].skip += habitat_max; - - ajax_positions = $.getJSON(url, function(response) { - habitat_translation_layer(response, prefix); - }); -} - var periodical, periodical_focus, periodical_receivers, periodical_recoveries; var periodical_predictions = null; var timer_seconds = 5; @@ -3130,7 +3004,11 @@ function updateReceiverMarker(receiver) { // init a marker if the receiver doesn't already have one if(!receiver.marker) { - if (!receiver.description.includes("radiosonde_auto_rx")) { + if (receiver.software == "radiosonde_auto_rx") { + //future option to show different icon per software + } else if (receiver.software == "rdzTTGO") { + //future option to show different icon per software + } else { //future option to show different icon per software } @@ -3154,6 +3032,8 @@ function updateReceiverMarker(receiver) { receiverCanvas.addMarker(receiver.marker); } else { receiver.marker.setLatLng(latlng); + receiver.infobox = new L.popup({ autoClose: false, closeOnClick: false }).setContent(receiver.description); + receiver.marker.bindPopup(receiver.infobox); } } @@ -3161,36 +3041,41 @@ function updateReceivers(r) { if(!r) return; ls_receivers = true; - var i = 0, ii = r.length; - for(; i < ii; i++) { - var lat = parseFloat(r[i].lat); - var lon = parseFloat(r[i].lon); + for (var i in r) { + if (r.hasOwnProperty(i)) { + var last = r[i][Object.keys(r[i])[Object.keys(r[i]).length - 1]]; + if(last.mobile === undefined || last.mobile == false) { + var lat = parseFloat(last.uploader_position[0]); + var lon = parseFloat(last.uploader_position[1]); + var alt = parseFloat(last.uploader_position[2]); - if(lat < -90 || lat > 90 || lon < -180 || lon > 180) continue; + if(lat < -90 || lat > 90 || lon < -180 || lon > 180) continue; - // Filter out any receivers that are from the TTN Bridge code, and that are older than 1 hour. - // This helps de-clutter the map during launches utilising TTN, and that result in *many* new - // receivers showing up on the map. - var age = parseFloat(r[i].tdiff_hours); // Grab age of the receiver. - if(r[i].description.includes('TTN_LORAWAN_GW') && age > 1.0) continue; + var age = new Date(last.ts); - var r_index = $.inArray(r[i].name, receiver_names); + var r_index = $.inArray(last.uploader_callsign, receiver_names); - if(r_index == -1) { - receiver_names.push(r[i].name); - r_index = receiver_names.length - 1; - receivers[r_index] = {marker: null, infobox: null}; - } - - var receiver = receivers[r_index]; - receiver.name = r[i].name; - receiver.lat = lat; - receiver.lon = lon; - receiver.alt = parseFloat(r[i].alt); - receiver.description = ""+r[i].name+"
" + r[i].description.replace(">
\n<","><").replace("ago
\n<","ago<"); - receiver.fresh = true; + if(r_index == -1) { + receiver_names.push(last.uploader_callsign); + r_index = receiver_names.length - 1; + receivers[r_index] = {marker: null, infobox: null}; + } - updateReceiverMarker(receiver); + var receiver = receivers[r_index]; + receiver.name = last.uploader_callsign; + receiver.software = last.software_name; + receiver.version = last.software_version; + receiver.lat = lat; + receiver.lon = lon; + receiver.alt = alt; + receiver.age = age.toISOString(); + receiver.description = ""+receiver.name+"

Radio: " + last.software_name + "-" + last.software_version + + "
Antenna: " + last.uploader_antenna + "
Last Contact: " + age.toISOString() + "
"; + receiver.fresh = true; + + updateReceiverMarker(receiver); + } + } } // clear old receivers @@ -3380,7 +3265,7 @@ function updatePredictions(r) { if(vehicles.hasOwnProperty(vcallsign)) { var vehicle = vehicles[vcallsign]; - if(vcallsign in hysplit || vehicle.marker.mode == "landed") { + if(vehicle.marker.mode == "landed") { removePrediction(vcallsign); continue; } @@ -3478,6 +3363,16 @@ function update(response, flag) { } } + if (typeof flag == 'undefined') { + for (var i = response.positions.position.length - 1; i >= 0; i--) { + try { + if (response.positions.position[i].vehicle == ajax_single_serial) { + response.positions.position.splice(i, 1) + } + } catch (e) {} + } + } + ssdv = (!response.ssdv) ? {} : response.ssdv; // create a dummy response object for postions @@ -3504,7 +3399,9 @@ function update(response, flag) { this_position_id.setMilliseconds(0) if (new Date(position_id) < this_position_id || position_id == 0){ - position_id = this_position_id.toISOString() + if (new Date() > this_position_id) { + position_id = this_position_id.toISOString() + } } if (!row.picture) {