Пример #1
0
        public ProjectedVectorRenderer(String strName, World parentWorld)
            : base(strName, parentWorld)
        {
            RenderPriority = WorldWind.Renderable.RenderPriority.LinePaths;

            CreateRootTiles();
        }
Пример #2
0
 internal static RenderableObject CreateKMLLayer(KMLFile oSource, World oWorld, out GeographicBoundingBox oBounds)
 {
     oBounds = GeographicBoundingBox.NullBox();
     RenderableObject result = Construct(Path.GetDirectoryName(oSource.Filename), oSource.Document, oWorld, oBounds, null, null);
     if (!oBounds.IsValid) oBounds = new GeographicBoundingBox(90.0, -90.0, -180.0, 180.0);
     return result;
 }
Пример #3
0
        public ModelFeature(string name,World parentWorld,string fileName,float Latitude,
            float Longitude,float Altitude,float Scale,float rotX,float rotY,float rotZ)
            : base(name,parentWorld) 
		{
			meshFileName = fileName;
            this.Latitude = Latitude;
            this.Longitude = Longitude;
            this.Altitude = Altitude;
            this.Scale = Scale;
            this.Rotx = rotX;
            this.Roty = rotY;
            this.Rotz = rotZ;
		}
Пример #4
0
		Vector3[] sphericalCoordinates = new Vector3[0]; // x = lat, y = lon, z = height

		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.PathLine"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="terrainfileName"></param>
		/// <param name="heightAboveSurface"></param>
		/// <param name="lineColor"></param>
		public PathLine(string name, World parentWorld, string terrainfileName, float heightAboveSurface, 
			System.Drawing.Color lineColor) 
			: base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			this._parentWorld = parentWorld;
			//this.terrainManager = terrainManager;
			this.terrainFileName = terrainfileName;
			this.heightAboveSurface = heightAboveSurface;
			this.lineColor = lineColor.ToArgb();
			
			if(this.terrainFileName == null)
			{
				this.isInitialized = true;
				this.isLoaded = true;
				this.linePoints = new CustomVertex.PositionColored[0];
				return;
			}
			
			FileInfo inFile = new FileInfo(this.terrainFileName);
			if(!inFile.Exists)
			{
				this.isInitialized = true;
				this.isLoaded = true;
				this.linePoints = new CustomVertex.PositionColored[0];
				return;
			}
			
			if(inFile.FullName.IndexOf('_') == -1)
			{
				return;
			}

			string[] parsedFileName = inFile.Name.Replace(".wwb","").Split('_');

			if(parsedFileName.Length < 5)
			{
				return;
			}
			else
			{
				this.north = (float)Int32.Parse(parsedFileName[1], CultureInfo.InvariantCulture);
				this.south = (float)Int32.Parse(parsedFileName[2], CultureInfo.InvariantCulture);
				this.west = (float)Int32.Parse(parsedFileName[3], CultureInfo.InvariantCulture);
				this.east = (float)Int32.Parse(parsedFileName[4], CultureInfo.InvariantCulture);
			}

			this.boundingBox = new BoundingBox( this.south, this.north, this.west, this.east, 
				(float)this._parentWorld.EquatorialRadius, 
				(float)this._parentWorld.EquatorialRadius + this.heightAboveSurface );
		}
Пример #5
0
        public WorldSurfaceRenderer(uint samplesPerTile, double distanceAboveSeaLevel, World parentWorld)
        {
            m_SamplesPerTile = samplesPerTile;
            m_ParentWorld = parentWorld;
            m_DistanceAboveSeaLevel = distanceAboveSeaLevel;

            double tileSize = 180.0f/m_NumberRootTilesHigh;

            m_RootSurfaceTiles = new SurfaceTile[m_NumberRootTilesHigh*(m_NumberRootTilesHigh*2)];
            for (int i = 0; i < m_NumberRootTilesHigh; i++) {
                for (int j = 0; j < m_NumberRootTilesHigh*2; j++) {
                    m_RootSurfaceTiles[i*m_NumberRootTilesHigh*2 + j] = new SurfaceTile((i + 1)*tileSize - 90.0f, i*tileSize - 90.0f, j*tileSize - 180.0f, (j + 1)*tileSize - 180.0f, 0, this);
                }
            }
        }
