Exemple #1
0
        /// <summary>
        /// Loads visible place names from one file.
        /// If cache files are appropriately named only files in view are hit
        /// </summary>
        void UpdateNames(WorldWindWFSPlacenameFile placenameFileDescriptor, ArrayList tempPlacenames, DrawArgs drawArgs)
        {
            // TODO: Replace with bounding box frustum intersection test
            double viewRange = drawArgs.WorldCamera.TrueViewRange.Degrees;
            double north     = drawArgs.WorldCamera.Latitude.Degrees + viewRange;
            double south     = drawArgs.WorldCamera.Latitude.Degrees - viewRange;
            double west      = drawArgs.WorldCamera.Longitude.Degrees - viewRange;
            double east      = drawArgs.WorldCamera.Longitude.Degrees + viewRange;

            //TODO: Implement GML parsing
            if (placenameFileDescriptor.north < south)
            {
                return;
            }
            if (placenameFileDescriptor.south > north)
            {
                return;
            }
            if (placenameFileDescriptor.east < west)
            {
                return;
            }
            if (placenameFileDescriptor.west > east)
            {
                return;
            }

            WorldWindPlacename[] tilednames = placenameFileDescriptor.PlaceNames;
            if (tilednames == null)
            {
                return;
            }

            tempPlacenames.Capacity = tempPlacenames.Count + tilednames.Length;
            WorldWindPlacename curPlace = new WorldWindPlacename();

            for (int i = 0; i < tilednames.Length; i++)
            {
                if (this.m_placeNames != null && this.curPlaceNameIndex < this.m_placeNames.Length)
                {
                    curPlace = this.m_placeNames[this.curPlaceNameIndex];
                }

                WorldWindPlacename pn = tilednames[i];
                float lat             = pn.Lat;
                float lon             = pn.Lon;

                // for easier hit testing

                float lonRanged = lon;
                if (lonRanged < west)
                {
                    lonRanged += 360; // add a revolution
                }
                if (lat > north || lat < south || lonRanged > east || lonRanged < west)
                {
                    continue;
                }

                float elevation = 0;
                if (this.m_parentWorld.TerrainAccessor != null && drawArgs.WorldCamera.Altitude < 300000)
                {
                    elevation = (float)this.m_parentWorld.TerrainAccessor.GetElevationAt(lat, lon);
                }
                float altitude = (float)(this.m_parentWorld.EquatorialRadius + World.Settings.VerticalExaggeration * this.m_altitude + World.Settings.VerticalExaggeration * elevation);
                pn.cartesianPoint = MathEngine.SphericalToCartesian(lat, lon, altitude);
                float distanceSq = Vector3.LengthSq(pn.cartesianPoint - drawArgs.WorldCamera.Position);
                if (distanceSq > this.m_maximumDistanceSq)
                {
                    continue;
                }
                if (distanceSq < this.m_minimumDistanceSq)
                {
                    continue;
                }

                if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(pn.cartesianPoint))
                {
                    continue;
                }

                tempPlacenames.Add(pn);
            }
        }
Exemple #2
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)));
        }