コード例 #1
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);
        }
コード例 #2
0
        private static void addQuadTileLayersFromXPathNodeIterator(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
        {
            if (iter.Count > 0) {
                while (iter.MoveNext()) {
                    string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                    double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
                    bool showAtStartup = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));

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

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

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

                    bool terrainMapped = true;

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

                    QuadTileSet qts = null;

                    byte opacity = 255;

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

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

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

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

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

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

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

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

                            //	ia.DataExpirationTime = dataExpiration;

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

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

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

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

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

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

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

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

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

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

                                    WmsImageStore wmsLayerStore = new WmsImageStore();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            qts.MetaData.Add("XmlSource", (string) parentRenderable.MetaData["XmlSource"]);
                            addExtendedInformation(iter.Current.Select("ExtendedInformation"), qts);
                            parentRenderable.Add(qts);
                        }
                    }
                }
            }
        }