Example #1
0
        private bool IsInvalidMessage(string code, IGeoPoint message)
        {
            var discardReason = DiscardReason.None;

            if (Coche == null && !MessageIdentifierX.IsEntityMessage(code))
            {
                discardReason = DiscardReason.NoAssignedMobile;
            }
            else if (message.GeoPoint != null && FechaInvalida(message.GeoPoint.Date, DeviceParameters))
            {
                discardReason = DiscardReason.InvalidDate;
            }
            else if (message.GeoPoint != null && FueraDelGlobo(message.GeoPoint))
            {
                discardReason = DiscardReason.OutOfGlobe;
            }
            else if (IsVelocidadInvalida(message))
            {
                discardReason = DiscardReason.InvalidSpeed;
            }

            if (discardReason.Equals(DiscardReason.None))
            {
                return(false);
            }

            DiscardEvent(code, message, discardReason);

            return(true);
        }
Example #2
0
        public void TestGetLeftBottomOffsetPoint()
        {
            IGeoPoint <double> point    = _center.GetLeftBottomOffsetPoint(_pointList, 0, 0);
            IGeoPoint <double> expected = new GeoPoint(0.95, 0.95);

            AssertSamePoints(point, expected);
        }
Example #3
0
        private string ProcessVelocidadExcedidaGenericEvent(IGeoPoint generico)
        {
            var text   = ExtraText.GetVelocidadExcedidaExtraText(generico, Coche);
            var chofer = GetChofer(generico.GetRiderId());
            var fecha  = generico.GetDateTime();
            var evento = MessageSaver.Save(generico, MessageCode.SpeedingTicket.GetMessageCode(), Dispositivo, Coche, chofer, fecha, generico.GeoPoint, text, ZonaManejo);

            var infraccion = new Infraccion
            {
                Vehiculo         = Coche,
                Alcanzado        = generico.GeoPoint.Speed.Unpack(),
                CodigoInfraccion = Infraccion.Codigos.ExcesoVelocidad,
                Empleado         = evento.Chofer,
                Fecha            = fecha,
                Latitud          = generico.GeoPoint.Lat,
                Longitud         = generico.GeoPoint.Lon,
                FechaFin         = null,
                LatitudFin       = 0,
                LongitudFin      = 0,
                Permitido        = 0,
                Zona             = ZonaManejo,
                FechaAlta        = DateTime.UtcNow
            };

            DaoFactory.InfraccionDAO.Save(infraccion);

            return(MessageCode.SpeedingTicket.GetMessageCode());
        }
Example #4
0
        public void TestGetRightTopOffsetPoint()
        {
            IGeoPoint <double> point    = _center.GetRightTopOffsetPoint(_pointList, 0, 0);
            IGeoPoint <double> expected = new GeoPoint(1.15, 1.15);

            AssertSamePoints(point, expected);
        }
Example #5
0
        public EvaluationRegion(IGeoPoint <double> leftBottom, IGeoPoint <double> rightTop,
                                double distanceInMeter)
        {
            if ((leftBottom.Longtitute >= rightTop.Longtitute) || (leftBottom.Lattitute >= rightTop.Lattitute))
            {
                throw new ArgumentOutOfRangeException("leftBottom");
            }

            degreeInterval = distanceInMeter.GetDegreeInterval();
            int xDimensionPoints = (int)Math.Ceiling((rightTop.Longtitute - leftBottom.Longtitute) / degreeInterval);
            int yDimensionPoints = (int)Math.Ceiling((rightTop.Lattitute - leftBottom.Lattitute) / degreeInterval);

            pointList = new MeasurePoint[xDimensionPoints * yDimensionPoints];

            for (int i = 0; i < xDimensionPoints; i++)
            {
                for (int j = 0; j < yDimensionPoints; j++)
                {
                    pointList[i * yDimensionPoints + j] = new MeasurePoint
                    {
                        Longtitute = leftBottom.Longtitute + i * degreeInterval,
                        Lattitute  = leftBottom.Lattitute + j * degreeInterval
                    };
                }
            }
        }
Example #6
0
        public static IGeoPoint <double> Move(this IGeoPoint <double> origin, double radiusInMeter, double azimuth)
        {
            var degree = radiusInMeter * 180 / 1000 / EarthRadius / Math.Cos(origin.Lattitute * Math.PI / 180);

            return(new GeoPoint(origin.Longtitute + degree * Math.Sin(azimuth * Math.PI / 180),
                                origin.Lattitute + degree * Math.Cos(azimuth * Math.PI / 180)));
        }
