Пример #1
0
		private NltTerrainAccessor getTerrainAccessorFromXML(WorldXmlDescriptor.TerrainAccessor curTerrainAccessorType)
		{
			double east = curTerrainAccessorType.LatLonBoundingBox.East.Value.DoubleValue();
			double west = curTerrainAccessorType.LatLonBoundingBox.West.Value.DoubleValue();
			double north = curTerrainAccessorType.LatLonBoundingBox.North.Value.DoubleValue();
			double south = curTerrainAccessorType.LatLonBoundingBox.South.Value.DoubleValue();

			NltTerrainAccessor[] subsets = null;
			if(curTerrainAccessorType.HasHigherResolutionSubsets())
			{
				subsets = new NltTerrainAccessor[curTerrainAccessorType.HigherResolutionSubsetsCount];
				for(int i = 0; i < curTerrainAccessorType.HigherResolutionSubsetsCount; i++)
				{
					subsets[i] = this.getTerrainAccessorFromXML(curTerrainAccessorType.GetHigherResolutionSubsetsAt(i));
				}
			}

			if(curTerrainAccessorType.HasDownloadableWMSSet())
			{
			/*	WMSLayerAccessor wmsLayer = new WMSLayerAccessor();

				wmsLayer.ImageFormat = curTerrainAccessorType.DownloadableWMSSet.ImageFormat.Value;
				wmsLayer.IsTransparent = curTerrainAccessorType.DownloadableWMSSet.UseTransparency.Value;
				wmsLayer.ServerGetMapUrl = curTerrainAccessorType.DownloadableWMSSet.ServerGetMapUrl.Value;
				wmsLayer.Version = curTerrainAccessorType.DownloadableWMSSet.Version.Value;
				wmsLayer.WMSLayerName = curTerrainAccessorType.DownloadableWMSSet.WMSLayerName.Value;

				if(curTerrainAccessorType.DownloadableWMSSet.HasUsername())
					wmsLayer.Username = curTerrainAccessorType.DownloadableWMSSet.Username.Value;

				if(curTerrainAccessorType.DownloadableWMSSet.HasPassword())
					wmsLayer.Password = curTerrainAccessorType.DownloadableWMSSet.Password.Value;

				if(curTerrainAccessorType.DownloadableWMSSet.HasWMSLayerStyle())
					wmsLayer.WMSLayerStyle = curTerrainAccessorType.DownloadableWMSSet.WMSLayerStyle.Value;
				else
					wmsLayer.WMSLayerStyle = "";

				if(curTerrainAccessorType.DownloadableWMSSet.HasBoundingBoxOverlap())
					wmsLayer.BoundingBoxOverlap = curTerrainAccessorType.DownloadableWMSSet.BoundingBoxOverlap.DoubleValue();

				return new NltTerrainAccessor(
					curTerrainAccessorType.Name.Value,
					west,
					south,
					east,
					north,
					wmsLayer,
					subsets
					);
					*/
			}
			else if(curTerrainAccessorType.HasTerrainTileService())
			{
				/*string serverUrl = curTerrainAccessorType.TerrainTileService.ServerUrl.Value;
				double levelZeroTileSizeDegrees = curTerrainAccessorType.TerrainTileService.LevelZeroTileSizeDegrees.DoubleValue();
				int numberLevels = curTerrainAccessorType.TerrainTileService.NumberLevels.Value;
				int samplesPerTile = curTerrainAccessorType.TerrainTileService.SamplesPerTile.Value;
				string fileExtension = curTerrainAccessorType.TerrainTileService.FileExtension.Value;

				TerrainTileService tts = new TerrainTileService(
					serverUrl,
					curTerrainAccessorType.TerrainTileService.DataSetName.Value,
					levelZeroTileSizeDegrees,
					samplesPerTile,
					fileExtension,
					numberLevels,
					Path.Combine(this.worldWindow.Cache.CacheDirectory,
					Path.Combine(Path.Combine( worldWindow.CurrentWorld.Name, "TerrainAccessor"), curTerrainAccessorType.Name.Value )));

				return new NltTerrainAccessor(
					curTerrainAccessorType.Name.Value,
					west,
					south,
					east,
					north,
					tts,
					subsets
					);*/
			}

			return null;
		}
