Ejemplo n.º 1
0
        /// <summary>
        /// Generates a capabilities file from a map object for use in WMS services
        /// </summary>
        /// <remarks>The capabilities document uses the v1.3.0 OpenGIS WMS specification</remarks>
        /// <param name="map">The map to create capabilities for</param>
        /// <param name="description">Additional description of WMS</param>
        /// <param name="request">An abstraction of the <see cref="HttpContext"/> request</param>
        /// <returns>Returns XmlDocument describing capabilities</returns>
        public static XmlDocument GetCapabilities(Map map, WmsServiceDescription description, IContextRequest request)
        {
            XmlDocument capabilities = new XmlDocument();

            // Insert XML tag
            capabilities.InsertBefore(capabilities.CreateXmlDeclaration("1.0", "UTF-8", String.Empty), capabilities.DocumentElement);
            string format = String.Format("Capabilities generated by SharpMap v. {0}", Assembly.GetExecutingAssembly().GetName().Version);
            capabilities.AppendChild(capabilities.CreateComment(format));

            // Create root node
            XmlNode rootNode = capabilities.CreateNode(XmlNodeType.Element, "WMS_Capabilities", WmsNamespaceUri);
            rootNode.Attributes.Append(CreateAttribute("version", "1.3.0", capabilities));

            XmlAttribute attr = capabilities.CreateAttribute("xmlns", "xsi", "http://www.w3.org/2000/xmlns/");
            attr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";
            rootNode.Attributes.Append(attr);

            rootNode.Attributes.Append(CreateAttribute("xmlns:xlink", XlinkNamespaceUri, capabilities));
            XmlAttribute attr2 = capabilities.CreateAttribute("xsi", "schemaLocation",
                                                              "http://www.w3.org/2001/XMLSchema-instance");
            attr2.InnerText = "http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd";
            rootNode.Attributes.Append(attr2);

            // Build Service node
            rootNode.AppendChild(GenerateServiceNode(ref description, capabilities));

            // Build Capability node
            XmlNode capabilityNode = GenerateCapabilityNode(map, capabilities, description.PublicAccessURL, request);
            rootNode.AppendChild(capabilityNode);

            capabilities.AppendChild(rootNode);

            //TODO: Validate output against schema
            return capabilities;
        }
