コード例 #1
0
ファイル: BlueMarbleBuilder.cs プロジェクト: paladin74/Dapple
        internal BlueMarbleBuilder()
            : base("Blue Marble", MainForm.WorldWindowSingleton, null)
        {
            ImageLayer oBaseLayer = new WorldWind.Renderable.ImageLayer(
            "Blue Marble ImageLayer",
            MainForm.WorldWindowSingleton.CurrentWorld,
            0,
            String.Format(CultureInfo.InvariantCulture, "{0}\\Data\\Earth\\BmngBathy\\world.topo.bathy.2004{1:D2}.jpg", Path.GetDirectoryName(Application.ExecutablePath), 7),
            -90, 90, -180, 180, 1.0f, null);

             WorldWind.NltImageStore imageStore = new WorldWind.NltImageStore(String.Format(CultureInfo.InvariantCulture, "bmng.topo.bathy.2004{0:D2}", 7), "http://worldwind25.arc.nasa.gov/tile/tile.aspx");
             imageStore.DataDirectory = null;
             imageStore.LevelZeroTileSizeDegrees = 36.0;
             imageStore.LevelCount = 5;
             imageStore.ImageExtension = "jpg";
             imageStore.CacheDirectory = MainForm.WorldWindowSingleton.Cache.CacheDirectory + "\\Earth\\BMNG\\";

             WorldWind.ImageStore[] ias = new WorldWind.ImageStore[1];
             ias[0] = imageStore;

             QuadTileSet oTiledBaseLayer = new WorldWind.Renderable.QuadTileSet(
                 "Blue Marble QuadTileSet",
                 MainForm.WorldWindowSingleton.CurrentWorld,
                 0,
                 90, -90, -180, 180, true, ias);

             RenderableObjectList oRenderableList = new RenderableObjectList("This name doesn't matter, it gets rewritten");
             oRenderableList.Add(oBaseLayer);
             oRenderableList.Add(oTiledBaseLayer);
             oRenderableList.RenderPriority = RenderPriority.TerrainMappedImages;

             m_hObject = oRenderableList;
        }
