Exemplo n.º 1
0
        // REWORK ALL THIS LOGIC
        private void doFrameRanger(double elapsedSeconds)
        {
            // convert km/h to m/s
            double rangerSpeed = viewModel.RangerSpeed / 3.6;

            lock (rangerLayer.DataLock)
            {
                foreach (Ranger ranger in rangerLayer.Elements)
                {
                    MapPoint newPos = ranger.UpdateUiPosition(rangerSpeed, elapsedSeconds);

                    Geometry buf = GeoUtil.GetBuffer(newPos, Ranger.FineRange);

                    // catch interlopers nearby
                    lock (interloperLayer.DataLock)
                    {
                        List <Interloper> caught = interloperLayer.Elements.Where(x => GeometryEngine.Intersects(buf, x.EsriPosition) == true).ToList();
                        if (caught.Count > 0)
                        {
                            rangerLayer.ShowFineAnimation(ranger);
                            caught.ForEach(x => interloperLayer.RemoveElement(x));
                            ranger.Route = null;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        // REWORK ALL THIS LOGIC
        private void handleAlarm(Sensor sensor)
        {
            sensorLayer.RaiseAlarm(sensor);

            Crossing nearestCrossing = crossingLayer.GetNearestTo(sensor.EsriPosition);

            lock (rangerLayer.DataLock)
            {
                List <Ranger> freeRangers = rangerLayer.Elements.Where(x => x.State != MobileUnitState.EN_ROUTE).ToList();
                if (freeRangers.Count > 0)
                {
                    List <Graphic> freeRangersGraphics = freeRangers.Select(x => x.Graphic).ToList();

                    MapPoint pt     = GeoUtil.GetNearestCoordinateInGraphicsCollection(nearestCrossing.EsriPosition, freeRangersGraphics);
                    Ranger   ranger = rangerLayer.ByPosition(pt);

                    viewModel.LeadMobileToCrossing(ranger, nearestCrossing);
                }
            }
        }