Skip to content

Commit

Permalink
Merge pull request #34 from davewalker5/BSR-57-Receiver-Lat-Long
Browse files Browse the repository at this point in the history
BSR-57 Receiver Latitude and Longitude
  • Loading branch information
davewalker5 authored Sep 24, 2023
2 parents cb5c237 + f02f95f commit 287b6fb
Show file tree
Hide file tree
Showing 48 changed files with 595 additions and 84 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
| ApplicationSettings | WriterBatchSize | --writer-batch-size | -b | Maximum number of changes to consider on each WriterInterval |
| ApplicationSettings | RefreshInterval | --ui-interval | -b | GUI live view refresh interval (ms) |
| ApplicationSettings | MaximumRows | --max-rows | -m | Maximum rows in the live table view at any one time or 0 for unlimited rows |
| ApplicationSettings | ReceiverLatitude | --latitude | -la | Receiver latitude, used in aircraft distance calculations |
| ApplicationSettings | ReceiverLongitude | --longitude | -lo | Receiver longitude, used in aircraft distance calculations |
| ApplicationSettings | Columns | - | - | Set of column definitions for columns to be included in the output |
| ConnectionStrings | BaseStationReaderDB | - | - | SQLite connection string for the database |

Expand Down
4 changes: 2 additions & 2 deletions src/BaseStationReader.Data/BaseStationReader.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>BaseStationReader.Data</PackageId>
<PackageVersion>1.25.0.0</PackageVersion>
<PackageVersion>1.26.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/davewalker5/ADS-B-BaseStationReader</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.25.0.0</ReleaseVersion>
<ReleaseVersion>1.26.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/BaseStationReader.Data/BaseStationReaderDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.Squawk).HasColumnName("Squawk");
entity.Property(e => e.Status).HasColumnName("Status");
entity.Property(e => e.Messages).HasColumnName("Messages");
entity.Property(e => e.Distance).HasColumnName("Distance");

entity.Property(e => e.FirstSeen)
.IsRequired()
Expand Down Expand Up @@ -77,6 +78,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnName("Timestamp")
.HasColumnType("DATETIME");

entity.Property(e => e.Distance).HasColumnName("Distance");
});
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System.Diagnostics.CodeAnalysis;

#nullable disable

namespace BaseStationReader.Data.Migrations
{
/// <inheritdoc />
[ExcludeFromCodeCoverage]
public partial class AircraftDistance : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "Distance",
table: "AIRCRAFT_POSITION",
type: "REAL",
nullable: true);

migrationBuilder.AddColumn<double>(
name: "Distance",
table: "AIRCRAFT",
type: "REAL",
nullable: true);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Distance",
table: "AIRCRAFT_POSITION");

migrationBuilder.DropColumn(
name: "Distance",
table: "AIRCRAFT");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// <auto-generated />
using System;
using System.Diagnostics.CodeAnalysis;
using BaseStationReader.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
Expand All @@ -11,7 +10,6 @@
namespace BaseStationReader.Data.Migrations
{
[DbContext(typeof(BaseStationReaderDbContext))]
[ExcludeFromCodeCoverage]
partial class BaseStationReaderDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
Expand Down Expand Up @@ -39,6 +37,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("TEXT")
.HasColumnName("Callsign");

b.Property<double?>("Distance")
.HasColumnType("REAL")
.HasColumnName("Distance");

b.Property<DateTime>("FirstSeen")
.HasColumnType("DATETIME")
.HasColumnName("FirstSeen");
Expand All @@ -60,7 +62,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnName("Longitude");

b.Property<int>("Messages")
.HasColumnType("INTEGER");
.HasColumnType("INTEGER")
.HasColumnName("Messages");

b.Property<string>("Squawk")
.HasColumnType("TEXT")
Expand Down Expand Up @@ -97,6 +100,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<decimal>("Altitude")
.HasColumnType("TEXT");

b.Property<double?>("Distance")
.HasColumnType("REAL")
.HasColumnName("Distance");

b.Property<decimal>("Latitude")
.HasColumnType("TEXT")
.HasColumnName("Latitude");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>BaseStationReader.Entities</PackageId>
<PackageVersion>1.25.0.0</PackageVersion>
<PackageVersion>1.26.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/davewalker5/ADS-B-BaseStationReader</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.25.0.0</ReleaseVersion>
<ReleaseVersion>1.26.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public enum CommandLineOptionType
WriterBatchSize,
RefreshInterval,
MaximumRows,
ReceiverLatitude,
ReceiverLongitude,
SendInterval,
NumberOfAircraft,
Lifespan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class TrackerApplicationSettings
public int WriterInterval { get; set; }
public int WriterBatchSize { get; set; }
public int MaximumRows { get; set; }
public double? ReceiverLatitude { get; set; }
public double? ReceiverLongitude { get; set; }
public List<TrackerColumn> Columns { get; set; } = new List<TrackerColumn>();
}
}
1 change: 1 addition & 0 deletions src/BaseStationReader.Entities/Config/TrackerColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public class TrackerColumn
public string Label { get; set; } = "";
public string Format { get; set; } = "";
public PropertyInfo? Info { get; set; } = null;
public string TypeName { get; set; } = "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;

namespace BaseStationReader.Entities.Exceptions
{

[Serializable]
[ExcludeFromCodeCoverage]
public class DuplicateOptionException : Exception
{
public DuplicateOptionException()
{
}

public DuplicateOptionException(string message) : base(message)
{
}

public DuplicateOptionException(string message, Exception inner) : base(message, inner)
{
}

protected DuplicateOptionException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
}
}
11 changes: 11 additions & 0 deletions src/BaseStationReader.Entities/Interfaces/IDistanceCalculator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace BaseStationReader.Entities.Interfaces
{
public interface IDistanceCalculator
{
double ReferenceLatitude { get; set; }
double ReferenceLongitude { get; set; }
double CalculateDistance(double latitude1, double longitude1, double latitude2, double longitude2);
double CalculateDistance(double latitude, double longitude);
double MetresToNauticalMiles(double metres);
}
}
21 changes: 12 additions & 9 deletions src/BaseStationReader.Entities/Tracking/Aircraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class Aircraft : ICloneable
[Export("Callsign", 2)]
public string? Callsign { get; set; } = null;

[Export("Squawk", 3)]
public string? Squawk { get; set; }

[Export("Altitude", 4)]
public decimal? Altitude { get; set; }

Expand All @@ -32,26 +35,26 @@ public class Aircraft : ICloneable
[Export("Longitude", 8)]
public decimal? Longitude { get; set; }

[Export("Vertical Rate", 9)]
public decimal? VerticalRate { get; set; }
[Export("Distance", 9)]
public double? Distance { get; set; }

[Export("Squawk", 3)]
public string? Squawk { get; set; }
[Export("Vertical Rate", 10)]
public decimal? VerticalRate { get; set; }

[Export("First Seen", 10)]
[Export("First Seen", 11)]
[Required]
public DateTime FirstSeen { get; set; }

[Export("Last Seen", 11)]
[Export("Last Seen", 12)]
[Required]
public DateTime LastSeen { get; set; }

[Export("Messages", 13)]
public int Messages { get; set; }

[Required]
public TrackingStatus Status { get; set; }

[Export("Messages", 12)]
public int Messages { get; set; }

public object Clone()
{
return MemberwiseClone();
Expand Down
Loading

0 comments on commit 287b6fb

Please sign in to comment.