示例#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 (m_placeNames != null && curPlaceNameIndex < m_placeNames.Length)
                {
                    curPlace = m_placeNames[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 (m_parentWorld.TerrainAccessor != null && drawArgs.WorldCamera.Altitude < 300000)
                {
                    elevation = (float)m_parentWorld.TerrainAccessor.GetElevationAt(lat, lon);
                }
                float altitude = (float)(m_parentWorld.EquatorialRadius + World.Settings.VerticalExaggeration * m_altitude + World.Settings.VerticalExaggeration * elevation);
                pn.cartesianPoint = MathEngine.SphericalToCartesian(lat, lon, altitude);
                float distanceSq = Vector3.LengthSq(pn.cartesianPoint - drawArgs.WorldCamera.Position);
                if (distanceSq > m_maximumDistanceSq)
                {
                    continue;
                }
                if (distanceSq < m_minimumDistanceSq)
                {
                    continue;
                }

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

                tempPlacenames.Add(pn);
            }
        }
        /// <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 (m_placeNames != null && curPlaceNameIndex < m_placeNames.Length)
                    curPlace = m_placeNames[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 (m_parentWorld.TerrainAccessor != null && drawArgs.WorldCamera.Altitude < 300000)
                    elevation = (float)m_parentWorld.TerrainAccessor.GetElevationAt(lat, lon);
                float altitude = (float)(m_parentWorld.EquatorialRadius + World.Settings.VerticalExaggeration * m_altitude + World.Settings.VerticalExaggeration * elevation);
                pn.cartesianPoint = MathEngine.SphericalToCartesian(lat, lon, altitude);
                float distanceSq = Vector3.LengthSq(pn.cartesianPoint - drawArgs.WorldCamera.Position);
                if (distanceSq > m_maximumDistanceSq)
                    continue;
                if (distanceSq < m_minimumDistanceSq)
                    continue;
                
                if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(pn.cartesianPoint))
                    continue;
                
                tempPlacenames.Add(pn);
            }
            
		}
示例#3
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(m_maximumDistanceSq);

            double factor = maxDistance / m_parentWorld.EquatorialRadius;

            // True view range
            if (factor < 1)
            {
                tileSize = Angle.FromRadians(Math.Abs(Math.Asin(maxDistance / 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(
                        m_name, m_placenameBaseUrl, m_typename, m_labelfield, currentNorth, currentSouth, currentWest, currentEast, m_parentWorld, m_cache);

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

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

            return((WorldWindWFSPlacenameFile[])placenameFiles.ToArray(typeof(WorldWindWFSPlacenameFile)));
        }
        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(m_maximumDistanceSq);
            
            double factor = maxDistance / m_parentWorld.EquatorialRadius;
            // True view range 
			if(factor < 1)
				tileSize = Angle.FromRadians(Math.Abs(Math.Asin(maxDistance / 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(
                        m_name, m_placenameBaseUrl, m_typename, m_labelfield, currentNorth, currentSouth, currentWest, currentEast, m_parentWorld, m_cache);
                    
                    int key = placenameFile.GetHashCode();
                    if (!m_fileHash.Contains(key))
                    {
                        m_fileHash.Add(key, placenameFile);
                    }
                    else
                    {
                        placenameFile = (WorldWindWFSPlacenameFile)m_fileHash[key];
                    }
                    placenameFiles.Add(placenameFile);
                    
                    currentWest += tileSize;
                }
                currentSouth += tileSize;
            }

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