Пример #1
0
        public WmsCapabilities(XDocument doc)
            : this()
        {
            if (doc.Root != null && doc.Root.Name == "ServiceExceptionReport")
            {
                ServiceExceptionReport = new ServiceExceptionReport(doc.Root, "");
                return;
            }

            var node = doc.Element(XName.Get("WMT_MS_Capabilities"));
            if (node == null) node = doc.Element(XName.Get("WMS_Capabilities"));
            if (node == null)
            {
                // try load root node with xmlns="http://www.opengis.net/wms"
                node = doc.Element(XName.Get("WMS_Capabilities", "http://www.opengis.net/wms"));
                if (node == null)
                {
                    throw WmsParsingException.ElementNotFound("WMS_Capabilities or WMT_MS_Capabilities");
                }
            }

            var att = node.Attribute(XName.Get("version"));
            if (att == null)
                throw WmsParsingException.AttributeNotFound("version");
            Version = new WmsVersion(att.Value);

            var @namespace = Version.Version == WmsVersionEnum.Version_1_3_0
                          ? "http://www.opengis.net/wms"
                          : string.Empty;
            XmlObject.Namespace = @namespace;

            att = node.Attribute("updateSequence");
            if (att != null)
                UpdateSequence = int.Parse(att.Value, NumberFormatInfo.InvariantInfo);

            var element = node.Element(XName.Get("Service", @namespace));
            if (element == null)
            {
                XmlObject.Namespace = @namespace = string.Empty;
                element = node.Element(XName.Get("Service", @namespace));
            }
            if (element == null)
                throw WmsParsingException.ElementNotFound("Service");

            Service = new Service(element, @namespace);

            element = node.Element(XName.Get("Capability", @namespace));

            if (element == null)
                throw WmsParsingException.ElementNotFound("Capability");

            Capability = new Capability(element, @namespace);
        }
Пример #2
0
 public XDocument ToXDocument()
 {
     var declaration = new XDeclaration("1.0", "UTF-8", "no");
     if (Version.Version < WmsVersionEnum.Version_1_3_0)
     {
         return new XDocument(declaration,
             new XDocumentType("WMS_MT_Capabilities", string.Empty, WmsVersion.System(Version.Version, "capabilities"), string.Empty),
             ToXElement(string.Empty)
             );
     }
     return new XDocument(declaration, ToXElement(WmsNamespaces.Wms));
 }
Пример #3
0
        public WmsCapabilities(XDocument doc)
            : this()
        {
            if (doc.Root.Name == "ServiceExceptionReport")
            {
                ServiceExceptionReport = new ServiceExceptionReport(doc.Root, "");
                return;
            }

            var node = doc.Element(XName.Get("WMT_MS_Capabilities"));
            if (node == null) node = doc.Element(XName.Get("WMS_Capabilities"));
            if (node == null)
            {
                // try load root node with xmlns="http://www.opengis.net/wms"
                node = doc.Element(XName.Get("WMS_Capabilities", "http://www.opengis.net/wms"));
                if (node == null)
                {
                    throw WmsParsingException.ElementNotFound("WMS_Capabilities or WMT_MS_Capabilities");
                }
            }

            var att = node.Attribute(XName.Get("version"));
            if (att == null)
                throw WmsParsingException.AttributeNotFound("version");
            Version = new WmsVersion(att.Value);

            var @namespace = Version.Version == WmsVersionEnum.Version_1_3_0
                          ? "http://www.opengis.net/wms"
                          : string.Empty;
            XmlObject.Namespace = @namespace;

            att = node.Attribute("updateSequence");
            if (att != null)
                UpdateSequence = int.Parse(att.Value, NumberFormatInfo.InvariantInfo);

            var element = node.Element(XName.Get("Service", @namespace));
            if (element == null)
            {
                XmlObject.Namespace = @namespace = string.Empty;
                element = node.Element(XName.Get("Service", @namespace));
            }
            if (element == null)
                throw WmsParsingException.ElementNotFound("Service");

            Service = new Service(element, @namespace);

            element = node.Element(XName.Get("Capability", @namespace));

            if (element == null)
                throw WmsParsingException.ElementNotFound("Capability");

            Capability = new Capability(element, @namespace);
        }
 public WmsCapabilities(WmsVersionEnum version)
 {
     Version = new WmsVersion(version);
 }
 public WmsCapabilities(string version)
 {
     Version = new WmsVersion(version);
 }
Пример #6
0
 public WmsCapabilities(WmsVersionEnum version)
 {
     Version = new WmsVersion(version);
 }
Пример #7
0
 public WmsCapabilities(string version)
 {
     Version = new WmsVersion(version);
 }