// utility function - given a layerset, add all its placenamesets to the above collection, recursing into child layers private void collectTiledPlacenamesSets(LayerSet.Type_LayerSet curLayerSet) { if (curLayerSet.HasTiledPlacenameSet()) // any placenames at all? { // yes, iterate over them for (int i = 0; i < curLayerSet.TiledPlacenameSetCount; i++) { // get tilesplacenameset LayerSet.Type_TiledPlacenameSet2 tpns = curLayerSet.GetTiledPlacenameSetAt(i); // compute full path to wpl file - WplIndex constructor needs this string wplFullPath = Path.Combine(MainApplication.DirectoryPath, tpns.PlacenameListFilePath.Value); // build an index descriptor (does not create or load the index yet) WplIndex idx = new WplIndex(tpns, wplFullPath); // an indexedTilePlacenameSet associates the index descriptor with the placenameset IndexedTiledPlaceNameSet ipns = new IndexedTiledPlaceNameSet(tpns, idx); // add them to our collection this.indexedTiledPlacenameSets.Add(ipns); } } // now recurse into child layers of this set and do the same if (curLayerSet.HasChildLayerSet()) { for (int i = 0; i < curLayerSet.ChildLayerSetCount; i++) { this.collectTiledPlacenamesSets(curLayerSet.GetChildLayerSetAt(i)); } } }
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() == "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(PluginEngineGlobal.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(PluginEngineGlobal.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); } } 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(), PluginEngineGlobal.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(PluginEngineGlobal.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 = Global.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(PluginEngineGlobal.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(PluginEngineGlobal.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(PluginEngineGlobal.DirectoryPath, filePath); } Microsoft.DirectX.Direct3D.FontDescription fd = Global.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(PluginEngineGlobal.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); }