Beispiel #1
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;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.QuadTile"/> class.
        /// </summary>
        /// <param name="south"></param>
        /// <param name="north"></param>
        /// <param name="west"></param>
        /// <param name="east"></param>
        /// <param name="level"></param>
        /// <param name="quadTileSet"></param>
        public QuadTile(double south, double north, double west, double east, int level, QuadTileSet quadTileSet)
        {
            this.South      = south;
            this.North      = north;
            this.West       = west;
            this.East       = east;
            CenterLatitude  = Angle.FromDegrees(0.5f * (North + South));
            CenterLongitude = Angle.FromDegrees(0.5f * (West + East));
            LatitudeSpan    = Math.Abs(North - South);
            LongitudeSpan   = Math.Abs(East - West);

            this.Level       = level;
            this.QuadTileSet = quadTileSet;

            BoundingBox = new BoundingBox((float)south, (float)north, (float)west, (float)east, (float)quadTileSet.LayerRadius, (float)quadTileSet.LayerRadius + 300000f);
            //localOrigin = BoundingBox.CalculateCenter();
            localOrigin = MathEngine.SphericalToCartesianD(CenterLatitude, CenterLongitude, quadTileSet.LayerRadius);

            // To avoid gaps between neighbouring tiles truncate the origin to
            // a number that doesn't get rounded. (nearest 10km)
            localOrigin.X = (float)(Math.Round(localOrigin.X / 10000) * 10000);
            localOrigin.Y = (float)(Math.Round(localOrigin.Y / 10000) * 10000);
            localOrigin.Z = (float)(Math.Round(localOrigin.Z / 10000) * 10000);

            Row = MathEngine.GetRowFromLatitude(South, North - South);
            Col = MathEngine.GetColFromLongitude(West, North - South);
        }
Beispiel #3
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.QuadTile"/> class.
		/// </summary>
		/// <param name="south"></param>
		/// <param name="north"></param>
		/// <param name="west"></param>
		/// <param name="east"></param>
		/// <param name="level"></param>
		/// <param name="quadTileSet"></param>
		public QuadTile(double south, double north, double west, double east, int level, QuadTileSet quadTileSet)
		{
			this.South = south;
			this.North = north;
			this.West = west;
			this.East = east;
			CenterLatitude = Angle.FromDegrees(0.5f * (North + South));
			CenterLongitude = Angle.FromDegrees(0.5f * (West + East));
			LatitudeSpan = Math.Abs(North - South);
			LongitudeSpan = Math.Abs(East - West);

			this.Level = level;
			this.QuadTileSet = quadTileSet;

			BoundingBox = new BoundingBox((float)south, (float)north, (float)west, (float)east,
								(float)quadTileSet.LayerRadius, (float)quadTileSet.LayerRadius + 300000f);
			//localOrigin = BoundingBox.CalculateCenter();
			localOrigin = MathEngine.SphericalToCartesianD(CenterLatitude, CenterLongitude, quadTileSet.LayerRadius);

			// To avoid gaps between neighbouring tiles truncate the origin to 
			// a number that doesn't get rounded. (nearest 10km)
			localOrigin.X = (float)(Math.Round(localOrigin.X / 10000) * 10000);
			localOrigin.Y = (float)(Math.Round(localOrigin.Y / 10000) * 10000);
			localOrigin.Z = (float)(Math.Round(localOrigin.Z / 10000) * 10000);

			Row = MathEngine.GetRowFromLatitude(South, North - South);
			Col = MathEngine.GetColFromLongitude(West, North - South);
		}
