Example #1
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);
            }
        }
        /// <summary>
        /// Enables layer with specified name
        /// </summary>
        /// <returns>False if layer not found.</returns>
        public virtual bool Enable(string name)
        {
            if (name == null || name.Length == 0)
            {
                return(true);
            }

            string lowerName = name.ToLower();

            foreach (RenderableObject ro in m_children)
            {
                if (ro.Name.ToLower() == lowerName)
                {
                    ro.IsOn = true;
                    return(true);
                }

                RenderableObjectList rol = ro as RenderableObjectList;
                if (rol == null)
                {
                    continue;
                }

                // Recurse down
                if (rol.Enable(name))
                {
                    rol.isOn = true;
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        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;
        }
Example #4
0
        private void updateNode(TreeNode tn)
        {
            RenderableObjectInfo roi = (RenderableObjectInfo)tn.Tag;

            roi.LastSpotted = System.DateTime.Now;
            if (tn.Checked != roi.Renderable.IsOn)
            {
                tn.Checked = roi.Renderable.IsOn;
                //treeView1.BeginInvoke(new UpdateCheckStateNodeDelegate(this.UpdateCheckStateNode), new object[] {tn, roi.Renderable.IsOn});
            }

            if (roi.Renderable is WorldWind.Renderable.RenderableObjectList)
            {
                WorldWind.Renderable.RenderableObjectList rol = (WorldWind.Renderable.RenderableObjectList)roi.Renderable;
                for (int i = 0; i < rol.Count; i++)
                {
                    WorldWind.Renderable.RenderableObject childRo = (WorldWind.Renderable.RenderableObject)rol.ChildObjects[i];
                    string absolutePath = GetAbsoluteRenderableObjectPath(childRo);

                    TreeNode correctNode = (TreeNode)m_NodeHash[absolutePath];
                    if (correctNode == null)
                    {
                        correctNode = new TreeNode(childRo.Name);
                        RenderableObjectInfo curRoi = new RenderableObjectInfo();
                        curRoi.Renderable = childRo;
                        correctNode.Tag   = curRoi;

                        m_NodeHash.Add(absolutePath, correctNode);
                        treeView1.BeginInvoke(new UpdateChildNodeDelegate(this.UpdateChildNodeTree), new object[] { tn, correctNode });
                    }

                    updateNode(correctNode);
                }
            }
        }
Example #5
0
        /// <summary>
        /// disable a layer with specified name.
        /// </summary>
        /// <param name="layerName">the layer's name.</param>
        /// <returns>false if layer not found.</returns>
        public virtual bool Disable(string layerName)
        {
            bool result = false;

            if (string.IsNullOrEmpty(layerName))
            {
                result = true;
            }

            string lowerName = layerName.ToLower();

            foreach (RenderableObject ro in m_children)
            {
                if (ro.Name.ToLower() == lowerName)
                {
                    ro.IsOn = false;
                    result  = true;
                }

                RenderableObjectList rol = ro as RenderableObjectList;
                if (rol == null)
                {
                    continue;
                }

                // Recurse down
                if (rol.Disable(name))
                {
                    //rol.isOn = false;
                    result = true;
                }
            }

            return(result);
        }
Example #6
0
 /// <summary>
 /// ��ʼ��һ�� <see cref= "T:WorldWind.World"/> ��ʵ��.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="position"></param>
 /// <param name="orientation"></param>
 /// <param name="equatorialRadius"></param>
 /// <param name="cacheDirectory"></param>
 /// <param name="terrainAccessor"></param>
 public World(string name, Vector3 position, Quaternion orientation, double equatorialRadius, string cacheDirectory, TerrainAccessor terrainAccessor)
     : base(name, position, orientation)
 {
     this._equatorialRadius = equatorialRadius;
     this._terrainAccessor = terrainAccessor;
     this._renderableObjects = new RenderableObjectList(this.Name);
     this.MetaData.Add("CacheDirectory", cacheDirectory);
 }
Example #7
0
        //
        //  REMOVED because we no longer ever render all ROs in a a ROL without explicitly checking
        //  render priority anyway.
        //

        /// <summary>
        /// Sorts the children list according to priority - ONLY called in worker thread (in Update())
        /// </summary>
        //private void SortChildren()
        //{
        //    int index = 0;
        //    m_childrenRWLock.AcquireWriterLock(Timeout.Infinite);
        //    try
        //    {
        //        while (index + 1 < m_children.Count)
        //        {
        //            RenderableObject a = (RenderableObject)m_children[index];
        //            RenderableObject b = (RenderableObject)m_children[index + 1];
        //            if (a.RenderPriority > b.RenderPriority)
        //            {
        //                // Swap
        //                m_children[index] = b;
        //                m_children[index + 1] = a;
        //                index = 0;
        //                continue;
        //            }
        //            index++;
        //        }
        //    }
        //    finally
        //    {
        //        m_childrenRWLock.ReleaseWriterLock();
        //        m_needsSort = false;
        //    }
        //}

        private void UpdateRenderable(RenderableObject oldRenderable, RenderableObject newRenderable)
        {
            if (oldRenderable is Icon && newRenderable is Icon)
            {
                Icon oldIcon = (Icon)oldRenderable;
                Icon newIcon = (Icon)newRenderable;

                oldIcon.SetPosition((float)newIcon.Latitude, (float)newIcon.Longitude, (float)newIcon.Altitude);
            }
            else if (oldRenderable is RenderableObjectList && newRenderable is RenderableObjectList)
            {
                RenderableObjectList oldList = (RenderableObjectList)oldRenderable;
                RenderableObjectList newList = (RenderableObjectList)newRenderable;

                compareRefreshLists(newList, oldList);
            }
        }
Example #8
0
        /// <summary>
        /// Enables layer with specified name
        /// </summary>
        /// <returns>False if layer not found.</returns>
        public virtual bool Enable(string name)
        {
            if (name == null || name.Length == 0)
            {
                return(true);
            }

            string lowerName = name.ToLower();
            bool   result    = false;

            m_childrenRWLock.AcquireReaderLock(Timeout.Infinite);
            try
            {
                foreach (RenderableObject ro in m_children)
                {
                    if (ro.Name.ToLower() == lowerName)
                    {
                        ro.IsOn = true;
                        result  = true;
                        break;
                    }

                    RenderableObjectList rol = ro as RenderableObjectList;
                    if (rol == null)
                    {
                        continue;
                    }

                    // Recurse down
                    if (rol.Enable(name))
                    {
                        rol.isOn = true;
                        result   = true;
                        break;
                    }
                }
            }
            finally
            {
                m_childrenRWLock.ReleaseReaderLock();
            }

            return(result);
        }
Example #9
0
 public virtual void TurnOffAllChildren()
 {
     m_childrenRWLock.AcquireReaderLock(Timeout.Infinite);
     try
     {
         foreach (RenderableObject ro in this.m_children)
         {
             ro.IsOn = false;
             if (ro is RenderableObjectList)
             {
                 RenderableObjectList list = ro as RenderableObjectList;
                 list.TurnOffAllChildren();
             }
         }
     }
     finally
     {
         m_childrenRWLock.ReleaseReaderLock();
     }
 }
Example #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref= "T:WorldWind.World"/> class.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="position"></param>
        /// <param name="orientation"></param>
        /// <param name="equatorialRadius"></param>
        /// <param name="cacheDirectory"></param>
        /// <param name="terrainAccessor"></param>
        public World(string name, Point3d position, Quaternion4d orientation, double equatorialRadius,
            string cacheDirectory,
            TerrainAccessor terrainAccessor)
            : base(name, position, orientation)
        {
            this.equatorialRadius = equatorialRadius;

            this._terrainAccessor = terrainAccessor;
            this._renderableObjects = new RenderableObjectList(this.Name);
            this.MetaData.Add("CacheDirectory", cacheDirectory);

            //	this.m_WorldSurfaceRenderer = new WorldSurfaceRenderer(32, 0, this);
            this.m_projectedVectorRenderer = new ProjectedVectorRenderer("World Default ProjectedVectorRenderer", this);

            m_outerSphere = new AtmosphericScatteringSphere();
            AtmosphericScatteringSphere.m_fInnerRadius = (float)equatorialRadius;
            AtmosphericScatteringSphere.m_fOuterRadius = (float)equatorialRadius * 1.025f;

            m_outerSphere.Init((float)equatorialRadius * 1.025f);
        }
		/// <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);
		}
Example #12
0
        private void m_RefreshTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (!hasSkippedFirstRefresh)
            {
                hasSkippedFirstRefresh = true;
                return;
            }

            try {
                string dataSource = m_DataSource;

                RenderableObjectList newList = ConfigurationLoader.getRenderableFromLayerFile(dataSource, m_ParentWorld, m_Cache, false);

                if (newList != null)
                {
                    compareRefreshLists(newList, this);
                }
            }
            catch (Exception ex) {
                Log.Write(ex);
            }
        }
Example #13
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);
        }