Пример #6
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.BoundaryLayer"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="distanceAboveSurface"></param>
		/// <param name="minDisplayAltitude"></param>
		/// <param name="maxDisplayAltitude"></param>
		/// <param name="boundaryFilePath"></param>
		/// <param name="color"></param>
		public BoundaryLayer(
			string name,
			World parentWorld,
			double distanceAboveSurface,
			double minDisplayAltitude,
			double maxDisplayAltitude,
			string boundaryFilePath,
			int color) : base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0))
		{
			this._parentWorld = parentWorld;
			this._distanceAboveSurface = distanceAboveSurface;
			this._minDisplayAltitude = minDisplayAltitude;
			this._maxDisplayAltitude = maxDisplayAltitude;
			this._boundaryFilePath = boundaryFilePath;
			this._color = color;
		}
Пример #7
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.TerrainPath"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="minDisplayAltitude"></param>
		/// <param name="maxDisplayAltitude"></param>
		/// <param name="terrainFileName"></param>
		/// <param name="heightAboveSurface"></param>
		/// <param name="lineColor"></param>
		/// <param name="terrainAccessor"></param>
		public TerrainPath(
			string name, 
			World parentWorld, 
			double minDisplayAltitude, 
			double maxDisplayAltitude, 
			string terrainFileName, 
			float heightAboveSurface, 
			System.Drawing.Color lineColor,
			TerrainAccessor terrainAccessor) 
			: base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			this._parentWorld = parentWorld;
			this._minDisplayAltitude = minDisplayAltitude;
			this._maxDisplayAltitude = maxDisplayAltitude;
			this.terrainFileName = terrainFileName;
			this.heightAboveSurface = heightAboveSurface;
			//this.terrainMapped = terrainMapped;
			this.lineColor = lineColor.ToArgb();
			this._terrainAccessor = terrainAccessor;
			this.RenderPriority = RenderPriority.LinePaths;
		}
Пример #8
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.TiledPlacenameSet"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="altitude"></param>
		/// <param name="maximumDisplayAltitude"></param>
		/// <param name="minimumDisplayAltitude"></param>
		/// <param name="placenameListFilePath"></param>
		/// <param name="fontDescription"></param>
		/// <param name="color"></param>
		/// <param name="iconFilePath"></param>
		public TiledPlacenameSet(
			string name, 
			World parentWorld,
			double altitude,
			double maximumDisplayAltitude,
			double minimumDisplayAltitude,
			string placenameListFilePath,
			FontDescription fontDescription,
			System.Drawing.Color color,
			string iconFilePath
			) : base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0))
		{
			m_parentWorld = parentWorld;
			m_altitude = altitude;
			m_maximumDistanceSq = maximumDisplayAltitude*maximumDisplayAltitude;
			m_minimumDistanceSq = minimumDisplayAltitude*minimumDisplayAltitude;
			m_placenameListFilePath = placenameListFilePath;
			m_fontDescription = fontDescription;
			m_color = color.ToArgb();
			m_iconFilePath = iconFilePath;
			
			// Set default render priority
			m_renderPriority = RenderPriority.Placenames;
		}
Пример #9
0
 internal static RenderableObjectList getRenderableFromLayerFile(string layerFile, World parentWorld, Cache cache, bool enableRefresh)
 {
     return getRenderableFromLayerFile(layerFile, parentWorld, cache, enableRefresh, null);
 }
Пример #10
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;
        }
Пример #11
0
 internal static RenderableObjectList getRenderableFromLayerFile(string layerFile, World parentWorld, Cache cache)
 {
     return getRenderableFromLayerFile(layerFile, parentWorld, cache, true);
 }
Пример #12
0
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(m_WorkerThread != null && m_WorkerThread.IsAlive)
				{
					m_WorkerThreadRunning = false;
					m_WorkerThread.Abort();
				}

				m_FpsTimer.Stop();
				if(m_World != null)
				{
					m_World.Dispose();
					m_World = null;
				}
				if(this.drawArgs != null)
				{
					this.drawArgs.Dispose();
					this.drawArgs = null;
				}
				if(this._menuBar!=null)
				{
					this._menuBar.Dispose();
					this._menuBar = null;
				}

				m_Device3d.Dispose();
/*
				if(m_downloadIndicator != null)
				{
					m_downloadIndicator.Dispose();
					m_downloadIndicator = null;
				}
*/				
			}

			base.Dispose( disposing );
			GC.SuppressFinalize(this);
		}
