private void AddTiledLayer(WMS.Layer wmsLayer, WMS.Style style) { double baseTileDegrees = 180; int totalLevels = 12; string styles = style != null ? style.Name : ""; string url = FillBoundingBoxUrl(MakeWmsGetMapUrl(wmsLayer.Name, styles, 0, 0, 0, 0, 256, 256, "", "")); int baseLevel = 1; string imageType = ".png"; double meanRadius = 300000000; //todo string referenceFrame = LayerManager.CurrentMap; string thumbUrl = "http://www.worldwidetelescope.org/wwtweb/thumbnail.aspx?name=" + referenceFrame; ImageSetHelper ish = new ImageSetHelper(wmsLayer.Title, url, ImageSetType.Planet, BandPass.Visible, ProjectionType.Equirectangular, (int)(uint)url.GetHashCode32(), baseLevel, totalLevels, 512, baseTileDegrees, imageType, true, "", 0, 0, 0, false, thumbUrl, false, false, 1, 0, 0, wmsLayer.Abstract, "", "", "", meanRadius, referenceFrame); if (AddAsLayer.Checked == false) { Earth3d.MainWindow.CurrentImageSet = ish; } else { ImageSetLayer layer = new ImageSetLayer(ish); layer.Enabled = true; layer.Name = wmsLayer.Title; layer.ReferenceFrame = LayerManager.CurrentMap; LayerManager.Add(layer, true); } }
private void AddTiledLayer(WMS.Layer wmsLayer, Style style) { double baseTileDegrees = 180; var totalLevels = 12; var styles = style != null ? style.Name : ""; var url = FillBoundingBoxUrl(MakeWmsGetMapUrl(wmsLayer.Name, styles, 0, 0, 0, 0, 256, 256, "", "")); var baseLevel = 1; var imageType = ".png"; double meanRadius = 300000000; //todo var referenceFrame = LayerManager.CurrentMap; var thumbUrl = "http://www.worldwidetelescope.org/wwtweb/thumbnail.aspx?name=" + referenceFrame; var ish = new ImageSetHelper(wmsLayer.Title, url, ImageSetType.Planet, BandPass.Visible, ProjectionType.Equirectangular, (int)(uint)url.GetHashCode32(), baseLevel, totalLevels, 512, baseTileDegrees, imageType, true, "", 0, 0, 0, false, thumbUrl, false, false, 1, 0, 0, wmsLayer.Abstract, "", "", "", meanRadius, referenceFrame); if (AddAsLayer.Checked == false) { Earth3d.MainWindow.CurrentImageSet = ish; } else { var layer = new ImageSetLayer(ish); layer.Enabled = true; layer.Name = wmsLayer.Title; layer.ReferenceFrame = LayerManager.CurrentMap; LayerManager.Add(layer, true); } }
private void LayersTree_AfterSelect(object sender, TreeViewEventArgs e) { WMS.Layer wmsLayer = LayersTree.SelectedNode.Tag as WMS.Layer; WMS.Style style = LayersTree.SelectedNode.Tag as WMS.Style; WMS_Tile_ServiceTiledPatternsTiledGroup tileGroup = LayersTree.SelectedNode.Tag as WMS_Tile_ServiceTiledPatternsTiledGroup; if (style != null && LayersTree.SelectedNode.Parent != null) { wmsLayer = LayersTree.SelectedNode.Parent.Tag as WMS.Layer; } if (wmsLayer != null) { add.Enabled = true; if (style != null && !string.IsNullOrEmpty(style.Abstract)) { SetAbstractText(style.Abstract); } else { SetAbstractText(wmsLayer.Abstract); } } else if (tileGroup != null) { SetAbstractText(tileGroup.Abstract); add.Enabled = true; } else { SetAbstractText(""); add.Enabled = false; } if (tileGroup != null || (wmsLayer != null && !string.IsNullOrEmpty(wmsLayer.Name))) { add.Enabled = true; if (tileGroup != null) { TiledWMS.Enabled = false; TiledWMS.Checked = true; AddAsLayer.Checked = true; AddAsLayer.Enabled = true; } else if (wmsLayer.IsTileable) { TiledWMS.Enabled = true; AddAsLayer.Checked = true; AddAsLayer.Enabled = true; } else { AddAsLayer.Checked = true; AddAsLayer.Enabled = false; TiledWMS.Enabled = false; } AddAsLayer.Visible = true; TiledWMS.Visible = true; } else { add.Enabled = false; AddAsLayer.Visible = false; TiledWMS.Visible = false; } }
private void add_Click(object sender, EventArgs e) { if (LayersTree.SelectedNode == null) { return; } WMS_Tile_ServiceTiledPatternsTiledGroup tileGroup = LayersTree.SelectedNode.Tag as WMS_Tile_ServiceTiledPatternsTiledGroup; if (tileGroup != null) { AddTiledLayer(tileGroup); return; } WMS.Layer wmsLayer = LayersTree.SelectedNode.Tag as WMS.Layer; WMS.Style style = LayersTree.SelectedNode.Tag as WMS.Style; if (style != null && LayersTree.SelectedNode.Parent != null) { wmsLayer = LayersTree.SelectedNode.Parent.Tag as WMS.Layer; } if (wmsLayer != null) { if (TiledWMS.Checked) { AddTiledLayer(wmsLayer, style); return; } double west = -180; double east = 180; double north = 90; double south = -90; int width = 2048; int height = 2048; if (wmsLayer.EX_GeographicBoundingBox != null) { west = wmsLayer.EX_GeographicBoundingBox.westBoundLongitude; north = wmsLayer.EX_GeographicBoundingBox.northBoundLatitude; east = wmsLayer.EX_GeographicBoundingBox.eastBoundLongitude; south = wmsLayer.EX_GeographicBoundingBox.southBoundLatitude; } if (wmsLayer.LatLonBoundingBox != null) { west = wmsLayer.LatLonBoundingBox.minx; north = wmsLayer.LatLonBoundingBox.maxy; east = wmsLayer.LatLonBoundingBox.maxx; south = wmsLayer.LatLonBoundingBox.miny; } if (wmsLayer.fixedHeight != null) { int h = int.Parse(wmsLayer.fixedHeight); if (h > 0) { height = h; } } if (wmsLayer.fixedWidth != null) { int w = int.Parse(wmsLayer.fixedWidth); if (w > 0) { width = w; } } WmsLayer layer = new WmsLayer(); //string path = MakeWmsGetMapUrl(wmsLayer.Name, style != null ? style.Name : "", // west,north, east, south, // width, height, // "", // ""); layer.ServiceUrl = serviceUrl; layer.WmsVersion = wmsVersion; layer.Layers = wmsLayer.Name; layer.Styles = style != null ? style.Name : ""; layer.Overlay.north = north; layer.Overlay.south = south; layer.Overlay.west = west; layer.Overlay.east = east; layer.Height = height; layer.Width = width; if (wmsLayer.Dimension != null) { foreach (Dimension dim in wmsLayer.Dimension) { if (dim.name == "time") { string[] dates = wmsLayer.Dimension[0].Value.Split(new char[] { ',' }); foreach (string date in dates) { layer.TimeRanges.Add(new TimeRange(date)); } layer.UpdateTimeRange(); } } } layer.Enabled = true; layer.Name = wmsLayer.Title; layer.ReferenceFrame = LayerManager.CurrentMap; LayerManager.Add(layer, true); } }