Example #14
0
        public bool OnMouseUp(MouseEventArgs e)
        {
            if (e.Y < this._y)
            {
                // Above
                return(false);
            }

            if (e.Y <= this._y + 20)
            {
                if (e.X > this._x + this._itemXOffset &&
                    e.X < this._x + (this._itemXOffset + this._width) &&
                    e.Button == MouseButtons.Right)
                {
                    m_parent.ShowContextMenu(e.X, e.Y, this);
                }

                if (e.X > this._x + this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset &&
                    e.X < this._x + (this._itemXOffset + this._width) &&
                    e.Button == MouseButtons.Left &&
                    m_renderableObject != null &&
                    m_renderableObject.MetaData.Contains("InfoUri"))
                {
                    string infoUri = (string)m_renderableObject.MetaData["InfoUri"];

                    if (World.Settings.UseInternalBrowser || infoUri.StartsWith(@"worldwind://"))
                    {
                        SplitContainer          sc      = (SplitContainer)this.ParentControl.Parent.Parent;
                        InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0];
                        browser.NavigateTo(infoUri);
                    }
                    else
                    {
                        ProcessStartInfo psi = new ProcessStartInfo();
                        psi.FileName        = infoUri;
                        psi.Verb            = "open";
                        psi.UseShellExecute = true;
                        psi.CreateNoWindow  = true;
                        Process.Start(psi);
                    }
                }

                if (e.X > this._x + this._itemXOffset &&
                    e.X < this._x + (this._itemXOffset + this._expandArrowXSize) &&
                    m_renderableObject is WorldWind.Renderable.RenderableObjectList)
                {
                    WorldWind.Renderable.RenderableObjectList rol = (WorldWind.Renderable.RenderableObjectList)m_renderableObject;
                    if (!rol.DisableExpansion)
                    {
                        this.isExpanded = !this.isExpanded;
                        return(true);
                    }
                }

                if (e.X > this._x + this._itemXOffset + this._expandArrowXSize &&
                    e.X < this._x + (this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset))
                {
                    if (!m_renderableObject.IsOn && m_renderableObject.ParentList != null &&
                        m_renderableObject.ParentList.ShowOnlyOneLayer)
                    {
                        m_renderableObject.ParentList.TurnOffAllChildren();
                    }

                    m_renderableObject.IsOn = !m_renderableObject.IsOn;
                    return(true);
                }
            }

            if (isExpanded)
            {
                foreach (LayerMenuItem lmi in m_subItems)
                {
                    if (lmi.OnMouseUp(e))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #15
0
        /// <summary>
        /// Permanently delete the layer
        /// </summary>
        public virtual void Delete()
        {
            RenderableObjectList list = this.ParentList;

            string xmlConfigFile = (string)this.MetaData["XmlSource"];

            if (this.ParentList.Name == "Earth" & xmlConfigFile != null)
            {
                string message = "Permanently delete layer '" + this.Name + "' and rename its .xml config file to .bak?";
                if (DialogResult.Yes != MessageBox.Show(message, "Delete layer", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                                        MessageBoxDefaultButton.Button2))
                {
                    return;
                }
                //throw new Exception("Delete cancelled.");

                //MessageBox.Show("Checking xml source of " + this.Name);

                if (xmlConfigFile.Contains("http"))
                {
                    throw new Exception("Can't delete network layers.");
                }

                //MessageBox.Show("Found " + xmlConfigFile);
                if (File.Exists(xmlConfigFile.Replace(".xml", ".bak")))
                {
                    //MessageBox.Show("Deleting old .bak");
                    File.Delete(xmlConfigFile.Replace(".xml", ".bak"));
                }
                //MessageBox.Show("Moving old .xml");
                File.Move(xmlConfigFile, xmlConfigFile.Replace(".xml", ".bak"));

                //MessageBox.Show("File backed up, now removing from LM");
                this.ParentList.Remove(this);
                //World.RenderableObjects.Remove(this);

                //MessageBox.Show("Removed");
            }
            else if (xmlConfigFile == null)
            {
                string message = "Delete plugin layer '" + this.Name + "'?\n\nThis may cause problems for a running plugin that expects the layer to be\nthere.  Restart the plugin in question to replace the layer after deleting.";
                if (DialogResult.Yes != MessageBox.Show(message, "Delete layer", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                                        MessageBoxDefaultButton.Button2))
                {
                    return;
                }
                //throw new Exception("Delete cancelled.");

                this.ParentList.Remove(this);
            }
            else
            {
                throw new Exception("Can't delete this sub-item from the layer manager.  Try deleting the top-level entry for this layer.");
            }



            // Needs re-thinking...

            /*
             * string xmlConfigFile = (string)MetaData["XmlSource"];
             * //MessageBox.Show(xmlConfigFile);
             * if(xmlConfigFile == null)
             *      xmlConfigFile = (string)ParentList.MetaData["XmlSource"];
             *
             * if(xmlConfigFile == null || !File.Exists(xmlConfigFile))
             *      throw new ApplicationException("Error deleting layer.");
             *
             * XmlDocument doc = new XmlDocument();
             * doc.Load(xmlConfigFile);
             *
             * XmlNodeList list;
             * XmlElement root = doc.DocumentElement;
             * list = root.SelectNodes("//ChildLayerSet[@Name='" + namestring + "'] || //*[Name='" + namestring + "']");
             * MessageBox.Show("Checked childlayersets, returned " + list[0].ToString());
             *
             * ParentList.Remove(Name);
             * MessageBox.Show("Removed " + Name + ", now changing " + xmlConfigFile);
             *
             * if (list != null)
             *      MessageBox.Show("Removing " + list[0].ToString() + " from xml");
             *
             * list[0].ParentNode.RemoveChild(list[0]);
             * MessageBox.Show("node removed, now saving file");
             *
             * if (File.Exists(xmlConfigFile.Replace(".xml", ".bak")))
             * {
             *      MessageBox.Show("Deleting old .bak");
             *      File.Delete(xmlConfigFile.Replace(".xml", ".bak"));
             *
             * }
             * MessageBox.Show("Moving old .xml");
             * File.Move(xmlConfigFile, xmlConfigFile.Replace(".xml",".bak"));
             *
             * MessageBox.Show("Saving new xml");
             * doc.Save(xmlConfigFile);
             */
        }
Example #16
0
		private void ProcessWmsEncodedUri()
		{
			//first parse the rawUri string looking for "functions"
			string uri = worldWindUri.RawUrl.Substring(12, worldWindUri.RawUrl.Length - 12);
			uri = uri.Replace("wmsimage=", "wmsimage|");
			uri = uri.Replace("&wmsimage", "#wmsimage");
			string[] uriFunctions = uri.Split('#');

			foreach(string uriFunction in uriFunctions)
			{
				string[] paramValuePair = uriFunction.Split('|');

				if(String.Compare(paramValuePair[0], "wmsimage", true, CultureInfo.InvariantCulture) == 0)
				{
					string displayName = null;
					int transparencyPercent = 0;
					double heightAboveSurface = 0.0;
					string wmslink = "";
					string[] wmsImageParams = new string[0];
					if(paramValuePair[1].IndexOf("://") > 0)
					{
						wmsImageParams = paramValuePair[1].Replace("%26", "|").Split('|');
					}
					else
					{
						wmsImageParams = System.Web.HttpUtility.UrlDecode(paramValuePair[1]).Replace("%26", "|").Split('|');
					}
					foreach(string p in wmsImageParams)
					{
						string new_p = p.Replace("%3d", "|");
						char[] deliminator = new char[1] {'|'};
						string[] functionParam = new_p.Split(deliminator, 2);

						if(String.Compare(functionParam[0], "displayname", true, CultureInfo.InvariantCulture) == 0)
						{
							displayName = functionParam[1];
						}
						else if(String.Compare(functionParam[0], "transparency", true, CultureInfo.InvariantCulture) == 0)
						{
							transparencyPercent = Int32.Parse(functionParam[1], CultureInfo.InvariantCulture);
						}
						else if(String.Compare(functionParam[0], "altitude", true, CultureInfo.InvariantCulture) == 0)
						{
							heightAboveSurface = Double.Parse(functionParam[1], CultureInfo.InvariantCulture);
						}
						else if(String.Compare(functionParam[0], "link", true, CultureInfo.InvariantCulture) == 0)
						{
							wmslink = functionParam[1];
							if(wmslink.EndsWith("/"))
								wmslink = wmslink.Substring(0, wmslink.Length - 1);
						}
					}

					try
					{
						string[] wmslinkParams = wmslink.Split('?')[1].Split('&');

						string wmsLayerName = null;
						LayerSet.Type_LatitudeCoordinate2 bb_north = new LayerSet.Type_LatitudeCoordinate2();
						LayerSet.Type_LatitudeCoordinate2 bb_south = new LayerSet.Type_LatitudeCoordinate2();
						LayerSet.Type_LongitudeCoordinate2 bb_west = new LayerSet.Type_LongitudeCoordinate2();
						LayerSet.Type_LongitudeCoordinate2 bb_east = new LayerSet.Type_LongitudeCoordinate2();

						foreach(string wmslinkParam in wmslinkParams)
						{
							string linkParamUpper = wmslinkParam.ToUpper(CultureInfo.InvariantCulture);
							if(linkParamUpper.IndexOf("BBOX") >= 0)
							{
								string[] bb_parts = wmslinkParam.Split('=')[1].Split(',');
								bb_west.AddValue2(new LayerSet.ValueType4(bb_parts[0]));
								bb_south.AddValue2(new LayerSet.ValueType3(bb_parts[1]));
								bb_east.AddValue2(new LayerSet.ValueType4(bb_parts[2]));
								bb_north.AddValue2(new LayerSet.ValueType3(bb_parts[3]));
							}
							else if(linkParamUpper.IndexOf("LAYERS") >= 0)
							{
								wmsLayerName = wmslinkParam.Split('=')[1];
							}
						}

						string path = String.Format(CultureInfo.InvariantCulture,
							@"{0}\{1}\___DownloadedWMSImages.xml", Settings.ConfigPath, "");//this.currentWorld.LayerDirectory.Value);
						
						string texturePath = string.Format(CultureInfo.InvariantCulture,
							@"{0}\Data\DownloadedWMSImages\{1}", DirectoryPath, System.DateTime.Now.ToFileTimeUtc());

						if(!File.Exists(path))
						{
							LayerSet.LayerSetDoc newDoc = new LayerSet.LayerSetDoc();
							LayerSet.Type_LayerSet root = new LayerSet.Type_LayerSet();

							root.AddName(new LayerSet.NameType2("Downloaded WMS Images"));
							root.AddShowAtStartup(new Altova.Types.SchemaBoolean(true));
							root.AddShowOnlyOneLayer(new Altova.Types.SchemaBoolean(false));
							newDoc.SetRootElementName("", "LayerSet");
							newDoc.Save(path, root);
						}

						LayerSet.LayerSetDoc doc = new LayerSet.LayerSetDoc();
						LayerSet.Type_LayerSet curRoot = new LayerSet.Type_LayerSet(doc.Load(path));

						if(displayName == null)
						{
							displayName = wmslink.Split('?')[0] + " - " + wmsLayerName + " : " + System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToLongTimeString();
						}

						for(int i = 0; i < curRoot.ImageLayerCount; i++)
						{
							LayerSet.Type_ImageLayer curImageLayerType = (LayerSet.Type_ImageLayer)curRoot.GetImageLayerAt(i);
							if(curImageLayerType.Name.Value.Equals(displayName))
							{
								displayName += String.Format(CultureInfo.CurrentCulture, " : {0} {1}", System.DateTime.Now.ToShortDateString(), System.DateTime.Now.ToLongTimeString());
							}
						}

						LayerSet.Type_ImageLayer newImageLayer = new LayerSet.Type_ImageLayer();
						newImageLayer.AddShowAtStartup(new Altova.Types.SchemaBoolean(false));

						if(bb_north.Value2.DoubleValue() - bb_south.Value2.DoubleValue() > 90 ||
							bb_east.Value2.DoubleValue() - bb_west.Value2.DoubleValue() > 90)
							heightAboveSurface = 10000.0;

						newImageLayer.AddName(new LayerSet.NameType(
							displayName));
						newImageLayer.AddDistanceAboveSurface( new Altova.Types.SchemaDecimal(heightAboveSurface));

						LayerSet.Type_LatLonBoundingBox2 bb = new LayerSet.Type_LatLonBoundingBox2();

						bb.AddNorth(bb_north);
						bb.AddSouth(bb_south);
						bb.AddWest(bb_west);
						bb.AddEast(bb_east);
						newImageLayer.AddBoundingBox(bb);
						newImageLayer.AddTexturePath(new Altova.Types.SchemaString(
							texturePath));

						byte opacityValue = (byte)((100.0 - transparencyPercent) * 0.01 * 255);
						newImageLayer.AddOpacity(new LayerSet.OpacityType( opacityValue.ToString(CultureInfo.InvariantCulture)));
						newImageLayer.AddTerrainMapped(new Altova.Types.SchemaBoolean(false));

						curRoot.AddImageLayer(newImageLayer);
						doc.Save(path, curRoot);

						ImageLayer newLayer = new ImageLayer(
							displayName,
							this.worldWindow.CurrentWorld,
							(float)heightAboveSurface,
							texturePath,
							(float)bb_south.Value2.DoubleValue(),
							(float)bb_north.Value2.DoubleValue(),
							(float)bb_west.Value2.DoubleValue(),
							(float)bb_east.Value2.DoubleValue(),
							0.01f * (100.0f - transparencyPercent),
							this.worldWindow.CurrentWorld.TerrainAccessor);
						newLayer.ImageUrl = wmslink;

						RenderableObjectList downloadedImagesRol = (RenderableObjectList)this.worldWindow.CurrentWorld.RenderableObjects.GetObject("Downloaded WMS Images");
						if(downloadedImagesRol == null)
							downloadedImagesRol = new RenderableObjectList("Downloaded WMS Images");

						this.worldWindow.CurrentWorld.RenderableObjects.Add(newLayer);

						worldWindUri.Latitude = Angle.FromDegrees(0.5 * (bb_north.Value2.DoubleValue() + bb_south.Value2.DoubleValue()));
						worldWindUri.Longitude = Angle.FromDegrees(0.5 * (bb_west.Value2.DoubleValue() + bb_east.Value2.DoubleValue()));

						if(bb_north.Value2.DoubleValue() - bb_south.Value2.DoubleValue() > bb_east.Value2.DoubleValue() - bb_west.Value2.DoubleValue())
							worldWindUri.ViewRange = Angle.FromDegrees(bb_north.Value2.DoubleValue() - bb_south.Value2.DoubleValue());
						else
							worldWindUri.ViewRange = Angle.FromDegrees(bb_east.Value2.DoubleValue() - bb_west.Value2.DoubleValue());

						if(worldWindUri.ViewRange.Degrees > 180)
							worldWindUri.ViewRange = Angle.FromDegrees(180);

						System.Threading.Thread.Sleep(10);
					}
					catch
					{}
				}
			}
		}
Example #17
0
        public static RenderableObjectList getRenderableFromLayerFile(string layerFile, World parentWorld, Cache cache, bool enableRefresh, string layerSetSchema)
        {
            Log.Write(Log.Levels.Debug + 1, "CONF", "Loading renderable from " + layerFile);
            try
            {
                XPathDocument docNav = null;
                XPathNavigator nav = null;

                XmlReaderSettings readerSettings = new XmlReaderSettings();

                if (layerSetSchema != null && File.Exists(layerSetSchema))
                {
                    Log.Write(Log.Levels.Debug, "CONF", "validating " + layerFile + " against LayerSet.xsd");
                    readerSettings.ValidationType = ValidationType.Schema;
                    XmlSchemaSet schemas = new XmlSchemaSet();
                    schemas.Add(null, layerSetSchema);

                    readerSettings.Schemas = schemas;
                    readerSettings.ValidationEventHandler += new ValidationEventHandler(XMLValidationCallback);
                    readerSettings.ValidationFlags |= System.Xml.Schema.XmlSchemaValidationFlags.ReportValidationWarnings;
                }
                else
                {
                    Log.Write(Log.Levels.Debug, "CONF", "loading " + layerFile + " without validation");
                    readerSettings.ValidationType = ValidationType.None;
                }

                try
                {
                    if (layerFile.IndexOf(@"http://") < 0)
                    {
                        XmlReader docReader = XmlReader.Create(layerFile, readerSettings);
                        docNav = new XPathDocument(docReader);
                        docReader.Close();
                    }
                    else
                    {
                        Angle[] bbox = CameraBase.getViewBoundingBox();
                        string viewBBox = string.Format(CultureInfo.InvariantCulture,
                             "{0},{1},{2},{3}",
                             bbox[0].ToString().TrimEnd('°'), bbox[1].ToString().TrimEnd('°'), bbox[2].ToString().TrimEnd('°'), bbox[3].ToString().TrimEnd('°'));

                        //See if there is a ? already in the URL
                        int flag = layerFile.IndexOf("?");
                        if (flag == -1)
                            layerFile = layerFile + "?BBOX=" + viewBBox;
                        else
                            layerFile = layerFile + "&BBOX=" + viewBBox;

                        WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(layerFile);
                        download.DownloadMemory();

                        XmlReader docReader = XmlReader.Create(download.ContentStream, readerSettings);
                        docNav = new XPathDocument(docReader);
                        docReader.Close();
                    }

                    nav = docNav.CreateNavigator();
                }
                catch (Exception ex)
                {
                    Log.Write(ex);
                    return null;
                }

                XPathNodeIterator iter = nav.Select("/LayerSet");

                if (iter.Count > 0)
                {
                    iter.MoveNext();
                    string redirect = iter.Current.GetAttribute("redirect", "");
                    redirect = redirect.Replace("${WORLDWINDVERSION}", System.Windows.Forms.Application.ProductVersion);
                    string redirectWithoutBBOX = redirect;
                    if (redirect != null && redirect.Length > 0)
                    {
                        FileInfo layerFileInfo = new FileInfo(layerFile);

                        try
                        {
                            Angle[] bbox = CameraBase.getViewBoundingBox();
                            string viewBBox = string.Format(CultureInfo.InvariantCulture,
                                 "{0},{1},{2},{3}",
                                 bbox[0].ToString().TrimEnd('°'), bbox[1].ToString().TrimEnd('°'), bbox[2].ToString().TrimEnd('°'), bbox[3].ToString().TrimEnd('°'));

                            //See if there is a ? already in the URL
                            int flag = redirect.IndexOf("?");
                            if (flag == -1)
                                redirect = redirect + "?BBOX=" + viewBBox;
                            else
                                redirect = redirect + "&BBOX=" + viewBBox;

                            WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(redirect);

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

                            if (username != null)
                            {
                                ////	download.UserName = username;
                                ////	download.Password = password;
                            }

                            FileInfo tempDownloadFile = new FileInfo(layerFile.Replace(layerFileInfo.Extension, "_.tmp"));

                            download.DownloadFile(tempDownloadFile.FullName, WorldWind.Net.DownloadType.Unspecified);

                            tempDownloadFile.Refresh();
                            if (tempDownloadFile.Exists && tempDownloadFile.Length > 0)
                            {
                                FileInfo tempStoreFile = new FileInfo(tempDownloadFile.FullName.Replace("_.tmp", ".tmp"));
                                if (tempStoreFile.Exists)
                                    tempStoreFile.Delete();

                                tempDownloadFile.MoveTo(tempStoreFile.FullName);
                            }

                            download.Dispose();

                            using (StreamWriter writer = new StreamWriter(layerFile.Replace(layerFileInfo.Extension, ".uri"), false))
                            {
                                writer.WriteLine(redirectWithoutBBOX);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Write(ex);
                        }

                        return getRenderableFromLayerFile(layerFile.Replace(layerFileInfo.Extension, ".tmp"), parentWorld, cache);
                    }
                    else
                    {
                        RenderableObjectList parentRenderable = null;

                        string sourceUri = null;
                        if (layerFile.EndsWith(".tmp"))
                        {
                            //get source url
                            using (StreamReader reader = new StreamReader(layerFile.Replace(".tmp", ".uri")))
                            {
                                sourceUri = reader.ReadLine();
                            }
                        }
                        string refreshString = iter.Current.GetAttribute("Refresh", "");
                        if (refreshString != null && refreshString.Length > 0)
                        {

                            if (iter.Current.Select("Icon").Count > 0)
                            {
                                parentRenderable = new Icons(iter.Current.GetAttribute("Name", ""),
                                     (sourceUri != null ? sourceUri : layerFile),
                                     TimeSpan.FromSeconds(ParseDouble(refreshString)),
                                     parentWorld,
                                     cache);
                            }
                            else
                            {
                                parentRenderable = new RenderableObjectList(
                                     iter.Current.GetAttribute("Name", ""),
                                     (sourceUri != null ? sourceUri : layerFile),
                                     TimeSpan.FromSeconds(ParseDouble(refreshString)),
                                     parentWorld,
                                     cache);
                            }

                        }
                        else
                        {
                            if (iter.Current.Select("Icon").Count > 0)
                            {
                                parentRenderable = new Icons(iter.Current.GetAttribute("Name", ""));
                            }
                            else
                            {
                                parentRenderable = new RenderableObjectList(iter.Current.GetAttribute("Name", ""));
                            }
                        }

                        parentRenderable.ParentList = parentWorld.RenderableObjects;
                        parentRenderable.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));

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

                        parentRenderable.ShowOnlyOneLayer = ParseBool(iter.Current.GetAttribute("ShowOnlyOneLayer", ""));

                        parentRenderable.MetaData.Add("XmlSource", (sourceUri != null ? sourceUri : layerFile));

                        parentRenderable.MetaData.Add("World", parentWorld);
                        parentRenderable.MetaData.Add("Cache", cache);
                        parentRenderable.ParentList = parentWorld.RenderableObjects;

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

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

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

                        addTiledWFSPlacenameSet(iter.Current.Select("TiledWFSPlacenameSet"), parentWorld, parentRenderable, cache);
                        addExtendedInformation(iter.Current.Select("ExtendedInformation"), parentRenderable);

                        if (parentRenderable.RefreshTimer != null && enableRefresh)
                        {
                            parentRenderable.RefreshTimer.Start();
                        }
                        return parentRenderable;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                //Log.Write(Log.Levels.Debug, layerFile);
            }
            Log.Write(Log.Levels.Warning, "CONF", "WARNING: no renderable created for " + layerFile);

            return null;
        }
Example #18
0
        public static RenderableObjectList getRenderableFromLayerFile(string layerFile, World parentWorld, Cache cache, bool enableRefresh)
        {
            try {
                XPathDocument docNav = null;
                XPathNavigator nav = null;

                try {
                    docNav = new XPathDocument(layerFile);
                    nav = docNav.CreateNavigator();
                }
                catch (Exception ex) {
                    Log.Write(ex);
                    return null;
                }

                XPathNodeIterator iter = nav.Select("/LayerSet");

                if (iter.Count > 0) {
                    iter.MoveNext();
                    string redirect = iter.Current.GetAttribute("redirect", "");
                    if (redirect != null
                        && redirect.Length > 0) {
                        FileInfo layerFileInfo = new FileInfo(layerFile);

                        try {
                            Angle[] bbox = CameraBase.getViewBoundingBox();
                            string viewBBox = string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", bbox[0].ToString().TrimEnd('бу'), bbox[1].ToString().TrimEnd('бу'), bbox[2].ToString().TrimEnd('бу'), bbox[3].ToString().TrimEnd('бу'));

                            //See if there is a ? already in the URL
                            int flag = redirect.IndexOf("?");
                            if (flag == -1) {
                                redirect = redirect + "?BBOX=" + viewBBox;
                            }
                            else {
                                redirect = redirect + "&BBOX=" + viewBBox;
                            }

                            WebDownload download = new WebDownload(redirect);

                            string username = iter.Current.GetAttribute("username", "");
                            string password = iter.Current.GetAttribute("password", "");

                            if (username != null) {
                                ////	download.UserName = username;
                                ////	download.Password = password;
                            }

                            FileInfo tempDownloadFile = new FileInfo(layerFile.Replace(layerFileInfo.Extension, "_.tmp"));

                            download.DownloadFile(tempDownloadFile.FullName, DownloadType.Unspecified);

                            tempDownloadFile.Refresh();
                            if (tempDownloadFile.Exists
                                && tempDownloadFile.Length > 0) {
                                FileInfo tempStoreFile = new FileInfo(tempDownloadFile.FullName.Replace("_.tmp", ".tmp"));
                                if (tempStoreFile.Exists) {
                                    tempStoreFile.Delete();
                                }

                                tempDownloadFile.MoveTo(tempStoreFile.FullName);
                            }

                            download.Dispose();

                            using (StreamWriter writer = new StreamWriter(layerFile.Replace(layerFileInfo.Extension, ".uri"), false)) {
                                writer.WriteLine(redirect);
                            }
                        }
                        catch (Exception ex) {
                            Log.Write(ex);
                        }

                        return getRenderableFromLayerFile(layerFile.Replace(layerFileInfo.Extension, ".tmp"), parentWorld, cache);
                    }
                    else {
                        RenderableObjectList parentRenderable = null;

                        string sourceUri = null;
                        if (layerFile.EndsWith(".tmp")) {
                            //get source url
                            using (StreamReader reader = new StreamReader(layerFile.Replace(".tmp", ".uri"))) {
                                sourceUri = reader.ReadLine();
                            }
                        }
                        string refreshString = iter.Current.GetAttribute("Refresh", "");
                        if (refreshString != null
                            && refreshString.Length > 0) {
                            if (iter.Current.Select("Icon").Count > 0) {
                                parentRenderable = new Icons(iter.Current.GetAttribute("Name", ""), (sourceUri != null ? sourceUri : layerFile), TimeSpan.FromSeconds(ParseDouble(refreshString)), parentWorld, cache);
                            }
                                #region by zzm
                            else if (iter.Current.Select("MyIcon").Count > 0) {
                                // add my icon here.
                                parentRenderable = new MyIcons(iter.Current.GetAttribute("Name", ""), (sourceUri != null ? sourceUri : layerFile), TimeSpan.FromSeconds(ParseDouble(refreshString)), parentWorld, cache);
                            }
                            else if (iter.Current.Select("MyChart").Count > 0) {
                                // add chart here.
                                parentRenderable = new MyCharts(iter.Current.GetAttribute("Name", ""), (sourceUri != null ? sourceUri : layerFile), TimeSpan.FromSeconds(ParseDouble(refreshString)), parentWorld, cache);
                            }
                                #endregion

                            else {
                                parentRenderable = new RenderableObjectList(iter.Current.GetAttribute("Name", ""), (sourceUri != null ? sourceUri : layerFile), TimeSpan.FromSeconds(ParseDouble(refreshString)), parentWorld, cache);
                            }
                        }
                        else {
                            if (iter.Current.Select("Icon").Count > 0) {
                                parentRenderable = new Icons(iter.Current.GetAttribute("Name", ""));
                            }
                                #region by zzm
                            else if (iter.Current.Select("MyIcon").Count > 0) {
                                // add my icon here.
                                parentRenderable = new MyIcons(iter.Current.GetAttribute("Name", ""));
                            }
                            else if (iter.Current.Select("MyChart").Count > 0) {
                                // add chart here.
                                parentRenderable = new MyCharts(iter.Current.GetAttribute("Name", ""));
                            }
                                #endregion

                            else {
                                parentRenderable = new RenderableObjectList(iter.Current.GetAttribute("Name", ""));
                            }
                        }

                        parentRenderable.ParentList = parentWorld.RenderableObjects;

                        if (World.Settings.useDefaultLayerStates) {
                            parentRenderable.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
                        }
                        else {
                            parentRenderable.IsOn = IsLayerOn(parentRenderable);
                        }

                        parentRenderable.ShowOnlyOneLayer = ParseBool(iter.Current.GetAttribute("ShowOnlyOneLayer", ""));

                        parentRenderable.MetaData.Add("XmlSource", (sourceUri != null ? sourceUri : layerFile));

                        parentRenderable.MetaData.Add("World", parentWorld);
                        parentRenderable.MetaData.Add("Cache", cache);
                        parentRenderable.ParentList = parentWorld.RenderableObjects;

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

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

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

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

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

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

                        if (parentRenderable.RefreshTimer != null && enableRefresh) {
                            parentRenderable.RefreshTimer.Start();
                        }
                        return parentRenderable;
                    }
                }
            }
            catch (Exception ex) {
                Log.Write(ex);
                //Utility.Log.Write(layerFile);
            }
            return null;
        }
Example #19
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);
            }
        }
