Example #1
0
        WorldWindWFSPlacenameFile[] GetWFSFiles(double north, double south, double west, double east)
        {
            double tileSize = 0;

            //base the tile size on the max viewing distance
            double maxDistance = Math.Sqrt(this.m_maximumDistanceSq);

            double factor = maxDistance / this.m_parentWorld.EquatorialRadius;

            // True view range
            if (factor < 1)
            {
                tileSize = Angle.FromRadians(Math.Abs(Math.Asin(maxDistance / this.m_parentWorld.EquatorialRadius)) * 2).Degrees;
            }
            else
            {
                tileSize = Angle.FromRadians(Math.PI).Degrees;
            }

            tileSize = (180 / (int)(180 / tileSize));

            if (tileSize == 0)
            {
                tileSize = 0.1;
            }
            //Log.Write(Log.Levels.Debug, string.Format("TS: {0} -> {1}", name, tileSize));
            //not working for some reason...
            //int startRow = MathEngine.GetRowFromLatitude(south, tileSize);
            //int endRow = MathEngine.GetRowFromLatitude(north, tileSize);
            //int startCol = MathEngine.GetColFromLongitude(west, tileSize);
            //int endCol = MathEngine.GetColFromLongitude(east, tileSize);

            ArrayList placenameFiles = new ArrayList();

            double currentSouth = -90;

            //for (int row = 0; row <= endRow; row++)
            while (currentSouth < 90)
            {
                double currentNorth = currentSouth + tileSize;
                if (currentSouth > north || currentNorth < south)
                {
                    currentSouth += tileSize;
                    continue;
                }

                double currentWest = -180;
                while (currentWest < 180)
                //    for (int col = startCol; col <= endCol; col++)
                {
                    double currentEast = currentWest + tileSize;
                    if (currentWest > east || currentEast < west)
                    {
                        currentWest += tileSize;
                        continue;
                    }

                    WorldWindWFSPlacenameFile placenameFile = new WorldWindWFSPlacenameFile(this.m_name, this.m_placenameBaseUrl, this.m_typename, this.m_labelfield, currentNorth, currentSouth, currentWest, currentEast, this.m_parentWorld, this.m_cache);

                    int key = placenameFile.GetHashCode();
                    if (!this.m_fileHash.Contains(key))
                    {
                        this.m_fileHash.Add(key, placenameFile);
                    }
                    else
                    {
                        placenameFile = (WorldWindWFSPlacenameFile)this.m_fileHash[key];
                    }
                    placenameFiles.Add(placenameFile);

                    currentWest += tileSize;
                }
                currentSouth += tileSize;
            }

            return((WorldWindWFSPlacenameFile[])placenameFiles.ToArray(typeof(WorldWindWFSPlacenameFile)));
        }