Пример #13
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.TerrainPath"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="minDisplayAltitude"></param>
		/// <param name="maxDisplayAltitude"></param>
		/// <param name="dataArchiveReader"></param>
		/// <param name="fileOffset"></param>
		/// <param name="fileSize"></param>
		/// <param name="north"></param>
		/// <param name="south"></param>
		/// <param name="east"></param>
		/// <param name="west"></param>
		/// <param name="heightAboveSurface"></param>
		/// <param name="lineColor"></param>
		/// <param name="terrainAccessor"></param>
		public JHU_TerrainPath(
			string name, 
			World parentWorld, 
			double minDisplayAltitude, 
			double maxDisplayAltitude, 
			BinaryReader dataArchiveReader,
			long fileOffset,
			long fileSize,
			double north,
			double south,
			double east, 
			double west,
			float heightAboveSurface, 
			System.Drawing.Color lineColor,
			TerrainAccessor terrainAccessor) 
			: base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			this._parentWorld = parentWorld;
			this._minDisplayAltitude = minDisplayAltitude;
			this._maxDisplayAltitude = maxDisplayAltitude;
			this._dataArchiveReader = dataArchiveReader;
			this._fileOffset = fileOffset;
			this._fileSize = fileSize;
			this.heightAboveSurface = heightAboveSurface;
			this.lineColor = lineColor.ToArgb();
			this._terrainAccessor = terrainAccessor;
			this.sphericalCoordinates = new ArrayList();
			
			this.north = (float)north;
			this.south = (float)south;
			this.west = (float)west;
			this.east = (float)east;

			this.RenderPriority = RenderPriority.LinePaths;

			this.boundingBox = new BoundingBox( this.south, this.north, this.west, this.east, 
				(float)this._parentWorld.EquatorialRadius, 
				(float)(this._parentWorld.EquatorialRadius + this.verticalExaggeration * heightAboveSurface));
		}
Пример #14
0
		/// <summary>
		/// Constructor
		/// </summary>
		public Stars3DLayer(string LayerName, string pluginPath, WorldWind.WorldWindow worldWindow) : base(LayerName)
		{
			this.pluginPath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"Plugins\stars3d\");
			this.world = worldWindow.CurrentWorld;
			this.drawArgs = worldWindow.DrawArgs;
			this.RenderPriority = RenderPriority.SurfaceImages;
			//this.sphereRadius = this.drawArgs.WorldCamera.WorldRadius * 20;
			ReadSettings();
		}
        public GPSGeoFence(World parentWorld, string sDescription, GpsTrackerPlugin Plugin)
            : base(sDescription, parentWorld.Position, Quaternion.RotationYawPitchRoll(0, 0, 0))
        {
            m_parentWorld = parentWorld;
            m_Plugin = Plugin;
            m_sDescription = sDescription;

            m_bDone = false;
            m_bCancel = false;
        }
Пример #16
0
		public LineFeature(string name, World parentWorld, Point3d[] points, string imageUri) : base(name, parentWorld)
		{
			m_points = points;
			m_imageUri = imageUri;
			m_numPoints = m_points.LongLength;

			RenderPriority = WorldWind.Renderable.RenderPriority.LinePaths;
		}
Пример #17
0
		public LineFeature(string name, World parentWorld, Point3d[] points, System.Drawing.Color lineColor) : base(name, parentWorld)
		{
			m_points = points;
			m_lineColor = lineColor;
			m_polygonColor = lineColor;
			m_numPoints = m_points.LongLength;

			RenderPriority = WorldWind.Renderable.RenderPriority.LinePaths;
		}
Пример #18
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.TiledPlacenameSet"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="altitude"></param>
		/// <param name="maximumDisplayAltitude"></param>
		/// <param name="minimumDisplayAltitude"></param>
		/// <param name="placenameBaseUrl"></param>
        /// <param name="labelfield">Field in Feature type used as PlacenameLabel</param>
		/// <param name="fontDescription"></param>
		/// <param name="color"></param>
		/// <param name="iconFilePath"></param>
		public TiledWFSPlacenameSet(
			string name, 
			World parentWorld,
			double altitude,
			double maximumDisplayAltitude,
			double minimumDisplayAltitude,
			string placenameBaseUrl,
            string typename,
            string labelfield,
			FontDescription fontDescription,
			System.Drawing.Color color,
			string iconFilePath,
			Cache cache
			) : base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0))
		{
		    m_name = name;
			m_parentWorld = parentWorld;
			m_altitude = altitude;
			m_maximumDistanceSq = maximumDisplayAltitude*maximumDisplayAltitude;
			m_minimumDistanceSq = minimumDisplayAltitude*minimumDisplayAltitude;
			m_placenameBaseUrl = placenameBaseUrl;
            m_typename = typename;
            m_labelfield = labelfield;
			m_fontDescription = fontDescription;
			m_color = color.ToArgb();
			m_iconFilePath = iconFilePath;
			m_cache = cache;
			
			// Set default render priority
			m_renderPriority = RenderPriority.Placenames;
		}