Ejemplo n.º 2
0
        private static XmlNode GenerateServiceNode(ref WmsServiceDescription description, XmlDocument capabilities)
        {
            XmlElement serviceNode = capabilities.CreateElement("Service", WmsNamespaceUri);
            XmlNode name = CreateElement("Name", "WMS", capabilities, WmsNamespaceUri);
            serviceNode.AppendChild(name);
            XmlNode title = CreateElement("Title", description.Title, capabilities, WmsNamespaceUri);
            serviceNode.AppendChild(title);
            if (!String.IsNullOrEmpty(description.Abstract))
            {
                XmlNode @abstract = CreateElement("Abstract", description.Abstract, capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(@abstract);
            }
            if (description.Keywords != null && description.Keywords.Length > 0)
            {
                XmlElement keywordListNode = capabilities.CreateElement("KeywordList", WmsNamespaceUri);
                foreach (string kw in description.Keywords)
                {
                    XmlNode keyword = CreateElement("Keyword", kw, capabilities, WmsNamespaceUri);
                    keywordListNode.AppendChild(keyword);
                }
                serviceNode.AppendChild(keywordListNode);
            }

            XmlElement onlineResource = GenerateOnlineResourceElement(capabilities, description.OnlineResource);
            serviceNode.AppendChild(onlineResource);

            XmlElement contactInfo = GenerateContactInfoElement(capabilities, description.ContactInformation);
            if (contactInfo.HasChildNodes)
                serviceNode.AppendChild(contactInfo);

            if (!String.IsNullOrEmpty(description.Fees))
            {
                XmlNode fees = CreateElement("Fees", description.Fees, capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(fees);
            }
            if (!String.IsNullOrEmpty(description.AccessConstraints))
            {
                XmlNode accessConstraints = CreateElement("AccessConstraints", description.AccessConstraints, capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(accessConstraints);
            }
            if (description.LayerLimit > 0)
            {
                XmlNode layerLimit = CreateElement("LayerLimit", description.LayerLimit.ToString(), capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(layerLimit);
            }
            if (description.MaxWidth > 0)
            {
                XmlNode maxWidth = CreateElement("MaxWidth", description.MaxWidth.ToString(), capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(maxWidth);
            }
            if (description.MaxHeight > 0)
            {
                XmlNode maxHeight = CreateElement("MaxHeight", description.MaxHeight.ToString(), capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(maxHeight);
            }
            return serviceNode;
        }
Ejemplo n.º 3
0
        private static XmlNode GenerateServiceNode(ref WmsServiceDescription serviceDescription, XmlDocument capabilities)
        {
            //XmlNode ServiceNode = capabilities.CreateNode(XmlNodeType.Element, "Service", "");
            XmlElement ServiceNode = capabilities.CreateElement("Service", wmsNamespaceURI);

            ServiceNode.AppendChild(CreateElement("Name", "WMS", capabilities, false, wmsNamespaceURI));
            ServiceNode.AppendChild(CreateElement("Title", serviceDescription.Title, capabilities, false, wmsNamespaceURI)); //Add WMS Title
            if (!String.IsNullOrEmpty(serviceDescription.Abstract))                                                          //Add WMS abstract
            {
                ServiceNode.AppendChild(CreateElement("Abstract", serviceDescription.Abstract, capabilities, false, wmsNamespaceURI));
            }
            if (serviceDescription.Keywords.Length > 0)             //Add keywords
            {
                XmlElement KeywordListNode = capabilities.CreateElement("KeywordList", wmsNamespaceURI);
                foreach (string keyword in serviceDescription.Keywords)
                {
                    KeywordListNode.AppendChild(CreateElement("Keyword", keyword, capabilities, false, wmsNamespaceURI));
                }
                ServiceNode.AppendChild(KeywordListNode);
            }
            //Add Online resource
            XmlElement OnlineResourceNode = GenerateOnlineResourceElement(capabilities, serviceDescription.OnlineResource);

            ServiceNode.AppendChild(OnlineResourceNode);

            //Add ContactInformation info
            XmlElement ContactInfoNode = GenerateContactInfoElement(capabilities, serviceDescription.ContactInformation);

            if (ContactInfoNode.HasChildNodes)
            {
                ServiceNode.AppendChild(ContactInfoNode);
            }

            if (serviceDescription.Fees != null && serviceDescription.Fees != string.Empty)
            {
                ServiceNode.AppendChild(CreateElement("Fees", serviceDescription.Fees, capabilities, false, wmsNamespaceURI));
            }
            if (serviceDescription.AccessConstraints != null && serviceDescription.AccessConstraints != string.Empty)
            {
                ServiceNode.AppendChild(CreateElement("AccessConstraints", serviceDescription.AccessConstraints, capabilities, false, wmsNamespaceURI));
            }
            if (serviceDescription.LayerLimit > 0)
            {
                ServiceNode.AppendChild(CreateElement("LayerLimit", serviceDescription.LayerLimit.ToString(), capabilities, false, wmsNamespaceURI));
            }
            if (serviceDescription.MaxWidth > 0)
            {
                ServiceNode.AppendChild(CreateElement("MaxWidth", serviceDescription.MaxWidth.ToString(), capabilities, false, wmsNamespaceURI));
            }
            if (serviceDescription.MaxHeight > 0)
            {
                ServiceNode.AppendChild(CreateElement("MaxHeight", serviceDescription.MaxHeight.ToString(), capabilities, false, wmsNamespaceURI));
            }
            return(ServiceNode);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Generates a capabilities file from a map object for use in WMS services
        /// </summary>
        /// <remarks>The capabilities document uses the v1.3.0 OpenGIS WMS specification</remarks>
        /// <param name="map">The map to create capabilities for</param>
        /// <param name="serviceDescription">Additional description of WMS</param>
        /// <param name="request">An abstraction of the <see cref="HttpContext"/> request</param>
        /// <returns>Returns XmlDocument describing capabilities</returns>
        public static XmlDocument GetCapabilities(Map map, WmsServiceDescription serviceDescription, IContextRequest request)
        {
            XmlDocument capabilities = new XmlDocument();


            //Set XMLSchema
            //capabilities.Schemas.Add(GetCapabilitiesSchema());

            //Instantiate an XmlNamespaceManager object.
            //System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(capabilities.NameTable);
            //xmlnsManager.AddNamespace(xlinkNamespaceURI, "urn:Books");

            //Insert XML tag
            capabilities.InsertBefore(capabilities.CreateXmlDeclaration("1.0", "UTF-8", string.Empty),
                                      capabilities.DocumentElement);
            capabilities.AppendChild(
                capabilities.CreateComment("Capabilities generated by SharpMap v. " +
                                           Assembly.GetExecutingAssembly().GetName().Version));
            //Create root node
            XmlNode RootNode = capabilities.CreateNode(XmlNodeType.Element, "WMS_Capabilities", wmsNamespaceURI);

            RootNode.Attributes.Append(CreateAttribute("version", "1.3.0", capabilities));

            XmlAttribute attr = capabilities.CreateAttribute("xmlns", "xsi", "http://www.w3.org/2000/xmlns/");

            attr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";
            RootNode.Attributes.Append(attr);

            RootNode.Attributes.Append(CreateAttribute("xmlns:xlink", xlinkNamespaceURI, capabilities));
            XmlAttribute attr2 = capabilities.CreateAttribute("xsi", "schemaLocation",
                                                              "http://www.w3.org/2001/XMLSchema-instance");

            attr2.InnerText = "http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd";
            RootNode.Attributes.Append(attr2);

            //Build Service node
            RootNode.AppendChild(GenerateServiceNode(ref serviceDescription, capabilities));

            //Build Capability node
            XmlNode capabilityNode = GenerateCapabilityNode(map, capabilities, serviceDescription.PublicAccessURL, request);

            RootNode.AppendChild(capabilityNode);

            capabilities.AppendChild(RootNode);

            //TODO: Validate output against schema

            return(capabilities);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates a capabilities file from a map object for use in WMS services
        /// </summary>
        /// <remarks>The capabilities document uses the v1.3.0 OpenGIS WMS specification</remarks>
        /// <param name="map">The map to create capabilities for</param>
        /// <param name="serviceDescription">Additional description of WMS</param>
        /// <param name="request">An abstraction of the <see cref="HttpContext"/> request</param>
        /// <returns>Returns XmlDocument describing capabilities</returns>
        public static XmlDocument GetCapabilities(Map map, WmsServiceDescription serviceDescription, IContextRequest request)
        {
            XmlDocument capabilities = new XmlDocument();


            //Set XMLSchema
            //capabilities.Schemas.Add(GetCapabilitiesSchema());

            //Instantiate an XmlNamespaceManager object.
            //System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(capabilities.NameTable);
            //xmlnsManager.AddNamespace(xlinkNamespaceURI, "urn:Books");

            //Insert XML tag
            capabilities.InsertBefore(capabilities.CreateXmlDeclaration("1.0", "UTF-8", string.Empty),
                                      capabilities.DocumentElement);
            capabilities.AppendChild(
                capabilities.CreateComment("Capabilities generated by SharpMap v. " +
                                           Assembly.GetExecutingAssembly().GetName().Version));
            //Create root node
            XmlNode RootNode = capabilities.CreateNode(XmlNodeType.Element, "WMS_Capabilities", wmsNamespaceURI);
            RootNode.Attributes.Append(CreateAttribute("version", "1.3.0", capabilities));

            XmlAttribute attr = capabilities.CreateAttribute("xmlns", "xsi", "http://www.w3.org/2000/xmlns/");
            attr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";
            RootNode.Attributes.Append(attr);

            RootNode.Attributes.Append(CreateAttribute("xmlns:xlink", xlinkNamespaceURI, capabilities));
            XmlAttribute attr2 = capabilities.CreateAttribute("xsi", "schemaLocation",
                                                              "http://www.w3.org/2001/XMLSchema-instance");
            attr2.InnerText = "http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd";
            RootNode.Attributes.Append(attr2);

            //Build Service node
            RootNode.AppendChild(GenerateServiceNode(ref serviceDescription, capabilities));

            //Build Capability node
            XmlNode capabilityNode = GenerateCapabilityNode(map, capabilities, serviceDescription.PublicAccessURL, request);
            RootNode.AppendChild(capabilityNode);

            capabilities.AppendChild(RootNode);

            //TODO: Validate output against schema

            return capabilities;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Generates a capabilities file from a map object for use in WMS services
        /// </summary>
        /// <remarks>The capabilities document uses the v1.3.0 OpenGIS WMS specification</remarks>
        /// <param name="map">The map to create capabilities for</param>
        /// <param name="description">Additional description of WMS</param>
        /// <param name="request">An abstraction of the <see cref="HttpContext"/> request</param>
        /// <returns>Returns XmlDocument describing capabilities</returns>
        public static XmlDocument GetCapabilities(Map map, WmsServiceDescription description, IContextRequest request)
        {
            XmlDocument capabilities = new XmlDocument();

            // Insert XML tag
            capabilities.InsertBefore(capabilities.CreateXmlDeclaration("1.0", "UTF-8", String.Empty), capabilities.DocumentElement);
            string format = String.Format("Capabilities generated by SharpMap v. {0}", Assembly.GetExecutingAssembly().GetName().Version);

            capabilities.AppendChild(capabilities.CreateComment(format));

            // Create root node
            XmlNode rootNode = capabilities.CreateNode(XmlNodeType.Element, "WMS_Capabilities", WmsNamespaceUri);

            rootNode.Attributes.Append(CreateAttribute("version", "1.3.0", capabilities));

            XmlAttribute attr = capabilities.CreateAttribute("xmlns", "xsi", "http://www.w3.org/2000/xmlns/");

            attr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";
            rootNode.Attributes.Append(attr);

            rootNode.Attributes.Append(CreateAttribute("xmlns:xlink", XlinkNamespaceUri, capabilities));
            XmlAttribute attr2 = capabilities.CreateAttribute("xsi", "schemaLocation",
                                                              "http://www.w3.org/2001/XMLSchema-instance");

            attr2.InnerText = "http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd";
            rootNode.Attributes.Append(attr2);

            // Build Service node
            rootNode.AppendChild(GenerateServiceNode(ref description, capabilities));

            // Build Capability node
            XmlNode capabilityNode = GenerateCapabilityNode(map, capabilities, description.PublicAccessURL, request);

            rootNode.AppendChild(capabilityNode);

            capabilities.AppendChild(rootNode);

            //TODO: Validate output against schema
            return(capabilities);
        }
Ejemplo n.º 7
0
        private static XmlNode GenerateServiceNode(ref WmsServiceDescription description, XmlDocument capabilities)
        {
            XmlElement serviceNode = capabilities.CreateElement("Service", WmsNamespaceUri);
            XmlNode    name        = CreateElement("Name", "WMS", capabilities, WmsNamespaceUri);

            serviceNode.AppendChild(name);
            XmlNode title = CreateElement("Title", description.Title, capabilities, WmsNamespaceUri);

            serviceNode.AppendChild(title);
            if (!String.IsNullOrEmpty(description.Abstract))
            {
                XmlNode @abstract = CreateElement("Abstract", description.Abstract, capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(@abstract);
            }
            if (description.Keywords != null && description.Keywords.Length > 0)
            {
                XmlElement keywordListNode = capabilities.CreateElement("KeywordList", WmsNamespaceUri);
                foreach (string kw in description.Keywords)
                {
                    XmlNode keyword = CreateElement("Keyword", kw, capabilities, WmsNamespaceUri);
                    keywordListNode.AppendChild(keyword);
                }
                serviceNode.AppendChild(keywordListNode);
            }

            XmlElement onlineResource = GenerateOnlineResourceElement(capabilities, description.OnlineResource);

            serviceNode.AppendChild(onlineResource);

            XmlElement contactInfo = GenerateContactInfoElement(capabilities, description.ContactInformation);

            if (contactInfo.HasChildNodes)
            {
                serviceNode.AppendChild(contactInfo);
            }

            if (!String.IsNullOrEmpty(description.Fees))
            {
                XmlNode fees = CreateElement("Fees", description.Fees, capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(fees);
            }
            if (!String.IsNullOrEmpty(description.AccessConstraints))
            {
                XmlNode accessConstraints = CreateElement("AccessConstraints", description.AccessConstraints, capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(accessConstraints);
            }
            if (description.LayerLimit > 0)
            {
                XmlNode layerLimit = CreateElement("LayerLimit", description.LayerLimit.ToString(), capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(layerLimit);
            }
            if (description.MaxWidth > 0)
            {
                XmlNode maxWidth = CreateElement("MaxWidth", description.MaxWidth.ToString(), capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(maxWidth);
            }
            if (description.MaxHeight > 0)
            {
                XmlNode maxHeight = CreateElement("MaxHeight", description.MaxHeight.ToString(), capabilities, WmsNamespaceUri);
                serviceNode.AppendChild(maxHeight);
            }
            return(serviceNode);
        }
Ejemplo n.º 8
0
		private static XmlNode GenerateServiceNode(ref WmsServiceDescription serviceDescription, XmlDocument capabilities)
		{
			//XmlNode ServiceNode = capabilities.CreateNode(XmlNodeType.Element, "Service", "");
			XmlElement ServiceNode = capabilities.CreateElement("Service", wmsNamespaceURI);
			ServiceNode.AppendChild(CreateElement("Name", "WMS", capabilities, false, wmsNamespaceURI));
			ServiceNode.AppendChild(CreateElement("Title", serviceDescription.Title, capabilities, false, wmsNamespaceURI)); //Add WMS Title
			if (!String.IsNullOrEmpty(serviceDescription.Abstract)) //Add WMS abstract
				ServiceNode.AppendChild(CreateElement("Abstract", serviceDescription.Abstract, capabilities, false, wmsNamespaceURI));
			if (serviceDescription.Keywords.Length > 0) //Add keywords
			{
				XmlElement KeywordListNode = capabilities.CreateElement("KeywordList", wmsNamespaceURI);
				foreach (string keyword in serviceDescription.Keywords)
					KeywordListNode.AppendChild(CreateElement("Keyword", keyword, capabilities, false, wmsNamespaceURI));
				ServiceNode.AppendChild(KeywordListNode);
			}
			//Add Online resource
			XmlElement OnlineResourceNode = GenerateOnlineResourceElement(capabilities, serviceDescription.OnlineResource);
			ServiceNode.AppendChild(OnlineResourceNode);

			//Add ContactInformation info
			XmlElement ContactInfoNode = GenerateContactInfoElement(capabilities, serviceDescription.ContactInformation);
			if(ContactInfoNode.HasChildNodes)
				ServiceNode.AppendChild(ContactInfoNode);

			if (serviceDescription.Fees != null && serviceDescription.Fees != string.Empty)
				ServiceNode.AppendChild(CreateElement("Fees", serviceDescription.Fees, capabilities, false, wmsNamespaceURI));
			if (serviceDescription.AccessConstraints != null && serviceDescription.AccessConstraints != string.Empty)
				ServiceNode.AppendChild(CreateElement("AccessConstraints", serviceDescription.AccessConstraints, capabilities, false, wmsNamespaceURI));
			if(serviceDescription.LayerLimit>0)
				ServiceNode.AppendChild(CreateElement("LayerLimit", serviceDescription.LayerLimit.ToString(), capabilities, false, wmsNamespaceURI));
			if (serviceDescription.MaxWidth > 0)
				ServiceNode.AppendChild(CreateElement("MaxWidth", serviceDescription.MaxWidth.ToString(), capabilities, false, wmsNamespaceURI));
			if (serviceDescription.MaxHeight > 0)
				ServiceNode.AppendChild(CreateElement("MaxHeight", serviceDescription.MaxHeight.ToString(), capabilities, false, wmsNamespaceURI));
			return ServiceNode;
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Generates a capabilities file from a map object for use in WMS services
 /// </summary>
 /// <remarks>The capabilities document uses the v1.3.0 OpenGIS WMS specification</remarks>
 /// <param name="map">The map to create capabilities for</param>
 /// <param name="serviceDescription">Additional description of WMS</param>
 /// <returns>Returns XmlDocument describing capabilities</returns>
 public static XmlDocument GetCapabilities(Map map, WmsServiceDescription serviceDescription)
 {
     return GetCapabilities(HttpContext.Current, map, serviceDescription);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Generates a capabilities file from a map object for use in WMS services
 /// </summary>
 /// <remarks>The capabilities document uses the v1.3.0 OpenGIS WMS specification</remarks>
 /// <param name="map">The map to create capabilities for</param>
 /// <param name="serviceDescription">Additional description of WMS</param>
 /// <returns>Returns XmlDocument describing capabilities</returns>
 public static XmlDocument GetCapabilities(Map map, WmsServiceDescription serviceDescription)
 {
     return(GetCapabilities(HttpContext.Current, map, serviceDescription));
 }