public WfsServiceViewModel Parse(XDocument getCapabilitiesXmlDocument)
        {
            WfsServiceViewModel serviceModel = new WfsServiceViewModel();

            XElement root = getCapabilitiesXmlDocument.Element(WFS + "WFS_Capabilities");


            //Implement support english later
            //serviceModel.SupportsEnglishGetCapabilities = CheckSupportForEnglishGetCapabilities(root);

            IEnumerable <XElement> layers =
                from el in root.Elements(WFS + "FeatureTypeList").Elements(WFS + "FeatureType")
                select el;

            List <WfsLayerViewModel> layerModels = new List <WfsLayerViewModel>();

            foreach (var layer in layers)
            {
                layerModels.AddRange(ParseLayerData(layer));
            }

            serviceModel.Layers = layerModels;

            return(serviceModel);
        }
Exemplo n.º 2
0
        public WfsServiceViewModel GetLayers(string wfsUrl)
        {
            if (!string.IsNullOrWhiteSpace(wfsUrl))
            {
                WfsServiceViewModel serviceModel = new WfsServiceViewModel();

                XDocument xmlDocument = XDocument.Load(wfsUrl);

                XElement root = xmlDocument.Element(WFS + "WFS_Capabilities");
                if (root != null)
                {
                    string version = root.Attribute("version").Value;
                    version = version.Substring(0, 3);

                    if (version == "1.0")
                    {
                        WfsGetCapabilities10Parser parser = new WfsGetCapabilities10Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }

                    else if (version == "1.1")
                    {
                        WfsGetCapabilities11Parser parser = new WfsGetCapabilities11Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }
                    else
                    {
                        WfsGetCapabilities11Parser parser = new WfsGetCapabilities11Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }
                }
                else
                {
                    XElement root2 = xmlDocument.Element(WFS2 + "WFS_Capabilities");
                    if (root2 != null)
                    {
                        WfsGetCapabilities20Parser parser = new WfsGetCapabilities20Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }
                    else
                    {
                        serviceModel = null;
                    }
                }

                return(serviceModel);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        public WfsServiceViewModel GetLayers(string wfsUrl)
        {
            if (!string.IsNullOrWhiteSpace(wfsUrl))
            {
                WfsServiceViewModel serviceModel = new WfsServiceViewModel();

                XDocument xmlDocument = XDocument.Load(wfsUrl);

                XElement root = xmlDocument.Element(WFS + "WFS_Capabilities");
                if (root != null)
                {
                    string version = root.Attribute("version").Value;
                    version = version.Substring(0, 3);

                    if (version == "1.0")
                    {
                    WfsGetCapabilities10Parser parser = new WfsGetCapabilities10Parser();
                    serviceModel = parser.Parse(xmlDocument);
                    }

                    else if (version == "1.1")
                    {
                    WfsGetCapabilities11Parser parser = new WfsGetCapabilities11Parser();
                    serviceModel = parser.Parse(xmlDocument);
                    }
                    else
                    {
                        WfsGetCapabilities11Parser parser = new WfsGetCapabilities11Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }

                }
                else
                {
                    XElement root2 = xmlDocument.Element(WFS2 + "WFS_Capabilities");
                    if (root2 != null)
                    {
                        WfsGetCapabilities20Parser parser = new WfsGetCapabilities20Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }
                    else
                        serviceModel = null;
                }

                return serviceModel;
            }
            else
                return null;
        }
        public WfsServiceViewModel Parse(XDocument getCapabilitiesXmlDocument)
        {
            WfsServiceViewModel serviceModel = new WfsServiceViewModel();

            XElement root = getCapabilitiesXmlDocument.Element(WFS + "WFS_Capabilities");

            //Implement support english later
            //serviceModel.SupportsEnglishGetCapabilities = CheckSupportForEnglishGetCapabilities(root);

            IEnumerable<XElement> layers =
                    from el in root.Elements(WFS + "FeatureTypeList").Elements(WFS + "FeatureType")
                    select el;

            List<WfsLayerViewModel> layerModels = new List<WfsLayerViewModel>();

            foreach (var layer in layers)
            {
                layerModels.AddRange(ParseLayerData(layer));
            }

            serviceModel.Layers = layerModels;

            return serviceModel;
        }