Example #7
0
 public LocationManagerMock(IGeoPoint point)
 {
     this.point    = point;
     this.timer    = new Timer(_ => ping());
     this.interval = new ThreadSafe <int>(Timeout.Infinite);
     this.listener = new ThreadSafe <ILocationListener>();
     this.provider = new ThreadSafe <string>();
 }
Example #8
0
        public void TestMovePoint_50m_Northwest()
        {
            GeoPoint           origin = new GeoPoint(112.1, 23.1);
            IGeoPoint <double> point  = origin.Move(50, 315);

            Assert.AreEqual(point.Longtitute, 112.0989140, 1E-6);
            Assert.AreEqual(point.Lattitute, 23.101086, 1E-6);
        }
 public EvaluationInfrastructure(IGeoPoint<double> leftBottom, IGeoPoint<double> rightTop,
     IEnumerable<EvaluationOutdoorCell> cells)
     : this()
 {
     Region = new EvaluationRegion(leftBottom, rightTop, EvaluationSettings.DistanceInMeter);
     CellList = cells.Where(x => x.Height > 0).ToList();
     Region.InitializeParameters(CellList, EvaluationSettings.DegreeSpan);
 }
Example #10
0
 public EvaluationInfrastructure(IGeoPoint <double> leftBottom, IGeoPoint <double> rightTop,
                                 IEnumerable <EvaluationOutdoorCell> cells)
     : this()
 {
     Region   = new EvaluationRegion(leftBottom, rightTop, EvaluationSettings.DistanceInMeter);
     CellList = cells.Where(x => x.Height > 0).ToList();
     Region.InitializeParameters(CellList, EvaluationSettings.DegreeSpan);
 }
Example #11
0
        public static IGeoPoint <double>[] GetTopPoints(this IGeoPoint <double>[] geoPoints,
                                                        IGeoPoint <double> center)
        {
            IEnumerable <IGeoPoint <double> > topPoints
                = geoPoints.Where(x => x.Lattitute >= center.Lattitute);
            var points = topPoints as IGeoPoint <double>[] ?? topPoints.ToArray();

            return(points);
        }
Example #12
0
        public static IGeoPoint <double>[] GetLeftPoints(this IGeoPoint <double>[] geoPoints,
                                                         IGeoPoint <double> center)
        {
            IEnumerable <IGeoPoint <double> > leftPoints
                = geoPoints.Where(x => x.Longtitute <= center.Longtitute);
            var points = leftPoints as IGeoPoint <double>[] ?? leftPoints.ToArray();

            return(points);
        }
Example #13
0
        private static double GetLongtituteOffset(this IGeoPoint <double>[] leftPoints,
                                                  IGeoPoint <double> center, double defaultLongtituteOffset)
        {
            double longtituteOffset = (leftPoints.Any())
                ? (leftPoints.Select(x => x.Longtitute).Average() - center.Longtitute) * 2
                : defaultLongtituteOffset;

            return(longtituteOffset);
        }
Example #14
0
        public static IGeoPoint <double>[] GetBottomPoints(this IGeoPoint <double>[] geoPoints,
                                                           IGeoPoint <double> center)
        {
            IEnumerable <IGeoPoint <double> > bottomPoints
                = geoPoints.Where(x => x.Lattitute <= center.Lattitute);
            var enumerable = bottomPoints as IGeoPoint <double>[] ?? bottomPoints.ToArray();

            return(enumerable);
        }
Example #15
0
        private static double GetLattituteOffset(this IGeoPoint <double>[] bottomPoints,
                                                 IGeoPoint <double> center, double defaultLattituteOffset)
        {
            double lattituteOffset = (bottomPoints.Any())
                ? (bottomPoints.Select(x => x.Lattitute).Average() - center.Lattitute) * 2
                : defaultLattituteOffset;

            return(lattituteOffset);
        }
Example #16
0
        public static IGeoPoint <double>[] GetRightPoints(this IGeoPoint <double>[] geoPoints,
                                                          IGeoPoint <double> center)
        {
            IEnumerable <IGeoPoint <double> > rightPoints
                = geoPoints.Where(x => x.Longtitute >= center.Longtitute);
            var enumerable = rightPoints as IGeoPoint <double>[] ?? rightPoints.ToArray();

            return(enumerable);
        }
Example #17
0
 private void TestInitialize(double distance)
 {
     _point2 = new StubGeoPoint(point, distance, 45);
     _ocell  = new StubOutdoorCell(_point2, 195)
     {
         Height = 40, ETilt = 4, MTilt = 1
     };
     _ccell = new ComparableCell(point, _ocell);
     _cell  = new MeasurableCell(_ccell, point, budget);
 }
        public override bool OnSingleTapUp(MotionEvent p0, MapView p1)
        {
            var         x    = p0.GetX();
            var         y    = p0.GetY();
            IProjection proj = p1.Projection;
            IGeoPoint   p    = proj.FromPixels((int)p0.GetX(), (int)p0.GetY());

            GeoPointTapped?.Invoke(this, p);
            return(base.OnSingleTapUp(p0, p1));
        }