コード例 #2
0
        private void compareRefreshLists(RenderableObjectList newList, RenderableObjectList curList)
        {
            ArrayList addList = new ArrayList();
            ArrayList delList = new ArrayList();

            foreach (RenderableObject newObject in newList.ChildObjects)
            {
                bool foundObject = false;
                foreach (RenderableObject curObject in curList.ChildObjects)
                {
                    string xmlSource = curObject.MetaData["XmlSource"] as string;

                    if (xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
                    {
                        foundObject = true;
                        UpdateRenderable(curObject, newObject);
                        break;
                    }
                }

                if (!foundObject)
                {
                    addList.Add(newObject);
                }
            }

            foreach (RenderableObject curObject in curList.ChildObjects)
            {
                bool foundObject = false;
                foreach (RenderableObject newObject in newList.ChildObjects)
                {
                    string xmlSource = newObject.MetaData["XmlSource"] as string;
                    if (xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
                    {
                        foundObject = true;
                        break;
                    }
                }

                if (!foundObject)
                {
                    string src = (string)curObject.MetaData["XmlSource"];

                    if (src != null || src == m_DataSource)
                    {
                        delList.Add(curObject);
                    }
                }
            }

            foreach (RenderableObject o in addList)
            {
                curList.Add(o);
            }

            foreach (RenderableObject o in delList)
            {
                curList.Remove(o);
            }
        }
コード例 #3
0
        /// <summary>
        /// Return a list of all direct and indirect children that match the given name and/or object type.
        /// </summary>
        /// <example> Get all QuadTileSets defined in this world:
        /// <code>
        /// RenderableObjectList allQTS = CurrentWorld.RenderableObjects.GetObjects(null, typeof(QuadTileSet));
        /// </code></example>
        /// <param name="name">The name of the <c>RenderableObject</c> to search for, or <c>null</c> if any name should match.</param>
        /// <param name="objectType">The object type to search for, or <c>null</c> if any type should match.</param>
        /// <returns>A list of all <c>RenderableObject</c>s that match the given search criteria (may be empty), or <c>null</c> if an error occurred.</returns>
        public virtual RenderableObjectList GetObjects(string name, Type objectType)
        {
            RenderableObjectList result = new RenderableObjectList("results");

            m_childrenRWLock.AcquireReaderLock(Timeout.Infinite);
            try
            {
                foreach (RenderableObject ro in this.m_children)
                {
                    if (ro.GetType() == typeof(RenderableObjectList))
                    {
                        RenderableObjectList sub = ro as RenderableObjectList;

                        RenderableObjectList subres = sub.GetObjects(name, objectType);
                        foreach (RenderableObject hit in subres.ChildObjects)
                        {
                            result.Add(hit);
                        }
                    }
                    if (ro.Name.Equals(name) && ((objectType == null) || (ro.GetType() == objectType)))
                    {
                        result.Add(ro);
                    }
                }
            }
            catch
            {
                result = null;
            }
            finally
            {
                m_childrenRWLock.ReleaseReaderLock();
            }

            return(result);
        }
コード例 #4
0
		/// <summary>
		/// Plugin entry point - All plugins must implement this function
		/// </summary>
		public override void Load()
		{
			m_BaseList = new RenderableObjectList("Satellite Tracker");

			m_SatElementsList = new WorldWind.Renderable.RenderableObjectList[tleList.Length - 1];
			string LayerName = "";
			for(int x = 0; x < tleList.Length-1; x++)
			{
				int start = tleList[x].LastIndexOf("/")+1;
				int end = tleList[x].LastIndexOf(@".");
				LayerName = tleList[x].Substring(start,end-start);
				//Create each URLs Layer
				m_SatElementsList[x] = new SatelliteTrackerOverlay(this, LayerName.ToUpper(), tleList[x]);
				//Add each URL s Layer to the display
				m_BaseList.Add(m_SatElementsList[x]);
			}
			m_BaseList.IsOn = true;
			//satOverLays = new SatelliteTrackerOverlay(this);
			Application.WorldWindow.CurrentWorld.RenderableObjects.Add(m_BaseList);
		}
コード例 #5
0
		private void compareRefreshLists(RenderableObjectList newList, RenderableObjectList curList)
		{
			ArrayList addList = new ArrayList();
			ArrayList delList = new ArrayList();

			foreach(RenderableObject newObject in newList.ChildObjects)
			{
				bool foundObject = false;
				foreach(RenderableObject curObject in curList.ChildObjects)
				{
					string xmlSource = curObject.MetaData["XmlSource"] as string;
						
					if(xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
					{
						foundObject = true;
						UpdateRenderable(curObject, newObject);
						break;
					}
				}

				if(!foundObject)
				{
					addList.Add(newObject);
				}
			}

			foreach(RenderableObject curObject in curList.ChildObjects)
			{
				bool foundObject = false;
				foreach(RenderableObject newObject in newList.ChildObjects)
				{
					string xmlSource = newObject.MetaData["XmlSource"] as string;
					if(xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
					{
						foundObject = true;
						break;
					}
				}

				if(!foundObject)
				{
					string src = (string)curObject.MetaData["XmlSource"];

					if(src != null || src == m_DataSource)
						delList.Add(curObject);
				}
			}

			foreach(RenderableObject o in addList)
			{
				curList.Add(o);
			}

			foreach(RenderableObject o in delList)
			{
				curList.Remove(o);
			}
		}
コード例 #6
0
        /// <summary>
        /// Add a child object to this layer.  If the new object has the same name as an existing object in this
        /// ROL it gets a number appended.  If the new object is a ROL and there was already a ROL with the same
        /// name then the children of the new ROL gets added to the old ROL.
        ///
        /// Not sure who uses this but the functionality was kept this way.
        /// </summary>
        public virtual void Add(RenderableObject ro)
        {
            ro.ParentList = this;

            RenderableObjectList dupList   = null;
            RenderableObject     duplicate = null;

            // We get a write lock here because if you get a reader lock and then upgrade
            // the data can change on us before we get the write lock.
            //
            // This is somewhat unfortunate since we spend a bit of time going through the
            // child list.
            //
            // if we can't get the writer lock in 2 seconds something is probably borked
            if (GetWriterLock(200))
            {
                try
                {
                    // find duplicate names
                    foreach (RenderableObject childRo in m_children)
                    {
                        if (childRo is RenderableObjectList &&
                            ro is RenderableObjectList &&
                            childRo.Name == ro.Name)
                        {
                            dupList = (RenderableObjectList)childRo;
                            break;
                        }
                        else if (childRo.Name == ro.Name)
                        {
                            duplicate = childRo;
                            break;
                        }
                    }


                    // if we have two ROLs with the same name, don't rename the new ROL but add the children of the new ROL to the
                    // existing ROL.
                    if (dupList != null)
                    {
                        RenderableObjectList rol = (RenderableObjectList)ro;

                        foreach (RenderableObject childRo in rol.ChildObjects)
                        {
                            dupList.Add(childRo);
                        }
                    }
                    else
                    {
                        // Try to find an unused number for this name
                        if (duplicate != null)
                        {
                            for (int i = 1; i < 1000; i++)
                            {
                                ro.Name = string.Format("{0} [{1}]", duplicate.Name, i);
                                bool found = false;

                                foreach (RenderableObject childRo in m_children)
                                {
                                    if (childRo.Name == ro.Name)
                                    {
                                        found = true;
                                        break;
                                    }
                                }

                                if (!found)
                                {
                                    break;
                                }
                            }
                        }

                        // Add the new child
                        m_children.Add(ro);

                        // Resort during the next update
                        // NeedsSort = true;
                    }
                }
                finally
                {
                    m_childrenRWLock.ReleaseWriterLock();
                }
            }
            else
            {
                MessageBox.Show("Unable to add new object " + ro.Name);
            }
        }
コード例 #7
0
		/// <summary>
		/// This method Loads a shapefile 
		/// </summary>
		/// <param name="shapeConfigFilePath">Full Path to the Shapefiles XML configuration file</param>
		/// <param name="checkForUpdate">true if it should check for a newer version of the shapefile</param>
		public void loadShapeFileWithAlreadyExistingXML(string shapeConfigFilePath, bool checkForUpdate)
		{
			//Check for updates
			if(checkForUpdate)
			{
				try
				{
					XmlDocument doc=new XmlDocument();
					doc.Load(shapeConfigFilePath);  
					string downloadURL;
					
					if((downloadURL=doc.SelectSingleNode("/LayerSet/DownloadPage/URL").InnerText)!="")
					{
						if(checkIfUpdateNeeded(downloadURL,shapeConfigFilePath))
						{
							//Update xml+files
							UpdateXMLAndFiles(shapeConfigFilePath, downloadURL);								
						}
					}
				}
				catch{}
			}


			XPathNavigator nav;
			XPathDocument docNav;
			
			// Open the XML.
			docNav = new XPathDocument(shapeConfigFilePath);			

			// Create a navigator to query with XPath.
			nav = docNav.CreateNavigator();

			XPathNodeIterator layersetIter = nav.Select("/LayerSet");
			if(layersetIter.Count > 0)
			{
				while(layersetIter.MoveNext())
				{
					string layersetName = layersetIter.Current.GetAttribute("Name","");
					if(layersetName == null)
						continue;
					string showOnlyOneLayerString = layersetIter.Current.GetAttribute("ShowOnlyOneLayer", "");
					string showAtStartupString = layersetIter.Current.GetAttribute("ShowAtStartup", "");
					bool showOnlyOneLayer = false;
					bool showAtStartup = false;
					try
					{
						showOnlyOneLayer = ParseBool(showOnlyOneLayerString);
						
					}
					catch(Exception)
					{
					}

					try
					{
						showAtStartup = ParseBool(showAtStartupString);
					}
					catch{}
					
					WorldWind.Renderable.RenderableObjectList newLayerSetList
						= new RenderableObjectList(layersetName);					
					
					newLayerSetList.ShowOnlyOneLayer = showOnlyOneLayer;
					
					newLayerSetList.ParentList = ParentApplication.WorldWindow.CurrentWorld.RenderableObjects;					
					
					if(World.Settings.UseDefaultLayerStates)
					{
						newLayerSetList.IsOn = showAtStartup;
					}
					else
					{
						newLayerSetList.IsOn = ConfigurationLoader.IsLayerOn(newLayerSetList);
					}
					XPathNodeIterator shapeIter = layersetIter.Current.Select("ShapeFileDescriptor");
					if(shapeIter.Count > 0)
					{
						while(shapeIter.MoveNext())
						{
							string name = getInnerTextFromFirstChild(shapeIter.Current.Select("Name"));
							string shapeFilePath = getInnerTextFromFirstChild(shapeIter.Current.Select("ShapeFilePath"));
							string dataKey = getInnerTextFromFirstChild(shapeIter.Current.Select("DataKey"));

							string showLabelsString = getInnerTextFromFirstChild(shapeIter.Current.Select("ShowLabels"));
							string polygonFillString = getInnerTextFromFirstChild(shapeIter.Current.Select("PolygonFill"));
							string outlinePolygonsString = getInnerTextFromFirstChild(shapeIter.Current.Select("OutlinePolygons"));
							string lineWidthString = getInnerTextFromFirstChild(shapeIter.Current.Select("LineWidth"));
							string iconFilePath = getInnerTextFromFirstChild(shapeIter.Current.Select("IconFilePath"));
							string iconWidthString = getInnerTextFromFirstChild(shapeIter.Current.Select("IconWidth"));
							string iconHeightString = getInnerTextFromFirstChild(shapeIter.Current.Select("IconHeight"));
							string iconOpacityString = getInnerTextFromFirstChild(shapeIter.Current.Select("IconOpacity"));
							string scaleColorsToDataString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScaleColorsToData"));

							/*Altitude Rendering*/
							string maxAltString = getInnerTextFromFirstChild(shapeIter.Current.Select("MaxAltitude"));
							string minAltString = getInnerTextFromFirstChild(shapeIter.Current.Select("MinAltitude"));

							/*Tile Size Rendering*/
							string lztsdString = getInnerTextFromFirstChild(shapeIter.Current.Select("LevelZeroTileSize"));

							/*LatLong Bounding Box*/
							string northString = getInnerTextFromFirstChild(shapeIter.Current.Select("North"));
							string southString = getInnerTextFromFirstChild(shapeIter.Current.Select("South"));
							string eastString = getInnerTextFromFirstChild(shapeIter.Current.Select("East"));
							string westString = getInnerTextFromFirstChild(shapeIter.Current.Select("West"));

							/*Opacity added by Argon helm*/
							string layerOpacityString = getInnerTextFromFirstChild(shapeIter.Current.Select("LayerOpacity")); 
							
							bool showLabels = false;
							bool polygonFill = false;
							float lineWidth = 1.0f;
							bool outlinePolygons = false;
							bool scaleColorsToData = false;
							int iconWidth = 32;
							int iconHeight = 32;
							byte iconOpacity = 255;

							/*Layer Opacity added by Argon Helm*/
							byte layerOpacity = 255; 

							/*Altitude Rendering*/
							double maxAlt = double.MaxValue;
							double minAlt = 0;

							/*Tile Size Rendering*/
							float lztsd = 180.0f/5;

							/*LatLong Bounding Box*/
							GeographicBoundingBox bounds = new GeographicBoundingBox(90.0,-90,-180.0,180.0);

							System.Drawing.Color lineColor = System.Drawing.Color.Black;
							System.Drawing.Color polygonColor = System.Drawing.Color.Black;
							System.Drawing.Color labelColor = System.Drawing.Color.White;
							WorldWind.ShapeFillStyle shapeFillStyle = getShapeFillStyleFromString(getInnerTextFromFirstChild(shapeIter.Current.Select("PolygonFillStyle")));

							XPathNodeIterator lineColorIter = shapeIter.Current.Select("LineColor");
							if(lineColorIter.Count > 0)
							{
								lineColor = getColorFromXPathIter(lineColorIter);
							}

							XPathNodeIterator polygonColorIter = shapeIter.Current.Select("PolygonColor");
							if(polygonColorIter.Count > 0)
							{
								polygonColor = getColorFromXPathIter(polygonColorIter);
							}

							XPathNodeIterator labelColorIter = shapeIter.Current.Select("LabelColor");
							if(labelColorIter.Count > 0)
							{
								labelColor = getColorFromXPathIter(labelColorIter);
							}

							showAtStartupString = shapeIter.Current.GetAttribute("ShowAtStartup","");
							try
							{
								if(showAtStartupString != null)
								{
									showAtStartup = ParseBool(showAtStartupString);
								}
								else
								{
									showAtStartup = false;
								}

								if(scaleColorsToDataString != null)
								{
									scaleColorsToData = ParseBool(scaleColorsToDataString);
								}
								
								if(showLabelsString != null)
								{
									showLabels = ParseBool(showLabelsString);
								}

								if(polygonFillString != null)
								{
									polygonFill = ParseBool(polygonFillString);
								}

								if(lineWidthString != null)
								{
									lineWidth = float.Parse(lineWidthString);
								}

								if(outlinePolygonsString != null)
								{
									outlinePolygons = ParseBool(outlinePolygonsString);
								}
								if(iconHeightString != null)
								{
									iconHeight = int.Parse(iconHeightString);
								}
								if(iconWidthString != null)
								{
									iconWidth = int.Parse(iconWidthString);
								}
								if(iconOpacityString != null)
								{
									iconOpacity = byte.Parse(iconOpacityString);
								}
								/*Altitude Rendering*/
								if(minAltString!=null)
								{
									minAlt=ParseDouble(minAltString);
								}
								if(maxAltString!=null)
								{
									maxAlt=ParseDouble(maxAltString);
								}

								/*Lztsd rendering*/
								if(lztsdString!=null)
								{
									lztsd=float.Parse(lztsdString);
								}

								/*latlon bounds*/
								if(northString!=null&&southString!=null&&westString!=null&&eastString!=null)
								{
									bounds = new GeographicBoundingBox(ParseDouble(northString),
										ParseDouble(southString),
										ParseDouble(westString),
										ParseDouble(eastString));
								}
								/*Layer Opacity added by argon helm*/
								if(layerOpacityString != null) 
								{
									layerOpacity = byte.Parse(layerOpacityString);
								}
							}
							catch(Exception ex)
							{
								Log.Write(ex);
							}
							string scalarMinString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScalarMin"));
							string scalarMaxString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScalarMax"));
							string scalarFilterMinString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScalarFilterMin"));
							string scalarFilterMaxString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScalarFilterMax"));
							string[] noDataValues = getStringValues(shapeIter.Current.Select("NoDataValue"));
							string[] activeDataValues = getStringValues(shapeIter.Current.Select("ActiveDataValue"));

							double scalarMin = double.NaN;
							double scalarMax = double.NaN;
							double scalarFilterMin = double.NaN;
							double scalarFilterMax = double.NaN;
							
							if(scalarMinString != null)
							{
								scalarMin = ParseDouble(scalarMinString);
							}

							if(scalarMaxString != null)
							{
								scalarMax = ParseDouble(scalarMaxString);
							}

							if(scalarFilterMinString != null)
							{
								scalarFilterMin = ParseDouble(scalarFilterMinString);
							}

							if(scalarFilterMaxString != null)
							{
								scalarFilterMax = ParseDouble(scalarFilterMaxString);
							}							
							/*if(!Path.IsPathRooted(shapeFilePath))
							{
								shapeFilePath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\" + shapeFilePath;
							}*/
							//path is relative to xml file not to executing apps directory
							if(!Path.IsPathRooted(shapeFilePath))
							{
								shapeFilePath = shapeConfigFilePath.Remove(
									shapeConfigFilePath.LastIndexOfAny(new char[]{'\\','/'}),
									shapeConfigFilePath.Length-
									shapeConfigFilePath.LastIndexOfAny(new char[]{'\\','/'})) 
									+ "\\" + shapeFilePath;
							}

							

							WorldWind.ShapeFileLayer shapeFileLayer = new ShapeFileLayer(
								name,
								ParentApplication.WorldWindow.CurrentWorld,
								shapeFilePath,
								minAlt,
								maxAlt,
								lztsd,
								bounds,
								dataKey,
								scaleColorsToData,
								scalarFilterMin,
								scalarFilterMax,
								scalarMin,
								scalarMax,
								noDataValues,
								activeDataValues,
								polygonFill,
								outlinePolygons,
								polygonColor,
								shapeFillStyle,
								lineColor,
								lineWidth,
								showLabels,
								labelColor,
								Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\" + iconFilePath,
								iconWidth,
								iconHeight,
								iconOpacity
								);

							/*Layer Opacity added by Argon Helm*/
							shapeFileLayer.Opacity = layerOpacity;
							shapeFileLayer.ParentList = newLayerSetList;

							// this goes after opacity because setting opacity "turns on" a renderable object
							if(World.Settings.UseDefaultLayerStates)
							{
								shapeFileLayer.IsOn = showAtStartup;
							}
							else
							{
								shapeFileLayer.IsOn = ConfigurationLoader.IsLayerOn(shapeFileLayer);
							}			
							if(shapeFilePath.ToLower().EndsWith(".shp"))
							{								
								shapeFileLayer.dbfPath=Path.ChangeExtension(shapeFilePath,".dbf");
								shapeFileLayer.dbfIsInZip=false;								
							}
							else if(shapeFilePath.ToLower().EndsWith(".zip"))
							{
								shapeFileLayer.dbfIsInZip=true;
								shapeFileLayer.dbfPath=shapeFilePath;								
							}
							newLayerSetList.Add(shapeFileLayer);
							
						}
					}

					ParentApplication.WorldWindow.CurrentWorld.RenderableObjects.Add(newLayerSetList);

					
				}
			}			
			
		}
コード例 #8
0
		private static void addQuadTileLayersFromXPathNodeIterator(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
		{
			while(iter.MoveNext())
			{
                string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
				bool showAtStartup = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));

                Log.Write(Log.Levels.Debug+1, "CONF", "adding QuadTileSet "+name);

				double north = 0;
				double south = 0;
				double west = 0;
				double east = 0;
				
				XPathNodeIterator boundingBoxIter = iter.Current.Select("BoundingBox");
				if(boundingBoxIter.Count > 0)
				{
					boundingBoxIter.MoveNext();
					north = ParseDouble(getInnerTextFromFirstChild(boundingBoxIter.Current.Select("North")));
					south = ParseDouble(getInnerTextFromFirstChild(boundingBoxIter.Current.Select("South")));
					west = ParseDouble(getInnerTextFromFirstChild(boundingBoxIter.Current.Select("West")));
					east = ParseDouble(getInnerTextFromFirstChild(boundingBoxIter.Current.Select("East")));
				}

				string terrainMappedString = getInnerTextFromFirstChild(iter.Current.Select("TerrainMapped"));
				string renderStrutsString = getInnerTextFromFirstChild(iter.Current.Select("RenderStruts"));

				TimeSpan dataExpiration = getCacheExpiration(iter.Current.Select("CacheExpirationTime"));
				
				bool terrainMapped = true;

				if(terrainMappedString != null)
				{
					terrainMapped = ParseBool(terrainMappedString);
				}
				XPathNodeIterator imageAccessorIter = iter.Current.Select("descendant::ImageAccessor");

                if (imageAccessorIter.Count == 0)
                {
                    Log.Write(Log.Levels.Warning, "CONF", "skipping QuadTileSet without any ImageAccessor");
                    return;
                }

                int currentStore = 0;
                ImageStore[] imageStores = new ImageStore[imageAccessorIter.Count];

                while (imageAccessorIter.MoveNext())
                {
                    imageStores[currentStore] = getImageStoreFromXPathNodeIterator(name, imageAccessorIter, parentRenderable, cache);
                    currentStore++;
                }

				QuadTileSet qts = null;

				qts = new QuadTileSet(
					name,
					parentWorld,
					distanceAboveSurface,
					north,
					south,
					west,
					east,
					terrainMapped,
					imageStores
					);
                if(imageStores[0].IsDownloadableLayer)
                    qts.ServerLogoFilePath = imageStores[0].ServerLogo;

				qts.CacheExpirationTime = dataExpiration;

				string infoUri = iter.Current.GetAttribute("InfoUri", "");

				if(infoUri != null && infoUri.Length > 0)
				{
					if(qts.MetaData.Contains("InfoUri"))
					{
						qts.MetaData["InfoUri"] = infoUri;
					}
					else
					{
						qts.MetaData.Add("InfoUri", infoUri);
					}
				}

                string effectFile = getInnerTextFromFirstChild(iter.Current.Select("Effect"));
                if (effectFile != null && effectFile.Length > 0)
                {
                    Log.Write(Log.Levels.Debug, "CONF", "QuadTileSet with effect " + effectFile);
                    if (qts.MetaData.Contains("EffectPath"))
                    {
                        qts.MetaData["EffectPath"] = effectFile;
                    }
                    else
                    {
                        qts.MetaData.Add("EffectPath", effectFile);
                    }
                }


				string description = getInnerTextFromFirstChild(iter.Current.Select("Description"));
				if(description != null && description.Length > 0)
					qts.Description = description;

				if(iter.Current.Select("TransparentColor").Count > 0)
				{
					System.Drawing.Color c = getColor(iter.Current.Select("TransparentColor"));
					qts.ColorKey = c.ToArgb();
				}

				if(iter.Current.Select("TransparentMinValue").Count > 0)
				{
					qts.ColorKey = int.Parse(getInnerTextFromFirstChild(iter.Current.Select("TransparentMinValue")));
				}

				if(iter.Current.Select("TransparentMaxValue").Count > 0)
				{
					qts.ColorKeyMax = int.Parse(getInnerTextFromFirstChild(iter.Current.Select("TransparentMaxValue")));
				}

				if(renderStrutsString != null)
				{
					qts.RenderStruts = ParseBool(renderStrutsString);
				}

				qts.ParentList = parentRenderable;
				if(World.Settings.useDefaultLayerStates)
				{
					qts.IsOn = showAtStartup;
				}
				else
				{
					qts.IsOn = IsLayerOn(qts);
				}

				qts.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);
				addExtendedInformation(iter.Current.Select("ExtendedInformation"), qts);
				parentRenderable.Add(qts);
			}
		}
コード例 #9
0
ファイル: WavingFlags.cs プロジェクト: jpespartero/WorldWind
        /// <summary>
        /// Plugin entry point - All plugins must implement this function
        /// </summary>
        public override void Load()
        {
            FileInfo savedFile = new FileInfo(SavedFilePath);
            if (!savedFile.Exists)
            {
                if (!savedFile.Directory.Exists)
                    savedFile.Directory.Create();

                try
                {
                    WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(DataFileUri);
                    download.DownloadFile(savedFile.FullName);
                    download.Dispose();
                }
                catch { }
            }

            m_wavingFlagsList = new RenderableObjectList("Waving Flags");
            m_wavingFlagsList.IsOn = false;
            System.Collections.Hashtable countryHash = new System.Collections.Hashtable();

            using (StreamReader reader = savedFile.OpenText())
            {
                string header = reader.ReadLine();
                string[] headers = header.Split('\t');

                string line = reader.ReadLine();
                while (line != null)
                {
                    System.Collections.Hashtable fieldHash = new System.Collections.Hashtable();
                    string[] lineParts = line.Split('\t');

                    //Log.Write(string.Format("{0}\t{1}", lineParts[0], lineParts[1]));
                    try
                    {
                        double latitude = double.Parse(lineParts[3], System.Globalization.CultureInfo.InvariantCulture);
                        double longitude = double.Parse(lineParts[4], System.Globalization.CultureInfo.InvariantCulture);

                        if (lineParts[1].Length == 2)
                        {
                            string flagFileUri = FlagTextureDirectoryUri + "/" + lineParts[1] + FlagSuffix;
                            FileInfo savedFlagFile = new FileInfo(SavedFlagsDirectory + "\\" + lineParts[1] + ".dds");

                            WavingFlagLayer flag = new WavingFlagLayer(
                                lineParts[0],
                                ParentApplication.WorldWindow.CurrentWorld,
                                latitude,
                                longitude,
                                flagFileUri);

                            flag.SavedImagePath = savedFlagFile.FullName;
                            flag.ScaleX = 100000;
                            flag.ScaleY = 100000;
                            flag.ScaleZ = 100000;
                            flag.Bar3D = new Bar3D(flag.Name, flag.World, latitude, longitude, 0, flag.ScaleZ, System.Drawing.Color.Red);
                            flag.Bar3D.ScaleX = 0.3f * flag.ScaleX;
                            flag.Bar3D.ScaleY = 0.3f * flag.ScaleY;
                            flag.Bar3D.IsOn = false;
                            flag.RenderPriority = RenderPriority.Custom;

                            flag.OnMouseEnterEvent += new EventHandler(flag_OnMouseEnterEvent);
                            flag.OnMouseLeaveEvent += new EventHandler(flag_OnMouseLeaveEvent);
                            flag.OnMouseUpEvent += new System.Windows.Forms.MouseEventHandler(flag_OnMouseUpEvent);
                            m_wavingFlagsList.Add(flag);

                            for (int i = 0; i < lineParts.Length; i++)
                            {
                                try
                                {
                                    double value = double.Parse(lineParts[i], System.Globalization.CultureInfo.InvariantCulture);
                                    fieldHash.Add(headers[i], value);
                                }
                                catch
                                {
                                    fieldHash.Add(headers[i], lineParts[i]);
                                }
                            }
                            countryHash.Add(lineParts[0], fieldHash);
                        }
                        else
                        {
                            //Log.Write(Log.Levels.Debug, "blank: " + lineParts[0]);
                        }
                    }
                    catch(Exception ex)
                    {
                        Log.Write(Log.Levels.Warning, string.Format("Exception: {0} - {1}", lineParts[0], ex.ToString()));
                    }

                    line = reader.ReadLine();
                }
                Headers = headers;
            }
            
            CountryHash = countryHash;
            
            InitializeCiaForm();

            ParentApplication.WorldWindow.CurrentWorld.RenderableObjects.Add(m_wavingFlagsList);
        }
コード例 #10
0
        private static void addModelFeature(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable)
        {
            if (iter.Count > 0)
            {
                while (iter.MoveNext())
                {
                    string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                    float lat = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("Latitude")), CultureInfo.InvariantCulture);
                    float lon = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("Longitude")), CultureInfo.InvariantCulture);
                    float alt = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")), CultureInfo.InvariantCulture);
                    float scaleFactor = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.Select("ScaleFactor")), CultureInfo.InvariantCulture);
                    string meshFilePath = getInnerTextFromFirstChild(iter.Current.Select("MeshFilePath"));

                    float rotX = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                        .Select("RotationX")), CultureInfo.InvariantCulture);
                    float rotY = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                        .Select("RotationY")), CultureInfo.InvariantCulture);
                    float rotZ = Convert.ToSingle(getInnerTextFromFirstChild(iter.Current.SelectSingleNode("Orientation")
                        .Select("RotationZ")), CultureInfo.InvariantCulture);

                    ModelFeature model = new ModelFeature(name, parentWorld
                        , meshFilePath, lat, lon, alt,scaleFactor,rotX,rotY,rotZ);
                     if(iter.Current.Select("IsVerticalExaggerable").Count > 0)
                    {
						model.isVertExaggerable = Convert.ToBoolean(getInnerTextFromFirstChild(iter.Current.Select("IsVerticalExaggerable")));
					}
                    if(iter.Current.Select("IsElevationRelativeToGround").Count > 0)
                    {
						model.isElevationRelative2Ground = Convert.ToBoolean(getInnerTextFromFirstChild(iter.Current.Select("IsElevationRelativeToGround")));
					}
                   parentRenderable.Add(model);
                }
            }
        }