Пример #19
0
        bool showGlow = false;          // If shadows on, will render an atmospheric glow

        /// <summary>
        /// Constructor
        /// </summary>
        public PlanetaryRingsLayer(string LayerName, string pluginPath, WorldWindow worldWindow)
            : base(LayerName)
        {
            this.pluginPath = pluginPath;
            this.pluginName = LayerName;
            this.world = worldWindow.CurrentWorld;
            this.settingsFileName = this.world.Name + ".ini";
            this.drawArgs = worldWindow.DrawArgs;
            this.RenderPriority = RenderPriority.AtmosphericImages;
            this.IsOn = false;
            ReadSettings();
        }
Пример #20
0
		public WorldWindWFSPlacenameFile(
		    string name,
            String wfsBaseUrl,
            string typename,
            String labelfield,
            double north,
            double south,
            double west,
            double east,
			World world,
			Cache cache)
		{
            //TODO:Validate basewfsurl
            this.name = name;
            this.wfsBaseUrl = wfsBaseUrl;
            this.typename = typename;
            this.labelfield = labelfield;
            this.north = north;
            this.south = south;
            this.west = west;
            this.east = east;
            wfsURL = wfsBaseUrl + "&OUTPUTFORMAT=GML2-GZIP&BBOX=" + west + "," + south + "," + east + "," + north;
			this.m_world = world;
			this.m_cache = cache;
        }
        //static int VK_RCONTROL = 0xA3;
        //static int VK_LALT = 0xA4;
        //static int VK_RALT = 0xA5;

		//float fFeetToMeter = 31F/100F;

		public GPSIcon(
			GPSTrackerOverlay gpsTrackerOverlay,
			int iIndex, 
			GPSRenderInformation renderInformation,
			World parentWorld)
			: base(renderInformation.sDescription, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			m_fVerticalExaggeration = World.Settings.VerticalExaggeration;
			m_RenderInfo=renderInformation;
			m_RenderInfo.bPOI=true;
			this.m_gpsTrackerOverlay=gpsTrackerOverlay;
			m_RenderInfo.iIndex=iIndex;
			this.m_parentWorld = parentWorld;
			this.m_textureFileName = m_RenderInfo.sIcon;
			this.m_iTextureWidth = 32;
			this.m_iTextureHeight = 32;
			this.m_iIconWidth = 32;
			this.m_iIconHeight = 32;
			this.m_iIconWidthHalf = m_iIconWidth/2;
			this.m_iIconHeightHalf = m_iIconHeight/2;
			this.m_bTrack=renderInformation.fTrack;
			m_bShowInfo = m_RenderInfo.bShowInfo;

			m_fLatitudeFrom=1000F;
			m_fLongitudeFrom=1000F;
			m_sDescriptionFrom="";
			m_bSignalDistance=false;

			m_uVerticesCount=0;
			m_uPointCount=0;
			m_fTotalDistance=0;
			m_uTotalPointCount=0;

			this.RenderPriority = RenderPriority.Icons;
		}
        public GPSTrackLine(World parentWorld, string sDescription)
			: base(sDescription, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			m_parentWorld=parentWorld;
		}
Пример #23
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;

                }
            }
        }