Example #20
0
        private void saveRenderableStates(RenderableObjectList rol)
        {
            saveRenderableState(rol);

            foreach (RenderableObject ro in rol.ChildObjects)
            {
                if (ro is RenderableObjectList)
                {
                    RenderableObjectList childRol = (RenderableObjectList)ro;
                    saveRenderableStates(childRol);
                }
                else
                {
                    saveRenderableState(ro);
                }
            }
        }
        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);
                }
            }
        }
		private static void addPolygonFeature(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
					
					string distanceAboveSurfaceString = getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface"));
					string minimumDisplayAltitudeString = getInnerTextFromFirstChild(iter.Current.Select("MinimumDisplayAltitude"));
					string maximumDisplayAltitudeString = getInnerTextFromFirstChild(iter.Current.Select("MaximumDisplayAltitude"));
					string opacityString = getInnerTextFromFirstChild(iter.Current.Select("Opacity"));
					string extrudeHeightString = getInnerTextFromFirstChild(iter.Current.Select("ExtrudeHeight"));
					string extrudeUpwardsString = getInnerTextFromFirstChild(iter.Current.Select("ExtrudeUpwards"));
					string imageUri = getInnerTextFromFirstChild(iter.Current.Select("ImageUri"));
					string outlineString = getInnerTextFromFirstChild(iter.Current.Select("Outline"));

					XPathNodeIterator posListIter = iter.Current.Select("exterior/LinearRing/posList");
					posListIter.MoveNext();

					string lineString = getInnerTextFromFirstChild(posListIter);
					
					string[] lineParts = lineString.Split(' ');
					Point3d[] points = new Point3d[lineParts.Length];
					
					for(int i = 0; i < lineParts.Length; i++)
					{
						string[] pointParts = lineParts[i].Split(',');
						points[i] = new Point3d();
						points[i].X = ParseDouble(pointParts[0]);
						points[i].Y = ParseDouble(pointParts[1]);
						
						if(pointParts.Length > 2)
							points[i].Z = ParseDouble(pointParts[2]);

					}

					System.Drawing.Color c = System.Drawing.Color.Black;
					System.Drawing.Color outlineColor = System.Drawing.Color.Black;
					
					if(iter.Current.Select("FeatureColor").Count > 0)
					{
						c =	getColor(iter.Current.Select("FeatureColor"));
					}

					if(iter.Current.Select("OutlineColor").Count > 0)
					{
						outlineColor =	getColor(iter.Current.Select("OutlineColor"));
					}

					PolygonFeature pf = null;
					
					LinearRing outerRing = new LinearRing();
					outerRing.Points = points;

					pf = new PolygonFeature(name, parentWorld, outerRing, null, c);

					pf.OutlineColor = outlineColor;

					if(outlineString != null && outlineString.Length > 0)
						pf.Outline = ParseBool(outlineString);

					if(opacityString != null && opacityString.Length > 0)
						pf.Opacity = byte.Parse(opacityString);

					if(distanceAboveSurfaceString != null && distanceAboveSurfaceString.Length > 0)
						pf.DistanceAboveSurface = ParseDouble(distanceAboveSurfaceString);

					if(minimumDisplayAltitudeString != null && minimumDisplayAltitudeString.Length > 0)
						pf.MinimumDisplayAltitude = ParseDouble(minimumDisplayAltitudeString);

					if(maximumDisplayAltitudeString != null && maximumDisplayAltitudeString.Length > 0)
						pf.MaximumDisplayAltitude = ParseDouble(maximumDisplayAltitudeString);

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

					addExtendedInformation(iter.Current.Select("ExtendedInformation"), pf);

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

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

					pf.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);
					pf.ParentList = parentRenderable;

					if(World.Settings.useDefaultLayerStates)
					{
						pf.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
					}
					else
					{
						pf.IsOn = IsLayerOn(pf);
					}
					parentRenderable.ChildObjects.Add(
						pf
						);

					parentRenderable.RenderPriority = RenderPriority.LinePaths;
					
				}
			}
		}
		private static void addLineFeature(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
					
					string distanceAboveSurfaceString = getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface"));
					string minimumDisplayAltitudeString = getInnerTextFromFirstChild(iter.Current.Select("MinimumDisplayAltitude"));
					string maximumDisplayAltitudeString = getInnerTextFromFirstChild(iter.Current.Select("MaximumDisplayAltitude"));
					string opacityString = getInnerTextFromFirstChild(iter.Current.Select("Opacity"));
					//string extrudeHeightString = getInnerTextFromFirstChild(iter.Current.Select("ExtrudeHeight"));
					string extrudeUpwardsString = getInnerTextFromFirstChild(iter.Current.Select("Extrude"));
					string imageUri = getInnerTextFromFirstChild(iter.Current.Select("ImageUri"));
					string outlineString = getInnerTextFromFirstChild(iter.Current.Select("Outline"));
					string lineWidthString = getInnerTextFromFirstChild(iter.Current.Select("LineWidth"));
                    string altitudemodeString = getInnerTextFromFirstChild(iter.Current.Select("AltitudeMode"));

					XPathNodeIterator posListIter = iter.Current.Select("LineString/posList");
					posListIter.MoveNext();

					string lineString = getInnerTextFromFirstChild(posListIter);
					
					string[] lineParts = lineString.Split(' ');
					Point3d[] points = new Point3d[lineParts.Length];
					
					for(int i = 0; i < lineParts.Length; i++)
					{
						string[] pointParts = lineParts[i].Split(',');
						points[i] = new Point3d();
						points[i].X = ParseDouble(pointParts[0]);
						points[i].Y = ParseDouble(pointParts[1]);
						
						if(pointParts.Length > 2)
							points[i].Z = ParseDouble(pointParts[2]);

					}

					System.Drawing.Color c = System.Drawing.Color.Black;
					
					if(iter.Current.Select("RGBColor").Count > 0)
					{
						c =	getColor(iter.Current.Select("RGBColor"));
					}

					if(iter.Current.Select("FeatureColor").Count > 0)
					{
						c =	getColor(iter.Current.Select("FeatureColor"));
					}

					LineFeature lf = null;
					
					if(imageUri != null && imageUri.Length > 0)
					{
						lf = new LineFeature(name, parentWorld, points, imageUri);
					}
					else
					{
						lf = new LineFeature(
							name,
							parentWorld,
							points,
							c);
					}

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

					if(iter.Current.Select("OutlineColor").Count > 0)
					{
						lf.LineColor =	getColor(iter.Current.Select("OutlineColor"));
					}
					
					if(lineWidthString != null)
						lf.LineWidth = (float)ParseDouble(lineWidthString);

					if(outlineString != null && outlineString.Length > 0)
						lf.Outline = ParseBool(outlineString);

					if(opacityString != null && opacityString.Length > 0)
						lf.Opacity = byte.Parse(opacityString);

					if(distanceAboveSurfaceString != null && distanceAboveSurfaceString.Length > 0)
						lf.DistanceAboveSurface = ParseDouble(distanceAboveSurfaceString);

					if(minimumDisplayAltitudeString != null && minimumDisplayAltitudeString.Length > 0)
						lf.MinimumDisplayAltitude = ParseDouble(minimumDisplayAltitudeString);

					if(maximumDisplayAltitudeString != null && maximumDisplayAltitudeString.Length > 0)
						lf.MaximumDisplayAltitude = ParseDouble(maximumDisplayAltitudeString);

                    if (altitudemodeString != null && altitudemodeString.Length > 0)
                    {
                        if (altitudemodeString.ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("absolute")) lf.AltitudeMode = AltitudeMode.Absolute;
                        if (altitudemodeString.ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("relativetoground")) lf.AltitudeMode = AltitudeMode.RelativeToGround;
                        if (altitudemodeString.ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("clampedtoground")) lf.AltitudeMode = AltitudeMode.ClampedToGround;
                    }

                    if(extrudeUpwardsString!=null)
                    {
                        bool extrude = Convert.ToBoolean(extrudeUpwardsString);
                        lf.Extrude = extrude;
                    }

					addExtendedInformation(iter.Current.Select("ExtendedInformation"), lf);

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

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

					lf.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);
					lf.ParentList = parentRenderable;

					if(World.Settings.useDefaultLayerStates)
					{
						lf.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
					}
					else
					{
						lf.IsOn = IsLayerOn(lf);
					}
					parentRenderable.ChildObjects.Add(
						lf
						);

					parentRenderable.RenderPriority = RenderPriority.LinePaths;
					
				}
			}
		}
		private static void addPathList(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
					double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
					double minimumDisplayAltitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("MinDisplayAltitude")));
					double maximumDisplayAltitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("MaxDisplayAltitude")));
					
					string pathsDirectory = getInnerTextFromFirstChild(iter.Current.Select("PathsDirectory"));

					if(!Path.IsPathRooted(pathsDirectory))
					{
						Path.Combine(
							Path.GetDirectoryName(
							System.Windows.Forms.Application.ExecutablePath),
							pathsDirectory);
					}
					
					string winColorName = getInnerTextFromFirstChild(iter.Current.Select("WinColorName"));
					System.Drawing.Color c = System.Drawing.Color.White;

					if(winColorName != null)
					{
						c = System.Drawing.Color.FromName(winColorName);
					}
					else
					{
						c = getColor(iter.Current.Select("RGBColor"));
					}

					PathList pl = new PathList(
						name,
						parentWorld,
						minimumDisplayAltitude,
						maximumDisplayAltitude,
						pathsDirectory,
						distanceAboveSurface,
						c,
						parentWorld.TerrainAccessor
						);

					addExtendedInformation(iter.Current.Select("ExtendedInformation"), pl);

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

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

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

					pl.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);
					pl.ParentList = parentRenderable;

					if(World.Settings.useDefaultLayerStates)
					{
						pl.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
					}
					else
					{
						pl.IsOn = IsLayerOn(pl);
					}
					parentRenderable.ChildObjects.Add(
						pl
						);

					parentRenderable.RenderPriority = RenderPriority.LinePaths;
					
				}
			}
		}
		private static void addIcon(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					XPathNodeIterator nameIter = iter.Current.Select("Name");
					string name = getInnerTextFromFirstChild(nameIter);
		
					double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
					double latitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("Latitude/Value")));
					double longitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("Longitude/Value")));
					
					string refreshString = iter.Current.GetAttribute("Refresh", "");
					string description = getInnerTextFromFirstChild(iter.Current.Select("Description"));

					string isRotatedString = getInnerTextFromFirstChild(iter.Current.Select("IsRotated"));
					string rotationDegreesString =  getInnerTextFromFirstChild(iter.Current.Select("RotationDegrees"));

					string minimumDisplayAltitudeString = getInnerTextFromFirstChild(iter.Current.Select("MinimumDisplayAltitude"));
					string maximumDisplayAltitudeString = getInnerTextFromFirstChild(iter.Current.Select("MaximumDisplayAltitude"));

					string clickableUrl = getInnerTextFromFirstChild(iter.Current.Select("ClickableUrl"));
					
					string textureFilePath = getInnerTextFromFirstChild(iter.Current.Select("TextureFilePath"));

                    if (textureFilePath.Length > 0 && !Path.IsPathRooted(textureFilePath) && !textureFilePath.ToLower(System.Globalization.CultureInfo.InvariantCulture).StartsWith("http://"))
						// Use absolute path to icon image
						textureFilePath = Path.Combine( 
							Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), textureFilePath );

					if(!Path.IsPathRooted(textureFilePath))
					{
						Path.Combine(
							Path.GetDirectoryName(
							System.Windows.Forms.Application.ExecutablePath),
							textureFilePath);
					}
					
					WorldWind.Renderable.Icon ic = new WorldWind.Renderable.Icon(
						name,
						latitude,
						longitude,
						distanceAboveSurface );
					
					string nameAlwaysVisibleString = nameIter.Current.GetAttribute("AlwaysVisible", "");
					if(nameAlwaysVisibleString != null && nameAlwaysVisibleString.Length > 0)
					{
						ic.NameAlwaysVisible = ParseBool(nameAlwaysVisibleString);
					}

					ic.TextureFileName = textureFilePath;
					ic.Width =	int.Parse(getInnerTextFromFirstChild(iter.Current.Select("IconWidthPixels")));
					ic.Height = int.Parse(getInnerTextFromFirstChild(iter.Current.Select("IconHeightPixels")));
					
					if(refreshString != null && refreshString.Length > 0)
					{
						ic.RefreshInterval = TimeSpan.FromSeconds(ParseDouble(refreshString));
					}

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

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

					if(description != null)
						ic.Description = description;

					if(clickableUrl != null)
						ic.ClickableActionURL = clickableUrl;

					if(maximumDisplayAltitudeString != null)
						ic.MaximumDisplayDistance = ParseDouble(maximumDisplayAltitudeString);

					if(minimumDisplayAltitudeString != null)
						ic.MinimumDisplayDistance = ParseDouble(minimumDisplayAltitudeString);

					string onClickZoomAltString = getInnerTextFromFirstChild(iter.Current.Select("OnClickZoomAltitude"));
					string onClickZoomHeadingString = getInnerTextFromFirstChild(iter.Current.Select("OnClickZoomHeading"));
					string onClickZoomTiltString = getInnerTextFromFirstChild(iter.Current.Select("OnClickZoomTilt"));
					
					if(onClickZoomAltString != null)
						ic.OnClickZoomAltitude = ParseDouble(onClickZoomAltString);

					if(onClickZoomHeadingString != null)
						ic.OnClickZoomHeading = ParseDouble(onClickZoomHeadingString);

					if(onClickZoomTiltString != null)
						ic.OnClickZoomTilt = ParseDouble(onClickZoomTiltString);

					if(isRotatedString != null)
					{
						ic.IsRotated = ParseBool(isRotatedString);
					}

					if(rotationDegreesString != null)
					{
						if(!ic.IsRotated)
							ic.IsRotated = true;

						ic.Rotation = Angle.FromDegrees(ParseDouble(rotationDegreesString));
					}

					addExtendedInformation(iter.Current.Select("ExtendedInformation"), ic);
					
					ic.ParentList = parentRenderable;

					string cachePath = String.Format("{0}{1}{2}{1}{3}{1}{3}", cache.CacheDirectory, Path.DirectorySeparatorChar, getRenderablePathString(parentRenderable), name);

					ic.SaveFilePath = cachePath;

					if(World.Settings.useDefaultLayerStates)
					{
						ic.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
					}
					else
					{
						ic.IsOn = IsLayerOn(ic);
					}
					ic.MetaData["XmlSource"] = (string)parentRenderable.MetaData["XmlSource"];

					Icons parentIconList = (Icons)parentRenderable;

					parentIconList.Add(ic);

					addScreenOverlaysToIcon(iter.Current.Select("ScreenOverlay"), parentWorld, ic, cache);
				}
			}
		}
		private static void addTiledPlacenameSet(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
					double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
					double minimumDisplayAltitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("MinimumDisplayAltitude")));
					double maximumDisplayAltitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("MaximumDisplayAltitude")));
					
					string placenameListFilePath = getInnerTextFromFirstChild(iter.Current.Select("PlacenameListFilePath"));

					if(!Path.IsPathRooted(placenameListFilePath))
					{
						Path.Combine(
							Path.GetDirectoryName(
							System.Windows.Forms.Application.ExecutablePath),
							placenameListFilePath);
					}
					string winColorName = getInnerTextFromFirstChild(iter.Current.Select("WinColorName"));
					string iconFilePath = getInnerTextFromFirstChild(iter.Current.Select("IconFilePath"));

					Microsoft.DirectX.Direct3D.FontDescription fd = getDisplayFont(iter.Current.Select("DisplayFont"));

					System.Drawing.Color c = System.Drawing.Color.White;

					if(winColorName != null)
					{
						c = System.Drawing.Color.FromName(winColorName);
					}
					else
					{
						c = getColor(iter.Current.Select("RGBColor"));
					}

					TiledPlacenameSet tps = new TiledPlacenameSet(
						name,
						parentWorld,
						distanceAboveSurface,
						maximumDisplayAltitude,
						minimumDisplayAltitude,
						placenameListFilePath,
						fd,
						c,
						iconFilePath);

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

					addExtendedInformation(iter.Current.Select("ExtendedInformation"), tps);

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

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

					tps.MetaData.Add("PlacenameDataFile", placenameListFilePath);
					tps.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);
					tps.ParentList = parentRenderable;
					
					if(World.Settings.useDefaultLayerStates)
					{
						tps.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
					}
					else
					{
						tps.IsOn = IsLayerOn(tps);
					}
					parentRenderable.ChildObjects.Add(
						tps
						);

					parentRenderable.RenderPriority = RenderPriority.Placenames;
					
				}
			}
		}
        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;
		}
		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;
		}
