Ejemplo n.º 1
0
 public LayerVehicles(PictureManager pm, CameraManager cm) : base(pm, cm)
 {
     VehiclesCache.DynamicObjectCreateCallback += new DynamicObjectCreateHandler(VehicleCreateHandler);
     VehiclesCache.DynamicObjectDeleteCallback += new DynamicObjectDeleteHandler(VehicleDeleteHandler);
     VehiclesCache.DynamicObjectMoveCallback   += new DynamicObjectMoveHandler(VehicleMoveHandler);
     VehiclesCache.init();
 }
Ejemplo n.º 2
0
        public VehicleGps(GpsRealTimeData rtData, string name, string sym, string source, string url, string desc, bool doTrackLog)
            : base(rtData.location.Clone(), name, sym, source, url, desc)                               // location must be not null
        {
            RealTimeData = rtData;
            m_doTrackLog = doTrackLog;

            if (m_doTrackLog)
            {
                logTrack(rtData);
            }

            if (m_image_nofix == null)
            {
                m_image_nofix = VehiclesCache.getVehicleImage("gps_nofix");
            }

            if (m_image_default == null)
            {
                m_image_default = VehiclesCache.getVehicleImage("gps_car_default");
            }

            setImage(sym);

            Image = m_imageSym;              //m_image_nofix;				// may be null

            imageBoundingRect();
        }
Ejemplo n.º 3
0
 public override void shutdown()
 {
     VehiclesCache.shutdown();
 }
Ejemplo n.º 4
0
 public void setImage(string sym)
 {
     m_imageSym = VehiclesCache.getVehicleImage(sym);                    // may be null
 }
Ejemplo n.º 5
0
        public void ProcessMove(GpsRealTimeData rtData)
        {
            if (rtData == null)
            {
                resetTrackLog();
                return;
            }

            if (rtData.location != null)
            {
                RealTimeData = rtData;

                bool locationChanged = false;
                bool imageChanged    = false;
                bool haveFix         = false;

                Rectangle prev    = this.BoundingRect;                  // on previous image/location
                Rectangle prevImg = this.m_imageBoundingRect;           // on previous image

                switch (rtData.fix)
                {
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                    if (Image != m_imageSym)
                    {
                        imageChanged = true;
                        Image        = m_imageSym;
                    }
                    haveFix   = true;
                    m_lastFix = DateTime.Now;
                    //if(rtData.location.Lng != this.Location.Lng || rtData.location.Lat != this.Location.Lat)
                    double moveTreshold = 0.000005d;
                    if (Math.Abs(rtData.location.Lng - this.Location.Lng) > moveTreshold ||
                        Math.Abs(rtData.location.Lat - this.Location.Lat) > moveTreshold)
                    {
                        locationChanged   = true;
                        this.Location.Lng = rtData.location.Lng;
                        this.Location.Lat = rtData.location.Lat;
                    }
                    imageBoundingRect();
                    if (!prevImg.Equals(this.m_imageBoundingRect))
                    {
                        imageChanged = true;
                    }
                    break;

                default:
                    if (Image != m_image_nofix)
                    {
                        imageChanged = true;
                        Image        = m_image_nofix;
                    }
                    break;
                }

                if (imageChanged)
                {
                    m_pixelRadius = (Image == null) ? MIN_VEH_PIXEL_RADIUS : (Image.Width + Image.Height) * 3 / 16;
                }

                this.tick();

                if (haveFix && m_doTrackLog)
                {
                    logTrack(rtData);
                }

                if (locationChanged || imageChanged)
                {
                    VehiclesCache.vehicleMoved(this, prev);                     // will put on map and recalculate image bounding rect
                }
            }
            else if (Image != m_image_nofix && m_lastFix.AddSeconds(10).CompareTo(DateTime.Now) < 0)
            {
                RealTimeData = rtData;
                Rectangle prev = this.BoundingRect;                     // on previous image/location
                Image = m_image_nofix;
                this.tick();
                VehiclesCache.vehicleMoved(this, prev);                 // will put on map and recalculate image bounding rect
            }
        }