Пример #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.QuadTileSet"/> class.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="parentWorld"></param>
        /// <param name="distanceAboveSurface"></param>
        /// <param name="north"></param>
        /// <param name="south"></param>
        /// <param name="west"></param>
        /// <param name="east"></param>
        /// <param name="terrainAccessor"></param>
        /// <param name="imageAccessor"></param>
        public QuadTileSet(
                string name,
                World parentWorld,
                double distanceAboveSurface,
                double north,
                double south,
                double west,
                double east,
                bool terrainMapped,
                                        ImageStore[] imageStores)
            : base(name, parentWorld)
        {
            float layerRadius = (float)(parentWorld.EquatorialRadius + distanceAboveSurface);
            m_north = north;
            m_south = south;
            m_west = west;
            m_east = east;

            // Layer center position
            Position = MathEngine.SphericalToCartesian(
                    (north + south) * 0.5f,
                    (west + east) * 0.5f,
                    layerRadius);

            m_layerRadius = layerRadius;
            m_tileDrawDistance = 3.5f;
            m_tileDrawSpread = 2.9f;
            m_imageStores = imageStores;
            m_terrainMapped = terrainMapped;

            // Default terrain mapped imagery to terrain mapped priority
            if (terrainMapped)
                m_renderPriority = RenderPriority.TerrainMappedImages;
        }
Пример #25
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;
		}
Пример #26
0
        /// <summary>
        /// Find the intersection of a ray with the terrain.
        /// </summary>
        /// <param name="p1">Cartesian coordinate of starting point</param>
        /// <param name="p2">Cartesian coordinate of end point</param>
        /// <param name="samplingPrecision">Sample length in meter</param>
        /// <param name="resultPrecision">Final sampling length in meter</param>
        /// <param name="latitude">Out : intersection latitude</param>
        /// <param name="longitude">Out : intersection longitude</param>
        /// <param name="world">Current world</param>
        /// <returns>NaN if no intersection found</returns>
        internal static void RayIntersectionWithTerrain(
            Point3d p1,
            Point3d p2,
            double samplingPrecision,
            double resultPrecision,
            out Angle latitude,
            out Angle longitude,
            World world)
        {
            // Check for sphere intersection first
            // Note : checks for world radius + highest possible elevation
            float vertEx = World.Settings.VerticalExaggeration;
            double maxRadius = world.EquatorialRadius + 9000 * vertEx; // Max altitude for earth - should be dependant on world
            double a = (p2.X - p1.X) * (p2.X - p1.X) + (p2.Y - p1.Y) * (p2.Y - p1.Y) + (p2.Z - p1.Z) * (p2.Z - p1.Z);
            double b = 2.0 * ((p2.X - p1.X) * (p1.X) + (p2.Y - p1.Y) * (p1.Y) + (p2.Z - p1.Z) * (p1.Z));
            double c = p1.X * p1.X + p1.Y * p1.Y + p1.Z * p1.Z - maxRadius * maxRadius;
            double discriminant = b * b - 4 * a * c;
            if (discriminant <= 0)
            {
                // No intersection with sphere
                latitude = Angle.NaN;
                longitude = Angle.NaN;
                return;
            }
            // Factor to intersection
            // Note : if t1 > 0 intersection is forward, < 0 is behind us
            double t1 = ((-1.0) * b - Math.Sqrt(discriminant)) / (2 * a);
            Point3d p1LatLon = MathEngine.CartesianToSpherical(p1.X, p1.Y, p1.Z);
            if (t1 > 0 && p1LatLon.X > maxRadius)
            {
                // Looking from above max altitude : move p1 forward to intersection with max alt sphere
                p1 = new Point3d(p1.X + t1 * (p2.X - p1.X), p1.Y + t1 * (p2.Y - p1.Y), p1.Z + t1 * (p2.Z - p1.Z));
            }

            // Ray sample
            Vector3 sample = new Vector3((float)(p2.X - p1.X), (float)(p2.Y - p1.Y), (float)(p2.Z - p1.Z));
            double maxLength = sample.Length();     // Max length for ray tracing
            double sampleLength = samplingPrecision;// Sampling steps length
            sample.Normalize();
            sample.Scale((float)sampleLength);

            // Casting
            Point3d ray = p1;
            double rayLength = 0;
            while (rayLength < maxLength)
            {
                Point3d rayLatLon = MathEngine.CartesianToSpherical(ray.X, ray.Y, ray.Z);
                // Altitude at ray position
                double rayAlt = rayLatLon.X - world.EquatorialRadius;
                // Altitude at terrain position - from cached data (no download)
                double terrainAlt = world.TerrainAccessor.GetCachedElevationAt(MathEngine.RadiansToDegrees(rayLatLon.Y), MathEngine.RadiansToDegrees(rayLatLon.Z)); // best loaded data
                if (double.IsNaN(terrainAlt)) terrainAlt = 0;
                terrainAlt *= vertEx;
                if (terrainAlt > rayAlt)
                {
                    // Intersection found
                    if (sampleLength > resultPrecision)
                    {
                        // Go back one step
                        ray.X -= sample.X;
                        ray.Y -= sample.Y;
                        ray.Z -= sample.Z;
                        rayLength -= sampleLength;
                        // and refine sampling
                        sampleLength /= 10;
                        sample.Normalize();
                        sample.Scale((float)sampleLength);
                    }
                    else
                    {
                        // return location
                        latitude = Angle.FromRadians(rayLatLon.Y);
                        longitude = Angle.FromRadians(rayLatLon.Z);
                        return;
                    }
                }
                // Move forward
                ray.X += sample.X;
                ray.Y += sample.Y;
                ray.Z += sample.Z;
                rayLength += sampleLength;
            }
            // No intersection with terrain found
            latitude = Angle.NaN;
            longitude = Angle.NaN;
        }
