public WMSZoomBuilder(WMSLayer layer, string cachePath, WorldWindow worldWindow, IBuilder parent) { m_wmsLayer = layer; m_WorldWindow = worldWindow; m_strCacheRoot = cachePath; m_Parent = parent; m_oWorld = m_WorldWindow.CurrentWorld; m_strName = layer.Title; }
internal WMSQuadLayerBuilder(WMSLayer layer, WorldWindow worldWindow, WMSServerBuilder server, IBuilder parent) : base(layer.Title, worldWindow, parent) { m_Server = server; m_wmsLayer = layer; distAboveSurface = 0; m_hBoundary = new GeographicBoundingBox((double)layer.North, (double)layer.South, (double)layer.West, (double)layer.East); // Determine the needed levels (function of tile size and resolution, for which we just use ~5 meters because it is not available with WMS) double dRes = 5.0 / 100000.0; if (dRes > 0) { double dTileSize = LevelZeroTileSize; m_iLevels = 1; while (dTileSize / Convert.ToDouble(TextureSizePixels) > dRes / 4.0) { m_iLevels++; dTileSize /= 2; } } }
internal WMSFolderModelNode(DappleModel oModel, WMSLayer oData) : base(oModel) { m_oData = oData; foreach (WMSLayer oLayer in m_oData.ChildLayers) { if (oLayer.ChildLayers == null) { AddChildSilently(new WMSLayerModelNode(m_oModel, oLayer)); } else { AddChildSilently(new WMSFolderModelNode(m_oModel, oLayer)); } } if (oData.Name != null) { AddChildSilently(new WMSLayerModelNode(m_oModel, oData)); } MarkLoaded(); }
internal static WMSLayer GetLayer(String strDesiredLayerName, WMSLayer[] oSearchRoot) { if (oSearchRoot == null) return null; foreach (WMSLayer iter in oSearchRoot) { if (iter.Name != null && iter.Name.Equals(strDesiredLayerName)) return iter; WMSLayer result = GetLayer(strDesiredLayerName, iter.ChildLayers); if (result != null) return result; } return null; }
internal static WMSLayer FindLayer(string layerName, WMSLayer list) { foreach (WMSLayer layer in list.ChildLayers) { if (layer.ChildLayers != null && layer.ChildLayers.Length > 0) { WMSLayer result = FindLayer(layerName, layer); if (result != null) { return result; } } if (layer.Name == layerName) { return layer; } } return null; }
private void QueueAndDownload(WMSLayer layer) { if(layer.dates != null && layer.dates.Length>0) { UpdateProgressBarFrame(0, layer.dates.Length - 1); this.progressBarTotalProgress.Maximum = layer.dates.Length; } else { UpdateProgressBarFrame(0,1); this.progressBarTotalProgress.Maximum = 1; } if(layer.dates == null) this.downloadLayer(layer, null); else { foreach(string curDate in layer.dates) this.downloadLayer(layer, curDate); } this.buttonPlay.Enabled = true; this.downloadState = DownloadState.Pending; // Start Download thread if (downloadThread!=null && downloadThread.IsAlive) return; downloadThread = new Thread( new ThreadStart(Downloader)); downloadThread.Name = "AnimatedEarthManager.Downloader"; downloadThread.IsBackground = true; downloadThread.Start(); }
private void downloadLayer(WMSLayer layer, string curDate) { bool cancel = (this.downloadState == DownloadState.Cancel); if(cancel) return; string fileName = "Default"; string time=""; if(curDate != null) { time = "&time=" + curDate; fileName = curDate.Replace(":",""); } string layerPath = CacheDirectory; if(layer.Name!=null) layerPath = Path.Combine( CacheDirectory, layer.Name ); const string fileType = "png"; string url = AnimatedEarthManager.ServerUrl+ "?service=" + this.serviceName + "&version=" + WmsVersion + "&request=GetMap" + "&layers=" + layer.Name + "&format=image/png" + "&width=" + (layer.Width != 0 ? layer.Width.ToString(CultureInfo.InvariantCulture) : "1024") + "&height=" + (layer.Height != 0 ? layer.Height.ToString(CultureInfo.InvariantCulture) : "512") + time + "&crs=" + layer.crs + "&bbox=" + String.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", layer.west, layer.south, layer.east, layer.north); WMSDownload wmsDownload = new WMSDownload( url ); wmsDownload.Date = curDate; wmsDownload.Title = layer.Title; wmsDownload.West = layer.west; wmsDownload.South = layer.south; wmsDownload.East = layer.east; wmsDownload.North = layer.north; // Use fast dds format if available wmsDownload.SavedFilePath = Path.Combine( layerPath, fileName) + ".dds"; if(File.Exists(wmsDownload.SavedFilePath)) { AddAnimationFrame(wmsDownload); return; } // Or try the original format from server wmsDownload.SavedFilePath = Path.Combine(layerPath, fileName) + "." + fileType; if(File.Exists(wmsDownload.SavedFilePath)) { AddAnimationFrame(wmsDownload); return; } // File wasn't available locally - queue it for download lock(this.downloadQueue.SyncRoot) { this.downloadQueue.Enqueue(wmsDownload); } }
private void treeViewLayers_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { if (e.Action==TreeViewAction.Unknown) // Programmatic listview update return; if( this.animationState != AnimationState.Pending) { if(e.Node == this.currentlyAnimatingNode && this.animationState != AnimationState.Paused) this.buttonPlay.ImageIndex = 2; else this.buttonPlay.ImageIndex = 4; } this.currentlySelectedLayer = (WMSLayer)e.Node.Tag; if(this.currentlySelectedLayer == null) return; float targetViewRange = (float)(4 * (this.currentlySelectedLayer.north - this.currentlySelectedLayer.south > this.currentlySelectedLayer.east - this.currentlySelectedLayer.west ? this.currentlySelectedLayer.north - this.currentlySelectedLayer.south : this.currentlySelectedLayer.east - this.currentlySelectedLayer.west)); this.worldWindow.GotoLatLon( 0.5f * (float)(this.currentlySelectedLayer.north + this.currentlySelectedLayer.south), 0.5f * (float)(this.currentlySelectedLayer.west + this.currentlySelectedLayer.east), 0, double.NaN, (targetViewRange > 180.0f ? 180.0f : targetViewRange), 0); this.richTextBoxDescription.Text = this.currentlySelectedLayer.Title; if(this.currentlySelectedLayer.Name != null && this.currentlySelectedLayer.dates != null) { this.richTextBoxDescription.Text += "\n# Frames: " + (this.currentlySelectedLayer.dates.Length == 0 ? "1" : this.currentlySelectedLayer.dates.Length.ToString(CultureInfo.CurrentCulture)); } if(this.currentlySelectedLayer.Abstract != null) { this.richTextBoxDescription.Text += "\n" + this.currentlySelectedLayer.Abstract.Replace("\n", " "); } }
internal WMSLayerModelNode(DappleModel oModel, WMSLayer oData) : base(oModel) { m_oData = oData; m_oBounds = new GeographicBoundingBox((double)m_oData.North, (double)m_oData.South, (double)m_oData.West, (double)m_oData.East); m_oViewLegend = new ToolStripMenuItem("View Legend...", IconKeys.ImageList.Images[IconKeys.ViewLegendMenuItem], new EventHandler(c_miViewLegend_Click)); MarkLoaded(); }
private WMSLayer getWMSLayer(capabilities_1_3_0.wms.LayerType layer, capabilities_1_3_0.wms.EX_GeographicBoundingBoxType parentLatLonBoundingBox, string[] imageFormats) { WMSLayer wmsLayer = new WMSLayer(); wmsLayer.ParentWMSList = this; wmsLayer.ImageFormats = imageFormats; if (layer.HasName()) wmsLayer.Name = layer.Name.Value; if (layer.HasTitle()) wmsLayer.Title = layer.Title.Value; if (layer.HasAbstract2()) wmsLayer.Description = layer.Abstract2.Value; if (layer.HasCRS()) wmsLayer.CRS = layer.CRS.Value; if (layer.HasDimension()) { for (int i = capabilities_1_3_0.wms.LayerType.DimensionMinCount; i < layer.DimensionCount; i++) { capabilities_1_3_0.wms.DimensionType curDimension = layer.GetDimensionAt(i); if (curDimension.Hasname()) { if (String.Compare(layer.Dimension.name.Value, "time", true, CultureInfo.InvariantCulture) == 0) { WMSList.GetDatesFromDateTimeString(curDimension.Value.Value); } } } } if (layer.HasEX_GeographicBoundingBox()) { wmsLayer.North = (decimal)layer.EX_GeographicBoundingBox.northBoundLatitude.Value; wmsLayer.South = (decimal)layer.EX_GeographicBoundingBox.southBoundLatitude.Value; wmsLayer.East = (decimal)layer.EX_GeographicBoundingBox.eastBoundLongitude.Value; wmsLayer.West = (decimal)layer.EX_GeographicBoundingBox.westBoundLongitude.Value; } else if (parentLatLonBoundingBox != null) { wmsLayer.North = (decimal)parentLatLonBoundingBox.northBoundLatitude.Value; wmsLayer.South = (decimal)parentLatLonBoundingBox.southBoundLatitude.Value; wmsLayer.West = (decimal)parentLatLonBoundingBox.westBoundLongitude.Value; wmsLayer.East = (decimal)parentLatLonBoundingBox.eastBoundLongitude.Value; } if (layer.HasStyle()) { wmsLayer.Styles = new WMSLayerStyle[layer.StyleCount]; for (int i = capabilities_1_3_0.wms.LayerType.StyleMinCount; i < layer.StyleCount; i++) { capabilities_1_3_0.wms.StyleType curStyle = layer.GetStyleAt(i); wmsLayer.Styles[i] = new WMSLayerStyle(); if (curStyle.HasTitle()) wmsLayer.Styles[i].title = curStyle.Title.Value; if (curStyle.HasLegendURL()) { wmsLayer.Styles[i].legendURL = new WMSLayerStyleLegendURL[curStyle.LegendURLCount]; for (int j = 0; j < curStyle.LegendURLCount; j++) { capabilities_1_3_0.wms.LegendURLType curLegend = curStyle.GetLegendURLAt(j); wmsLayer.Styles[i].legendURL[j] = new WMSLayerStyleLegendURL(); if (curLegend.HasOnlineResource()) { if (curLegend.OnlineResource.Hashref()) wmsLayer.Styles[i].legendURL[j].href = curLegend.OnlineResource.href.Value; } } } } } if (layer.HasLayer()) { wmsLayer.ChildLayers = new WMSLayer[layer.LayerCount]; for (int i = 0; i < layer.LayerCount; i++) { wmsLayer.ChildLayers[i] = this.getWMSLayer((capabilities_1_3_0.wms.LayerType)layer.GetLayerAt(i), parentLatLonBoundingBox, imageFormats); } } return wmsLayer; }
private WMSLayer getWMSLayer(WMS_MS_Capabilities.LayerType layer, WMS_MS_Capabilities.LatLonBoundingBoxType parentLatLonBoundingBox, string[] imageFormats) { WMSLayer wmsLayer = new WMSLayer(); wmsLayer.ParentWMSList = this; wmsLayer.ImageFormats = imageFormats; if (layer.HasName()) wmsLayer.Name = layer.Name.Value.Value; if (layer.HasTitle()) wmsLayer.Title = layer.Title.Value.Value; if (layer.HasAbstract2()) wmsLayer.Description = layer.Abstract2.Value.Value; if (layer.HasSRS()) wmsLayer.SRS = layer.SRS.Value.Value; if (layer.HasExtent()) { for (int i = WMS_MS_Capabilities.LayerType.ExtentMinCount; i < layer.ExtentCount; i++) { WMS_MS_Capabilities.ExtentType curExtent = layer.GetExtentAt(i); if (curExtent.Hasname()) { if (String.Compare(curExtent.name.Value, "time", true) == 0) { WMSList.GetDatesFromDateTimeString(curExtent.getDOMNode().InnerText); } } } } if (layer.HasLatLonBoundingBox()) { wmsLayer.North = Convert.ToDecimal(Double.Parse(layer.LatLonBoundingBox.maxy.Value, CultureInfo.InvariantCulture)); wmsLayer.South = Convert.ToDecimal(Double.Parse(layer.LatLonBoundingBox.miny.Value, CultureInfo.InvariantCulture)); wmsLayer.West = Convert.ToDecimal(Double.Parse(layer.LatLonBoundingBox.minx.Value, CultureInfo.InvariantCulture)); wmsLayer.East = Convert.ToDecimal(Double.Parse(layer.LatLonBoundingBox.maxx.Value, CultureInfo.InvariantCulture)); parentLatLonBoundingBox = layer.LatLonBoundingBox; } else if (parentLatLonBoundingBox != null) { wmsLayer.North = Convert.ToDecimal(Double.Parse(parentLatLonBoundingBox.maxy.Value, CultureInfo.InvariantCulture)); wmsLayer.South = Convert.ToDecimal(Double.Parse(parentLatLonBoundingBox.miny.Value, CultureInfo.InvariantCulture)); wmsLayer.West = Convert.ToDecimal(Double.Parse(parentLatLonBoundingBox.minx.Value, CultureInfo.InvariantCulture)); wmsLayer.East = Convert.ToDecimal(Double.Parse(parentLatLonBoundingBox.maxx.Value, CultureInfo.InvariantCulture)); } if (layer.HasStyle()) { wmsLayer.Styles = new WMSLayerStyle[layer.StyleCount]; for (int i = 0; i < layer.StyleCount; i++) { WMS_MS_Capabilities.StyleType curStyle = layer.GetStyleAt(i); wmsLayer.Styles[i] = new WMSLayerStyle(); if (curStyle.HasTitle()) wmsLayer.Styles[i].title = curStyle.Title.Value.Value; if (curStyle.HasLegendURL()) { wmsLayer.Styles[i].legendURL = new WMSLayerStyleLegendURL[curStyle.LegendURLCount]; for (int j = 0; j < curStyle.LegendURLCount; j++) { WMS_MS_Capabilities.LegendURLType curLegend = curStyle.GetLegendURLAt(j); wmsLayer.Styles[i].legendURL[j] = new WMSLayerStyleLegendURL(); if (curLegend.HasOnlineResource()) { System.Xml.XmlNode n = curLegend.OnlineResource.getDOMNode(); foreach (System.Xml.XmlAttribute attr in n.Attributes) { if (attr.Name.IndexOf("href") >= 0) { wmsLayer.Styles[i].legendURL[j].href = attr.InnerText; } } } } } } } if (layer.HasLayer()) { wmsLayer.ChildLayers = new WMSLayer[layer.LayerCount]; for (int i = 0; i < layer.LayerCount; i++) { wmsLayer.ChildLayers[i] = this.getWMSLayer((WMS_MS_Capabilities.LayerType)layer.GetLayerAt(i), parentLatLonBoundingBox, imageFormats); } } return wmsLayer; }