summaryrefslogtreecommitdiff
path: root/src/com/benburwell/planes/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/benburwell/planes/data')
-rw-r--r--src/com/benburwell/planes/data/Aircraft.java66
-rw-r--r--src/com/benburwell/planes/data/Position.java46
2 files changed, 112 insertions, 0 deletions
diff --git a/src/com/benburwell/planes/data/Aircraft.java b/src/com/benburwell/planes/data/Aircraft.java
new file mode 100644
index 0000000..71ee5b5
--- /dev/null
+++ b/src/com/benburwell/planes/data/Aircraft.java
@@ -0,0 +1,66 @@
+package com.benburwell.planes.data;
+
+import com.benburwell.planes.sbs.SBSPacket;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Created by ben on 11/15/16.
+ */
+public class Aircraft implements Comparable<Aircraft> {
+ private final String hexIdent;
+ private Position currentPosition = new Position();
+ private List<Position> positionHistory = new ArrayList<>();
+ private String callsign = "";
+ private String squawk = "";
+ private long packetCount = 0;
+
+ public Aircraft(String hexIdent) {
+ this.hexIdent = hexIdent;
+ }
+
+ public void handleUpdate(SBSPacket packet) {
+ this.packetCount++;
+ if (packet.getAltitude() != null) {
+ this.currentPosition.setAltitude(packet.getAltitude());
+ }
+ if (packet.getLatitude() != null) {
+ this.currentPosition.setLatitude(packet.getLatitude());
+ }
+ if (packet.getLongitude() != null) {
+ this.currentPosition.setLongitude(packet.getLongitude());
+ }
+ if (packet.getCallsign() != null && !packet.getCallsign().isEmpty()) {
+ this.callsign = packet.getCallsign();
+ }
+ if (packet.getSquawk() != null && !packet.getSquawk().isEmpty()) {
+ this.callsign = packet.getSquawk();
+ }
+ }
+
+ public Position getCurrentPosition() {
+ return currentPosition;
+ }
+
+ public String getCallsign() {
+ return callsign;
+ }
+
+ public String getSquawk() {
+ return squawk;
+ }
+
+ public Long getPacketCount() {
+ return packetCount;
+ }
+
+ public String getHexIdent() {
+ return this.hexIdent;
+ }
+
+ @Override
+ public int compareTo(Aircraft that) {
+ return this.getHexIdent().compareTo(that.getHexIdent());
+ }
+}
diff --git a/src/com/benburwell/planes/data/Position.java b/src/com/benburwell/planes/data/Position.java
new file mode 100644
index 0000000..4b37235
--- /dev/null
+++ b/src/com/benburwell/planes/data/Position.java
@@ -0,0 +1,46 @@
+package com.benburwell.planes.data;
+
+import java.util.Date;
+
+/**
+ * Created by ben on 11/15/16.
+ */
+public class Position {
+ private Date timestamp = new Date(System.currentTimeMillis());
+ private Double latitude = 0.0;
+ private Double longitude = 0.0;
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ public double getAltitude() {
+ return altitude;
+ }
+
+ public void setAltitude(double altitude) {
+ this.altitude = altitude;
+ }
+
+ private double altitude = 0;
+}