public void ShouldParseFeatureTypesFromWfs2_0_GetCapabilitiesDocument()
        {
            XDocument doc = XDocument.Parse(xmlFile);
            WfsServiceViewModel serviceModel = new WfsGetCapabilities20Parser().Parse(doc);

            Assert.NotNull(serviceModel.Layers, "No features/layers found");
            Assert.AreEqual(1, serviceModel.Layers.Count, "Should have featureType");
        }
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;
        }