public LayerWms(string serviceName, string url) { WmsProjectInfo info = new WmsProjectInfo(); info.LatLonBoundingBox = new Extent(-180, -90, 180, 90); info.Name = serviceName; info.GetMapInfo.Formats.Add("image/png"); Initialize(info); wmsService = new WmsService(url); InitializeEvents(); setupDone = true; }
private void Initialize(WmsProjectInfo wmsInfo) { _wmsInfo = wmsInfo; _boundingBox = wmsInfo.LatLonBoundingBox; name = _wmsInfo.Name; Abstract = _wmsInfo.Abstract; Title = _wmsInfo.Title; if (!string.IsNullOrEmpty(_wmsInfo.MercatorEpsg)) _mercatorEpsg = Convert.ToInt32(_wmsInfo.MercatorEpsg); if (!_wmsInfo.GetMapInfo.Formats.Contains("image/png") && !_wmsInfo.GetMapInfo.Formats.Contains("image/png8")) throw new FormatException("Only PNG support is available at this time"); if (!_wmsInfo.GetMapInfo.Formats.Contains("image/png")) _imageFormat = "image/png8"; Layers = _wmsInfo.Layers; }
/// <summary> /// Creates a new instance of the <see cref="WmsProjectEventArgs"/> /// </summary> /// <param name="value">Value.</param> public WmsProjectEventArgs(WmsProjectInfo value) : base() { _value = value; }
public LayerWms(WmsProjectInfo wmsInfo) { wmsService = new WmsService(wmsInfo.GetCapabilities.Url); InitializeEvents(); Initialize(wmsInfo); }
public static WmsProjectInfo Read(string capabilities) { var result = new WmsProjectInfo(); XDocument doc; var settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = XmlReader.Create(new StringReader(capabilities), settings)) { doc = XDocument.Load(reader); } var docRoot = doc.Element("WMT_MS_Capabilities"); result.Name = docRoot.Element("Service").Element("Name").Value; result.Title = docRoot.Element("Service").Element("Title").Value; result.Abstract = docRoot.Element("Service").Element("Abstract").Value; var supportedProjections = docRoot.Element("Capability").Element("Layer").Descendants("SRS"); foreach (XElement xsupportedProjection in supportedProjections) { result.Projections.Add(xsupportedProjection.Value); } //LatLonBoundingBox is specific for WMS 1.1.1 servers if (docRoot.Element("Capability").Element("Layer").Element("LatLonBoundingBox") != null) result.LatLonBoundingBox = ParseElementAsExtent(docRoot.Element("Capability").Element("Layer").Element("LatLonBoundingBox")); //Layers var layers = docRoot.Element("Capability").Element("Layer").Descendants("Layer"); foreach (XElement xlayer in layers) { result.Layers.Add(ReadLayer(xlayer)); } //GetFeatureInfo var oocap = docRoot.Element("Capability") .Element("Request") .Element("GetCapabilities") .Element("DCPType") .Element("HTTP") .Element("Get") .Element("OnlineResource"); result.GetCapabilities.Url = oocap.Attribute(xlink + "href").Value; var formats = docRoot.Element("Capability").Element("Request").Element("GetCapabilities").Descendants("Format"); foreach (XElement format in formats) { result.GetCapabilities.Formats.Add(format.Value); } //GetMap var oor = docRoot.Element("Capability") .Element("Request") .Element("GetMap") .Element("DCPType") .Element("HTTP") .Element("Get") .Element("OnlineResource"); result.GetMapInfo.Url = oor.Attribute(xlink + "href").Value; formats = docRoot.Element("Capability").Element("Request").Element("GetMap").Descendants("Format"); foreach (XElement format in formats) { result.GetMapInfo.Formats.Add(format.Value); } //GetFeatureInfo oor = docRoot.Element("Capability") .Element("Request") .Element("GetFeatureInfo") .Element("DCPType") .Element("HTTP") .Element("Get") .Element("OnlineResource"); result.GetFeatureInfo.Url = oor.Attribute(xlink + "href").Value; formats = docRoot.Element("Capability").Element("Request").Element("GetFeatureInfo").Descendants("Format"); foreach (XElement format in formats) { result.GetFeatureInfo.Formats.Add(format.Value); } //GetLegendGraphic if (docRoot.Element("Capability").Element("Request").Element("GetLegendGraphic") != null) { result.GetLegendGraphic = new WmsGetLegendGraphic(); oor = docRoot.Element("Capability") .Element("Request") .Element("GetLegendGraphic") .Element("DCPType") .Element("HTTP") .Element("Get") .Element("OnlineResource"); result.GetLegendGraphic.Url = oor.Attribute(xlink + "href").Value; formats = docRoot.Element("Capability").Element("Request").Element("GetLegendGraphic").Descendants("Format"); foreach (XElement format in formats) { result.GetLegendGraphic.Formats.Add(format.Value); } } formats = docRoot.Element("Capability").Element("Exception").Descendants("Format"); foreach (XElement format in formats) { result.ExceptionFormats.Add(format.Value); } result.CalculateExtent(); return result; }