Пример #2
0
        /*
        private static void addWater(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable)
        {
            if (iter.Count > 0)
            {
                while (iter.MoveNext())
                {
                    string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                    bool isBumpMapped = getInnerTextFromFirstChild(iter.Current.Select("EffectType")).Equals("Bump");
                    float lat = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("Latitude")));
                    float lon = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("Longitude")));
                    float alt = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
                    float scaleFactor = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("ScaleFactor")));
                    /*
                    float rotX = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                        .Select("RotationX")));
                    float rotY = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                        .Select("RotationY")));
                    float rotZ = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                        .Select("RotationZ")));
                    */
	    /*
                    Water waterbody = new Water(name, parentWorld,isBumpMapped,lat,lon,alt,scaleFactor);
                    parentRenderable.Add(waterbody);
                }
            }
        }
        */ 

		private static TerrainAccessor[] getTerrainAccessorsFromXPathNodeIterator(XPathNodeIterator iter, string cacheDirectory)
		{
			System.Collections.ArrayList terrainAccessorList = new System.Collections.ArrayList();

			while(iter.MoveNext())
			{
				string terrainAccessorName = iter.Current.GetAttribute("Name", "");
				if(terrainAccessorName == null)
				{
					// TODO: Throw exception?
					continue;
				}

				XPathNodeIterator latLonBoxIter = iter.Current.Select("LatLonBoundingBox");
				if(latLonBoxIter.Count != 1)
				{
					// TODO: Throw exception?
					continue;
				}
				
				double north = 0;
				double south = 0;
				double west = 0;
				double east = 0;

				latLonBoxIter.MoveNext();

				north = ParseDouble(getInnerTextFromFirstChild(latLonBoxIter.Current.Select("North")));
				south = ParseDouble(getInnerTextFromFirstChild(latLonBoxIter.Current.Select("South")));
				west = ParseDouble(getInnerTextFromFirstChild(latLonBoxIter.Current.Select("West")));
				east = ParseDouble(getInnerTextFromFirstChild(latLonBoxIter.Current.Select("East")));
				

				TerrainAccessor[] higerResolutionSubsets = getTerrainAccessorsFromXPathNodeIterator(
					iter.Current.Select("HigherResolutionSubsets"),
					Path.Combine(cacheDirectory, terrainAccessorName));

				XPathNodeIterator tileServiceIter = iter.Current.Select("TerrainTileService");
				if(tileServiceIter.Count == 1)
				{
					string serverUrl = null;
					string dataSetName = null;
					double levelZeroTileSizeDegrees = double.NaN;
					uint numberLevels = 0;
					uint samplesPerTile = 0;
					string dataFormat = null;
					string fileExtension = null;
					string compressionType = null;

					tileServiceIter.MoveNext();
					
					serverUrl = getInnerTextFromFirstChild(tileServiceIter.Current.Select("ServerUrl"));
					dataSetName = getInnerTextFromFirstChild(tileServiceIter.Current.Select("DataSetName"));
					levelZeroTileSizeDegrees = ParseDouble(getInnerTextFromFirstChild(tileServiceIter.Current.Select("LevelZeroTileSizeDegrees")));
					numberLevels = uint.Parse(getInnerTextFromFirstChild(tileServiceIter.Current.Select("NumberLevels")));
					samplesPerTile = uint.Parse(getInnerTextFromFirstChild(tileServiceIter.Current.Select("SamplesPerTile")));
					dataFormat = getInnerTextFromFirstChild(tileServiceIter.Current.Select("DataFormat"));
					fileExtension = getInnerTextFromFirstChild(tileServiceIter.Current.Select("FileExtension"));
					compressionType = getInnerTextFromFirstChild(tileServiceIter.Current.Select("CompressonType"));

					TerrainTileService tts = new TerrainTileService(
						serverUrl,
						dataSetName,
						levelZeroTileSizeDegrees,
						(int)samplesPerTile,
						fileExtension,
						(int)numberLevels,
						Path.Combine(cacheDirectory, terrainAccessorName),
						World.Settings.TerrainTileRetryInterval,
						dataFormat);

					TerrainAccessor newTerrainAccessor = new NltTerrainAccessor(
						terrainAccessorName,
						west,
						south,
						east,
						north,
						tts,
						higerResolutionSubsets);

					terrainAccessorList.Add(newTerrainAccessor);
				}
				//TODO: Add Floating point terrain Accessor code
				//TODO: Add WMSAccessor code and make it work in TerrainAccessor (which it currently doesn't)
			}

			if(terrainAccessorList.Count > 0)
			{
				return (TerrainAccessor[])terrainAccessorList.ToArray(typeof(TerrainAccessor));
			}
			else
			{
				return null;
			}
		}