Beispiel #4
0
        ///<summary>
        ///  Goes to the extent specified by the bounding box for the QTS layer
        /// </summary>
        protected virtual void OnGotoExtentClick(object sender, EventArgs e)
        {
            lock (this.ParentList.ChildObjects.SyncRoot) {
                for (int i = 0; i < this.ParentList.ChildObjects.Count; i++)
                {
                    RenderableObject ro = (RenderableObject)this.ParentList.ChildObjects[i];
                    if (ro.Name.Equals(name))
                    {
                        if (ro is QuadTileSet)
                        {
                            QuadTileSet qts = (QuadTileSet)ro;
                            DrawArgs.Camera.SetPosition((qts.North + qts.South) / 2, (qts.East + qts.West) / 2);
                            double perpendicularViewRange = (qts.North - qts.South > qts.East - qts.West ? qts.North - qts.South : qts.East - qts.West);
                            double altitude = qts.LayerRadius * Math.Sin(MathEngine.DegreesToRadians(perpendicularViewRange * 0.5));

                            DrawArgs.Camera.Altitude = altitude;

                            break;
                        }
                        if (ro is ShapeFileLayer)
                        {
                            ShapeFileLayer slayer = (ShapeFileLayer)ro;
                            DrawArgs.Camera.SetPosition((slayer.North + slayer.South) / 2, (slayer.East + slayer.West) / 2);
                            double perpendicularViewRange = (slayer.North - slayer.South > slayer.East - slayer.West ? slayer.North - slayer.South : slayer.East - slayer.West);
                            double altitude = slayer.MaxAltitude;

                            DrawArgs.Camera.Altitude = altitude;

                            break;
                        }
                    }
                }
            }
        }
Beispiel #5
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;
        }