Example #29
0
        public override void Dispose()
        {
            saveRenderableStates(RenderableObjects);

            if (this.RenderableObjects != null)
            {
                this.RenderableObjects.Dispose();
                this.RenderableObjects = null;
            }

            if (m_WorldSurfaceRenderer != null)
            {
                m_WorldSurfaceRenderer.Dispose();
            }

            if (m_outerSphere != null)
            {
                m_outerSphere.Dispose();
            }
        }
Example #30
0
        private static void AddMyChart(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
        {
            if (iter.Count > 0) {
                while (iter.MoveNext()) {
                    string isOnStr = iter.Current.GetAttribute("ShowAtStartup", "");
                    string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                    string latStr = getInnerTextFromFirstChild(iter.Current.Select("Latitude/Value"));
                    string lonStr = getInnerTextFromFirstChild(iter.Current.Select("Longitude/Value"));
                    string distStr = getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface"));
                    string diaStr = getInnerTextFromFirstChild(iter.Current.Select("Diameter"));
                    string heightStr = getInnerTextFromFirstChild(iter.Current.Select("Height"));
                    Color chartColor = getColor(iter.Current.Select("ChartColor"));
                    string scaleStr = getInnerTextFromFirstChild(iter.Current.Select("Scale"));
                    string typeStr = getInnerTextFromFirstChild(iter.Current.Select("ChartType"));
                    string capTxt = getInnerTextFromFirstChild(iter.Current.Select("Caption/CaptionText"));
                    FontDescription capFontDesc = getDisplayFont(iter.Current.Select("Caption/DisplayFont"));
                    Color capColor = getColor(iter.Current.Select("CaptionColor"));
                    string clkUrl = getInnerTextFromFirstChild(iter.Current.Select("ClickableUrl"));
                    string minViewRng = getInnerTextFromFirstChild(iter.Current.Select("MinViewRange"));
                    string maxViewRng = getInnerTextFromFirstChild(iter.Current.Select("MaxViewRange"));

                    MyChart c = new MyChart(name, (float) ParseDouble(latStr), (float) ParseDouble(lonStr), (float) ParseDouble(distStr));
                    c.Diameter = (float) ParseDouble(diaStr);
                    c.Height = (float) ParseDouble(heightStr);
                    c.ChartColor = chartColor;
                    c.ChartType = typeStr;
                    c.Caption = capTxt;
                    c.CaptionFont = new Font(capFontDesc.FaceName, 9.0F);
                    c.CaptionColor = capColor;
                    c.ClickableUrl = clkUrl;
                    c.MinViewRange = (float) ParseDouble(minViewRng);
                    c.MaxViewRange = (float) ParseDouble(maxViewRng);
                    MyCharts.WindowWidth = 1024;
                    MyCharts myCharts = parentRenderable as MyCharts;
                    myCharts.Add(c);

                    c.ParentWorld = parentWorld;
                    c.ParentList = myCharts;
                    c.Scale = (float) ParseDouble(scaleStr);
                }
            }
        }
		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);
			}
		}
