WIP webmap cleanup

This commit is contained in:
Oliver Jowett 2015-01-05 23:20:03 +00:00
parent 99bca13844
commit 1f06abf67d
4 changed files with 242 additions and 288 deletions
public_html

View file

@ -20,10 +20,6 @@ var planeObject = {
messages : null,
seen : null,
// Vaild...
vPosition : false,
vTrack : false,
// GMap Details
marker : null,
markerColor : MarkerColor,
@ -130,85 +126,69 @@ var planeObject = {
},
// Update our data
funcUpdateData : function(data){
// So we can find out if we moved
var oldlat = this.latitude;
var oldlon = this.longitude;
var oldalt = this.altitude;
// Update all of our data
this.updated = new Date().getTime();
funcUpdateData : function(receiver_now,data){
// So we can find out if we moved
var oldlat = this.latitude;
var oldlon = this.longitude;
var oldalt = this.altitude;
// Update all of our data
this.updated = new Date().getTime();
this.icao = data.hex;
this.messages = data.messages;
this.seen = data.seen;
if (typeof data.altitude !== "undefined")
this.altitude = data.altitude;
this.speed = data.speed;
this.track = data.track;
if (typeof data.speed !== "undefined")
this.speed = data.speed;
if (typeof data.track !== "undefined")
this.track = data.track;
if (typeof data.lat !== "undefined") {
this.latitude = data.lat;
this.longitude = data.lon;
}
if (typeof data.flight !== "undefined")
this.flight = data.flight;
if (typeof data.squawk !== "undefined")
this.squawk = data.squawk;
this.icao = data.hex;
this.messages = data.messages;
this.seen = data.seen;
// If no packet in over 58 seconds, consider the plane reapable
// This way we can hold it, but not show it just in case the plane comes back
if (this.seen > 58) {
this.reapable = true;
if (this.marker) {
this.marker.setMap(null);
this.marker = null;
// If no packet in over 58 seconds, consider the plane reapable
// This way we can hold it, but not show it just in case the plane comes back
if (this.seen > 58) {
this.reapable = true;
if (this.marker) {
this.marker.setMap(null);
this.marker = null;
}
if (this.line) {
this.line.setMap(null);
this.line = null;
}
if (SelectedPlane == this.icao) {
if (this.is_selected) {
this.is_selected = false;
}
if (this.line) {
this.line.setMap(null);
this.line = null;
SelectedPlane = null;
}
} else {
this.reapable = false;
}
// Is the position valid?
if (!this.reapable && typeof data.lat !== "undefined") {
// Detech if the plane has moved
if (oldlat != this.latitude || oldlon != this.longitude) {
this.funcAddToTrack();
if (this.is_selected) {
this.line = this.funcUpdateLines();
}
if (SelectedPlane == this.icao) {
if (this.is_selected) {
this.is_selected = false;
}
SelectedPlane = null;
}
} else {
if (this.reapable == true) {
}
this.reapable = false;
}
// Is the position valid?
if ((data.validposition == 1) && (this.reapable == false)) {
this.vPosition = true;
// Detech if the plane has moved
changeLat = false;
changeLon = false;
changeAlt = false;
if (oldlat != this.latitude) {
changeLat = true;
}
if (oldlon != this.longitude) {
changeLon = true;
}
if (oldalt != this.altitude) {
changeAlt = true;
}
// Right now we only care about lat/long, if alt is updated only, oh well
if ((changeLat == true) || (changeLon == true)) {
this.funcAddToTrack();
if (this.is_selected) {
this.line = this.funcUpdateLines();
}
}
this.marker = this.funcUpdateMarker();
PlanesOnMap++;
} else {
this.vPosition = false;
}
// Do we have a valid track for the plane?
if (data.validtrack == 1)
this.vTrack = true;
else
this.vTrack = false;
},
this.marker = this.funcUpdateMarker();
PlanesOnMap++;
}
},
// Update our marker on the map
funcUpdateMarker: function() {
@ -231,7 +211,7 @@ var planeObject = {
}
// Setting the marker title
if (this.flight.length == 0) {
if (this.flight === null || this.flight.length == 0) {
this.marker.setTitle(this.hex);
} else {
this.marker.setTitle(this.flight+' ('+this.icao+')');