Beispiel #6
0
        /// <summary>
        /// Layer properties context menu item
        /// </summary>
        protected virtual void OnReloadShaderClick(object sender, EventArgs e)
        {
            QuadTileSet qts = this as QuadTileSet;

            if (qts != null)
            {
                qts.Effect = null;
            }
        }
 protected override void CleanUpLayer(bool bFinal)
 {
     if (m_oQuadTileSet != null)
         m_oQuadTileSet.Dispose();
     m_oQuadTileSet = null;
     m_blnIsChanged = true;
 }
        internal override RenderableObject GetLayer()
        {
            if (m_blnIsChanged)
            {
                ImageStore[] aImageStore = new ImageStore[1];
                aImageStore[0] = new ArcIMSImageStore(m_szServiceName, m_szLayerID, m_oServerUri as ArcIMSServerUri, TileSize, m_oCultureInfo, m_dMinScale, m_dMaxScale);
                aImageStore[0].DataDirectory = null;
                aImageStore[0].LevelZeroTileSizeDegrees = LevelZeroTileSize;
                aImageStore[0].LevelCount = m_iLevels;
                aImageStore[0].ImageExtension = ".png";
                aImageStore[0].CacheDirectory = GetCachePath();

                m_oQuadTileSet = new QuadTileSet(m_szTreeNodeText, m_oWorldWindow.CurrentWorld, 0,
                    Extents.North, Extents.South, Extents.West, Extents.East,
                    true, aImageStore);
                m_oQuadTileSet.AlwaysRenderBaseTiles = true;
                m_oQuadTileSet.IsOn = m_IsOn;
                m_oQuadTileSet.Opacity = m_bOpacity;
                m_blnIsChanged = false;
            }
            return m_oQuadTileSet;
        }
        internal override RenderableObject GetLayer()
        {
            if (m_blnIsChanged)
             {
            string strExt = ".png";
                string strCachePath = GetCachePath();
            System.IO.Directory.CreateDirectory(strCachePath);

            string imageFormat = "image/png";
            if (m_wmsLayer.ImageFormats != null)
            {
               foreach (string curFormat in m_wmsLayer.ImageFormats)
               {
                  if (string.Compare(curFormat, "image/png", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
                  {
                     imageFormat = curFormat;
                     break;
                  }
                  if (string.Compare(curFormat, "image/jpeg", true, System.Globalization.CultureInfo.InvariantCulture) == 0 ||
                    String.Compare(curFormat, "image/jpg", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
                  {
                     imageFormat = curFormat;
                  }
               }
            }
            if (string.Compare(imageFormat, "image/jpeg", true, System.Globalization.CultureInfo.InvariantCulture) == 0 ||
               string.Compare(imageFormat, "image/jpg", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
               strExt = ".jpg";

            WmsImageStoreDapple[] imageStores = new WmsImageStoreDapple[1];
            imageStores[0] = new WmsImageStoreDapple(imageFormat, m_wmsLayer.ParentWMSList.ServerGetMapUrl,
               m_wmsLayer.ParentWMSList.Version, m_wmsLayer.Name, string.Empty, m_wmsLayer.SRS, m_wmsLayer.CRS);
            imageStores[0].DataDirectory = null;
            imageStores[0].LevelZeroTileSizeDegrees = LevelZeroTileSize;
            imageStores[0].LevelCount = m_iLevels;
            imageStores[0].ImageExtension = strExt;
            imageStores[0].CacheDirectory = strCachePath;
            imageStores[0].TextureSizePixels = TextureSizePixels;

            m_oQuadTileSet = new QuadTileSet(m_szTreeNodeText, m_oWorldWindow.CurrentWorld, distAboveSurface,
               (double)m_wmsLayer.North, (double)m_wmsLayer.South, (double)m_wmsLayer.West, (double)m_wmsLayer.East,
               true, imageStores);
            m_oQuadTileSet.AlwaysRenderBaseTiles = true;
            m_oQuadTileSet.IsOn = m_IsOn;
            m_oQuadTileSet.Opacity = m_bOpacity;
            m_blnIsChanged = false;
             }
             return m_oQuadTileSet;
        }
		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);
			}
		}
Beispiel #11
0
        private QuadTileSet GetQuadLayer()
        {
            if (m_blnIsChanged)
             {
            NltImageStore[] imageStores = new NltImageStore[1];
            imageStores[0] = new NltImageStore(m_strDatasetName, m_strServerUrl);
            imageStores[0].DataDirectory = null;
            imageStores[0].LevelZeroTileSizeDegrees = LevelZeroTileSize;
            imageStores[0].LevelCount = m_iLevels;
            imageStores[0].ImageExtension = m_strImageExt;
            imageStores[0].CacheDirectory = GetCachePath();
            imageStores[0].TextureSizePixels = m_iTextureSizePixels;

            m_oQuadTileSet = new QuadTileSet(m_szTreeNodeText,
               m_oWorldWindow.CurrentWorld,
               distAboveSurface,
               90, -90, -180, 180, terrainMapped, imageStores);
            m_oQuadTileSet.IsOn = m_IsOn;
            m_oQuadTileSet.Opacity = m_bOpacity;

            m_oQuadTileSet.AlwaysRenderBaseTiles = true;
            m_oQuadTileSet.IsOn = m_IsOn;
            m_oQuadTileSet.Opacity = m_bOpacity;
            m_blnIsChanged = false;
             }
             return m_oQuadTileSet;
        }
        private static void addQuadTileLayersFromXPathNodeIterator(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
        {
            if (iter.Count > 0) {
                while (iter.MoveNext()) {
                    string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                    double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
                    bool showAtStartup = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));

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

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

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

                    bool terrainMapped = true;

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

                    QuadTileSet qts = null;

                    byte opacity = 255;

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

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

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

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

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

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

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

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

                            //	ia.DataExpirationTime = dataExpiration;

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

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

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

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

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

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

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

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

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

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

                                    WmsImageStore wmsLayerStore = new WmsImageStore();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            qts.MetaData.Add("XmlSource", (string) parentRenderable.MetaData["XmlSource"]);
                            addExtendedInformation(iter.Current.Select("ExtendedInformation"), qts);
                            parentRenderable.Add(qts);
                        }
                    }
                }
            }
        }
