Exemplo n.º 1
0
        public void Update(DrawArgs drawArgs)
        {
            try
            {
                double centerLatitude  = 0.5 * (m_GeoBB.North + m_GeoBB.South);
                double centerLongitude = 0.5 * (m_GeoBB.West + m_GeoBB.East);
                double tileSize        = m_GeoBB.North - m_GeoBB.South;

                if (!m_Initialized)
                {
                    if (drawArgs.WorldCamera.ViewRange * 0.5f < Angle.FromDegrees(ShapeTileArgs.TileDrawDistance * tileSize) &&
                        MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude),
                                                     drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) < Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor * tileSize * 1.25f) &&
                        drawArgs.WorldCamera.ViewFrustum.Intersects(BoundingBox)
                        )
                    {
                        Initialize(drawArgs);
                    }
                }

                if (m_Initialized)
                {
                    if (m_NwImageLayer != null)
                    {
                        m_NwImageLayer.Update(drawArgs);
                    }
                    if (m_NeImageLayer != null)
                    {
                        m_NeImageLayer.Update(drawArgs);
                    }
                    if (m_SwImageLayer != null)
                    {
                        m_SwImageLayer.Update(drawArgs);
                    }
                    if (m_SeImageLayer != null)
                    {
                        m_SeImageLayer.Update(drawArgs);
                    }

                    if (
                        drawArgs.WorldCamera.ViewRange < Angle.FromDegrees(ShapeTileArgs.TileDrawDistance * tileSize) &&
                        MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude),
                                                     drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) < Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor * tileSize) &&
                        drawArgs.WorldCamera.ViewFrustum.Intersects(BoundingBox)
                        )
                    {
                        if (m_NorthEastChild == null && m_NorthWestChild == null && m_SouthEastChild == null && m_SouthWestChild == null)
                        {
                            ComputeChildren(drawArgs);
                        }
                        else
                        {
                            if (m_NorthEastChild != null)
                            {
                                m_NorthEastChild.Update(drawArgs);
                            }

                            if (m_NorthWestChild != null)
                            {
                                m_NorthWestChild.Update(drawArgs);
                            }

                            if (m_SouthEastChild != null)
                            {
                                m_SouthEastChild.Update(drawArgs);
                            }

                            if (m_SouthWestChild != null)
                            {
                                m_SouthWestChild.Update(drawArgs);
                            }
                        }
                    }
                    else
                    {
                        if (m_NorthWestChild != null)
                        {
                            m_NorthWestChild.Dispose();
                            m_NorthWestChild = null;
                        }

                        if (m_NorthEastChild != null)
                        {
                            m_NorthEastChild.Dispose();
                            m_NorthEastChild = null;
                        }

                        if (m_SouthEastChild != null)
                        {
                            m_SouthEastChild.Dispose();
                            m_SouthEastChild = null;
                        }

                        if (m_SouthWestChild != null)
                        {
                            m_SouthWestChild.Dispose();
                            m_SouthWestChild = null;
                        }
                    }
                }

                if (m_Initialized)
                {
                    if (drawArgs.WorldCamera.ViewRange > Angle.FromDegrees(ShapeTileArgs.TileDrawDistance * tileSize * 1.5f) ||
                        MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude), drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) > Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor * tileSize * 1.5f))
                    {
                        //if(this.level != 0)
                        //{
                        Dispose();
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.Log.Write(ex);
            }
        }