コード例 #11
0
		private static RenderableObjectList addChildLayerSet(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					string layerName = iter.Current.GetAttribute("Name", "");
					bool showAtStartup = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
					bool showOnlyOneLayer = ParseBool(iter.Current.GetAttribute("ShowOnlyOneLayer", ""));

					string redirect = iter.Current.GetAttribute("redirect", "");

					if(redirect != null && redirect.Length > 0)
					{
						return ConfigurationLoader.getRenderableFromLayerFile(redirect, parentWorld, cache);
					}

					RenderableObjectList rol = new RenderableObjectList(layerName);
					if(iter.Current.Select("Icon").Count > 0)
					{
						rol = new Icons(layerName);
					}
					
					rol.ParentList = parentRenderable;

					if(World.Settings.useDefaultLayerStates)
					{
						rol.IsOn = showAtStartup;
					}
					else
					{
						rol.IsOn = IsLayerOn(rol);
					}

					string disableExpansionString = iter.Current.GetAttribute("DisableExpansion", "");
					if(disableExpansionString != null)
					{
						rol.DisableExpansion = ParseBool(disableExpansionString);
					}


					rol.ShowOnlyOneLayer = showOnlyOneLayer;
					rol.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);

					string renderPriorityString = iter.Current.GetAttribute("RenderPriority", "");
					if(renderPriorityString != null)
					{
                        if (String.Compare(renderPriorityString, "Icons", false, System.Globalization.CultureInfo.InvariantCulture) == 0)
						{
							rol.RenderPriority = RenderPriority.Icons;
						}
                        else if (String.Compare(renderPriorityString, "LinePaths", false, System.Globalization.CultureInfo.InvariantCulture) == 0)
						{
							rol.RenderPriority = RenderPriority.LinePaths;
						}
                        else if (String.Compare(renderPriorityString, "Placenames", false, System.Globalization.CultureInfo.InvariantCulture) == 0)
						{
							rol.RenderPriority = RenderPriority.Placenames;
						}
                        else if (String.Compare(renderPriorityString, "AtmosphericImages", false, System.Globalization.CultureInfo.InvariantCulture) == 0)
						{
							rol.RenderPriority = RenderPriority.AtmosphericImages;
						}
					}

					string description = getInnerTextFromFirstChild(iter.Current.Select("Description"));
					if(description != null && description.Length > 0)
						rol.Description = description;

					string infoUri = iter.Current.GetAttribute("InfoUri", "");

					if(infoUri != null && infoUri.Length > 0)
					{
						if(rol.MetaData.Contains("InfoUri"))
						{
							rol.MetaData["InfoUri"] = infoUri;
						}
						else
						{
							rol.MetaData.Add("InfoUri", infoUri);
						}
					}

					addImageLayersFromXPathNodeIterator(iter.Current.Select("ImageLayer"), parentWorld, rol);
					addQuadTileLayersFromXPathNodeIterator(iter.Current.Select("QuadTileSet"), parentWorld, rol, cache);
					addPolygonFeature(iter.Current.Select("PolygonFeature"), parentWorld, rol);
					addLineFeature(iter.Current.Select("LineFeature"), parentWorld, rol);
					addPathList(iter.Current.Select("PathList"), parentWorld, rol);
					addTiledPlacenameSet(iter.Current.Select("TiledPlacenameSet"), parentWorld, rol);
					addIcon(iter.Current.Select("Icon"), parentWorld, rol, cache);
					addScreenOverlays(iter.Current.Select("ScreenOverlay"), parentWorld, rol, cache);
					addChildLayerSet(iter.Current.Select("ChildLayerSet"), parentWorld, rol, cache);

					addExtendedInformation(iter.Current.Select("ExtendedInformation"), rol);
					parentRenderable.Add(rol);
				}
			}

			return null;
		}