Example #32
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);
                }
            }
        }
		private static void addImageLayersFromXPathNodeIterator(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
					double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
					string texturePath = getInnerTextFromFirstChild(iter.Current.Select("TexturePath"));
					byte opacity = byte.Parse(getInnerTextFromFirstChild(iter.Current.Select("Opacity")));

					TimeSpan dataExpiration = getCacheExpiration(iter.Current.Select("CacheExpirationTime"));
					string imageUrl = null;

					if(texturePath.StartsWith("http://"))
					{
						imageUrl = texturePath;
						texturePath = null;
					}

					XPathNodeIterator boundingBoxIter = iter.Current.Select("BoundingBox");
					if(boundingBoxIter.Count > 0)
					{
						boundingBoxIter.MoveNext();

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

						ImageLayer im = new ImageLayer(
							name,
							parentWorld,
							distanceAboveSurface,
							texturePath,
							south,
							north,
							west,
							east,
							opacity, 
							parentWorld.TerrainAccessor);

						im.ImageUrl = imageUrl;
						im.CacheExpiration = dataExpiration;

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

						addExtendedInformation(iter.Current.Select("ExtendedInformation"), im);

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

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

						im.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);

						im.ParentList = parentRenderable;
						if(World.Settings.useDefaultLayerStates)
						{
							im.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
						}
						else
						{
							im.IsOn = IsLayerOn(im);
						}
						parentRenderable.ChildObjects.Add(
							im
							);
					}
				}
			}
		}
		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);
			}
		}
