diff --git a/AirScout.AircraftPositions/AirScout.AircraftPositions.csproj b/AirScout.AircraftPositions/AirScout.AircraftPositions.csproj
index 2a6bbfe..e387adb 100644
--- a/AirScout.AircraftPositions/AirScout.AircraftPositions.csproj
+++ b/AirScout.AircraftPositions/AirScout.AircraftPositions.csproj
@@ -69,6 +69,14 @@
+
+ {288a26ec-b690-41a2-84e5-61c9b7b74046}
+ AirScout.Aircrafts
+
+
+ {41b66be4-6086-4ae3-be31-c81ee6b10154}
+ AirScout.Core
+
{ee86e933-d883-4b18-80eb-0fba55ec67c6}
ScoutBase.Core
diff --git a/AirScout.AircraftPositions/AircraftPositionDatabase.cs b/AirScout.AircraftPositions/AircraftPositionDatabase.cs
index 36b3af6..891f028 100644
--- a/AirScout.AircraftPositions/AircraftPositionDatabase.cs
+++ b/AirScout.AircraftPositions/AircraftPositionDatabase.cs
@@ -12,6 +12,8 @@ using System.Data.SQLite;
using System.ComponentModel;
using System.Windows.Forms;
using Newtonsoft.Json;
+using AirScout.Core;
+using AirScout.Aircrafts;
namespace AirScout.AircraftPositions
{
@@ -934,6 +936,98 @@ namespace AirScout.AircraftPositions
#endregion
+ #region PlaneInfo
+
+ public int PlaneInfoBulkInsertOrUpdateIfNewer(List planes)
+ {
+ if (planes == null)
+ return 0;
+ int i = 0;
+ lock (db)
+ {
+ db.BeginTransaction();
+ foreach (PlaneInfo plane in planes)
+ {
+ try
+ {
+ // update aircraft information
+ if (PlaneInfoChecker.Check_Hex(plane.Hex) && PlaneInfoChecker.Check_Call(plane.Call))
+ AircraftPositionData.Database.AircraftPositionInsertOrUpdateIfNewer(new AircraftPositionDesignator(plane.Hex, plane.Call, plane.Lat, plane.Lon, plane.Alt, plane.Track, plane.Speed, plane.Time));
+ }
+ catch (Exception ex)
+ {
+ Log.WriteMessage(ex.ToString());
+ return -1;
+ }
+ }
+ db.Commit();
+ }
+ return i;
+ }
+
+ public int PlaneInfoBulkInsertOrUpdateIfNewer(BackgroundWorker caller, List planes)
+ {
+ if (planes == null)
+ return 0;
+ int i = 0;
+ lock (db)
+ {
+ db.BeginTransaction();
+ foreach (PlaneInfo plane in planes)
+ {
+ try
+ {
+ // update aircraft information
+ if (PlaneInfoChecker.Check_Hex(plane.Hex) && PlaneInfoChecker.Check_Call(plane.Call))
+ AircraftPositionData.Database.AircraftPositionInsertOrUpdateIfNewer(new AircraftPositionDesignator(plane.Hex, plane.Call, plane.Lat, plane.Lon, plane.Alt, plane.Track, plane.Speed, plane.Time));
+ }
+ catch (Exception ex)
+ {
+ db.Rollback();
+ Log.WriteMessage(ex.ToString());
+ return -1;
+ }
+ // abort if called from background worker and cancellation pending
+ if (caller != null)
+ {
+ if (caller.WorkerSupportsCancellation && caller.CancellationPending)
+ {
+ db.Rollback();
+ return -1;
+ }
+ }
+
+ }
+ db.Commit();
+ }
+ return i;
+ }
+
+ public List PlaneInfoGetAll(DateTime newerthan)
+ {
+ List l = new List();
+ int i = SupportFunctions.DateTimeToUNIXTime(newerthan);
+ // SELECT max(AircraftPositions.Lastupdated) AS LastUpdated, Call, Reg, AircraftPositions.Hex, Lat, Lon, Track, Alt, Speed, TypeCode, Manufacturer, Model, Category FROM AircraftPositions INNER JOIN Aircrafts ON AircraftPositions.Hex = Aircrafts.Hex INNER JOIN AircraftTypes ON AircraftTypes.ICAO = Aircrafts.TypeCode WHERE AircraftPositions.LastUpdated > 1500000 GROUP BY AircraftPositions.Hex
+ DataTable Result = db.Select("SELECT max(AircraftPositions.Lastupdated) AS LastUpdated, Call, Reg, AircraftPositions.Hex, Lat, Lon, Track, Alt, Speed, TypeCode, Manufacturer, Model, Category FROM AircraftPositions INNER JOIN Aircrafts ON AircraftPositions.Hex = Aircrafts.Hex INNER JOIN AircraftTypes ON AircraftTypes.ICAO = Aircrafts.TypeCode WHERE AircraftPositions.LastUpdated > " + i.ToString() + " GROUP BY AircraftPositions.Hex");
+ if (!IsValid(Result) || (Result.Rows.Count == 0))
+ return l;
+ foreach (DataRow row in Result.Rows)
+ {
+ PlaneInfo info = new PlaneInfo(row);
+ try
+ {
+ l.Add(info);
+ }
+ catch (Exception ex)
+ {
+ Log.WriteMessage("Error inserting PlaneInfo[" + info.ToString() + "]: " + ex.ToString());
+ }
+ }
+ return l;
+ }
+
+ #endregion
+
}
}
diff --git a/AirScout.Aircrafts/AirScout.Aircrafts.csproj b/AirScout.Aircrafts/AirScout.Aircrafts.csproj
index d1150ee..62cdd3c 100644
--- a/AirScout.Aircrafts/AirScout.Aircrafts.csproj
+++ b/AirScout.Aircrafts/AirScout.Aircrafts.csproj
@@ -56,8 +56,7 @@
-
-
+
@@ -69,6 +68,10 @@
+
+ {41b66be4-6086-4ae3-be31-c81ee6b10154}
+ AirScout.Core
+
{ee86e933-d883-4b18-80eb-0fba55ec67c6}
ScoutBase.Core
diff --git a/AirScout.Aircrafts/AircraftDatabase.cs b/AirScout.Aircrafts/AircraftDatabase.cs
index 023b497..49cdae2 100644
--- a/AirScout.Aircrafts/AircraftDatabase.cs
+++ b/AirScout.Aircrafts/AircraftDatabase.cs
@@ -12,6 +12,7 @@ using System.Data.SQLite;
using Newtonsoft.Json;
using System.Windows.Forms;
using System.ComponentModel;
+using AirScout.Core;
namespace AirScout.Aircrafts
{
@@ -2392,7 +2393,7 @@ namespace AirScout.Aircrafts
try
{
// update aircraft information
- if (PlaneInfo.Check_Hex(plane.Hex) && PlaneInfo.Check_Call(plane.Call) && PlaneInfo.Check_Reg(plane.Reg) && PlaneInfo.Check_Type(plane.Type))
+ if (PlaneInfoChecker.Check_Hex(plane.Hex) && PlaneInfoChecker.Check_Call(plane.Call) && PlaneInfoChecker.Check_Reg(plane.Reg) && PlaneInfoChecker.Check_Type(plane.Type))
AircraftData.Database.AircraftInsertOrUpdateIfNewer(new AircraftDesignator(plane.Hex, plane.Call, plane.Reg, plane.Type, plane.Time));
// update aircraft type information
if (!String.IsNullOrEmpty(plane.Type))
diff --git a/AirScout.Aircrafts/AircraftType.cs b/AirScout.Aircrafts/AircraftType.cs
index 5b9edd2..f86406c 100644
--- a/AirScout.Aircrafts/AircraftType.cs
+++ b/AirScout.Aircrafts/AircraftType.cs
@@ -12,6 +12,7 @@ using System.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data.SQLite;
+using AirScout.Core;
namespace AirScout.Aircrafts
{
diff --git a/AirScout.Aircrafts/PlaneInfoCache.cs b/AirScout.Aircrafts/PlaneInfoCache.cs
index fd5ecde..4247849 100644
--- a/AirScout.Aircrafts/PlaneInfoCache.cs
+++ b/AirScout.Aircrafts/PlaneInfoCache.cs
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AirScout.Core;
namespace AirScout.Aircrafts
{
diff --git a/AirScout.Aircrafts/PlaneInfo.cs b/AirScout.Aircrafts/PlaneInfoChecker.cs
similarity index 50%
rename from AirScout.Aircrafts/PlaneInfo.cs
rename to AirScout.Aircrafts/PlaneInfoChecker.cs
index c0e58a1..df78236 100644
--- a/AirScout.Aircrafts/PlaneInfo.cs
+++ b/AirScout.Aircrafts/PlaneInfoChecker.cs
@@ -1,206 +1,13 @@
using System;
using System.Collections.Generic;
-using System.Collections;
using System.Linq;
using System.Text;
-using System.Threading;
-using System.ComponentModel;
-using System.Globalization;
-using System.Net;
-using System.IO;
-using System.Text.RegularExpressions;
-using System.Data;
-using ScoutBase.Core;
-using System.Reflection;
+using AirScout.Core;
namespace AirScout.Aircrafts
{
-
- // holds the complete aircraft info
- public class PlaneInfo
+ public static class PlaneInfoChecker
{
- public DateTime Time { get; set; }
- public string Call { get; set; }
- public string Reg { get; set; }
- public string Hex { get; set; }
- public double Lat { get; set; }
- public double Lon { get; set; }
- private double _Alt;
- public double Alt
- {
- get
- {
- return _Alt;
- }
- set
- {
- _Alt = value;
- _Alt_m = UnitConverter.ft_m(value);
- }
- }
- private double _Alt_m;
- public double Alt_m
- {
- get
- {
- return _Alt_m;
- }
- }
- public double Track = 0;
- private double _Speed;
- public double Speed
- {
- get
- {
- return _Speed;
- }
- set
- {
- _Speed = value;
- _Speed_kmh = UnitConverter.kts_kmh(value);
- }
- }
- private double _Speed_kmh;
- public double Speed_kmh
- {
- get
- {
- return _Speed_kmh;
- }
- }
- public string Type { get; set; }
- public string Manufacturer { get; set; }
- public string Model { get; set; }
- public PLANECATEGORY Category { get; set; }
-
- public LatLon.GPoint IntPoint = null;
- public double IntQRB = double.MaxValue;
- public double AltDiff = 0;
- public int Potential = 0;
- public double Eps1 = 0;
- public double Eps2 = 0;
- public double Theta1 = 0;
- public double Theta2 = 0;
- public double Angle = 0;
- public double Squint = 0;
- public double SignalStrength = double.MinValue;
- public bool Ambiguous = false;
- public string Comment = "";
-
- public PlaneInfo()
- {
- Time = DateTime.UtcNow;
- Call = "";
- Reg = "";
- Hex = "";
- Lat = 0;
- Lon = 0;
- Alt = 0;
- Track = 0;
- Speed = 0;
- Type = "";
- Manufacturer = "";
- Model = "";
- Category = PLANECATEGORY.NONE;
- }
-
- public PlaneInfo(DateTime time, string call, string reg, string hex, double lat, double lon, double track, double alt, double speed, string type, string manufacturer, string model, PLANECATEGORY category)
- {
- Time = time.ToUniversalTime();
- Call = call;
- Reg = reg;
- Hex = hex;
- Lat = lat;
- Lon = lon;
- Alt = alt;
- Track = track;
- Speed = speed;
- Type = type;
- Manufacturer = manufacturer;
- Model = model;
- Category = category;
- }
-
- // LEGACY!!!
- public PlaneInfo (DataRow row)
- {
- Time = SupportFunctions.UNIXTimeToDateTime(System.Convert.ToInt32(row[0]));
- Call = (string)row[1];
- Reg = (string)row[2];
- Hex = (string)row[3];
- Lat = (double)row[4];
- Lon = (double)row[5];
- Track = System.Convert.ToInt32(row[6]);
- Alt = System.Convert.ToInt32(row[7]);
- Speed = System.Convert.ToInt32(row[8]);
- Type = (string)row[9];
- Manufacturer = (string)row[10];
- Model = (string)row[11];
- Category = (PLANECATEGORY)row[12];
- }
-
- public PlaneInfo (PlaneInfo plane)
- {
- this.Ambiguous = plane.Ambiguous;
- this.Alt = plane.Alt;
- this.AltDiff = plane.AltDiff;
- this.Angle = plane.Angle;
- this.Call = plane.Call;
- this.Category = plane.Category;
- this.Comment = plane.Comment;
- this.Eps1 = plane.Eps1;
- this.Eps2 = plane.Eps2;
- this.Theta1 = plane.Theta1;
- this.Theta2 = plane.Theta2;
- this.Hex = plane.Hex;
- this.IntPoint = plane.IntPoint;
- this.IntQRB = plane.IntQRB;
- this.Lat = plane.Lat;
- this.Lon = plane.Lon;
- this.Manufacturer = plane.Manufacturer;
- this.Model = plane.Model;
- this.Potential = plane.Potential;
- this.Reg = plane.Reg;
- this.SignalStrength = plane.SignalStrength;
- this.Speed = plane.Speed;
- this.Squint = plane.Squint;
- this.Time = plane.Time;
- this.Track = plane.Track;
- this.Type = plane.Type;
-
- }
-
- public override string ToString()
- {
- string s = "";
- PropertyInfo[] properties = this.GetType().GetProperties();
- foreach (PropertyInfo p in properties)
- {
- if (p.PropertyType.Name.ToUpper() == "STRING")
- {
- string v = (string)p.GetValue(this, null);
- if (v == null)
- v = "[null]";
- else if (v.Length == 0)
- v = "[empty]";
- s = s + p.Name + ": " + v + "\n";
- }
- else if (p.PropertyType.Name.ToUpper() == "DATETIME")
- {
- DateTime dt = (DateTime)p.GetValue(this, null);
- s = s + p.Name + ": " + dt.ToString("yyyy-MM-dd HH:mm:ss") + "\n";
- }
- else
- {
- object o = p.GetValue(this, null);
- if (o == null)
- s = s + p.Name + ": " + "[null]" + "\n";
- else
- s = s + p.Name + ": " + o.ToString() + "\n";
- }
- }
- return s;
- }
public static bool Check_Hex(string hex)
{
@@ -246,7 +53,7 @@ namespace AirScout.Aircrafts
// Type B callsign?
if (char.IsNumber(call[2]))
{
- airline = call.Substring(0,2);
+ airline = call.Substring(0, 2);
if (AircraftData.Database.AirlineFindByIATA(airline) == null)
return false;
}
@@ -394,5 +201,4 @@ namespace AirScout.Aircrafts
}
}
-
-}
\ No newline at end of file
+}
diff --git a/AirScout.Core/AirScout.Core.csproj b/AirScout.Core/AirScout.Core.csproj
index f153113..17a7fe0 100644
--- a/AirScout.Core/AirScout.Core.csproj
+++ b/AirScout.Core/AirScout.Core.csproj
@@ -47,6 +47,8 @@
+
+
True
diff --git a/AirScout.Aircrafts/PlaneCategory.cs b/AirScout.Core/PlaneCategory.cs
similarity index 99%
rename from AirScout.Aircrafts/PlaneCategory.cs
rename to AirScout.Core/PlaneCategory.cs
index d59e725..d5a4f25 100644
--- a/AirScout.Aircrafts/PlaneCategory.cs
+++ b/AirScout.Core/PlaneCategory.cs
@@ -5,7 +5,7 @@ using System.Text;
using ScoutBase.Core;
using System.Reflection;
-namespace AirScout.Aircrafts
+namespace AirScout.Core
{
public enum PLANECATEGORY
{
diff --git a/AirScout.Core/PlaneInfo.cs b/AirScout.Core/PlaneInfo.cs
new file mode 100644
index 0000000..e8db6f6
--- /dev/null
+++ b/AirScout.Core/PlaneInfo.cs
@@ -0,0 +1,207 @@
+using System;
+using System.Collections.Generic;
+using System.Collections;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.ComponentModel;
+using System.Globalization;
+using System.Net;
+using System.IO;
+using System.Text.RegularExpressions;
+using System.Data;
+using ScoutBase.Core;
+using System.Reflection;
+
+namespace AirScout.Core
+{
+
+ // holds the complete aircraft info
+ public class PlaneInfo
+ {
+ public DateTime Time { get; set; }
+ public string Call { get; set; }
+ public string Reg { get; set; }
+ public string Hex { get; set; }
+ public double Lat { get; set; }
+ public double Lon { get; set; }
+ private double _Alt;
+ public double Alt
+ {
+ get
+ {
+ return _Alt;
+ }
+ set
+ {
+ _Alt = value;
+ _Alt_m = UnitConverter.ft_m(value);
+ }
+ }
+ private double _Alt_m;
+ public double Alt_m
+ {
+ get
+ {
+ return _Alt_m;
+ }
+ }
+ public double Track = 0;
+ private double _Speed;
+ public double Speed
+ {
+ get
+ {
+ return _Speed;
+ }
+ set
+ {
+ _Speed = value;
+ _Speed_kmh = UnitConverter.kts_kmh(value);
+ }
+ }
+ private double _Speed_kmh;
+ public double Speed_kmh
+ {
+ get
+ {
+ return _Speed_kmh;
+ }
+ }
+ public string Type { get; set; }
+ public string Manufacturer { get; set; }
+ public string Model { get; set; }
+ public PLANECATEGORY Category { get; set; }
+
+ public LatLon.GPoint IntPoint = null;
+ public double IntQRB = double.MaxValue;
+ public double AltDiff = 0;
+ public int Potential = 0;
+ public double Eps1 = 0;
+ public double Eps2 = 0;
+ public double Theta1 = 0;
+ public double Theta2 = 0;
+ public double Angle = 0;
+ public double Squint = 0;
+ public double SignalStrength = double.MinValue;
+ public bool Ambiguous = false;
+ public string Comment = "";
+
+ public PlaneInfo()
+ {
+ Time = DateTime.UtcNow;
+ Call = "";
+ Reg = "";
+ Hex = "";
+ Lat = 0;
+ Lon = 0;
+ Alt = 0;
+ Track = 0;
+ Speed = 0;
+ Type = "";
+ Manufacturer = "";
+ Model = "";
+ Category = PLANECATEGORY.NONE;
+ }
+
+ public PlaneInfo(DateTime time, string call, string reg, string hex, double lat, double lon, double track, double alt, double speed, string type, string manufacturer, string model, PLANECATEGORY category)
+ {
+ Time = time.ToUniversalTime();
+ Call = call;
+ Reg = reg;
+ Hex = hex;
+ Lat = lat;
+ Lon = lon;
+ Alt = alt;
+ Track = track;
+ Speed = speed;
+ Type = type;
+ Manufacturer = manufacturer;
+ Model = model;
+ Category = category;
+ }
+
+ // LEGACY!!!
+ public PlaneInfo (DataRow row)
+ {
+ Time = SupportFunctions.UNIXTimeToDateTime(System.Convert.ToInt32(row[0]));
+ Call = (string)row[1];
+ Reg = (string)row[2];
+ Hex = (string)row[3];
+ Lat = (double)row[4];
+ Lon = (double)row[5];
+ Track = System.Convert.ToInt32(row[6]);
+ Alt = System.Convert.ToInt32(row[7]);
+ Speed = System.Convert.ToInt32(row[8]);
+ Type = (string)row[9];
+ Manufacturer = (string)row[10];
+ Model = (string)row[11];
+ Category = (PLANECATEGORY)row[12];
+ }
+
+ public PlaneInfo (PlaneInfo plane)
+ {
+ this.Ambiguous = plane.Ambiguous;
+ this.Alt = plane.Alt;
+ this.AltDiff = plane.AltDiff;
+ this.Angle = plane.Angle;
+ this.Call = plane.Call;
+ this.Category = plane.Category;
+ this.Comment = plane.Comment;
+ this.Eps1 = plane.Eps1;
+ this.Eps2 = plane.Eps2;
+ this.Theta1 = plane.Theta1;
+ this.Theta2 = plane.Theta2;
+ this.Hex = plane.Hex;
+ this.IntPoint = plane.IntPoint;
+ this.IntQRB = plane.IntQRB;
+ this.Lat = plane.Lat;
+ this.Lon = plane.Lon;
+ this.Manufacturer = plane.Manufacturer;
+ this.Model = plane.Model;
+ this.Potential = plane.Potential;
+ this.Reg = plane.Reg;
+ this.SignalStrength = plane.SignalStrength;
+ this.Speed = plane.Speed;
+ this.Squint = plane.Squint;
+ this.Time = plane.Time;
+ this.Track = plane.Track;
+ this.Type = plane.Type;
+
+ }
+
+ public override string ToString()
+ {
+ string s = "";
+ PropertyInfo[] properties = this.GetType().GetProperties();
+ foreach (PropertyInfo p in properties)
+ {
+ if (p.PropertyType.Name.ToUpper() == "STRING")
+ {
+ string v = (string)p.GetValue(this, null);
+ if (v == null)
+ v = "[null]";
+ else if (v.Length == 0)
+ v = "[empty]";
+ s = s + p.Name + ": " + v + "\n";
+ }
+ else if (p.PropertyType.Name.ToUpper() == "DATETIME")
+ {
+ DateTime dt = (DateTime)p.GetValue(this, null);
+ s = s + p.Name + ": " + dt.ToString("yyyy-MM-dd HH:mm:ss") + "\n";
+ }
+ else
+ {
+ object o = p.GetValue(this, null);
+ if (o == null)
+ s = s + p.Name + ": " + "[null]" + "\n";
+ else
+ s = s + p.Name + ": " + o.ToString() + "\n";
+ }
+ }
+ return s;
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/AirScout.PlaneFeeds/ADSB.cs b/AirScout.PlaneFeeds/ADSB.cs
index 87f1b49..792c596 100644
--- a/AirScout.PlaneFeeds/ADSB.cs
+++ b/AirScout.PlaneFeeds/ADSB.cs
@@ -10,6 +10,7 @@ using System.Globalization;
using System.Net;
using System.Net.Sockets;
using System.IO;
+using AirScout.Core;
using AirScout.Aircrafts;
using AirScout.PlaneFeeds.Generic;
using LibADSB;
@@ -340,6 +341,9 @@ namespace AirScout.PlaneFeeds
MinAlt = args.MinAlt;
MaxAlt = args.MaxAlt;
+ // keep history settings from arguments
+ KeepHistory = args.KeepHistory;
+
// check boundaries
if ((MaxLat <= MinLat) || (MaxLon <= MinLon))
{
diff --git a/AirScout.PlaneFeeds/AirScout.PlaneFeeds.csproj b/AirScout.PlaneFeeds/AirScout.PlaneFeeds.csproj
index 57edf91..13a9714 100644
--- a/AirScout.PlaneFeeds/AirScout.PlaneFeeds.csproj
+++ b/AirScout.PlaneFeeds/AirScout.PlaneFeeds.csproj
@@ -107,6 +107,10 @@
{288a26ec-b690-41a2-84e5-61c9b7b74046}
AirScout.Aircrafts
+
+ {41b66be4-6086-4ae3-be31-c81ee6b10154}
+ AirScout.Core
+
{EE86E933-D883-4B18-80EB-0FBA55EC67C6}
ScoutBase.Core
diff --git a/AirScout.PlaneFeeds/AirScout.cs b/AirScout.PlaneFeeds/AirScout.cs
index b2709ef..fb11cfa 100644
--- a/AirScout.PlaneFeeds/AirScout.cs
+++ b/AirScout.PlaneFeeds/AirScout.cs
@@ -9,6 +9,7 @@ using System.Windows;
using System.Globalization;
using System.Net;
using System.IO;
+using AirScout.Core;
using AirScout.Aircrafts;
using AirScout.PlaneFeeds.Generic;
using ScoutBase.Core;
diff --git a/AirScout.PlaneFeeds/AutoJSON.cs b/AirScout.PlaneFeeds/AutoJSON.cs
index 170be95..074b256 100644
--- a/AirScout.PlaneFeeds/AutoJSON.cs
+++ b/AirScout.PlaneFeeds/AutoJSON.cs
@@ -11,6 +11,7 @@ using System.Net;
using System.IO;
using System.Windows.Forms;
using System.Xml.Serialization;
+using AirScout.Core;
using AirScout.Aircrafts;
using AirScout.PlaneFeeds.Generic;
using Newtonsoft.Json;
diff --git a/AirScout.PlaneFeeds/FileJSON.cs b/AirScout.PlaneFeeds/FileJSON.cs
index ea85f54..e6822ff 100644
--- a/AirScout.PlaneFeeds/FileJSON.cs
+++ b/AirScout.PlaneFeeds/FileJSON.cs
@@ -9,6 +9,7 @@ using System.Windows;
using System.Globalization;
using System.Net;
using System.IO;
+using AirScout.Core;
using AirScout.Aircrafts;
using AirScout.PlaneFeeds.Generic;
using ScoutBase.Core;
diff --git a/AirScout.PlaneFeeds/Flightradar24.cs b/AirScout.PlaneFeeds/Flightradar24.cs
index 04201b6..1c9e450 100644
--- a/AirScout.PlaneFeeds/Flightradar24.cs
+++ b/AirScout.PlaneFeeds/Flightradar24.cs
@@ -12,6 +12,7 @@ using System.Net;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;
+using AirScout.Core;
using AirScout.Aircrafts;
using AirScout.PlaneFeeds.Generic;
using Newtonsoft.Json;
diff --git a/AirScout.PlaneFeeds/Generic.cs b/AirScout.PlaneFeeds/Generic.cs
index f51b458..a3d2264 100644
--- a/AirScout.PlaneFeeds/Generic.cs
+++ b/AirScout.PlaneFeeds/Generic.cs
@@ -11,6 +11,7 @@ using System.Globalization;
using System.Net;
using System.IO;
using System.Xml.Serialization;
+using AirScout.Core;
using AirScout.Aircrafts;
using ScoutBase.Core;
@@ -206,6 +207,10 @@ namespace AirScout.PlaneFeeds.Generic
MinAlt = args.MinAlt;
MaxAlt = args.MaxAlt;
+ // keep history settings from arguments
+ KeepHistory = args.KeepHistory;
+
+
Status = STATUS.OK;
// narrow args according to QSO partners
@@ -270,7 +275,8 @@ namespace AirScout.PlaneFeeds.Generic
planes.Add(info);
}
ReportProgress((int)PROGRESS.PLANES, planes);
- AircraftData.Database.PlaneInfoBulkInsertOrUpdateIfNewer(planes);
+ // do not update anything in database
+// AircraftData.Database.PlaneInfoBulkInsertOrUpdateIfNewer(planes);
string msg = "[" + start.ToString("HH:mm:ss") + "] " +
count.ToString() + " Positions randomized.";
this.ReportProgress((int)PROGRESS.STATUS, msg);
diff --git a/AirScout.PlaneFeeds/Planefinder.cs b/AirScout.PlaneFeeds/Planefinder.cs
index c20da86..2f2edf0 100644
--- a/AirScout.PlaneFeeds/Planefinder.cs
+++ b/AirScout.PlaneFeeds/Planefinder.cs
@@ -9,6 +9,7 @@ using System.Windows;
using System.Globalization;
using System.Net;
using System.IO;
+using AirScout.Core;
using AirScout.Aircrafts;
using AirScout.PlaneFeeds.Generic;
using Newtonsoft.Json;
diff --git a/AirScout.PlaneFeeds/RTL1090.cs b/AirScout.PlaneFeeds/RTL1090.cs
index b3346be..450c272 100644
--- a/AirScout.PlaneFeeds/RTL1090.cs
+++ b/AirScout.PlaneFeeds/RTL1090.cs
@@ -10,6 +10,7 @@ using System.Globalization;
using System.Net;
using System.Net.Sockets;
using System.IO;
+using AirScout.Core;
using AirScout.Aircrafts;
using AirScout.PlaneFeeds.Generic;
using LibADSB;
diff --git a/AirScout.PlaneFeeds/VirtualRadarServer.cs b/AirScout.PlaneFeeds/VirtualRadarServer.cs
index 036e176..ea8b758 100644
--- a/AirScout.PlaneFeeds/VirtualRadarServer.cs
+++ b/AirScout.PlaneFeeds/VirtualRadarServer.cs
@@ -9,7 +9,9 @@ using System.Windows;
using System.Globalization;
using System.Net;
using System.IO;
+using AirScout.Core;
using AirScout.Aircrafts;
+using AirScout.AircraftPositions;
using AirScout.PlaneFeeds.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -224,7 +226,6 @@ namespace AirScout.PlaneFeeds
LogDirectory = args.LogDirectory;
TmpDirectory = args.TmpDirectory;
DatabaseDirectory = args.DatabaseDirectory;
- KeepHistory = args.KeepHistory;
// set boundaries from arguments
MaxLat = args.MaxLat;
@@ -238,6 +239,9 @@ namespace AirScout.PlaneFeeds
MinAlt = args.MinAlt;
MaxAlt = args.MaxAlt;
+ // keep history settings from arguments
+ KeepHistory = args.KeepHistory;
+
// intialize variables
VC.AddVar("APPDIR", AppDirectory);
VC.AddVar("DATADIR", AppDataDirectory);
@@ -369,7 +373,7 @@ namespace AirScout.PlaneFeeds
// get hex first
plane.Hex = ReadPropertyString(o, "Icao");
// do basic check on hex --> is strictly needed as identifier
- if (!PlaneInfo.Check_Hex(plane.Hex))
+ if (!PlaneInfoChecker.Check_Hex(plane.Hex))
{
if (Properties.Settings.Default.VR_LogErrors)
Log.WriteMessage("Incorrect aircraft data received [Hex]: " + plane.Hex);
@@ -378,7 +382,7 @@ namespace AirScout.PlaneFeeds
}
// get position and do basic check on lat/lon
plane.Lat = ReadPropertyDouble(o, "Lat");
- if (!PlaneInfo.Check_Lat(plane.Lat))
+ if (!PlaneInfoChecker.Check_Lat(plane.Lat))
{
if (Properties.Settings.Default.VR_LogErrors)
Log.WriteMessage("Incorrect aircraft data received [Lat]: " + plane.Lat.ToString("F8", CultureInfo.InvariantCulture));
@@ -386,7 +390,7 @@ namespace AirScout.PlaneFeeds
continue;
}
plane.Lon = ReadPropertyDouble(o, "Long");
- if (!PlaneInfo.Check_Lon(plane.Lon))
+ if (!PlaneInfoChecker.Check_Lon(plane.Lon))
{
if (Properties.Settings.Default.VR_LogErrors)
Log.WriteMessage("Incorrect aircraft data received [Lon]: " + plane.Lon.ToString("F8", CultureInfo.InvariantCulture));
@@ -397,7 +401,7 @@ namespace AirScout.PlaneFeeds
// 2017-07-23: take "GAlt" (corrected altitude by air pressure) rather than "Alt"
plane.Alt = ReadPropertyDoubleToInt(o, "GAlt");
// do basic chekc on altitude
- if (!PlaneInfo.Check_Alt(plane.Alt))
+ if (!PlaneInfoChecker.Check_Alt(plane.Alt))
{
// try to recover altitude from previuos messages
PlaneInfo info = null;
@@ -421,7 +425,7 @@ namespace AirScout.PlaneFeeds
// get callsign
plane.Call = ReadPropertyString(o, "Call");
// do basic check --> try to recover from cache if check fails or set it to [unknown]
- if (!PlaneInfo.Check_Call(plane.Call))
+ if (!PlaneInfoChecker.Check_Call(plane.Call))
{
PlaneInfo info = null;
if (PlanePositions.TryGetValue(plane.Hex, out info))
@@ -432,7 +436,7 @@ namespace AirScout.PlaneFeeds
plane.Call = "[unknown]";
}
// still unknown --> try to recover last known call from database
- if (!PlaneInfo.Check_Call(plane.Call))
+ if (!PlaneInfoChecker.Check_Call(plane.Call))
{
AircraftDesignator ad = AircraftData.Database.AircraftFindByHex(plane.Hex);
if (ad != null)
@@ -445,7 +449,7 @@ namespace AirScout.PlaneFeeds
// get registration
plane.Reg = ReadPropertyString(o, "Reg");
// do basic check --> try to recover from cache if check fails or set it to [unknown]
- if (!PlaneInfo.Check_Reg(plane.Reg))
+ if (!PlaneInfoChecker.Check_Reg(plane.Reg))
{
PlaneInfo info = null;
if (PlanePositions.TryGetValue(plane.Hex, out info))
@@ -456,7 +460,7 @@ namespace AirScout.PlaneFeeds
plane.Reg = "[unknown]";
}
// still unknown --> try to recover last known reg from database
- if (!PlaneInfo.Check_Reg(plane.Reg))
+ if (!PlaneInfoChecker.Check_Reg(plane.Reg))
{
AircraftDesignator ad = AircraftData.Database.AircraftFindByHex(plane.Hex);
if (ad != null)
@@ -469,7 +473,7 @@ namespace AirScout.PlaneFeeds
// get track
plane.Track = ReadPropertyDoubleToInt(o, "Trak");
// do basic check
- if (!PlaneInfo.Check_Track(plane.Track))
+ if (!PlaneInfoChecker.Check_Track(plane.Track))
{
if (Properties.Settings.Default.VR_LogErrors)
Log.WriteMessage("Incorrect aircraft data received [Track]: " + plane.Track.ToString("F8", CultureInfo.InvariantCulture));
@@ -479,7 +483,7 @@ namespace AirScout.PlaneFeeds
// get speed
plane.Speed = ReadPropertyDoubleToInt(o, "Spd");
// do basic check
- if (!PlaneInfo.Check_Speed(plane.Speed))
+ if (!PlaneInfoChecker.Check_Speed(plane.Speed))
{
// try to recover speed from previous messages
PlaneInfo info = null;
@@ -516,7 +520,7 @@ namespace AirScout.PlaneFeeds
}
// get type info
plane.Type = ReadPropertyString(o, "Type");
- if (!PlaneInfo.Check_Type(plane.Type))
+ if (!PlaneInfoChecker.Check_Type(plane.Type))
{
AircraftDesignator ad = AircraftData.Database.AircraftFindByHex(plane.Hex);
if (ad != null)
@@ -539,7 +543,7 @@ namespace AirScout.PlaneFeeds
if (plane.Type == "A388")
plane.Category = PLANECATEGORY.SUPERHEAVY;
// try to recover type info from database if check fails
- if (!PlaneInfo.Check_Manufacturer(plane.Manufacturer) || !PlaneInfo.Check_Model(plane.Model))
+ if (!PlaneInfoChecker.Check_Manufacturer(plane.Manufacturer) || !PlaneInfoChecker.Check_Model(plane.Model))
{
AircraftTypeDesignator td = AircraftData.Database.AircraftTypeFindByICAO(plane.Type);
if (td != null)
@@ -592,6 +596,9 @@ namespace AirScout.PlaneFeeds
this.ReportProgress((int)PROGRESS.PLANES, planes);
// update global database
AircraftData.Database.PlaneInfoBulkInsertOrUpdateIfNewer(this, planes);
+ // update position database if enabled
+ if (KeepHistory)
+ AircraftPositionData.Database.PlaneInfoBulkInsertOrUpdateIfNewer(planes);
st.Stop();
string msg = "[" + DateTime.UtcNow.ToString("HH:mm:ss") + "] " +
total.ToString() + " Positions updated from " + url + ", " +
diff --git a/AirScout.PlaneFeeds/WebFeed.cs b/AirScout.PlaneFeeds/WebFeed.cs
index 449a095..cb04cd4 100644
--- a/AirScout.PlaneFeeds/WebFeed.cs
+++ b/AirScout.PlaneFeeds/WebFeed.cs
@@ -12,6 +12,7 @@ using System.IO;
using System.Data;
using System.Windows.Forms;
using System.Xml.Serialization;
+using AirScout.Core;
using AirScout.Aircrafts;
using AirScout.PlaneFeeds.Generic;
using Newtonsoft.Json;
diff --git a/AirScout/MapDlg.cs b/AirScout/MapDlg.cs
index cab2acf..fe1c538 100644
--- a/AirScout/MapDlg.cs
+++ b/AirScout/MapDlg.cs
@@ -6301,7 +6301,7 @@ namespace AirScout
{
info.Time = DateTime.MinValue;
}
- if (PlaneInfo.Check(info) &&
+ if (PlaneInfoChecker.Check(info) &&
(info.Alt_m >= Properties.Settings.Default.Planes_MinAlt) &&
(info.Alt_m <= Properties.Settings.Default.Planes_MaxAlt) &&
(info.Lat >= Properties.Settings.Default.MinLat) &&
diff --git a/AirScout/Properties/Settings.Designer.cs b/AirScout/Properties/Settings.Designer.cs
index 145be61..feeab00 100644
--- a/AirScout/Properties/Settings.Designer.cs
+++ b/AirScout/Properties/Settings.Designer.cs
@@ -155,30 +155,6 @@ namespace AirScout.Properties {
}
}
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("\\Database\\calls.txt")]
- public string Calls_FileName {
- get {
- return ((string)(this["Calls_FileName"]));
- }
- set {
- this["Calls_FileName"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("\\Database\\call3.txt")]
- public string WSJTCalls_FileName {
- get {
- return ((string)(this["WSJTCalls_FileName"]));
- }
- set {
- this["WSJTCalls_FileName"] = value;
- }
- }
-
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("1000")]
@@ -206,9 +182,9 @@ namespace AirScout.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("NONE")]
- public global::AirScout.Aircrafts.PLANECATEGORY Planes_Filter_Min_Category {
+ public global::AirScout.Core.PLANECATEGORY Planes_Filter_Min_Category {
get {
- return ((global::AirScout.Aircrafts.PLANECATEGORY)(this["Planes_Filter_Min_Category"]));
+ return ((global::AirScout.Core.PLANECATEGORY)(this["Planes_Filter_Min_Category"]));
}
set {
this["Planes_Filter_Min_Category"] = value;
@@ -443,18 +419,6 @@ namespace AirScout.Properties {
}
}
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("Database\\localobstructions.txt")]
- public string LocalObstruction_FileName {
- get {
- return ((string)(this["LocalObstruction_FileName"]));
- }
- set {
- this["LocalObstruction_FileName"] = value;
- }
- }
-
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
@@ -1391,30 +1355,6 @@ namespace AirScout.Properties {
}
}
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("\\Database\\Airlines.txt")]
- public string Database_Airlines_FileName {
- get {
- return ((string)(this["Database_Airlines_FileName"]));
- }
- set {
- this["Database_Airlines_FileName"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("http://www.flugzeuginfo.net/table_airlinecodes_airline_en.php")]
- public string Database_Airlines_URL {
- get {
- return ((string)(this["Database_Airlines_URL"]));
- }
- set {
- this["Database_Airlines_URL"] = value;
- }
- }
-
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("1")]
@@ -1547,18 +1487,6 @@ namespace AirScout.Properties {
}
}
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("\\Database")]
- public string Database_Directory {
- get {
- return ((string)(this["Database_Directory"]));
- }
- set {
- this["Database_Directory"] = value;
- }
- }
-
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("10")]
@@ -1595,18 +1523,6 @@ namespace AirScout.Properties {
}
}
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("\\ElevationData")]
- public string Elevation_Directory {
- get {
- return ((string)(this["Elevation_Directory"]));
- }
- set {
- this["Elevation_Directory"] = value;
- }
- }
-
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::AirScout.Watchlist Watchlist {
@@ -1948,7 +1864,6 @@ Digital data base on the World Wide Web (URL: http://www.ngdc.noaa.gov/mgg/topo/
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("DL2ALF")]
public global::System.Collections.Generic.List MyCalls {
get {
return ((global::System.Collections.Generic.List)(this["MyCalls"]));
@@ -2113,5 +2028,29 @@ Digital data base on the World Wide Web (URL: http://www.ngdc.noaa.gov/mgg/topo/
this["Planes_KeepHistory"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("\\Database")]
+ public string Database_Directory {
+ get {
+ return ((string)(this["Database_Directory"]));
+ }
+ set {
+ this["Database_Directory"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("\\ElevationData")]
+ public string Elevation_Directory {
+ get {
+ return ((string)(this["Elevation_Directory"]));
+ }
+ set {
+ this["Elevation_Directory"] = value;
+ }
+ }
}
}
diff --git a/AirScout/Properties/Settings.settings b/AirScout/Properties/Settings.settings
index bfa1c00..b60c3ba 100644
--- a/AirScout/Properties/Settings.settings
+++ b/AirScout/Properties/Settings.settings
@@ -35,12 +35,6 @@
30
-
- \Database\calls.txt
-
-
- \Database\call3.txt
-
1000
@@ -107,9 +101,6 @@
False
-
- Database\localobstructions.txt
-
True
@@ -344,12 +335,6 @@
True
-
- \Database\Airlines.txt
-
-
- http://www.flugzeuginfo.net/table_airlinecodes_airline_en.php
-
1
@@ -383,9 +368,6 @@
\Log
-
- \Database
-
10
@@ -395,9 +377,6 @@
False
-
- \ElevationData
-
@@ -515,7 +494,7 @@ MEaSUREs data and products are available at no charge from the LP DAAC.See https
- DL2ALF
+
False
@@ -556,5 +535,11 @@ MEaSUREs data and products are available at no charge from the LP DAAC.See https
False
+
+ \Database
+
+
+ \ElevationData
+
\ No newline at end of file
diff --git a/AirScout/app.config b/AirScout/app.config
index ba8724c..ef460f0 100644
--- a/AirScout/app.config
+++ b/AirScout/app.config
@@ -42,12 +42,6 @@
30
-
- \Database\calls.txt
-
-
- \Database\call3.txt
-
1000
@@ -114,9 +108,6 @@
False
-
- Database\localobstructions.txt
-
True
@@ -351,12 +342,6 @@
True
-
- \Database\Airlines.txt
-
-
- http://www.flugzeuginfo.net/table_airlinecodes_airline_en.php
-
1
@@ -390,9 +375,6 @@
\Log
-
- \Database
-
10
@@ -402,9 +384,6 @@
False
-
- \ElevationData
-
http://www.airscout.eu
@@ -554,6 +533,12 @@ MEaSUREs data and products are available at no charge from the LP DAAC.See https
False
+
+ \Database
+
+
+ \ElevationData
+