예제 #1
0
        public override void Initialize(WorldWind.DrawArgs drawArgs)
        {
            lock (this)
            {
                m_oLastAoI           = drawArgs.CurrentRoI;
                m_oLastAoIChangeTime = DateTime.Now;

                if (m_oGroundOverlay.Icon.ViewRefreshMode == KMLViewRefreshMode.onStop)
                {
                    GeographicBoundingBox oRenderBox = GetNewBox(drawArgs.CurrentRoI, m_oGroundOverlay.Icon.ViewBoundScale);

                    m_oLayer = new ImageLayer(
                        m_oGroundOverlay.Name,
                        drawArgs.CurrentWorld,
                        m_oGroundOverlay.Altitude,
                        m_strImageFilename,
                        oRenderBox.South,
                        oRenderBox.North,
                        oRenderBox.West,
                        oRenderBox.East,
                        (byte)(m_oGroundOverlay.Color.A * ((double)m_opacity / (double)(byte.MaxValue))),
                        drawArgs.CurrentWorld.TerrainAccessor);

                    if (m_oGroundOverlay.Icon.IsLocalFile)
                    {
                        m_oLayer.ImagePath = Path.Combine(m_strKMLDirectory, m_oGroundOverlay.Icon.HRef);
                    }
                    else
                    {
                        m_oLayer.ImageUrl = m_oGroundOverlay.Icon.GetUri(oRenderBox.West, oRenderBox.South, oRenderBox.East, oRenderBox.North);
                    }
                    m_oLayerAoI = drawArgs.CurrentRoI.Clone() as GeographicBoundingBox;
                }
                else
                {
                    m_oLayer = new ImageLayer(
                        m_oGroundOverlay.Name,
                        drawArgs.CurrentWorld,
                        m_oGroundOverlay.Altitude,
                        m_strImageFilename,
                        m_oGroundOverlay.LatLonBox.South,
                        m_oGroundOverlay.LatLonBox.North,
                        m_oGroundOverlay.LatLonBox.West,
                        m_oGroundOverlay.LatLonBox.East,
                        (byte)(m_oGroundOverlay.Color.A * ((double)m_opacity / (double)(byte.MaxValue))),
                        drawArgs.CurrentWorld.TerrainAccessor);

                    if (m_oGroundOverlay.Icon.IsLocalFile)
                    {
                        m_oLayer.ImagePath = Path.Combine(m_strKMLDirectory, m_oGroundOverlay.Icon.HRef);
                    }
                    else
                    {
                        m_oLayer.ImageUrl = m_oGroundOverlay.GetUri();
                    }
                }
                m_oLayer.Initialize(drawArgs);
            }
        }
예제 #2
0
        public override void Update(WorldWind.DrawArgs drawArgs)
        {
            lock (this)
            {
                if (m_oLayer != null)
                {
                    if (m_oGroundOverlay.Icon.ViewRefreshMode == KMLViewRefreshMode.onStop)
                    {
                        double dTimeStopped;
                        if (drawArgs.CurrentRoI.Equals(m_oLastAoI))
                        {
                            dTimeStopped = (DateTime.Now - m_oLastAoIChangeTime).Seconds;
                        }
                        else
                        {
                            dTimeStopped         = 0.0;
                            m_oLastAoI           = drawArgs.CurrentRoI;
                            m_oLastAoIChangeTime = DateTime.Now;
                        }

                        if (dTimeStopped > m_oGroundOverlay.Icon.ViewRefreshTime && !m_oLayerAoI.Equivalent(drawArgs.CurrentRoI, 1e-6))
                        {
                            try
                            {
                                File.Delete(m_strImageFilename);
                            }
                            catch (IOException) { return; }
                            GeographicBoundingBox oRenderBox = GetNewBox(drawArgs.CurrentRoI, m_oGroundOverlay.Icon.ViewBoundScale);

                            m_oLayer = new ImageLayer(
                                m_oGroundOverlay.Name,
                                drawArgs.CurrentWorld,
                                m_oGroundOverlay.Altitude,
                                m_strImageFilename,
                                oRenderBox.South,
                                oRenderBox.North,
                                oRenderBox.West,
                                oRenderBox.East,
                                (byte)(m_oGroundOverlay.Color.A * ((double)m_opacity / (double)(byte.MaxValue))),
                                drawArgs.CurrentWorld.TerrainAccessor);

                            if (m_oGroundOverlay.Icon.IsLocalFile)
                            {
                                m_oLayer.ImagePath = Path.Combine(m_strKMLDirectory, m_oGroundOverlay.Icon.HRef);
                            }
                            else
                            {
                                m_oLayer.ImageUrl = m_oGroundOverlay.Icon.GetUri(oRenderBox.West, oRenderBox.South, oRenderBox.East, oRenderBox.North);
                            }
                            m_oLayer.Initialize(drawArgs);
                            m_oLayerAoI = drawArgs.CurrentRoI.Clone() as GeographicBoundingBox;
                        }
                    }

                    m_oLayer.Update(drawArgs);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 渲染当前图层
        /// </summary>
        /// <param name="drawArgs"></param>
        public void Render(DrawArgs drawArgs)
        {
            if (imagelyr == null)
            {
                return;
            }

            if (!IsOn)
            {
                return;
            }

            if (!imagelyr.Initialized)
            {
                imagelyr.Initialize(drawArgs);
            }
            imagelyr.Render(drawArgs);
        }