Example #35
0
 private void LoadPlacenames(Object oParams)
 {
     this.placeNames = ConfigurationLoader.getRenderableFromLayerFile(Path.Combine(CurrentSettingsDirectory, "^Placenames.xml"), this.WorldWindow.CurrentWorld, this.WorldWindow.Cache, true, null);
     try
     {
         if (!this.IsDisposed)
             Invoke(new MethodInvoker(LoadPlacenamesCallback));
     }
     catch (ObjectDisposedException)
     {
         // --- The user closed the form before the placenames were loaded.  Ignore, since we're shutting down anyway. ---
     }
 }
Example #36
0
        private static void addTiledWFSPlacenameSet(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")));
                    double minimumDisplayAltitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("MinimumDisplayAltitude")));
                    double maximumDisplayAltitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("MaximumDisplayAltitude")));

                    string wfsBaseUrl = getInnerTextFromFirstChild(iter.Current.Select("WFSBaseURL"));
                    string typename = getInnerTextFromFirstChild(iter.Current.Select("TypeName"));
                    string labelfield = getInnerTextFromFirstChild(iter.Current.Select("LabelField"));
                    /*
                    if (!Path.IsPathRooted(wfsBaseUrl))
                    {
                         Path.Combine(
                              Path.GetDirectoryName(
                              System.Windows.Forms.Application.ExecutablePath),
                              wfsBaseUrl);
                    }
                    */
                    string iconFilePath = getInnerTextFromFirstChild(iter.Current.Select("IconFilePath"));

                    Microsoft.DirectX.Direct3D.FontDescription fd = getDisplayFont(iter.Current.Select("DisplayFont"));

                    System.Drawing.Color c = parseColorNode(iter.Current);

                    //TODO:Validate URL
                    //Construct WFS Base URL
                    wfsBaseUrl += "TypeName=" + typename + "&Request=GetFeature&Service=WFS";

                    TiledWFSPlacenameSet twps = new TiledWFSPlacenameSet(
                         name,
                         parentWorld,
                         distanceAboveSurface,
                         maximumDisplayAltitude,
                         minimumDisplayAltitude,
                         wfsBaseUrl,
                         typename,
                         labelfield,
                         fd,
                         c,
                         iconFilePath,
                 cache);

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

                    addExtendedInformation(iter.Current.Select("ExtendedInformation"), twps);

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

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

                    twps.MetaData.Add("WFSBaseURL", wfsBaseUrl);
                    twps.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);
                    twps.ParentList = parentRenderable;
                    twps.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));

                    parentRenderable.ChildObjects.Add(
                         twps
                         );

                    parentRenderable.RenderPriority = RenderPriority.Placenames;

                }
            }
        }
Example #37
0
 /// <summary>
 /// Unloads our plugin
 /// </summary>
 public override void Unload()
 {
     if (m_wavingFlagsList != null)
     {
         ParentApplication.WorldWindow.CurrentWorld.RenderableObjects.Remove(m_wavingFlagsList.Name);
         m_wavingFlagsList.Dispose();
         m_wavingFlagsList = null;
     }
 }
