summaryrefslogtreecommitdiff
path: root/src/main/java/com/benburwell/planes/data
diff options
context:
space:
mode:
authorBen Burwell <ben.burwell@trifecta.com>2016-11-20 01:14:47 -0500
committerBen Burwell <ben.burwell@trifecta.com>2016-11-20 01:14:47 -0500
commitbe4974518d4e24f66c19ceffc1e633e3e306956b (patch)
treee83c250a5038136e38c9ec558a9060af365ab582 /src/main/java/com/benburwell/planes/data
parentd5fddf794c2fdc0ebad0f9625ed413158d3adc4b (diff)
Show track and remove planes after interval
Diffstat (limited to 'src/main/java/com/benburwell/planes/data')
-rw-r--r--src/main/java/com/benburwell/planes/data/Aircraft.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/com/benburwell/planes/data/Aircraft.java b/src/main/java/com/benburwell/planes/data/Aircraft.java
index 66a7a46..9f6b881 100644
--- a/src/main/java/com/benburwell/planes/data/Aircraft.java
+++ b/src/main/java/com/benburwell/planes/data/Aircraft.java
@@ -2,6 +2,7 @@ package com.benburwell.planes.data;
import com.benburwell.planes.sbs.SBSPacket;
+import java.util.Date;
import java.util.List;
import java.util.ArrayList;
@@ -25,14 +26,24 @@ public class Aircraft implements Comparable<Aircraft> {
public void handleUpdate(SBSPacket packet) {
this.packetCount++;
+
+ Position newPosition = new Position();
+ newPosition.setAltitude(this.currentPosition.getAltitude());
+ newPosition.setLatitude(this.currentPosition.getLatitude());
+ newPosition.setLongitude(this.currentPosition.getLongitude());
+ newPosition.setTimestamp(this.currentPosition.getTimestamp());
+
if (packet.getAltitude() != null) {
- this.currentPosition.setAltitude(packet.getAltitude());
+ newPosition.setAltitude(packet.getAltitude());
+ newPosition.setTimestamp(new Date(System.currentTimeMillis()));
}
if (packet.getLatitude() != null) {
- this.currentPosition.setLatitude(packet.getLatitude());
+ newPosition.setLatitude(packet.getLatitude());
+ newPosition.setTimestamp(new Date(System.currentTimeMillis()));
}
if (packet.getLongitude() != null) {
- this.currentPosition.setLongitude(packet.getLongitude());
+ newPosition.setLongitude(packet.getLongitude());
+ newPosition.setTimestamp(new Date(System.currentTimeMillis()));
}
if (packet.getCallsign() != null && !packet.getCallsign().isEmpty()) {
this.callsign = packet.getCallsign();
@@ -49,6 +60,11 @@ public class Aircraft implements Comparable<Aircraft> {
if (packet.getVerticalRate() != null) {
this.verticalRate = packet.getVerticalRate();
}
+
+ if (newPosition.getTimestamp().after(this.currentPosition.getTimestamp())) {
+ this.positionHistory.add(currentPosition);
+ this.currentPosition = newPosition;
+ }
}
public Position getCurrentPosition() {
@@ -83,6 +99,10 @@ public class Aircraft implements Comparable<Aircraft> {
return this.verticalRate;
}
+ public List<Position> getPositionHistory() {
+ return positionHistory;
+ }
+
@Override
public int compareTo(Aircraft that) {
return this.getHexIdent().compareTo(that.getHexIdent());