public WmsServiceViewModel GetLayers(string wmsUrl) { WmsServiceViewModel serviceModel = new WmsServiceViewModel(); if (!wmsUrl.EndsWith("?")) { wmsUrl = wmsUrl + "?"; } wmsUrl = wmsUrl + "service=wms&request=GetCapabilities"; XDocument xmlDocument = XDocument.Load(wmsUrl); XElement root = xmlDocument.Element(WMS + "WMS_Capabilities"); if (root != null) { WmsGetCapabilities13Parser parser = new WmsGetCapabilities13Parser(); serviceModel = parser.Parse(xmlDocument); if (serviceModel.SupportsEnglishGetCapabilities) { XDocument getCapabilitiesEnglish = XDocument.Load(wmsUrl + "&language=eng"); Dictionary<string, Dictionary<string, string>> englishInformation = parser.ParseEnglishGetCapabilities(getCapabilitiesEnglish); serviceModel.AppendEnglishInformation(englishInformation); } } else { root = xmlDocument.Element("WMT_MS_Capabilities"); if (root != null) { serviceModel = new WmsGetCapabilities11Parser().Parse(xmlDocument); } } return serviceModel; }
public WmsServiceViewModel Parse(XDocument getCapabilitiesXmlDocument) { WmsServiceViewModel serviceModel = new WmsServiceViewModel(); IEnumerable<XElement> layers = from el in getCapabilitiesXmlDocument.Element("WMT_MS_Capabilities").Elements("Capability").Elements("Layer").Elements("Layer") select el; foreach (var layer in layers) { serviceModel.Layers.AddRange(ParseLayerData(layer)); } return serviceModel; }
public WmsServiceViewModel Parse(XDocument getCapabilitiesXmlDocument) { WmsServiceViewModel serviceModel = new WmsServiceViewModel(); IEnumerable <XElement> layers = from el in getCapabilitiesXmlDocument.Element("WMT_MS_Capabilities").Elements("Capability").Elements("Layer").Elements("Layer") select el; foreach (var layer in layers) { serviceModel.Layers.AddRange(ParseLayerData(layer)); } return(serviceModel); }
public WmsServiceViewModel Parse(XDocument getCapabilitiesXmlDocument) { WmsServiceViewModel serviceModel = new WmsServiceViewModel(); XElement root = getCapabilitiesXmlDocument.Element(WMS + "WMS_Capabilities"); serviceModel.SupportsEnglishGetCapabilities = CheckSupportForEnglishGetCapabilities(root); IEnumerable<XElement> layers = from el in root.Elements(WMS + "Capability").Elements(WMS + "Layer").Elements(WMS + "Layer") select el; List<WmsLayerViewModel> layerModels = new List<WmsLayerViewModel>(); foreach (var layer in layers) { layerModels.AddRange(ParseLayerData(layer)); } serviceModel.Layers = layerModels; return serviceModel; }
public WmsServiceViewModel Parse(XDocument getCapabilitiesXmlDocument) { WmsServiceViewModel serviceModel = new WmsServiceViewModel(); XElement root = getCapabilitiesXmlDocument.Element(WMS + "WMS_Capabilities"); serviceModel.SupportsEnglishGetCapabilities = CheckSupportForEnglishGetCapabilities(root); IEnumerable <XElement> layers = from el in root.Elements(WMS + "Capability").Elements(WMS + "Layer").Elements(WMS + "Layer") select el; List <WmsLayerViewModel> layerModels = new List <WmsLayerViewModel>(); foreach (var layer in layers) { layerModels.AddRange(ParseLayerData(layer)); } serviceModel.Layers = layerModels; return(serviceModel); }
public WmsServiceViewModel GetLayers(string wmsUrl) { if (!string.IsNullOrWhiteSpace(wmsUrl)) { WmsServiceViewModel serviceModel = new WmsServiceViewModel(); XDocument xmlDocument = XDocument.Load(wmsUrl); XElement root = xmlDocument.Element(WMS + "WMS_Capabilities"); if (root != null) { WmsGetCapabilities13Parser parser = new WmsGetCapabilities13Parser(); serviceModel = parser.Parse(xmlDocument); if (serviceModel.SupportsEnglishGetCapabilities) { XDocument getCapabilitiesEnglish = XDocument.Load(wmsUrl + "&language=eng"); Dictionary <string, Dictionary <string, string> > englishInformation = parser.ParseEnglishGetCapabilities(getCapabilitiesEnglish); serviceModel.AppendEnglishInformation(englishInformation); } } else { root = xmlDocument.Element("WMT_MS_Capabilities"); if (root != null) { serviceModel = new WmsGetCapabilities11Parser().Parse(xmlDocument); } } return(serviceModel); } else { return(null); } }