Example #19
0
        private static void ProcessPosition(IGeoPoint message)
        {
            var pos = message.GeoPoint;

            if (pos == null || (pos.Date < new DateTime(2010, 1, 1)) || (pos.Lat == 0) || (pos.Lon == 0))
            {
                return;
            }
            new Positions().HandleMessage((Position)pos.ToPosition(message.DeviceId, 0));
        }
Example #20
0
 private void TestInitialize(double distance)
 {
     point2       = new StubGeoPoint(point, distance, 45);
     ocell        = new StubOutdoorCell(point2, 225);
     ocell.Height = 40;
     ocell.ETilt  = 4;
     ocell.MTilt  = 1;
     ccell        = new ComparableCell(point, ocell);
     cell         = new MeasurableCell(ccell, point, budget);
 }
Example #21
0
        public void ImportCellList(IENodebRepository eNodebRepository, ICellRepository cellRepository,
                                   IGeoPoint <double> southWest, IGeoPoint <double> northEast)
        {
            IEnumerable <ENodeb> eNodebs = eNodebRepository.GetAll().FilterGeoPointList(
                southWest.Longtitute - GeoMath.BaiduLongtituteOffset,
                southWest.Lattitute - GeoMath.BaiduLattituteOffset,
                northEast.Longtitute - GeoMath.BaiduLongtituteOffset,
                northEast.Lattitute - GeoMath.BaiduLattituteOffset).ToList();

            ImportCellList(cellRepository.Query(eNodebs));
        }
Example #22
0
        private string ProcessEstadoLogistico(string code, IGeoPoint generico)
        {
            if (code.Length == 1)
            {
                code = code.PadLeft(2, '0');
            }

            MessageSaver.Save(generico, code, Dispositivo, Coche, null, generico.GetDateTime(), generico.GeoPoint, string.Empty, ZonaManejo);

            return(code);
        }
Example #23
0
        public static ComparableCell[] GenerateComparableCellList(this IGeoPoint <double> p, IOutdoorCell[] cl)
        {
            int length = cl.Length;

            ComparableCell[] ccl = new ComparableCell[length];
            for (int i = 0; i < length; i++)
            {
                ccl[i] = new ComparableCell(p, cl[i]);
            }
            return(ccl);
        }
Example #24
0
        public static IGeoPoint <double> GetLeftBottomOffsetPoint(
            this IGeoPoint <double> center, IEnumerable <IGeoPoint <double> > pointList,
            double defaultLongtituteOffset, double defaultLattituteOffset)
        {
            var geoPoints        = pointList as IGeoPoint <double>[] ?? pointList.ToArray();
            var leftPoints       = geoPoints.GetLeftPoints(center);
            var longtituteOffset = leftPoints.GetLongtituteOffset(center, defaultLongtituteOffset);
            var bottomPoints     = geoPoints.GetBottomPoints(center);
            var lattituteOffset  = bottomPoints.GetLattituteOffset(center, defaultLattituteOffset);

            return(new GeoPoint(center, longtituteOffset, lattituteOffset));
        }
Example #25
0
        public static IGeoPoint <double> GetRightTopOffsetPoint(
            this IGeoPoint <double> center, IEnumerable <IGeoPoint <double> > pointList,
            double defaultLongtituteOffset, double defaultLattituteOffset)
        {
            var    geoPoints        = pointList as IGeoPoint <double>[] ?? pointList.ToArray();
            var    rightPoints      = geoPoints.GetRightPoints(center);
            double longtituteOffset = rightPoints.GetLongtituteOffset(center, defaultLongtituteOffset);
            var    topPoints        = geoPoints.GetTopPoints(center);
            double lattituteOffset  = topPoints.GetLattituteOffset(center, defaultLattituteOffset);

            return(new GeoPoint(center, longtituteOffset, lattituteOffset));
        }
Example #26
0
        private bool IsVelocidadInvalida(IGeoPoint message)
        {
            if (message.GeoPoint == null)
            {
                return(false);
            }

            var velocidadNegativa  = message.GeoPoint.Velocidad < 0;
            var velocidadMuyGrande = message.GeoPoint.Velocidad > Coche.TipoCoche.MaximaVelocidadAlcanzable;

            return(velocidadNegativa || velocidadMuyGrande);
        }
