Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
general improvements
  • Loading branch information
LukePrior committed Jul 24, 2021
commit c9400832ae1e2455ecba02f5f0428e04898cba45
2 changes: 1 addition & 1 deletion css/main.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Habitat Mobile Tracker
/* SondeHub Mobile Tracker
* Main style sheet
*
*/
Expand Down
Binary file modified img/sondehub_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 3 additions & 49 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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) {
Expand All @@ -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 }});
}
Expand Down
4 changes: 2 additions & 2 deletions js/chasecar.lib.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
139 changes: 7 additions & 132 deletions js/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ var receivers_url = "https://api.v2.sondehub.org/listeners";
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 = {};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1616,25 +1606,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&nbsp;found");
mapInfoBox.openOn(map);
Expand Down Expand Up @@ -2225,12 +2199,12 @@ function addPosition(position) {
var curr_ts = convert_time(vehicle.curr_position.gps_time);
var dt = (new_ts - curr_ts) / 1000; // convert to seconds

if(dt > 0) {
if(dt >= 0) {
if(vehicle.num_positions > 0) {
// 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;
}

Expand Down Expand Up @@ -2717,6 +2691,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) {
Expand Down Expand Up @@ -2763,7 +2738,7 @@ function refresh() {
}
} else {
ajax_inprogress_old = "none";
update(response);
update(response);
}
$("#stText").text("");
$("#stTimer").attr("data-timestamp", response.fetch_timestamp);
Expand Down Expand Up @@ -2809,6 +2784,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,"");
Expand Down Expand Up @@ -2957,107 +2933,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("<span>No vehicles :(</span>");
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;
Expand Down Expand Up @@ -3380,7 +3255,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;
}
Expand Down