Пример #27
0
		public ShapeTileArgs(
			World parentWorld,
			Size tilePixelSize,
			double layerRadius,
			ShapeFileLayer parentShapeLayer,
			string dataKey,
			bool scaleColors,
			double scaleMin,
			double scaleMax,
			string[] noDataValues,
			string[] activeDataValues,
			bool polygonFill,
			bool outlinePolygons,
			System.Drawing.Color polygonColor,
			ShapeFillStyle shapeFillStyle,
			System.Drawing.Color lineColor,
			System.Drawing.Color labelColor,
			float lineWidth,
			bool showLabels
			)
		{
			ParentShapeFileLayer = parentShapeLayer;
			LayerRadius = layerRadius;

			m_ParentWorld = parentWorld;
			m_TilePixelSize = tilePixelSize;
			m_DataKey = dataKey;
			m_ScaleColors = scaleColors;
			m_PolygonFill = polygonFill;
			m_ScaleMin = scaleMin;
			m_ScaleMax = scaleMax;
			m_NoDataValues = noDataValues;
			m_ActiveDataValues = activeDataValues;
			m_PolygonFill = polygonFill;
			m_OutlinePolygons = outlinePolygons;
			m_PolygonColor = polygonColor;
			m_ShapeFillStyle = shapeFillStyle;
			m_LineColor = lineColor;
			m_LabelColor = labelColor;
			m_LineWidth = lineWidth;
			m_ShowLabels = showLabels;
		}
		public GPSIcon(
			GPSTrackerOverlay gpsTrackerOverlay,
			GPSRenderInformation renderInformation,
			World parentWorld)
			: base(renderInformation.sDescription, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			m_fVerticalExaggeration = World.Settings.VerticalExaggeration;
			m_RenderInfo=renderInformation;
			m_RenderInfo.bPOI=false;
			this.m_gpsTrackerOverlay=gpsTrackerOverlay;
			this.m_parentWorld = parentWorld;
			this.m_textureFileName = m_RenderInfo.sIcon;
			this.m_iTextureWidth = 32;
			this.m_iTextureHeight = 32;
			this.m_iIconWidth = 32;
			this.m_iIconHeight = 32;
			this.m_iIconWidthHalf = m_iIconWidth/2;
			this.m_iIconHeightHalf = m_iIconHeight/2;
			m_bSignalDistance=false;
			this.m_bTrack=renderInformation.fTrack;
			m_bShowInfo = m_RenderInfo.bShowInfo;
            m_bTrackLine = m_RenderInfo.bTrackLine;
            m_bTrackHeading = gpsTrackerOverlay.Plugin.gpsTracker.m_bTrackHeading;

			m_fLastAlt=-1000000F;
			m_fLastRoll=-1000F;
			m_fLastDepth=-1000000F;
			m_fLastPitch=-1000F;
			m_fLastSpeed=-1F;
			m_fLastESpeed=-1000000F;
			m_fLastNSpeed=-1000000F;
			m_fLastVSpeed=-1000000F;
			m_fLastHeading=-1F;
			m_iLastHour=-1;
			m_iLastMin=-1;
			m_fLastSec=(float)-1;
			m_iLastDay=-1;
			m_iLastMonth=-1;
			m_iLastYear=-1;
			m_fLatitudeFrom=1000F;
			m_fLongitudeFrom=1000F;
			m_sDescriptionFrom="";

			m_uVerticesCount=0;
			m_uPointCount=0;
			m_fTotalDistance=0;
			m_uTotalPointCount=0;

			for (int i=0; i<m_gpsTrackerOverlay.m_iGpsIconIndex; i++)
				if (m_gpsTrackerOverlay.m_gpsIcons[i].m_RenderInfo.iIndex==m_RenderInfo.iIndex && 
					m_gpsTrackerOverlay.m_gpsIcons[i].m_bTrack &&
					m_bTrack)
					m_bTrack=false;

			this.RenderPriority = RenderPriority.Icons;
		}
