コード例 #1
0
        private ProjectedVectorTile ComputeChild(DrawArgs drawArgs, double childSouth, double childNorth, double childWest, double childEast, double tileSize)
        {
            ProjectedVectorTile child = new ProjectedVectorTile(
                new GeographicBoundingBox(childNorth, childSouth, childWest, childEast),
                m_parentProjectedLayer);

            return(child);
        }
コード例 #2
0
        public virtual void ComputeChildren(DrawArgs drawArgs)
        {
            float tileSize = (float)(0.5 * (m_geographicBoundingBox.North - m_geographicBoundingBox.South));

            //TODO: Stop children computation at some lower level
            if (tileSize > 0.0001)
            {
                double CenterLat = 0.5f * (m_geographicBoundingBox.North + m_geographicBoundingBox.South);
                double CenterLon = 0.5f * (m_geographicBoundingBox.East + m_geographicBoundingBox.West);

                if (m_NorthWestChild == null && m_NwImageLayer != null && m_Initialized)
                {
                    m_NorthWestChild       = ComputeChild(drawArgs, CenterLat, m_geographicBoundingBox.North, m_geographicBoundingBox.West, CenterLon, tileSize);
                    m_NorthWestChild.Level = Level++;
                    m_NorthWestChild.Row   = 2 * Row + 1;
                    m_NorthWestChild.Col   = 2 * Col;

                    m_NorthWestChild.Initialize(drawArgs);
                }

                if (m_NorthEastChild == null && m_NeImageLayer != null && m_Initialized)
                {
                    m_NorthEastChild       = ComputeChild(drawArgs, CenterLat, m_geographicBoundingBox.North, CenterLon, m_geographicBoundingBox.East, tileSize);
                    m_NorthEastChild.Level = Level++;
                    m_NorthEastChild.Row   = 2 * Row + 1;
                    m_NorthEastChild.Col   = 2 * Col + 1;

                    m_NorthEastChild.Initialize(drawArgs);
                }

                if (m_SouthWestChild == null && m_SwImageLayer != null && m_Initialized)
                {
                    m_SouthWestChild       = ComputeChild(drawArgs, m_geographicBoundingBox.South, CenterLat, m_geographicBoundingBox.West, CenterLon, tileSize);
                    m_SouthWestChild.Level = Level++;
                    m_SouthWestChild.Row   = 2 * Row;
                    m_SouthWestChild.Col   = 2 * Col;

                    m_SouthWestChild.Initialize(drawArgs);
                }

                if (m_SouthEastChild == null && m_SeImageLayer != null && m_Initialized)
                {
                    m_SouthEastChild       = ComputeChild(drawArgs, m_geographicBoundingBox.South, CenterLat, CenterLon, m_geographicBoundingBox.East, tileSize);
                    m_SouthEastChild.Level = Level++;
                    m_SouthEastChild.Row   = 2 * Row;
                    m_SouthEastChild.Col   = 2 * Col + 1;

                    m_SouthEastChild.Initialize(drawArgs);
                }
            }
        }
コード例 #3
0
        private void UpdateRootTiles()
        {
            int numberRows = (int)(180.0f / m_lzts);

            System.Collections.ArrayList tileList = new System.Collections.ArrayList();

            int istart = 0;
            int iend   = numberRows;
            int jstart = 0;
            int jend   = numberRows * 2;

            for (int i = istart; i < iend; i++)
            {
                for (int j = jstart; j < jend; j++)
                {
                    double north = (i + 1) * m_lzts - 90.0f;
                    double south = i * m_lzts - 90.0f;
                    double west  = j * m_lzts - 180.0f;
                    double east  = (j + 1) * m_lzts - 180.0f;

                    ProjectedVectorTile newTile = new ProjectedVectorTile(
                        new GeographicBoundingBox(
                            north,
                            south,
                            west,
                            east),
                        this);

                    newTile.Level = 0;
                    newTile.Row   = i;
                    newTile.Col   = j;
                    tileList.Add(newTile);
                }
            }

            m_rootTiles = (ProjectedVectorTile[])tileList.ToArray(typeof(ProjectedVectorTile));
        }
コード例 #4
0
        public void Update(DrawArgs drawArgs)
        {
            try
            {
                double centerLatitude  = 0.5 * (m_geographicBoundingBox.North + m_geographicBoundingBox.South);
                double centerLongitude = 0.5 * (m_geographicBoundingBox.West + m_geographicBoundingBox.East);
                double tileSize        = m_geographicBoundingBox.North - m_geographicBoundingBox.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_LastUpdate < m_parentProjectedLayer.LastUpdate)
                    {
                        UpdateImageLayers(drawArgs);
                    }

                    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)
            {
                Log.Write(ex);
            }
        }