コード例 #12
0
        private static RenderableObjectList getRenderablesFromLayerDirectory(string layerDirectory, World parentWorld, Cache cache)
		{
			RenderableObjectList renderableCollection = new RenderableObjectList(parentWorld.Name);

			DirectoryInfo layerDir = new DirectoryInfo(layerDirectory);
			if(!layerDir.Exists)
			{
				return renderableCollection;
			}

			foreach(FileInfo layerFile in layerDir.GetFiles("*.xml"))
			{
				RenderableObjectList currentRenderable = getRenderableFromLayerFile(layerFile.FullName, parentWorld, cache);
				if(currentRenderable != null)
				{
					renderableCollection.Add(currentRenderable);
				}
			}

			return renderableCollection;
		}
コード例 #13
0
        private static void AddMesh(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
        {
            if (iter.Count > 0) {
                while (iter.MoveNext()) {
                    string isOn = iter.Current.GetAttribute("ShowAtStartup", "");
                    string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                    string distAbvSfc = getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface"));
                    string lat = getInnerTextFromFirstChild(iter.Current.Select("Latitude/Value"));
                    string lon = getInnerTextFromFirstChild(iter.Current.Select("Longitude/Value"));
                    string rotX = getInnerTextFromFirstChild(iter.Current.Select("Orientation/RotationX"));
                    string rotY = getInnerTextFromFirstChild(iter.Current.Select("Orientation/RotationY"));
                    string rotZ = getInnerTextFromFirstChild(iter.Current.Select("Orientation/RotationZ"));
                    string scale = getInnerTextFromFirstChild(iter.Current.Select("ScaleFactor"));
                    string minView = getInnerTextFromFirstChild(iter.Current.Select("MinViewRange"));
                    string maxView = getInnerTextFromFirstChild(iter.Current.Select("MaxViewRange"));
                    string filePath = getInnerTextFromFirstChild(iter.Current.Select("MeshFilePath"));

                    MeshLayer meshLayer = new MeshLayer(name, (float) ParseDouble(lat), (float) ParseDouble(lon), 6378137.0F, (float) ParseDouble(scale), filePath, new Quaternion());
                    meshLayer.ParentList = parentRenderable;
                    meshLayer.IsOn = ParseBool(isOn);
                    parentRenderable.Add(meshLayer);
                }
            }
        }
コード例 #14
0
        private static RenderableObjectList addChildLayerSet(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
        {
            if (iter.Count > 0) {
                while (iter.MoveNext()) {
                    string layerName = iter.Current.GetAttribute("Name", "");
                    bool showAtStartup = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
                    bool showOnlyOneLayer = ParseBool(iter.Current.GetAttribute("ShowOnlyOneLayer", ""));

                    string redirect = iter.Current.GetAttribute("redirect", "");

                    if (redirect != null
                        && redirect.Length > 0) {
                        return getRenderableFromLayerFile(redirect, parentWorld, cache);
                    }

                    RenderableObjectList rol;
                    if (iter.Current.Select("Icon").Count > 0) {
                        rol = new Icons(layerName);
                    }
                        #region by zzm
                    else if (iter.Current.Select("MyIcon").Count > 0) {
                        rol = new MyIcons(layerName);
                    }
                    else if (iter.Current.Select("MyChart").Count > 0) {
                        rol = new MyCharts(layerName);
                    }
                    else {
                        rol = new RenderableObjectList(layerName);
                    }
                    #endregion

                    rol.ParentList = parentRenderable;

                    if (World.Settings.useDefaultLayerStates) {
                        rol.IsOn = showAtStartup;
                    }
                    else {
                        rol.IsOn = IsLayerOn(rol);
                    }
                    rol.ShowOnlyOneLayer = showOnlyOneLayer;
                    rol.MetaData.Add("XmlSource", (string) parentRenderable.MetaData["XmlSource"]);

                    string renderPriorityString = iter.Current.GetAttribute("RenderPriority", "");
                    if (renderPriorityString != null) {
                        if (String.Compare(renderPriorityString, "Icons", false) == 0) {
                            rol.RenderPriority = RenderPriority.Icons;
                        }
                        else if (String.Compare(renderPriorityString, "LinePaths", false) == 0) {
                            rol.RenderPriority = RenderPriority.LinePaths;
                        }
                        else if (String.Compare(renderPriorityString, "Placenames", false) == 0) {
                            rol.RenderPriority = RenderPriority.Placenames;
                        }
                        else if (String.Compare(renderPriorityString, "AtmosphericImages", false) == 0) {
                            rol.RenderPriority = RenderPriority.AtmosphericImages;
                        }
                    }

                    string infoUri = iter.Current.GetAttribute("InfoUri", "");

                    if (infoUri != null
                        && infoUri.Length > 0) {
                        if (rol.MetaData.Contains("InfoUri")) {
                            rol.MetaData["InfoUri"] = infoUri;
                        }
                        else {
                            rol.MetaData.Add("InfoUri", infoUri);
                        }
                    }

                    addImageLayersFromXPathNodeIterator(iter.Current.Select("ImageLayer"), parentWorld, rol);
                    addQuadTileLayersFromXPathNodeIterator(iter.Current.Select("QuadTileSet"), parentWorld, rol, cache);
                    addPolygonFeature(iter.Current.Select("PolygonFeature"), parentWorld, rol);
                    addLineFeature(iter.Current.Select("LineFeature"), parentWorld, rol);
                    addPathList(iter.Current.Select("PathList"), parentWorld, rol);
                    addTiledPlacenameSet(iter.Current.Select("TiledPlacenameSet"), parentWorld, rol);
                    addIcon(iter.Current.Select("Icon"), parentWorld, rol, cache);
                    addScreenOverlays(iter.Current.Select("ScreenOverlay"), parentWorld, rol, cache);
                    addChildLayerSet(iter.Current.Select("ChildLayerSet"), parentWorld, rol, cache);

                    #region by zzm
                    AddMyIcon(iter.Current.Select("MyIcon"), parentWorld, rol, cache);
                    AddMyChart(iter.Current.Select("MyChart"), parentWorld, rol, cache);
                    AddMesh(iter.Current.Select("MeshLayer"), parentWorld, rol, cache);
                    #endregion

                    addExtendedInformation(iter.Current.Select("ExtendedInformation"), rol);
                    parentRenderable.Add(rol);
                }
            }

            return null;
        }
コード例 #15
0
        private static void addQuadTileLayersFromXPathNodeIterator(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
        {
            if (iter.Count > 0) {
                while (iter.MoveNext()) {
                    string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                    double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
                    bool showAtStartup = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));

                    double north = 0;
                    double south = 0;
                    double west = 0;
                    double east = 0;

                    XPathNodeIterator boundingBoxIter = iter.Current.Select("BoundingBox");
                    if (boundingBoxIter.Count > 0) {
                        boundingBoxIter.MoveNext();
                        north = ParseDouble(getInnerTextFromFirstChild(boundingBoxIter.Current.Select("North")));
                        south = ParseDouble(getInnerTextFromFirstChild(boundingBoxIter.Current.Select("South")));
                        west = ParseDouble(getInnerTextFromFirstChild(boundingBoxIter.Current.Select("West")));
                        east = ParseDouble(getInnerTextFromFirstChild(boundingBoxIter.Current.Select("East")));
                    }

                    string terrainMappedString = getInnerTextFromFirstChild(iter.Current.Select("TerrainMapped"));
                    string renderStrutsString = getInnerTextFromFirstChild(iter.Current.Select("RenderStruts"));

                    bool terrainMapped = true;

                    if (terrainMappedString != null) {
                        terrainMapped = ParseBool(terrainMappedString);
                    }
                    XPathNodeIterator imageAccessorIter = iter.Current.Select("ImageAccessor");

                    QuadTileSet qts = null;

                    byte opacity = 255;

                    if (imageAccessorIter.Count > 0) {
                        imageAccessorIter.MoveNext();
                        double levelZeroTileSizeDegrees = ParseDouble(getInnerTextFromFirstChild(imageAccessorIter.Current.Select("LevelZeroTileSizeDegrees")));
                        int numberLevels = Int32.Parse(getInnerTextFromFirstChild(imageAccessorIter.Current.Select("NumberLevels")));
                        int textureSizePixels = Int32.Parse(getInnerTextFromFirstChild(imageAccessorIter.Current.Select("TextureSizePixels")));
                        string imageFileExtension = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("ImageFileExtension"));
                        string permanentDirectory = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("PermanentDirectory"));
                        if (permanentDirectory == null
                            || permanentDirectory.Length == 0) {
                            permanentDirectory = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("PermanantDirectory"));
                        }

                        TimeSpan dataExpiration = getCacheExpiration(imageAccessorIter.Current.Select("DataExpirationTime"));

                        string duplicateTilePath = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("DuplicateTilePath"));
                        string cacheDir = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("CacheDirectory"));

                        if (cacheDir == null
                            || cacheDir.Length == 0) {
                            cacheDir = String.Format("{0}{1}{2}{1}{3}", cache.CacheDirectory, Path.DirectorySeparatorChar, getRenderablePathString(parentRenderable), name);
                        }
                        else {
                            cacheDir = Path.Combine(cache.CacheDirectory, cacheDir);
                        }

                        if (permanentDirectory != null
                            && permanentDirectory.IndexOf(":") < 0) {
                            permanentDirectory = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), permanentDirectory);
                        }

                        if (duplicateTilePath != null
                            && duplicateTilePath.IndexOf(":") < 0) {
                            duplicateTilePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), duplicateTilePath);
                        }

                        if (permanentDirectory != null) {
                            ImageStore ia = new ImageStore();
                            ia.DataDirectory = permanentDirectory;
                            ia.LevelZeroTileSizeDegrees = levelZeroTileSizeDegrees;
                            ia.LevelCount = numberLevels;
                            ia.ImageExtension = imageFileExtension;
                            //doesn't work when this is set
                            //ia.CacheDirectory = cacheDir;

                            if (duplicateTilePath != null
                                && duplicateTilePath.Length > 0) {
                                ia.DuplicateTexturePath = duplicateTilePath;
                            }

                            //	ia.DataExpirationTime = dataExpiration;

                            qts = new QuadTileSet(name, parentWorld, distanceAboveSurface, north, south, west, east, terrainMapped, ia);
                        }
                        else {
                            XPathNodeIterator imageTileServiceIter = imageAccessorIter.Current.Select("ImageTileService");
                            if (imageTileServiceIter.Count > 0) {
                                imageTileServiceIter.MoveNext();

                                string serverUrl = getInnerTextFromFirstChild(imageTileServiceIter.Current.Select("ServerUrl"));
                                string dataSetName = getInnerTextFromFirstChild(imageTileServiceIter.Current.Select("DataSetName"));
                                string serverLogoFilePath = getInnerTextFromFirstChild(imageTileServiceIter.Current.Select("ServerLogoFilePath"));

                                TimeSpan cacheExpiration = getCacheExpiration(imageTileServiceIter.Current.Select("CacheExpirationTime"));

                                if (serverLogoFilePath != null && serverLogoFilePath.Length > 0
                                    && !Path.IsPathRooted(serverLogoFilePath)) {
                                    serverLogoFilePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), serverLogoFilePath);
                                }

                                string opacityString = getInnerTextFromFirstChild(imageTileServiceIter.Current.Select("Opacity"));

                                if (opacityString != null) {
                                    opacity = byte.Parse(opacityString);
                                }

                                ImageStore ia = new NltImageStore(dataSetName, serverUrl);
                                ia.DataDirectory = null;
                                ia.LevelZeroTileSizeDegrees = levelZeroTileSizeDegrees;
                                ia.LevelCount = numberLevels;
                                ia.ImageExtension = imageFileExtension;
                                ia.CacheDirectory = cacheDir;

                                //if(newImageTileService.CacheExpirationTime == TimeSpan.MaxValue)
                                //	{
                                //	ia.DataExpirationTime = dataExpiration;
                                //	}
                                //	else
                                //	{
                                //	ia.DataExpirationTime = newImageTileService.CacheExpirationTime;
                                //	}

                                qts = new QuadTileSet(name, parentWorld, distanceAboveSurface, north, south, west, east, terrainMapped, ia);

                                qts.Opacity = opacity;
                                if (serverLogoFilePath != null) {
                                    qts.ServerLogoFilePath = serverLogoFilePath;
                                }
                            }
                            else {
                                XPathNodeIterator wmsAccessorIter = imageAccessorIter.Current.Select("WMSAccessor");
                                if (wmsAccessorIter.Count > 0) {
                                    wmsAccessorIter.MoveNext();

                                    WmsImageStore wmsLayerStore = new WmsImageStore();

                                    wmsLayerStore.ImageFormat = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("ImageFormat"));

                                    wmsLayerStore.ImageExtension = imageFileExtension;
                                    wmsLayerStore.CacheDirectory = cacheDir;
                                    //wmsLayerAccessor.IsTransparent = ParseBool(getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("UseTransparency")));
                                    wmsLayerStore.ServerGetMapUrl = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("ServerGetMapUrl"));
                                    wmsLayerStore.Version = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("Version"));
                                    wmsLayerStore.WMSLayerName = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("WMSLayerName"));

                                    string username = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("Username"));
                                    string password = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("Password"));
                                    string wmsStyleName = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("WMSLayerStyle"));
                                    string serverLogoPath = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("ServerLogoFilePath"));
                                    string opacityString = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("Opacity"));

                                    if (serverLogoPath != null && serverLogoPath.Length > 0
                                        && !Path.IsPathRooted(serverLogoPath)) {
                                        serverLogoPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), serverLogoPath);
                                    }
                                    if (opacityString != null) {
                                        opacity = byte.Parse(opacityString);
                                    }

                                    TimeSpan cacheExpiration = getCacheExpiration(iter.Current.Select("CacheExpirationTime"));

                                    //	if(username != null && username.Length > 0)
                                    //		wmsLayerStore.Username = username;

                                    //	if(password != null)
                                    //		wmsLayerAccessor.Password = password;

                                    if (wmsStyleName != null
                                        && wmsStyleName.Length > 0) {
                                        wmsLayerStore.WMSLayerStyle = wmsStyleName;
                                    }
                                    else {
                                        wmsLayerStore.WMSLayerStyle = "";
                                    }

                                    wmsLayerStore.LevelCount = numberLevels;
                                    wmsLayerStore.LevelZeroTileSizeDegrees = levelZeroTileSizeDegrees;

                                    //	if(cacheExpiration == TimeSpan.MaxValue)
                                    //		imageAccessor.DataExpirationTime = dataExpiration;
                                    //	else
                                    //		imageAccessor.DataExpirationTime = cacheExpiration;

                                    if (wmsLayerStore != null) {
                                        qts = new QuadTileSet(name, parentWorld, distanceAboveSurface, north, south, west, east, terrainMapped, wmsLayerStore);

                                        qts.Opacity = opacity;
                                        if (serverLogoPath != null) {
                                            qts.ServerLogoFilePath = serverLogoPath;
                                        }
                                    }
                                }
                            }
                        }

                        if (qts != null) {
                            string infoUri = iter.Current.GetAttribute("InfoUri", "");

                            if (infoUri != null
                                && infoUri.Length > 0) {
                                if (qts.MetaData.Contains("InfoUri")) {
                                    qts.MetaData["InfoUri"] = infoUri;
                                }
                                else {
                                    qts.MetaData.Add("InfoUri", infoUri);
                                }
                            }

                            if (iter.Current.Select("TransparentColor").Count > 0) {
                                Color c = getColor(iter.Current.Select("TransparentColor"));
                                qts.ColorKey = c.ToArgb();
                            }

                            if (iter.Current.Select("TransparentMinValue").Count > 0) {
                                qts.ColorKey = int.Parse(getInnerTextFromFirstChild(iter.Current.Select("TransparentMinValue")));
                            }

                            if (iter.Current.Select("TransparentMaxValue").Count > 0) {
                                qts.ColorKeyMax = int.Parse(getInnerTextFromFirstChild(iter.Current.Select("TransparentMaxValue")));
                            }

                            if (renderStrutsString != null) {
                                qts.RenderStruts = ParseBool(renderStrutsString);
                            }

                            qts.ParentList = parentRenderable;
                            if (World.Settings.useDefaultLayerStates) {
                                qts.IsOn = showAtStartup;
                            }
                            else {
                                qts.IsOn = IsLayerOn(qts);
                            }

                            qts.MetaData.Add("XmlSource", (string) parentRenderable.MetaData["XmlSource"]);
                            addExtendedInformation(iter.Current.Select("ExtendedInformation"), qts);
                            parentRenderable.Add(qts);
                        }
                    }
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Add a child object to this layer.
        /// </summary>
        public virtual void Add(RenderableObject ro)
        {
            try
            {
                lock (this.m_children.SyncRoot)
                {
                    RenderableObjectList dupList   = null;
                    RenderableObject     duplicate = null;
                    ro.ParentList = this;
                    foreach (RenderableObject childRo in m_children)
                    {
                        if (childRo is RenderableObjectList && childRo.Name == ro.Name)
                        {
                            dupList = (RenderableObjectList)childRo;
                            break;
                        }
                        else if (childRo.Name == ro.Name)
                        {
                            duplicate = childRo;
                            break;
                        }
                    }

                    if (dupList != null)
                    {
                        RenderableObjectList rol = (RenderableObjectList)ro;

                        foreach (RenderableObject childRo in rol.ChildObjects)
                        {
                            dupList.Add(childRo);
                        }
                    }
                    else
                    {
                        if (duplicate != null)
                        {
                            for (int i = 1; i < 100; i++)
                            {
                                ro.Name = string.Format("{0} [{1}]", duplicate.Name, i);
                                bool found = false;
                                foreach (RenderableObject childRo in m_children)
                                {
                                    if (childRo.Name == ro.Name)
                                    {
                                        found = true;
                                        break;
                                    }
                                }

                                if (!found)
                                {
                                    break;
                                }
                            }
                        }

                        m_children.Add(ro);
                    }
                    SortChildren();
                }
            }
            catch
            {
            }
        }