Skip to content

Commit c940083

Browse files
committed
general improvements
1 parent fc786df commit c940083

File tree

5 files changed

+13
-184
lines changed

5 files changed

+13
-184
lines changed

css/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Habitat Mobile Tracker
1+
/* SondeHub Mobile Tracker
22
* Main style sheet
33
*
44
*/

img/sondehub_logo.png

1.41 KB
Loading

js/app.js

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -201,31 +201,6 @@ var loadComplete = function(e) {
201201
$('#loading .complete').stop(true,true).animate({width: 200}, {complete: trackerInit });
202202
};
203203

204-
var hysplit = {};
205-
var hysplit_data = {};
206-
var refresh_hysplit = function() {
207-
$.getJSON("//spacenear.us/tracker/datanew.php?type=hysplit&format=json", function(data) {
208-
var refresh = false;
209-
210-
for(var k in data) {
211-
if(k in hysplit_data) {
212-
// if the jobid is the same, skip to next one
213-
if(hysplit_data[k].jobid == data[k].jobid) continue;
214-
215-
// otherwise update the url
216-
hysplit_data[k] = data[k];
217-
hysplit[k].setUrl(hysplit_data[k].url_kmz);
218-
} else {
219-
hysplit_data[k] = data[k];
220-
hysplit[k] = new google.maps.KmlLayer({url: hysplit_data[k].url_kmz, preserveViewport:true });
221-
refresh = true;
222-
}
223-
}
224-
225-
if(refresh) refreshUI();
226-
});
227-
};
228-
229204
// loads the tracker interface
230205
function trackerInit() {
231206
$('#loading,#settingsbox,#aboutbox,#chasebox').hide(); // welcome screen
@@ -240,10 +215,6 @@ function trackerInit() {
240215
$.getScript("js/init_plot.js", function() { checkSize(); if(!map) load(); });
241216
if(wvar.graph) $('#telemetry_graph').attr('style','');
242217

243-
// fetch hysplit jobs
244-
// setInterval(refresh_hysplit, 60 * 1000);
245-
// refresh_hysplit();
246-
247218
return;
248219
}
249220
if(!map) load();
@@ -480,7 +451,7 @@ var updateTimebox = function(date) {
480451
};
481452

482453
var format_time_friendly = function(start, end) {
483-
var dt = Math.floor((end - start) / 1000);
454+
var dt = Math.floor((end - start) / 1000);;
484455
if(dt < 0) return null;
485456

486457
if(dt < 60) return dt + 's';
@@ -566,23 +537,6 @@ $(window).ready(function() {
566537
// expand graph on startup, if nessary
567538
if(wvar.graph_expanded) $('#telemetry_graph .graph_label').click();
568539

569-
// hysplit button
570-
$("#main").on('click','.row .data .vbutton.hysplit', function(event) {
571-
event.stopPropagation();
572-
573-
var elm = $(this);
574-
var name = elm.attr('data-vcallsign');
575-
576-
if(elm.hasClass("active")) {
577-
elm.removeClass('active');
578-
map.removeLayer(hysplit[name]);
579-
}
580-
else {
581-
elm.addClass('active');
582-
map.addLayer(hysplit[name]);
583-
}
584-
});
585-
586540
$("#main").on('click','.row .data .vbutton.path', function(event) {
587541
event.stopPropagation();
588542

@@ -721,7 +675,7 @@ $(window).ready(function() {
721675
field.attr('disabled','disabled');
722676
e.removeClass('off').addClass('on');
723677

724-
// push listener doc to habitat
678+
// push listener doc to SondeHub
725679
// this gets a station on the map, under the car marker
726680
// im still not sure its nessesary
727681
if(!CHASE_listenerSent) {
@@ -730,7 +684,7 @@ $(window).ready(function() {
730684
CHASE_listenerSent = true;
731685
}
732686
}
733-
// if already have a position push it to habitat
687+
// if already have a position push it to SondeHub
734688
if(GPS_ts) {
735689
ChaseCar.updatePosition(callsign, { coords: { latitude: GPS_lat, longitude: GPS_lon, altitude: GPS_alt, speed: GPS_speed }});
736690
}

js/chasecar.lib.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Habitat ChaseCar lib
2-
* Uploads geolocation for chase cars to habitat
1+
/* SondeHub ChaseCar lib
2+
* Uploads geolocation for chase cars to SondeHub
33
*
44
* Author: Rossen Gerogiev
55
* Requires: jQuery

js/tracker.js

Lines changed: 7 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ var receivers_url = "https://api.v2.sondehub.org/listeners";
55
var predictions_url = "https://api.v2.sondehub.org/predictions?vehicles=";
66
var recovered_sondes_url = "https://api.v2.sondehub.org/recovered";
77

8-
var habitat_max = 400;
9-
//var habitat_url = "//habitat.habhub.org/habitat/";
10-
var habitat_url = "/habitat/";
11-
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=";
12-
138
var host_url = "";
149
var markers_url = "img/markers/";
1510
var vehicles = {};
@@ -354,11 +349,6 @@ function clean_refresh(text, force, history_step) {
354349
vehicles[callsign].kill();
355350
}
356351

357-
// clear hysplit
358-
for(callsign in hysplit) {
359-
map.removeLayer(hysplit[callsign]);
360-
}
361-
362352
car_index = 0;
363353
balloon_index = 0;
364354
nyan_color_index = 0;
@@ -1616,25 +1606,9 @@ function mapInfoBox_handle_path(event) {
16161606
};
16171607

16181608
function mapInfoBox_handle_path_fetch(id,vehicle) {
1619-
var ishabitat = id.length == 64
1620-
1621-
if(ishabitat) {
1622-
var url = habitat_url + id;
1623-
} else {
1624-
var url = data_url + "?mode=single&format=json&position_id=" + id;
1625-
}
1609+
var url = data_url + "?mode=single&format=json&position_id=" + id;
16261610

16271611
$.getJSON(url, function(data) {
1628-
if(ishabitat) {
1629-
var encap = {positions: { position: [] }};
1630-
1631-
if(!data.hasOwnProperty('error')) {
1632-
data._id = data._id.substring(58);
1633-
encap.positions.position.push(habitat_doc_to_snus(data));
1634-
data = encap;
1635-
}
1636-
}
1637-
16381612
if('positions' in data && data.positions.position.length === 0) {
16391613
mapInfoBox.setContent("not&nbsp;found");
16401614
mapInfoBox.openOn(map);
@@ -2225,12 +2199,12 @@ function addPosition(position) {
22252199
var curr_ts = convert_time(vehicle.curr_position.gps_time);
22262200
var dt = (new_ts - curr_ts) / 1000; // convert to seconds
22272201

2228-
if(dt > 0) {
2202+
if(dt >= 0) {
22292203
if(vehicle.num_positions > 0) {
22302204
// calculate vertical rate
22312205
// TODO - Make this average over more points rather than use a FIR.
22322206
var rate = (position.gps_alt - vehicle.curr_position.gps_alt) / dt;
2233-
if (!isNaN(rate)) {
2207+
if (!isNaN(rate) && dt != 0) {
22342208
vehicle.ascent_rate = 0.7 * rate + 0.3 * vehicle.ascent_rate;
22352209
}
22362210

@@ -2717,6 +2691,7 @@ var ajax_positions_old = null;
27172691
var ajax_inprogress = false;
27182692
var ajax_inprogress_single = false;
27192693
var ajax_inprogress_old = "none";
2694+
var ajax_single_serial = null;
27202695

27212696
function refresh() {
27222697
if(ajax_inprogress) {
@@ -2763,7 +2738,7 @@ function refresh() {
27632738
}
27642739
} else {
27652740
ajax_inprogress_old = "none";
2766-
update(response);
2741+
update(response);
27672742
}
27682743
$("#stText").text("");
27692744
$("#stTimer").attr("data-timestamp", response.fetch_timestamp);
@@ -2809,6 +2784,7 @@ function refreshSingle(serial, first) {
28092784
}
28102785

28112786
ajax_inprogress_single = true;
2787+
ajax_single_serial = serial;
28122788

28132789
var mode = wvar.mode.toLowerCase();
28142790
mode = (mode == "position") ? "latest" : mode.replace(/ /g,"");
@@ -2957,107 +2933,6 @@ function refreshPredictions() {
29572933
});
29582934
}
29592935

2960-
function habitat_translation_layer(json_result, prefix) {
2961-
if(json_result.rows.length === 0) {
2962-
habitat_payload_step(true);
2963-
return;
2964-
}
2965-
2966-
json_result = json_result.rows;
2967-
2968-
var result = {positions: { position: [] }};
2969-
result.fetch_timestamp = Date.now();
2970-
$("#stTimer").attr("data-timestamp", result.fetch_timestamp);
2971-
2972-
for(var i in json_result) {
2973-
var doc = json_result[i].doc;
2974-
2975-
if(doc.data.latitude === 0 && doc.data.longitude === 0) continue;
2976-
2977-
var row = habitat_doc_to_snus(doc, prefix);
2978-
2979-
result.positions.position.push(row);
2980-
}
2981-
2982-
if(result.positions.position.length) update(result);
2983-
2984-
// next step
2985-
periodical = setTimeout(function() {
2986-
habitat_payload_step();
2987-
}, 500);
2988-
}
2989-
2990-
var habitat_field_blacklist = {
2991-
altitude: 1,
2992-
date: 1,
2993-
latitude: 1,
2994-
longitude: 1,
2995-
payload: 1,
2996-
sentence_id: 1,
2997-
time: 1,
2998-
};
2999-
3000-
function habitat_doc_to_snus(doc, prefix) {
3001-
prefix = prefix || '';
3002-
3003-
var row = {
3004-
'position_id': doc._id,
3005-
'vehicle': prefix + doc.data.payload,
3006-
'server_time': doc.data._parsed.time_parsed,
3007-
'sequence': doc.data.sentence_id,
3008-
'gps_lat': doc.data.latitude,
3009-
'gps_lon': doc.data.longitude,
3010-
'gps_alt': doc.data.altitude,
3011-
'callsign': "HABITAT ARCHIVE",
3012-
'data': {}
3013-
};
3014-
3015-
try {
3016-
row.gps_time = "20" + doc.data.date.replace(/([0-9]{2})/g, "$1-") + doc.data.time;
3017-
} catch (e) {
3018-
row.gps_time = row.server_time;
3019-
}
3020-
3021-
// move all other properties as data
3022-
for(var x in doc.data) {
3023-
// skip internal and reserved vars
3024-
if(x[0] == '_' || habitat_field_blacklist.hasOwnProperty(x)) continue;
3025-
3026-
row.data[x] = doc.data[x];
3027-
}
3028-
row.data = JSON.stringify(row.data);
3029-
3030-
return row;
3031-
}
3032-
3033-
var habitat_payload_step_data;
3034-
3035-
function habitat_payload_step(remove_current) {
3036-
remove_current = !!remove_current;
3037-
3038-
if(remove_current) {
3039-
habitat_payload_step_data.payloads.splice(habitat_payload_step_data.idx, 1);
3040-
}
3041-
3042-
if(habitat_payload_step_data.payloads.length === 0) {
3043-
$("#stText").text("");
3044-
$("#main .header.empty").html("<span>No vehicles :(</span>");
3045-
return;
3046-
}
3047-
3048-
habitat_payload_step_data.idx += 1;
3049-
habitat_payload_step_data.idx = habitat_payload_step_data.idx % habitat_payload_step_data.payloads.length;
3050-
3051-
var prefix = habitat_payload_step_data.payloads[habitat_payload_step_data.idx].prefix;
3052-
var url = habitat_payload_step_data.payloads[habitat_payload_step_data.idx].url;
3053-
url += habitat_payload_step_data.payloads[habitat_payload_step_data.idx].skip;
3054-
habitat_payload_step_data.payloads[habitat_payload_step_data.idx].skip += habitat_max;
3055-
3056-
ajax_positions = $.getJSON(url, function(response) {
3057-
habitat_translation_layer(response, prefix);
3058-
});
3059-
}
3060-
30612936
var periodical, periodical_focus, periodical_receivers, periodical_recoveries;
30622937
var periodical_predictions = null;
30632938
var timer_seconds = 5;
@@ -3380,7 +3255,7 @@ function updatePredictions(r) {
33803255
if(vehicles.hasOwnProperty(vcallsign)) {
33813256
var vehicle = vehicles[vcallsign];
33823257

3383-
if(vcallsign in hysplit || vehicle.marker.mode == "landed") {
3258+
if(vehicle.marker.mode == "landed") {
33843259
removePrediction(vcallsign);
33853260
continue;
33863261
}

0 commit comments

Comments
 (0)