Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to track aircraft type based on Aprs message #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions libs/Skyhop.FlightAnalysis/FlightContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions libs/Skyhop.FlightAnalysis/Models/AddressType.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
26 changes: 26 additions & 0 deletions libs/Skyhop.FlightAnalysis/Models/AircraftType.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
8 changes: 7 additions & 1 deletion libs/Skyhop.FlightAnalysis/Models/Flight.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using NetTopologySuite.Geometries;
using static Skyhop.FlightAnalysis.FlightContext;
Expand All @@ -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; }
Expand Down
44 changes: 41 additions & 3 deletions libs/Skyhop.FlightAnalysis/Models/PositionUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
using System;
using System;
using NetTopologySuite.Geometries;

namespace Skyhop.FlightAnalysis.Models
{
// ToDo: Get this into a readonly struct for performance reasons
public class PositionUpdate
{
/// <summary>
/// Create a new instance of the <see cref="PositionUpdate"/> class using all the available parameters.
/// </summary>
/// <param name="aircraft"></param>
/// <param name="timeStamp"></param>
/// <param name="latitude"></param>
/// <param name="longitude"></param>
/// <param name="altitude"></param>
/// <param name="speed"></param>
/// <param name="heading"></param>
/// <param name="deviceId"></param>
/// <param name="addressType"></param>
/// <param name="aircraftType"></param>
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
}

/// <summary>
/// Create a new instance of the <see cref="PositionUpdate"/> class using all the available parameters.
/// </summary>
Expand Down Expand Up @@ -37,7 +67,8 @@ public PositionUpdate(string aircraft, DateTime timeStamp, double latitude, doub
/// <param name="timeStamp"></param>
/// <param name="latitude"></param>
/// <param name="longitude"></param>
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) { }

/// <summary>
/// Create a new instance of the <see cref="PositionUpdate"/> class with a minimal set of data.
Expand All @@ -47,7 +78,8 @@ public PositionUpdate(string aircraft, DateTime timeStamp, double latitude, doub
/// <param name="aircraft"></param>
/// <param name="latitude"></param>
/// <param name="longitude"></param>
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; }

Expand All @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion libs/Skyhop.FlightAnalysis/States/Initialize.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Skyhop.FlightAnalysis.Models;
using Skyhop.FlightAnalysis.Models;
using System;

namespace Skyhop.FlightAnalysis
Expand Down