Beispiel #13
0
        // End New Cache
        /// <summary>
        /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.QuadTile"/> class.
        /// </summary>
        /// <param name="_south"></param>
        /// <param name="_north"></param>
        /// <param name="_west"></param>
        /// <param name="_east"></param>
        /// <param name="_level"></param>
        /// <param name="quadTileSet"></param>
        internal QuadTile(double _south, double _north, double _west, double _east, int _level, QuadTileSet quadTileSet)
        {
            this.south = _south;
            this.north = _north;
            this.west = _west;
            this.east = _east;
            centerLatitude = Angle.FromDegrees(0.5f * (north + south));
            centerLongitude = Angle.FromDegrees(0.5f * (west + east));
            LatitudeSpan = Math.Abs(north - south);
            LongitudeSpan = Math.Abs(east - west);

            this.level = _level;
            this.quadTileSet = quadTileSet;

            // --- Make bounding box slightly larger so the tile won't blink in and out near the edges ---
            BoundingBox = new BoundingBox(south - LatitudeSpan / 8.0, north + LatitudeSpan / 8.0, west - LongitudeSpan / 8.0, east + LongitudeSpan / 8.0, quadTileSet.LayerRadius, quadTileSet.LayerRadius + 300000.0);
            //localOrigin = BoundingBox.CalculateCenter();
            localOrigin = MathEngine.SphericalToCartesian(centerLatitude, centerLongitude, quadTileSet.LayerRadius);

            // To avoid gaps between neighbouring tiles truncate the origin to
            // a number that doesn't get rounded. (nearest 10km)
            localOrigin.X = (float)(Math.Round(localOrigin.X / 10000) * 10000);
            localOrigin.Y = (float)(Math.Round(localOrigin.Y / 10000) * 10000);
            localOrigin.Z = (float)(Math.Round(localOrigin.Z / 10000) * 10000);

            row = MathEngine.GetRowFromLatitude((north + south) / 2.0, north - south);
            col = MathEngine.GetColFromLongitude((east + west) / 2.0, east - west);

            downloadRequests = new List<GeoSpatialDownloadRequest>();

            key = string.Format("{0,4}", this.level)
                    + "_"
                    + string.Format("{0,4}", this.col)
                    + string.Format("{0,4}", this.row)
                    + this.quadTileSet.Name
                    + this.quadTileSet.ParentList.Name;

            quadTileSet.ImageStores[0].GetProjectionCorners(this, out UL, out UR, out LL, out LR);
        }
Beispiel #14
0
        private QuadTileSet GetQuadTileSet()
        {
            if (m_layer == null)
             {
                SwitchToUseTiles();

                string strCachePath = GetCachePath();
            System.IO.Directory.CreateDirectory(strCachePath);

            // Determine the needed levels (function of tile size and resolution if available)
            // Shared code in DappleUtils of dapxmlclient
            try
            {
               if (m_iLevels == 0)
                  m_iLevels = DappleUtils.Levels(m_oServer.Command, m_hDataSet);
            }
            catch
            {
               m_iLevels = 15;
            }

            ImageStore[] imageStores = new ImageStore[1];
            imageStores[0] = new DAPImageStore(m_hDataSet, m_oServer)
                             	{
                             		DataDirectory = null,
                             		LevelZeroTileSizeDegrees = LevelZeroTileSize,
                             		LevelCount = m_iLevels,
                             		ImageExtension = ".png",
                             		CacheDirectory = strCachePath,
                             		TextureSizePixels = m_iTextureSizePixels
                             	};

             	m_layer = new QuadTileSet(m_hDataSet.Title, m_oWorldWindow.CurrentWorld, 0, m_hDataSet.Boundary.MaxY, m_hDataSet.Boundary.MinY,
               m_hDataSet.Boundary.MinX, m_hDataSet.Boundary.MaxX, true, imageStores)
                      	{
                      		AlwaysRenderBaseTiles = true,
                      		IsOn = m_IsOn,
                      		Opacity = m_bOpacity
                      	};
             }
             return m_layer;
        }
Beispiel #15
0
 protected override void CleanUpLayer(bool bFinal)
 {
     if (m_layer != null)
     m_layer.Dispose();
      m_layer = null;
 }
        private QuadTileSet GetQuadTileSet()
        {
            if (m_layer == null)
             {

            ImageStore[] imageStores = new ImageStore[1];
            imageStores[0] = new DAPImageStore(null, m_oServer);
            imageStores[0].DataDirectory = null;
            imageStores[0].LevelZeroTileSizeDegrees = 22.5;
            imageStores[0].LevelCount = 10;
            imageStores[0].ImageExtension = ".png";
            imageStores[0].CacheDirectory = GetCachePath();
            imageStores[0].TextureSizePixels = 256;

            m_layer = new QuadTileSet(this.Title, m_oWorldWindow.CurrentWorld, 0, m_oServer.ServerExtents.MaxY, m_oServer.ServerExtents.MinY, m_oServer.ServerExtents.MinX, m_oServer.ServerExtents.MaxX, true, imageStores);
            m_layer.AlwaysRenderBaseTiles = true;
            m_layer.IsOn = m_IsOn;
            m_layer.Opacity = m_bOpacity;
             }
             return m_layer;
        }