Zonen werden erfolgreich erkannt
This commit is contained in:
parent
4c6dd5f287
commit
1100c4d7b6
@ -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<MonitorZone> allZones = _storage.LoadMonitorZones();
|
||||
Dictionary<int, List<MonitorZone>> testZones = new Dictionary<int, List<MonitorZone>>();
|
||||
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<MonitorZone>();
|
||||
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)
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user