Пример #29
0
               public string presetFileName;           // preset file (will overide defaults)

               /// <summary>
               /// Constructor
               /// </summary>
               public SkyGradientLayer(string LayerName, string pluginPath, WorldWindow worldWindow) : base(LayerName)
               {
                       this.pluginPath = pluginPath;
                       this.pluginName = LayerName;
                       this.world = worldWindow.CurrentWorld;
                       this.settingsFileName = this.world.Name + ".ini";
                       this.drawArgs = worldWindow.DrawArgs;
                       //this.RenderPriority = RenderPriority.AtmosphericImages;
                       this.RenderPriority = RenderPriority.SurfaceImages;
                       ReadSettings();
               }
Пример #30
0
		public ShapeFileLayer(
			string id,
			World parentWorld,
			string shapeFilePath,
			double minimumViewingAltitude,
			double maximumViewingAltitude,
			float lztsd,
			GeographicBoundingBox bounds,
			string dataKey,
			bool scaleColorsToData,
			double scalarFilterMin,
			double scalarFilterMax,
			double scaleMin,
			double scaleMax,
			string[] noDataValues,
			string[] activeDataValues,
			bool polygonFill,
			bool outlinePolygons,
			System.Drawing.Color polygonFillColor,
			ShapeFillStyle shapeFillHatchStyle,
			System.Drawing.Color lineColor,
			float lineWidth,
			bool showLabels,
			System.Drawing.Color labelColor,
			string iconFilePath,
			int iconWidth,
			int iconHeight,
			byte iconOpacity) : base(id, parentWorld.Position, parentWorld.Orientation)
		{

			this.RenderPriority = WorldWind.Renderable.RenderPriority.LinePaths;

			m_MinimumViewingAltitude = minimumViewingAltitude;
			m_MaximumViewingAltitude = maximumViewingAltitude;
			m_lztsd = lztsd;

			m_ShapeTileArgs = new ShapeTileArgs(
				parentWorld,
				new System.Drawing.Size(256, 256),
				parentWorld.EquatorialRadius,
				this,
				dataKey,
				scaleColorsToData,
				scaleMin,
				scaleMax,
				noDataValues,
				activeDataValues,
				polygonFill,
				outlinePolygons,
				polygonFillColor,
				shapeFillHatchStyle,
				lineColor,
				labelColor,
				lineWidth,
				showLabels
				);

			m_ScalarFilterMin = scalarFilterMin;
			m_ScalarFilterMax = scalarFilterMax;

			m_ShapeFilePath = shapeFilePath;

			m_IconFilePath = iconFilePath;
			m_IconWidth = iconWidth;
			m_IconHeight = iconHeight;
			m_IconOpacity = iconOpacity;
			/*Produces tile tree for whole earth*/
			/*Need to implement clipping*/			
			m_NumberRootTilesHigh = (int)(180.0f/m_lztsd);
			double tileSize = 180.0f/m_NumberRootTilesHigh;
			m_RootTiles = new ShapeTile[m_NumberRootTilesHigh * (m_NumberRootTilesHigh * 2)];

			System.Console.WriteLine("North:{0} South:{1} East:{2} West:{3}",
				bounds.North,bounds.South,bounds.East,bounds.West);
			int istart = 0;
			int iend = m_NumberRootTilesHigh;
			int jstart = 0;
			int jend = m_NumberRootTilesHigh * 2;

			int createdtiles = 0;
			for(int i = istart; i < iend; i++)
			{
				for(int j = jstart; j < jend; j++)
				{
					double north = (i + 1) * tileSize - 90.0f;
					double south = i  * tileSize - 90.0f;
					double west = j * tileSize - 180.0f;
					double east = (j + 1) * tileSize - 180.0f;
					m_RootTiles[i * m_NumberRootTilesHigh * 2 + j] = new ShapeTile(
							new GeographicBoundingBox(
							north,
							south,
							west,
							east),
							m_ShapeTileArgs);
					createdtiles++;
				}
			}
			Console.WriteLine("Created Tiles "+createdtiles);
		}