Example #27
0
        public static double DistanceMeters(IGeoPoint a, IGeoPoint b, bool includeElevation)
        {
            var m = DistanceMeters(a, b);

            if (includeElevation && a.Elevation.HasValue && b.Elevation.HasValue)
            {
                var h = Math.Abs(a.Elevation.Value - b.Elevation.Value);
                return(Math.Sqrt(Convert.ToDouble(h * h) + Convert.ToDouble(m * m)));
            }
            else
            {
                return(m);
            }
        }
Example #28
0
 public ComparableCell(IGeoPoint<double> point, IOutdoorCell cell, IList<ILinkBudget<double>> budgetList,
     byte modBase = 3)
 {
     SetupComparableCell(point, cell);
     ILinkBudget<double> budget = budgetList.FirstOrDefault(
         x => Math.Abs(x.TransmitPower - cell.RsPower) < Eps
         && Math.Abs(x.AntennaGain - cell.AntennaGain) < Eps
         && x.Model.Earfcn == cell.Frequency);
     if (budget == null)
     {
         budget = new LinkBudget(cell);
         budgetList.Add(budget);
     }
     Budget = budget;
     PciModx = (byte)(cell.Pci % modBase);
 }
Example #29
0
        public ComparableCell(IGeoPoint<double> point, IOutdoorCell cell, IList<ILinkBudget<double>> budgetList,
            IBroadcastModel model, byte pciModx = 0)
        {
            SetupComparableCell(point, cell);
            ILinkBudget<double> budget = budgetList.FirstOrDefault(
                x => Math.Abs(x.TransmitPower - cell.RsPower) < Eps
                && Math.Abs(x.AntennaGain - cell.AntennaGain) < Eps);
            if (budget == null)
            {
                budget = new LinkBudget(model, cell.RsPower, cell.AntennaGain);
                budgetList.Add(budget);
            }

            Budget = budget;
            PciModx = pciModx;
        }
Example #30
0
        public ComparableCell(IGeoPoint <double> point, IOutdoorCell cell, IList <ILinkBudget <double> > budgetList,
                              IBroadcastModel model, byte pciModx = 0)
        {
            SetupComparableCell(point, cell);
            ILinkBudget <double> budget = budgetList.FirstOrDefault(
                x => Math.Abs(x.TransmitPower - cell.RsPower) < Eps &&
                Math.Abs(x.AntennaGain - cell.AntennaGain) < Eps);

            if (budget == null)
            {
                budget = new LinkBudget(model, cell.RsPower, cell.AntennaGain);
                budgetList.Add(budget);
            }

            Budget  = budget;
            PciModx = pciModx;
        }
Example #31
0
        public ComparableCell(IGeoPoint <double> point, IOutdoorCell cell, IList <ILinkBudget <double> > budgetList,
                              byte modBase = 3)
        {
            SetupComparableCell(point, cell);
            ILinkBudget <double> budget = budgetList.FirstOrDefault(
                x => Math.Abs(x.TransmitPower - cell.RsPower) < Eps &&
                Math.Abs(x.AntennaGain - cell.AntennaGain) < Eps &&
                x.Model.Earfcn == cell.Frequency);

            if (budget == null)
            {
                budget = new LinkBudget(cell);
                budgetList.Add(budget);
            }
            Budget  = budget;
            PciModx = (byte)(cell.Pci % modBase);
        }
 public void TestInitialize()
 {
     _point = new StubGeoPoint(112, 23);
     _cell = new StubOutdoorCell
     {
         RsPower = 15.2,
         AntennaGain = 17.5,
         Azimuth = 60,
         Longtitute = 112.01,
         Lattitute = 23.01,
         Height = 30,
         MTilt = 5,
         ETilt = 1,
         Pci = 22,
         Frequency = 100,
         CellName = "Cell-1"
     };
 }
 public void TestInitialize()
 {
     _point = new StubGeoPoint(112, 23);
     _cell  = new StubOutdoorCell
     {
         RsPower     = 15.2,
         AntennaGain = 17.5,
         Azimuth     = 60,
         Longtitute  = 112.01,
         Lattitute   = 23.01,
         Height      = 30,
         MTilt       = 5,
         ETilt       = 1,
         Pci         = 22,
         Frequency   = 100,
         CellName    = "Cell-1"
     };
 }
