public WMSLayer(capabilities_1_3_0.wms.LayerType layer) { this.layer = layer; this.Title = layer.Title.Value; if(layer.HasName()) this.Name = layer.Name.Value; if(layer.HasAbstract2()) this.Abstract = layer.Abstract2.Value; if(layer.HasCRS()) this.crs = layer.CRS.Value; if(layer.HasfixedWidth()) this.Width = (uint)layer.fixedWidth.Value; if(layer.HasfixedHeight()) this.Height = (uint)layer.fixedHeight.Value; if(layer.HasEX_GeographicBoundingBox()) { this.north = layer.EX_GeographicBoundingBox.northBoundLatitude.Value; this.south = layer.EX_GeographicBoundingBox.southBoundLatitude.Value; this.west = layer.EX_GeographicBoundingBox.westBoundLongitude.Value; this.east = layer.EX_GeographicBoundingBox.eastBoundLongitude.Value; } for(int i = 0; i < layer.DimensionCount; i++) { capabilities_1_3_0.wms.DimensionType dim = (capabilities_1_3_0.wms.DimensionType)layer.GetDimensionAt(i); if(String.Compare(dim.name.Value, "time", true,CultureInfo.InvariantCulture) == 0) { this.dates = WMSLayer.GetDatesFromDateTimeString(dim.Value.Value); } } if(layer.HasStyle()) { for(int i = 0; i < layer.StyleCount; i++) { capabilities_1_3_0.wms.StyleType curStyle = (capabilities_1_3_0.wms.StyleType)layer.GetStyleAt(i); if(curStyle.HasLegendURL()) { for(int j = 0; j < curStyle.LegendURLCount; j++) { capabilities_1_3_0.wms.LegendURLType curLegend = (capabilities_1_3_0.wms.LegendURLType)curStyle.GetLegendURLAt(j); if(curLegend.HasOnlineResource() && (curLegend.Format.Value.IndexOf("png") != -1 || curLegend.Format.Value.IndexOf("jpeg") != -1)) { this.LegendUrl = curLegend.OnlineResource.href.Value; break; } else if(curLegend.HasOnlineResource() && this.LegendUrl == null) { this.LegendUrl = curLegend.OnlineResource.href.Value; } } } } } }
private TreeNode getTreeNodeFromLayerType(capabilities_1_3_0.wms.LayerType curLayer) { TreeNode tn = new TreeNode(curLayer.Title.Value); tn.Tag = new WMSLayer(curLayer); for(int i = 0; i < curLayer.LayerCount; i++) { capabilities_1_3_0.wms.LayerType childLayer = (capabilities_1_3_0.wms.LayerType)curLayer.GetLayerAt(i); TreeNode childNode = this.getTreeNodeFromLayerType(childLayer); tn.Nodes.Add(childNode); } return tn; }
private MyWMSLayer getWMSLayer(capabilities_1_3_0.wms.LayerType layer, capabilities_1_3_0.wms.EX_GeographicBoundingBoxType parentLatLonBoundingBox, string[] imageFormats) { MyWMSLayer wmsLayer = new MyWMSLayer(); 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.HasfixedHeight()) wmsLayer.Height = (uint)layer.fixedHeight.Value; if(layer.HasfixedWidth()) wmsLayer.Width = (uint)layer.fixedWidth.Value; if(layer.HasDimension()) { for(int i = layer.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) { wmsLayer.Dates = WMSList.GetDatesFromDateTimeString(curDimension.Value.Value); if(curDimension.Hasdefault2()) wmsLayer.DefaultDate = curDimension.default2.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 = layer.StyleMinCount; i < layer.StyleCount; i++) { capabilities_1_3_0.wms.StyleType curStyle = layer.GetStyleAt(i); wmsLayer.Styles[i] = new WMSLayerStyle(); if(curStyle.HasAbstract2()) wmsLayer.Styles[i].description = curStyle.Abstract2.Value; if(curStyle.HasName()) wmsLayer.Styles[i].name = curStyle.Name.Value; 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.HasFormat()) wmsLayer.Styles[i].legendURL[j].format = curLegend.Format.Value; if(curLegend.Haswidth()) wmsLayer.Styles[i].legendURL[j].width = (int)curLegend.width.Value; if(curLegend.Hasheight()) wmsLayer.Styles[i].legendURL[j].height = (int)curLegend.height.Value; if(curLegend.HasOnlineResource()) { if(curLegend.OnlineResource.Hashref()) wmsLayer.Styles[i].legendURL[j].href = curLegend.OnlineResource.href.Value; } } } } } if(layer.HasLayer()) { wmsLayer.ChildLayers = new MyWMSLayer[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; }