Skip to content
Merged
Changes from all commits
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
30 changes: 14 additions & 16 deletions js/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,17 +1032,11 @@ function updateVehicleInfo(vcallsign, newPosition) {
var latlng = new L.LatLng(newPosition.gps_lat, newPosition.gps_lon);
}

// update market z-index based on latitude, 90 being background and -90 foreground
// the first 2 decimal digits are included for added accuracy
var zIndex = 900000 - parseInt(newPosition.gps_lat*10000);

// update position
if(vehicle.marker_shadow) {
vehicle.marker_shadow.setLatLng(latlng);
//vehicle.marker_shadow.setZIndex(Z_SHADOW + zIndex);
}
vehicle.marker.setLatLng(latlng);
//vehicle.marker.setZIndex(((vehicle.vehicle_type=="car")? Z_CAR : Z_PAYLOAD) + zIndex);

if(!!vehicle.marker.setCourse) {
if (vehicle.curr_position.gps_heading) {
Expand Down Expand Up @@ -1165,8 +1159,6 @@ function updateVehicleInfo(vcallsign, newPosition) {
$('.portrait').append('<div class="row vehicle'+vehicle.uuid+'" data-vcallsign="'+vcallsign+'"></div>');
$('.landscape').append('<div class="row vehicle'+vehicle.uuid+'" data-vcallsign="'+vcallsign+'"></div>');
}



} else if(elm.attr('data-vcallsign') === undefined) {
elm.attr('data-vcallsign', vcallsign);
Expand Down Expand Up @@ -2220,6 +2212,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 (typeof position.type !== 'undefined' && typeof vehicle.curr_position.type !== 'undefined') {
if (position.type.length < vehicle.curr_position.type.length) {
position.type = vehicle.curr_position.type;
}
}

if(dt >= 0) {
if(vehicle.num_positions > 0) {
// calculate vertical rate
Expand Down Expand Up @@ -2904,16 +2902,16 @@ function liveData() {
$("#stText").text("websocket |");
})

client.on('connect', function () {
client.subscribe('#')
$("#stText").text("websocket |");
})

client.on('message', function (topic, message) {
var frame = JSON.parse(message.toString());
var test = formatData(frame, true);
update(test);
$("#stTimer").attr("data-timestamp", new Date().getTime());
if ((new Date().getTime() - new Date(frame.time_received).getTime()) < 30000) {
var test = formatData(frame, true);
update(test);
$("#stTimer").attr("data-timestamp", new Date().getTime());
$("#stText").text("websocket |");
} else {
$("#stText").text("error |");
}
})
}

Expand Down