/// <summary> /// returned an area that coordinate is inside it. /// </summary> /// <param name="coordinate"></param> /// <returns>If coordinate is not inside any area, it returns null.</returns> public static AVL.Area.JArea CheckGeofence(AVL.Coordinate.JCoordinate coordinate) { System.Data.DataTable AreaTable = AVL.Area.JAreas.GetAreas(false); AVL.Area.JArea area; AVL.Geofence.GeoData.JGeofenceData geof; List <AVL.Controls.Map.Point> points; AVL.Controls.Map.Point currentPoint = new AVL.Controls.Map.Point() { Latitude = coordinate.lat, Longitude = coordinate.lng }; foreach (System.Data.DataRow dr in AreaTable.Rows) { area = new AVL.Area.JArea() { ObjectsCodes = dr["ObjectsCodes"].ToString(), IsGeofence = bool.Parse(dr["IsGeofence"].ToString()), Points = dr["Points"].ToString() }; points = AVL.Area.JArea.ExtractPoints(area.Points); if (!AVL.Geofence.JGeofence.IsInThePolygon(currentPoint, points) || !AVL.Geofence.JGeofence.IsInTheLine(currentPoint, points)) { geof = new AVL.Geofence.GeoData.JGeofenceData() { entered = false, GeoCode = area.code, IsGeofence = area.IsGeofence, LastDate = coordinate.DeviceSendDateTime, ObjectCode = coordinate.ObjectCode }; geof.Insert(false, false); return(area); } } return(null); }
/// <summary> ///اگر ///true ///شی سرعت غیر مجاز دارد و از سرعت یتعیین شده برای دستگاه بیشتر است. /// </summary> /// <param name="ol"></param> /// <param name="device"></param> /// <param name="coordinate"></param> /// <returns></returns> public static bool CheckSpeedFault(AVL.ObjectList.JObjectList ol, AVL.RegisterDevice.JRegisterDevice device, AVL.Coordinate.JCoordinate coordinate) { if (device.speed != 0 && coordinate.Speed > device.speed) { AVL.SpeedFault.JSpeedFaultData speed = new AVL.SpeedFault.JSpeedFaultData(); speed.Datetime = coordinate.DeviceSendDateTime; speed.LimitedSpeed = device.speed; speed.speed = coordinate.Speed; speed.Insert(false, false); return(true); } return(false); }