From 119eebd00cd814b0d2ace874deff0854f2a557ab Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 30 Dec 2022 11:41:32 +0100 Subject: [PATCH] Zonen werden erfolgreich erkannt --- AIS/bsmd.AIS2Service/AISZoneMonitor.cs | 31 +++++++++++++++++++++++++- AIS/bsmd.AIS2Service/AIS_Target.cs | 9 ++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/AIS/bsmd.AIS2Service/AISZoneMonitor.cs b/AIS/bsmd.AIS2Service/AISZoneMonitor.cs index 376a3603..f94fece5 100644 --- a/AIS/bsmd.AIS2Service/AISZoneMonitor.cs +++ b/AIS/bsmd.AIS2Service/AISZoneMonitor.cs @@ -4,10 +4,12 @@ // to monitor zones // +using log4net; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Security.Policy; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -23,6 +25,7 @@ namespace bsmd.AIS2Service AIS_SQLiteStorage _storage; private Thread _thread; private bool _stopFlag = false; + private static readonly ILog _log = LogManager.GetLogger(typeof(AISZoneMonitor)); #endregion @@ -41,12 +44,38 @@ namespace bsmd.AIS2Service private void Monitor() { // load zones from storage + List allZones = _storage.LoadMonitorZones(); + Dictionary> testZones = new Dictionary>(); + foreach(MonitorZone zone in allZones) + { + // load up Zone list for all assignment mmsi's (to check) + foreach(MonitorAssignment ma in zone.Assignments) + { + if(!testZones.ContainsKey(ma.MMSI)) testZones[ma.MMSI] = new List(); + testZones[ma.MMSI].Add(zone); + } + } + // loop - while(!_stopFlag) { // check all "current" AIS Targets against the zones + + foreach(int mmsi in _sitRepDict.Keys) + { + if(testZones.ContainsKey(mmsi)) + { + AIS_Target target = _sitRepDict[mmsi]; + foreach(MonitorZone zone in testZones[mmsi]) { + if(zone.IsPointInPolygon4(target.Position)) + { + _log.InfoFormat("{0} is in zone {1}", target.ToString(), zone.Name); + } + } + } + } + int currentSaturationSecs = 0; // (DateTime.Now - alarm.FirstDetected).TotalSeconds; if(currentSaturationSecs > Properties.Settings.Default.MonitorTargetSaturationSecs) { diff --git a/AIS/bsmd.AIS2Service/AIS_Target.cs b/AIS/bsmd.AIS2Service/AIS_Target.cs index 71b71626..27800302 100644 --- a/AIS/bsmd.AIS2Service/AIS_Target.cs +++ b/AIS/bsmd.AIS2Service/AIS_Target.cs @@ -207,6 +207,15 @@ namespace bsmd.AIS2Service public int UpdateCount { get; private set; } + public GeoPoint Position + { + get { GeoPoint gp = new GeoPoint(-1); + gp.Lat = this.Latitude ?? 0; + gp.Lon = this.Longitude ?? 0; + return gp; + } + } + #endregion #region internal update methods