Example #38
0
		private RenderableObject getRenderableObjectListFromLayerSet(World curWorld, LayerSet.Type_LayerSet curLayerSet, string layerSetFile)//ref TreeNode treeNode)
		{
			RenderableObjectList rol = null;

			// If the layer set has icons, use the icon list layer as parent
			if(curLayerSet.HasIcon())
			{
				rol = new Icons(curLayerSet.Name.Value);
				rol.RenderPriority = RenderPriority.Icons;
			}
			else
				rol = new RenderableObjectList(curLayerSet.Name.Value);
			
			if(curLayerSet.HasShowOnlyOneLayer())
				rol.ShowOnlyOneLayer = curLayerSet.ShowOnlyOneLayer.Value;

			// HACK: This should be part of the settings
			if(curLayerSet.Name.ToString().ToUpper(System.Globalization.CultureInfo.InvariantCulture)=="PLACENAMES")
				rol.RenderPriority = RenderPriority.Placenames;

			if(curLayerSet.HasExtendedInformation())
			{
				if(curLayerSet.ExtendedInformation.HasToolBarImage())
					rol.MetaData.Add("ToolBarImagePath", curLayerSet.ExtendedInformation.ToolBarImage.Value);
			}
			if(curLayerSet.HasImageLayer())
			{
				for(int i = 0; i < curLayerSet.ImageLayerCount; i++)
				{
					LayerSet.Type_ImageLayer curImageLayerType = curLayerSet.GetImageLayerAt(i);
					
					// <TexturePath> could contain Url, relative path, or absolute path
					string imagePath = null;
					string imageUrl = null;
                    if (curImageLayerType.TexturePath.Value.ToLower(System.Globalization.CultureInfo.InvariantCulture).StartsWith(("http://")))
					{
						imageUrl = curImageLayerType.TexturePath.Value;
					}
					else
					{
						imagePath = curImageLayerType.TexturePath.Value;
						if(!Path.IsPathRooted(imagePath))
							imagePath = Path.Combine(DirectoryPath, imagePath);
					}

					int transparentColor = 0;

					if(curImageLayerType.HasTransparentColor())
					{
						transparentColor = System.Drawing.Color.FromArgb(
							curImageLayerType.TransparentColor.Red.Value,
							curImageLayerType.TransparentColor.Green.Value,
							curImageLayerType.TransparentColor.Blue.Value).ToArgb();

					}

					ImageLayer newImageLayer = new ImageLayer(
						curImageLayerType.Name.Value,
						curWorld,
						(float)curImageLayerType.DistanceAboveSurface.Value,
						imagePath,
						(float)curImageLayerType.BoundingBox.South.Value2.DoubleValue(),
						(float)curImageLayerType.BoundingBox.North.Value2.DoubleValue(),
						(float)curImageLayerType.BoundingBox.West.Value2.DoubleValue(),
						(float)curImageLayerType.BoundingBox.East.Value2.DoubleValue(),
						(byte)curImageLayerType.Opacity.Value,
						(curImageLayerType.TerrainMapped.Value ? curWorld.TerrainAccessor : null));

					newImageLayer.ImageUrl = imageUrl;
					newImageLayer.TransparentColor = transparentColor;
					newImageLayer.IsOn = curImageLayerType.ShowAtStartup.Value;
					if(curImageLayerType.HasLegendImagePath())
						newImageLayer.LegendImagePath = curImageLayerType.LegendImagePath.Value;
					
					if(curImageLayerType.HasExtendedInformation() && curImageLayerType.ExtendedInformation.HasToolBarImage())
						newImageLayer.MetaData.Add("ToolBarImagePath", Path.Combine(DirectoryPath, curImageLayerType.ExtendedInformation.ToolBarImage.Value));

					rol.Add(newImageLayer);
				}
			}

			if(curLayerSet.HasQuadTileSet())
			{
				for(int i = 0; i < curLayerSet.QuadTileSetCount; i++)
				{
					LayerSet.Type_QuadTileSet2 curQtsType = curLayerSet.GetQuadTileSetAt(i);

					/*ImageAccessor imageAccessor = null;

					string permDirPath = null;
					if(curQtsType.ImageAccessor.HasPermanantDirectory())
					{
						permDirPath = curQtsType.ImageAccessor.PermanantDirectory.Value;
						if(!Path.IsPathRooted(permDirPath))
							permDirPath = Path.Combine( DirectoryPath, permDirPath );
					}

					string cacheDirPath = Path.Combine(worldWindow.Cache.CacheDirectory,
						Path.Combine(curWorld.Name,
						Path.Combine(rol.Name, curQtsType.Name.Value )));

					int transparentColor = 0;
					if(curQtsType.HasTransparentColor())
					{
						transparentColor = System.Drawing.Color.FromArgb(
							curQtsType.TransparentColor.Red.Value,
							curQtsType.TransparentColor.Green.Value,
							curQtsType.TransparentColor.Blue.Value).ToArgb();

					}
					if(curQtsType.ImageAccessor.HasWMSAccessor())
					{
						WMSLayerAccessor wmsLayerAccessor = null;
						wmsLayerAccessor = new WMSLayerAccessor();
						wmsLayerAccessor.ImageFormat = curQtsType.ImageAccessor.WMSAccessor.ImageFormat.Value;
						wmsLayerAccessor.IsTransparent = curQtsType.ImageAccessor.WMSAccessor.UseTransparency.Value;
						wmsLayerAccessor.ServerGetMapUrl = curQtsType.ImageAccessor.WMSAccessor.ServerGetMapUrl.Value;
						wmsLayerAccessor.Version = curQtsType.ImageAccessor.WMSAccessor.Version.Value;
						wmsLayerAccessor.WMSLayerName = curQtsType.ImageAccessor.WMSAccessor.WMSLayerName.Value;

						if(curQtsType.ImageAccessor.WMSAccessor.HasUsername())
							wmsLayerAccessor.Username = curQtsType.ImageAccessor.WMSAccessor.Username.Value;

						if(curQtsType.ImageAccessor.WMSAccessor.HasPassword())
							wmsLayerAccessor.Password = curQtsType.ImageAccessor.WMSAccessor.Password.Value;

						if(curQtsType.ImageAccessor.WMSAccessor.HasWMSLayerStyle())
							wmsLayerAccessor.WMSLayerStyle = curQtsType.ImageAccessor.WMSAccessor.WMSLayerStyle.Value;
						else
							wmsLayerAccessor.WMSLayerStyle = "";

						if(curQtsType.ImageAccessor.WMSAccessor.HasServerLogoFilePath())
						{
							string logoPath = Path.Combine(DirectoryPath, curQtsType.ImageAccessor.WMSAccessor.ServerLogoFilePath.Value);
							if(File.Exists(logoPath))
								wmsLayerAccessor.LogoFilePath = logoPath;
						}

						imageAccessor = new ImageAccessor(
							permDirPath,
							curQtsType.ImageAccessor.TextureSizePixels.Value,
							curQtsType.ImageAccessor.LevelZeroTileSizeDegrees.DoubleValue(),
							curQtsType.ImageAccessor.NumberLevels.Value,
							curQtsType.ImageAccessor.ImageFileExtension.Value,
							cacheDirPath,
							wmsLayerAccessor);
					}
					else if(curQtsType.ImageAccessor.HasImageTileService())
					{
						string logoPath = null;
						if(curQtsType.ImageAccessor.ImageTileService.HasServerLogoFilePath())
							logoPath = Path.Combine( DirectoryPath, curQtsType.ImageAccessor.ImageTileService.ServerLogoFilePath.Value);

						ImageTileService imageTileService = new ImageTileService(
							curQtsType.ImageAccessor.ImageTileService.DataSetName.Value,
							curQtsType.ImageAccessor.ImageTileService.ServerUrl.Value,
							logoPath );

						imageAccessor = new ImageAccessor(
							permDirPath,
							curQtsType.ImageAccessor.TextureSizePixels.Value,
							curQtsType.ImageAccessor.LevelZeroTileSizeDegrees.DoubleValue(),
							curQtsType.ImageAccessor.NumberLevels.Value,
							curQtsType.ImageAccessor.ImageFileExtension.Value,
							cacheDirPath,
							imageTileService);
					}
					else if(curQtsType.ImageAccessor.HasDuplicateTilePath())
					{
						string dupePath = curQtsType.ImageAccessor.DuplicateTilePath.Value;
						if(!Path.IsPathRooted(dupePath))
							dupePath = Path.Combine(DirectoryPath, dupePath);
						imageAccessor = new ImageAccessor(
							permDirPath,
							curQtsType.ImageAccessor.TextureSizePixels.Value,
							curQtsType.ImageAccessor.LevelZeroTileSizeDegrees.DoubleValue(),
							curQtsType.ImageAccessor.NumberLevels.Value,
							curQtsType.ImageAccessor.ImageFileExtension.Value,
							cacheDirPath,
							dupePath);
					}
					else
					{
						imageAccessor = new ImageAccessor(
							permDirPath,
							curQtsType.ImageAccessor.TextureSizePixels.Value,
							curQtsType.ImageAccessor.LevelZeroTileSizeDegrees.DoubleValue(),
							curQtsType.ImageAccessor.NumberLevels.Value,
							curQtsType.ImageAccessor.ImageFileExtension.Value,
							cacheDirPath);
					}

					QuadTileSet qts = new QuadTileSet(
						curQtsType.Name.Value,
						curWorld,
						curQtsType.DistanceAboveSurface.DoubleValue(),
						curQtsType.BoundingBox.North.Value2.DoubleValue(),
						curQtsType.BoundingBox.South.Value2.DoubleValue(),
						curQtsType.BoundingBox.West.Value2.DoubleValue(),
						curQtsType.BoundingBox.East.Value2.DoubleValue(),
						(curQtsType.TerrainMapped.Value ? curWorld.TerrainAccessor : null),
						imageAccessor);

					qts.TransparentColor = transparentColor;

					if(curQtsType.ShowAtStartup.Value)
						qts.IsOn = true;
					else
						qts.IsOn = false;


					if(curQtsType.HasExtendedInformation() && curQtsType.ExtendedInformation.HasToolBarImage())
					{
						try
						{
							string fileName = Path.Combine(DirectoryPath, curQtsType.ExtendedInformation.ToolBarImage.Value);
							if (File.Exists(fileName))
								qts.MetaData.Add("ToolBarImagePath", fileName);
						}
						catch
						{
							// TODO: Log or display warning
						}
					}

					rol.Add(qts);*/
				}
			}

			if(curLayerSet.HasPathList())
			{
				for(int i = 0; i < curLayerSet.PathListCount; i++)
				{
					LayerSet.Type_PathList2 newPathList = curLayerSet.GetPathListAt(i);

					PathList pl = new PathList(
						newPathList.Name.Value,
						curWorld,
						newPathList.MinDisplayAltitude.DoubleValue(),
						newPathList.MaxDisplayAltitude.DoubleValue(),
						DirectoryPath + "//" + newPathList.PathsDirectory.Value,
						newPathList.DistanceAboveSurface.DoubleValue(),
						(newPathList.HasWinColorName() ? System.Drawing.Color.FromName(newPathList.WinColorName.Value) : System.Drawing.Color.FromArgb(newPathList.RGBColor.Red.Value, newPathList.RGBColor.Green.Value, newPathList.RGBColor.Blue.Value)),
						curWorld.TerrainAccessor);

					pl.IsOn = newPathList.ShowAtStartup.Value;

					if(newPathList.HasExtendedInformation() && newPathList.ExtendedInformation.HasToolBarImage())
						pl.MetaData.Add("ToolBarImagePath", Path.Combine(DirectoryPath, newPathList.ExtendedInformation.ToolBarImage.Value));
					
					rol.Add(pl);
				}
			}

			if(curLayerSet.HasShapeFileLayer())
			{
				for(int i = 0; i < curLayerSet.ShapeFileLayerCount; i++)
				{
					LayerSet.Type_ShapeFileLayer2 newShapefileLayer = curLayerSet.GetShapeFileLayerAt(i);
					Microsoft.DirectX.Direct3D.FontDescription fd = GetLayerFontDescription(newShapefileLayer.DisplayFont);
					Microsoft.DirectX.Direct3D.Font font = worldWindow.DrawArgs.CreateFont( fd );
					ShapeLayer sp = new ShapeLayer(
						newShapefileLayer.Name.Value,
						curWorld,
						newShapefileLayer.DistanceAboveSurface.DoubleValue(),
						newShapefileLayer.MasterFilePath.Value,
						newShapefileLayer.MinimumViewAltitude.DoubleValue(),
						newShapefileLayer.MaximumViewAltitude.DoubleValue(),
						font,
						(newShapefileLayer.HasWinColorName() ? System.Drawing.Color.FromName(newShapefileLayer.WinColorName.Value) : System.Drawing.Color.FromArgb(newShapefileLayer.RGBColor.Red.Value, newShapefileLayer.RGBColor.Green.Value, newShapefileLayer.RGBColor.Blue.Value)),
						(newShapefileLayer.HasScalarKey() ? newShapefileLayer.ScalarKey.Value : null),
						(newShapefileLayer.HasShowBoundaries() ? newShapefileLayer.ShowBoundaries.Value : false),
						(newShapefileLayer.HasShowFilledRegions() ? newShapefileLayer.ShowFilledRegions.Value : false));

					sp.IsOn = newShapefileLayer.ShowAtStartup.BoolValue();

					if(newShapefileLayer.HasExtendedInformation() && newShapefileLayer.ExtendedInformation.HasToolBarImage())
						sp.MetaData.Add("ToolBarImagePath", Path.Combine(DirectoryPath, newShapefileLayer.ExtendedInformation.ToolBarImage.Value));

					rol.Add(sp);
				}
			}

			if(curLayerSet.HasIcon())
			{
				Icons icons = (Icons)rol;

				for(int i = 0; i < curLayerSet.IconCount; i++)
				{
					LayerSet.Type_Icon newIcon = curLayerSet.GetIconAt(i);

					string textureFullPath = newIcon.TextureFilePath.Value;
					if (textureFullPath.Length > 0 && !Path.IsPathRooted(textureFullPath))
						// Use absolute path to icon image
						textureFullPath = Path.Combine( DirectoryPath, newIcon.TextureFilePath.Value );

					WorldWind.Renderable.Icon ic = new WorldWind.Renderable.Icon(
						newIcon.Name.Value,
						(float)newIcon.Latitude.Value2.DoubleValue(),
						(float)newIcon.Longitude.Value2.DoubleValue(),
						(float)newIcon.DistanceAboveSurface.DoubleValue() );
					
					ic.TextureFileName = textureFullPath;
					ic.Width =	newIcon.IconWidthPixels.Value;
					ic.Height = newIcon.IconHeightPixels.Value;
					ic.IsOn = newIcon.ShowAtStartup.Value;
					if(newIcon.HasDescription())
						ic.Description = newIcon.Description.Value;
					if(newIcon.HasClickableUrl())
						ic.ClickableActionURL = newIcon.ClickableUrl.Value;
					if(newIcon.HasMaximumDisplayAltitude())
						ic.MaximumDisplayDistance = (float)newIcon.MaximumDisplayAltitude.Value;
					if(newIcon.HasMinimumDisplayAltitude())
						ic.MinimumDisplayDistance = (float)newIcon.MinimumDisplayAltitude.Value;

					icons.Add(ic);
				}
			}

			if(curLayerSet.HasTiledPlacenameSet())
			{
				for(int i = 0; i < curLayerSet.TiledPlacenameSetCount; i++)
				{
					LayerSet.Type_TiledPlacenameSet2 newPlacenames = curLayerSet.GetTiledPlacenameSetAt(i);

					string filePath = newPlacenames.PlacenameListFilePath.Value;
					if(!Path.IsPathRooted(filePath))
						filePath = Path.Combine(DirectoryPath, filePath);

					Microsoft.DirectX.Direct3D.FontDescription fd = GetLayerFontDescription(newPlacenames.DisplayFont);
					TiledPlacenameSet tps = new TiledPlacenameSet(
						newPlacenames.Name.Value,
						curWorld,
						newPlacenames.DistanceAboveSurface.DoubleValue(),
						newPlacenames.MaximumDisplayAltitude.DoubleValue(),
						newPlacenames.MinimumDisplayAltitude.DoubleValue(),
						filePath,
						fd,
						(newPlacenames.HasWinColorName() ? System.Drawing.Color.FromName(newPlacenames.WinColorName.Value) : System.Drawing.Color.FromArgb(newPlacenames.RGBColor.Red.Value, newPlacenames.RGBColor.Green.Value, newPlacenames.RGBColor.Blue.Value)),
						(newPlacenames.HasIconFilePath() ? newPlacenames.IconFilePath.Value : null));

					if(newPlacenames.HasExtendedInformation() && newPlacenames.ExtendedInformation.HasToolBarImage())
						tps.MetaData.Add("ToolBarImagePath", Path.Combine(DirectoryPath, newPlacenames.ExtendedInformation.ToolBarImage.Value));

					tps.IsOn = newPlacenames.ShowAtStartup.Value;
					rol.Add(tps);
				}
			}

			if(curLayerSet.HasChildLayerSet())
			{
				for(int i = 0; i < curLayerSet.ChildLayerSetCount; i++)
				{
					LayerSet.Type_LayerSet ls = curLayerSet.GetChildLayerSetAt(i);

					rol.Add( getRenderableObjectListFromLayerSet( curWorld, ls, layerSetFile));
				}
			}

			rol.IsOn = curLayerSet.ShowAtStartup.Value;
			return rol;
		}