Example #34
0
        public static SectorTriangle GetSectorPoints(this IOutdoorCell outdoorCell, double radiusInMeter)
        {
            IGeoPoint <double> point1 = outdoorCell.Move(radiusInMeter, outdoorCell.Azimuth + 30);
            IGeoPoint <double> point2 = outdoorCell.Move(radiusInMeter, outdoorCell.Azimuth - 30);

            return(new SectorTriangle
            {
                X1 = outdoorCell.Longtitute + GeoMath.BaiduLongtituteOffset,
                Y1 = outdoorCell.Lattitute + GeoMath.BaiduLattituteOffset,
                X2 = point1.Longtitute + GeoMath.BaiduLongtituteOffset,
                Y2 = point1.Lattitute + GeoMath.BaiduLattituteOffset,
                X3 = point2.Longtitute + GeoMath.BaiduLongtituteOffset,
                Y3 = point2.Lattitute + GeoMath.BaiduLattituteOffset,
                Info = outdoorCell.Info(),
                CellName = outdoorCell.CellName,
                ColorString = "8C8C8C"
            });
        }
 public void TestInitialize()
 {
     p = new StubGeoPoint(112, 23);
 }
 private void AssertSamePoints(IGeoPoint<double> point1, IGeoPoint<double> point2)
 {
     Assert.AreEqual(point1.Longtitute, point2.Longtitute, Eps, "Longtitute should be " + point1.Longtitute);
     Assert.AreEqual(point1.Lattitute, point2.Lattitute, Eps, "Lattitute should be " + point1.Lattitute);
 }
Example #37
0
 public void SetAzimuthAngle(IGeoPoint<double> point, double value)
 {
     Cell.Azimuth = value;
     AzimuthAngle = Cell.AngleFromCellAzimuth(point);
 }
 private void TestInitialize(double distance)
 {
     _point2 = new StubGeoPoint(point, distance, 45);
     _ocell = new StubOutdoorCell(_point2, 195) {Height = 40, ETilt = 4, MTilt = 1};
     _ccell = new ComparableCell(point, _ocell);
     _cell = new MeasurableCell(_ccell, point, budget);
 }
Example #39
0
 public ComparableCell(IGeoPoint<double> point, IOutdoorCell cell, byte pciModx = 0)
 {
     SetupComparableCell(point, cell);
     Budget = new LinkBudget(cell);
     PciModx = pciModx;
 }
Example #40
0
 public void SetupComparableCell(IGeoPoint<double> point, IOutdoorCell cell)
 {
     Cell = cell;
     Distance = point.SimpleDistance(cell);
     AzimuthAngle = cell.AngleFromCellAzimuth(point);
 }
 public void ImportCellList(IENodebRepository eNodebRepository, ICellRepository cellRepository,
     IGeoPoint<double> southWest, IGeoPoint<double> northEast)
 {
     IEnumerable<ENodeb> eNodebs = eNodebRepository.GetAll().FilterGeoPointList(
         southWest.Longtitute - GeoMath.BaiduLongtituteOffset,
         southWest.Lattitute - GeoMath.BaiduLattituteOffset,
         northEast.Longtitute - GeoMath.BaiduLongtituteOffset,
         northEast.Lattitute - GeoMath.BaiduLattituteOffset).ToList();
     ImportCellList(cellRepository.Query(eNodebs));
 }
 private void TestInitialize(double distance)
 {
     point2 = new StubGeoPoint(point, distance, 45);
     ocell = new StubOutdoorCell(point2, 225);
     ocell.Height = 40;
     ocell.ETilt = 4;
     ocell.MTilt = 1;
     ccell = new ComparableCell(point, ocell);
     cell = new MeasurableCell(ccell, point, budget);
 }
Example #43
0
 public MeasurableCell(IGeoPoint<double> point, IOutdoorCell cell, byte modBase = 3)
     : this(new ComparableCell(point, cell, (byte)(cell.Pci % modBase)), point)
 {
 }
Example #44
0
 public MeasurableCell(ComparableCell cell, IGeoPoint<double> point)
 {
     Cell = cell;
     Budget = cell.Budget;
     TiltAngle = cell.Cell.AngleFromCellTilt(point);
 }
 public static double TiltFromCell(this IOutdoorCell c, IGeoPoint<double> p)
 {
     double d = p.SimpleDistance(c);
     return Math.Atan2(c.Height, d * 1000) * 180 / Math.PI;
 }
 public static double AngleFromCellTilt(this IOutdoorCell c, IGeoPoint<double> p)
 {
     return Math.Abs(c.MTilt + c.ETilt - c.TiltFromCell(p));
 }
 public static double AngleFromCellAzimuth(this IOutdoorCell c, IGeoPoint<double> p)
 {
     double pa = p.PositionAzimuth(c);
     return GeoMath.AllAngleBetweenAzimuths(pa, c.Azimuth);
 }