From 0626ee2502a582f469cca8d93e66a7005a2e62a0 Mon Sep 17 00:00:00 2001 From: pschuler78 Date: Sat, 9 Oct 2021 19:56:47 +0200 Subject: [PATCH] Added ability to track aircraft type based on Aprs message --- libs/Skyhop.FlightAnalysis/FlightContext.cs | 4 ++ .../Models/AddressType.cs | 14 ++++++ .../Models/AircraftType.cs | 26 +++++++++++ libs/Skyhop.FlightAnalysis/Models/Flight.cs | 8 +++- .../Models/PositionUpdate.cs | 44 +++++++++++++++++-- .../States/Initialize.cs | 2 +- 6 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 libs/Skyhop.FlightAnalysis/Models/AddressType.cs create mode 100644 libs/Skyhop.FlightAnalysis/Models/AircraftType.cs diff --git a/libs/Skyhop.FlightAnalysis/FlightContext.cs b/libs/Skyhop.FlightAnalysis/FlightContext.cs index 0ab603f..0b2f3c9 100644 --- a/libs/Skyhop.FlightAnalysis/FlightContext.cs +++ b/libs/Skyhop.FlightAnalysis/FlightContext.cs @@ -127,6 +127,10 @@ public bool Process(PositionUpdate positionUpdate) { if (positionUpdate == null) return false; + Flight.DeviceId = positionUpdate.DeviceId; + Flight.AddressType = positionUpdate.AddressType; + Flight.AircraftType = positionUpdate.AircraftType; + if (CurrentPosition != null) { if ((positionUpdate.TimeStamp - CurrentPosition.TimeStamp).TotalMilliseconds < 100) return false; diff --git a/libs/Skyhop.FlightAnalysis/Models/AddressType.cs b/libs/Skyhop.FlightAnalysis/Models/AddressType.cs new file mode 100644 index 0000000..e78e83f --- /dev/null +++ b/libs/Skyhop.FlightAnalysis/Models/AddressType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Skyhop.FlightAnalysis.Models +{ + public enum AddressType + { + Random = 0x0, + ICAO = 0x1, + Flarm = 0x2, + OGN = 0x3 + } +} diff --git a/libs/Skyhop.FlightAnalysis/Models/AircraftType.cs b/libs/Skyhop.FlightAnalysis/Models/AircraftType.cs new file mode 100644 index 0000000..fac1e35 --- /dev/null +++ b/libs/Skyhop.FlightAnalysis/Models/AircraftType.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Skyhop.FlightAnalysis.Models +{ + public enum AircraftType + { + Unknown = 0x0, + Glider = 0x1, + TowPlane = 0x2, + Helicopter = 0x3, + Skydiver = 0x4, + DropPlane = 0x5, + Hangglider = 0x6, + Paraglider = 0x7, + PoweredPiston = 0x8, + PoweredJet = 0x9, + Unknown2 = 0xA, + Balloon = 0xB, + Airship = 0xC, + UAV = 0xD, + Unknown3 = 0xE, + Static = 0xF + } +} diff --git a/libs/Skyhop.FlightAnalysis/Models/Flight.cs b/libs/Skyhop.FlightAnalysis/Models/Flight.cs index 52260a8..7268c04 100644 --- a/libs/Skyhop.FlightAnalysis/Models/Flight.cs +++ b/libs/Skyhop.FlightAnalysis/Models/Flight.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using NetTopologySuite.Geometries; using static Skyhop.FlightAnalysis.FlightContext; @@ -23,6 +23,12 @@ public class Flight public string Aircraft { get; set; } + public string DeviceId { get; internal set; } + + public AircraftType AircraftType { get; internal set; } + + public AddressType AddressType { get; internal set; } + public DateTime? DepartureTime { get; set; } public short DepartureHeading { get; set; } public Point DepartureLocation { get; set; } diff --git a/libs/Skyhop.FlightAnalysis/Models/PositionUpdate.cs b/libs/Skyhop.FlightAnalysis/Models/PositionUpdate.cs index 9888acd..11fda0a 100644 --- a/libs/Skyhop.FlightAnalysis/Models/PositionUpdate.cs +++ b/libs/Skyhop.FlightAnalysis/Models/PositionUpdate.cs @@ -1,4 +1,4 @@ -using System; +using System; using NetTopologySuite.Geometries; namespace Skyhop.FlightAnalysis.Models @@ -6,6 +6,36 @@ namespace Skyhop.FlightAnalysis.Models // ToDo: Get this into a readonly struct for performance reasons public class PositionUpdate { + /// + /// Create a new instance of the class using all the available parameters. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public PositionUpdate(string aircraft, DateTime timeStamp, double latitude, double longitude, double altitude, double speed, double heading, string deviceId, AddressType addressType, AircraftType aircraftType) + { + Aircraft = aircraft; + TimeStamp = timeStamp; + //Location = new Point(latitude, longitude, altitude); + Latitude = latitude; + Longitude = longitude; + Altitude = altitude; + Speed = speed; + Heading = heading; + DeviceId = deviceId; + AddressType = addressType; + AircraftType = aircraftType; + + // ToDo: Figure something out to implement the RBush again + } + /// /// Create a new instance of the class using all the available parameters. /// @@ -37,7 +67,8 @@ public PositionUpdate(string aircraft, DateTime timeStamp, double latitude, doub /// /// /// - public PositionUpdate(string aircraft, DateTime timeStamp, double latitude, double longitude) : this(aircraft, timeStamp, latitude, longitude, double.NaN, double.NaN, double.NaN) { } + public PositionUpdate(string aircraft, DateTime timeStamp, double latitude, double longitude) + : this(aircraft, timeStamp, latitude, longitude, double.NaN, double.NaN, double.NaN) { } /// /// Create a new instance of the class with a minimal set of data. @@ -47,7 +78,8 @@ public PositionUpdate(string aircraft, DateTime timeStamp, double latitude, doub /// /// /// - public PositionUpdate(string aircraft, double latitude, double longitude) : this(aircraft, DateTime.UtcNow, latitude, longitude, double.NaN, double.NaN, double.NaN) { } + public PositionUpdate(string aircraft, double latitude, double longitude) + : this(aircraft, DateTime.UtcNow, latitude, longitude, double.NaN, double.NaN, double.NaN) { } public string Aircraft { get; } @@ -59,6 +91,12 @@ public PositionUpdate(string aircraft, double latitude, double longitude) : this public double Longitude { get; } public double Altitude { get; } + public string DeviceId { get; } + + public AircraftType AircraftType { get; } + + public AddressType AddressType { get; } + // Note that these properties need to be internally assignable for the normalization algorithm to work. public double Speed { get; internal set; } public double Heading { get; internal set; } diff --git a/libs/Skyhop.FlightAnalysis/States/Initialize.cs b/libs/Skyhop.FlightAnalysis/States/Initialize.cs index 4807eb1..9ae061d 100644 --- a/libs/Skyhop.FlightAnalysis/States/Initialize.cs +++ b/libs/Skyhop.FlightAnalysis/States/Initialize.cs @@ -1,4 +1,4 @@ -using Skyhop.FlightAnalysis.Models; +using Skyhop.FlightAnalysis.Models; using System; namespace Skyhop.FlightAnalysis