Example #39
0
        /// <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);
        }
        /// <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
            {
            }
        }
Example #41
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);

					
				}
			}			
			
		}
        private static ImageStore getImageStoreFromXPathNodeIterator(string name, XPathNodeIterator imageAccessorIter, RenderableObjectList parentRenderable, Cache cache)
        {
			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(System.Windows.Forms.Application.ExecutablePath), permanentDirectory);
			}

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

            byte opacity = 255;

            // case 1 : permanent directory specified.
			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; 
				}
                return ia;
            }

            // case 2: ImageTileService specified
			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(System.Windows.Forms.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;
                ia.ServerLogo = serverLogoFilePath;

                return ia;
            }

            // case 3: WMSAccessor specified
			XPathNodeIterator wmsAccessorIter = imageAccessorIter.Current.Select("WMSAccessor");
			if(wmsAccessorIter.Count > 0)
			{
				wmsAccessorIter.MoveNext();
				
				WorldWind.Net.Wms.WmsImageStore wmsLayerStore = new WorldWind.Net.Wms.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(System.Windows.Forms.Application.ExecutablePath),
						serverLogoPath);
				}
				if(opacityString != null)
					opacity = byte.Parse(opacityString);

                TimeSpan cacheExpiration = getCacheExpiration(imageAccessorIter.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;

                return wmsLayerStore;
            }
            Log.Write(Log.Levels.Warning, "CONF", "WARNING: no valid image store found!");
            return null;
        }
		private static void addScreenOverlays(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
					string imageUri = getInnerTextFromFirstChild(iter.Current.Select("ImageUri"));
					string startXString = getInnerTextFromFirstChild(iter.Current.Select("StartX"));
					string startYString = getInnerTextFromFirstChild(iter.Current.Select("StartY"));
					string widthString = getInnerTextFromFirstChild(iter.Current.Select("Width"));
					string heightString = getInnerTextFromFirstChild(iter.Current.Select("Height"));
					string opacityString = getInnerTextFromFirstChild(iter.Current.Select("Opacity"));
					string showHeaderString = getInnerTextFromFirstChild(iter.Current.Select("ShowHeader"));
					string alignmentString = getInnerTextFromFirstChild(iter.Current.Select("Alignment"));
					string clickableUrl = getInnerTextFromFirstChild(iter.Current.Select("ClickableUrl"));
					string refreshTimeString = iter.Current.GetAttribute("Refresh", "");
					string hideBorderString = getInnerTextFromFirstChild(iter.Current.Select("HideBorder"));

					if(startXString != null && startYString != null)
					{
						int startX = int.Parse(startXString);
						int startY = int.Parse(startYString);

						WorldWind.Renderable.ScreenOverlay overlay = new ScreenOverlay(name, startX, startY, imageUri);
					
						if(widthString != null)
						{
							overlay.Width = int.Parse(widthString);
						}
						if(heightString != null)
						{
							overlay.Height = int.Parse(heightString);
						}

						if(alignmentString != null)
						{
                            if (alignmentString.ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("left"))
							{
								overlay.Alignment = ScreenAlignment.Left;
							}
                            else if (alignmentString.ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("right"))
							{
								overlay.Alignment = ScreenAlignment.Right;
							}
						}

						if(clickableUrl != null && clickableUrl.Length > 0)
						{
							overlay.ClickableUrl = clickableUrl;
						}
						
						if(hideBorderString != null && hideBorderString.Length > 0)
							overlay.HideBorder = ParseBool(hideBorderString);

						if(iter.Current.Select("BorderColor").Count != 0)
						{
							overlay.BorderColor = getColor(iter.Current.Select("BorderColor"));
						}

						string cachePath = String.Format("{0}{1}{2}{1}{3}{1}{3}", cache.CacheDirectory, Path.DirectorySeparatorChar, getRenderablePathString(parentRenderable), name);

						if(refreshTimeString != null && refreshTimeString.Length > 0)
						{
							overlay.RefreshTimeSec = ParseDouble(refreshTimeString);
						}

						overlay.SaveFilePath = cachePath;
						addExtendedInformation(iter.Current.Select("ExtendedInformation"), overlay);

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

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

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

						overlay.MetaData.Add("XmlSource", (string)parentRenderable.MetaData["XmlSource"]);
						overlay.ParentList = parentRenderable;
						if(opacityString != null)
						{
							overlay.Opacity = byte.Parse(opacityString);
						}

						if(showHeaderString != null)
						{
							overlay.ShowHeader = ParseBool(showHeaderString);
						}

						if(World.Settings.useDefaultLayerStates)
						{
							overlay.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
						}
						else
						{
							overlay.IsOn = IsLayerOn(overlay);
						}

						parentRenderable.ChildObjects.Add(
							overlay
							);
					}
				}
			}
		}