Stores metadata for a WMTS service.
Inheritance: MapAround.Web.Wms.BaseServiceDescription
        /// <summary>
        /// Generates an XML containing WMTS capabilities.
        /// </summary>
        /// <param name="map">A MapAround.Mapping.Map instance</param>
        /// <param name="serviceDescription"></param>
        /// <returns>A System.Xml.XmlDocument instance containing WMTS capabilities in compliance to the WMS standard</returns>
        public static XmlDocument GetCapabilities(Map map,
                                                  WmtsServiceDescription serviceDescription)
        {
            XmlDocument capabilities = new XmlDocument();

            capabilities.InsertBefore(capabilities.CreateXmlDeclaration("1.0", "UTF-8", string.Empty),
                                      capabilities.DocumentElement);

            XmlNode rootNode = capabilities.CreateNode(XmlNodeType.Element, "WMTS_Capabilities", wmtsNamespaceURI);

            rootNode.Attributes.Append(createAttribute("version", "1.0.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");

            rootNode.AppendChild(GenerateServiceNode(ref serviceDescription, capabilities));

            rootNode.AppendChild(GenerateCapabilityNode(map, serviceDescription, capabilities));

            capabilities.AppendChild(rootNode);

            return(capabilities);
        }
Example #2
0
        /// <summary>
        /// Generates an XML containing WMTS capabilities.
        /// </summary>
        /// <param name="map">A MapAround.Mapping.Map instance</param>        
        /// <param name="serviceDescription"></param>
        /// <returns>A System.Xml.XmlDocument instance containing WMTS capabilities in compliance to the WMS standard</returns>
        public static XmlDocument GetCapabilities(Map map,
                                                  WmtsServiceDescription serviceDescription)
        {
            XmlDocument capabilities = new XmlDocument();

            capabilities.InsertBefore(capabilities.CreateXmlDeclaration("1.0", "UTF-8", string.Empty),
                                      capabilities.DocumentElement);

            XmlNode rootNode = capabilities.CreateNode(XmlNodeType.Element, "WMTS_Capabilities", wmtsNamespaceURI);
            rootNode.Attributes.Append(createAttribute("version", "1.0.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");

            rootNode.AppendChild(GenerateServiceNode(ref serviceDescription, capabilities));

            rootNode.AppendChild(GenerateCapabilityNode(map, serviceDescription, capabilities));

            capabilities.AppendChild(rootNode);

            return capabilities;
        }
        private static XmlNode getWmtsLayerNode(WmtsServiceDescription serviceDescription, LayerBase layer, XmlDocument doc)
        {
            XmlNode layerNode = doc.CreateNode(XmlNodeType.Element, "Layer", wmtsNamespaceURI);

            layerNode.AppendChild(createElement("Name", layer.Alias, doc, false, wmtsNamespaceURI));
            layerNode.AppendChild(createElement("Title", layer.Title, doc, false, wmtsNamespaceURI));
            layerNode.Attributes.Append(doc.CreateAttribute("queryable")).Value =
                layer is FeatureLayer && (layer as FeatureLayer).FeaturesSelectable ? "1" : "0";

            layerNode.AppendChild(GenerateTileMatrixSet(serviceDescription, doc));

            return(layerNode);
        }
        private static XmlNode GenerateTileMatrixInfo(WmtsServiceDescription serviceDescription, XmlDocument capabilities, int i)
        {
            XmlNode matrixInfo = capabilities.CreateNode(XmlNodeType.Element, "TileMatrix", wmtsNamespaceURI);

            matrixInfo.AppendChild(createElement("ows:Identifier", serviceDescription.ZoomLevel.Keys.ToList()[i].ToString(), capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("ScaleDenominator", serviceDescription.GetScaleDenominator(i).ToString(), capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("TopLeftCorner", "-180 90", capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("TileWidth", "256", capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("TileHeight", "256", capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("MatrixWidth", Math.Pow(2, i).ToString(), capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("MatrixHeight", Math.Pow(2, i).ToString(), capabilities, false, wmtsNamespaceURI));

            return(matrixInfo);
        }
Example #5
0
        private static XmlNode GenerateServiceNode(ref WmtsServiceDescription serviceDescription,
                                                   XmlDocument capabilities)
        {
            XmlElement serviceNode = capabilities.CreateElement("Service", wmtsNamespaceURI);
            serviceNode.AppendChild(createElement("Name", "OGC:WMTS", capabilities, false, wmtsNamespaceURI));
            serviceNode.AppendChild(createElement("Title", serviceDescription.Title, capabilities, false,
                                                  wmtsNamespaceURI));
            if (!String.IsNullOrEmpty(serviceDescription.Abstract))
                serviceNode.AppendChild(createElement("Abstract", serviceDescription.Abstract, capabilities, false,
                                                      wmtsNamespaceURI));

            if (serviceDescription.Keywords != null && serviceDescription.Keywords.Length > 0)
            {
                XmlElement KeywordListNode = capabilities.CreateElement("KeywordList", wmtsNamespaceURI);
                foreach (string keyword in serviceDescription.Keywords)
                    KeywordListNode.AppendChild(createElement("Keyword", keyword, capabilities, false, wmtsNamespaceURI));
                serviceNode.AppendChild(KeywordListNode);
            }

            // ссылка
            XmlElement onlineResourceNode = GenerateOnlineResourceElement(capabilities,
                                                                          serviceDescription.OnlineResource);
            serviceNode.AppendChild(onlineResourceNode);

            // контактная информация
            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,
                                                      wmtsNamespaceURI));
            if (serviceDescription.AccessConstraints != null && serviceDescription.AccessConstraints != string.Empty)
                serviceNode.AppendChild(createElement("AccessConstraints", serviceDescription.AccessConstraints,
                                                      capabilities, false, wmtsNamespaceURI));
            if (serviceDescription.LayerLimit > 0)
                serviceNode.AppendChild(createElement("LayerLimit", serviceDescription.LayerLimit.ToString(CultureInfo.InvariantCulture),
                                                      capabilities, false, wmtsNamespaceURI));
            if (serviceDescription.MaxWidth > 0)
                serviceNode.AppendChild(createElement("MaxWidth", serviceDescription.MaxWidth.ToString(CultureInfo.InvariantCulture), capabilities,
                                                      false, wmtsNamespaceURI));
            if (serviceDescription.MaxHeight > 0)
                serviceNode.AppendChild(createElement("MaxHeight", serviceDescription.MaxHeight.ToString(CultureInfo.InvariantCulture), capabilities,
                                                      false, wmtsNamespaceURI));
            return serviceNode;
        }
        private static XmlNode GenerateTileMatrixSet(WmtsServiceDescription serviceDescription, XmlDocument capabilities)
        {
            XmlNode tileMatrixSetLink = capabilities.CreateNode(XmlNodeType.Element, "TileMatrixSetLink", wmtsNamespaceURI);

            XmlNode tileMatrixSet = capabilities.CreateNode(XmlNodeType.Element, "TileMatrixSet", wmtsNamespaceURI);

            tileMatrixSet.AppendChild(createElement("Identifier", "EPSG:3857", capabilities, false, wmtsNamespaceURI));
            tileMatrixSet.AppendChild(createElement("WellKnownScaleSet", "EPSG", capabilities, false, wmtsNamespaceURI));

            for (int i = 0; i < serviceDescription.ZoomLevel.Count; i++)
            {
                tileMatrixSet.AppendChild(GenerateTileMatrixInfo(serviceDescription, capabilities, i));
            }

            tileMatrixSetLink.AppendChild(tileMatrixSet);

            return(tileMatrixSetLink);
        }
Example #7
0
 /// <summary>
 /// Designer.
 /// </summary>       
 public WMTSServer(WmtsServiceDescription description)
     : base("1.0.0", "wmts",description)
 {
     _description = description;
 }
        private static XmlNode GenerateServiceNode(ref WmtsServiceDescription serviceDescription,
                                                   XmlDocument capabilities)
        {
            XmlElement serviceNode = capabilities.CreateElement("Service", wmtsNamespaceURI);

            serviceNode.AppendChild(createElement("Name", "OGC:WMTS", capabilities, false, wmtsNamespaceURI));
            serviceNode.AppendChild(createElement("Title", serviceDescription.Title, capabilities, false,
                                                  wmtsNamespaceURI));
            if (!String.IsNullOrEmpty(serviceDescription.Abstract))
            {
                serviceNode.AppendChild(createElement("Abstract", serviceDescription.Abstract, capabilities, false,
                                                      wmtsNamespaceURI));
            }

            if (serviceDescription.Keywords != null && serviceDescription.Keywords.Length > 0)
            {
                XmlElement KeywordListNode = capabilities.CreateElement("KeywordList", wmtsNamespaceURI);
                foreach (string keyword in serviceDescription.Keywords)
                {
                    KeywordListNode.AppendChild(createElement("Keyword", keyword, capabilities, false, wmtsNamespaceURI));
                }
                serviceNode.AppendChild(KeywordListNode);
            }

            // ссылка
            XmlElement onlineResourceNode = GenerateOnlineResourceElement(capabilities,
                                                                          serviceDescription.OnlineResource);

            serviceNode.AppendChild(onlineResourceNode);

            // контактная информация
            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,
                                                      wmtsNamespaceURI));
            }
            if (serviceDescription.AccessConstraints != null && serviceDescription.AccessConstraints != string.Empty)
            {
                serviceNode.AppendChild(createElement("AccessConstraints", serviceDescription.AccessConstraints,
                                                      capabilities, false, wmtsNamespaceURI));
            }
            if (serviceDescription.LayerLimit > 0)
            {
                serviceNode.AppendChild(createElement("LayerLimit", serviceDescription.LayerLimit.ToString(CultureInfo.InvariantCulture),
                                                      capabilities, false, wmtsNamespaceURI));
            }
            if (serviceDescription.MaxWidth > 0)
            {
                serviceNode.AppendChild(createElement("MaxWidth", serviceDescription.MaxWidth.ToString(CultureInfo.InvariantCulture), capabilities,
                                                      false, wmtsNamespaceURI));
            }
            if (serviceDescription.MaxHeight > 0)
            {
                serviceNode.AppendChild(createElement("MaxHeight", serviceDescription.MaxHeight.ToString(CultureInfo.InvariantCulture), capabilities,
                                                      false, wmtsNamespaceURI));
            }
            return(serviceNode);
        }
        private static XmlNode GenerateCapabilityNode(Map map, WmtsServiceDescription serviceDescription, XmlDocument capabilities)
        {
            string OnlineResource = string.Empty; // !!!!!!!!!!!! Доработать!

            XmlNode CapabilityNode      = capabilities.CreateNode(XmlNodeType.Element, "Capability", wmtsNamespaceURI);
            XmlNode RequestNode         = capabilities.CreateNode(XmlNodeType.Element, "Request", wmtsNamespaceURI);
            XmlNode GetCapabilitiesNode = capabilities.CreateNode(XmlNodeType.Element, "GetCapabilities",
                                                                  wmtsNamespaceURI);

            GetCapabilitiesNode.AppendChild(createElement("Format", "text/xml", capabilities, false, wmtsNamespaceURI));
            GetCapabilitiesNode.AppendChild(GenerateDCPTypeNode(capabilities, OnlineResource));
            RequestNode.AppendChild(GetCapabilitiesNode);

            XmlNode getMapNode = capabilities.CreateNode(XmlNodeType.Element, "GetTile", wmtsNamespaceURI);

            // поддерживаемые форматы изображений
            foreach (ImageCodecInfo encoder in ImageCodecInfo.GetImageEncoders())
            {
                getMapNode.AppendChild(createElement("Format", encoder.MimeType, capabilities, false, wmtsNamespaceURI));
            }

            getMapNode.AppendChild(GenerateDCPTypeNode(capabilities, OnlineResource));

            RequestNode.AppendChild(getMapNode);
            CapabilityNode.AppendChild(RequestNode);
            XmlElement exceptionNode = capabilities.CreateElement("Exception", wmtsNamespaceURI);

            exceptionNode.AppendChild(createElement("Format", "text/xml", capabilities, false, wmtsNamespaceURI));
            CapabilityNode.AppendChild(exceptionNode); //Add supported exception types

            // список слоев
            XmlNode layerRootNode = capabilities.CreateNode(XmlNodeType.Element, "Layer", wmtsNamespaceURI);

            layerRootNode.AppendChild(createElement("Title", "MapAround", capabilities, false, wmtsNamespaceURI));

            string srs = "EPSG:-1";

            if (!string.IsNullOrEmpty(map.CoodrinateSystemWKT))
            {
                ICoordinateSystem coordinateSystem =
                    (ICoordinateSystem)CoordinateSystemWktDeserializer.Parse(map.CoodrinateSystemWKT);

                srs = coordinateSystem.Authority + ":" + coordinateSystem.AuthorityCode;
            }

            layerRootNode.AppendChild(createElement("SRS", srs, capabilities, false,
                                                    wmtsNamespaceURI));

            if (serviceDescription.Tile != null &&
                !serviceDescription.Tile.IsEmpty())
            {
                layerRootNode.AppendChild(GenerateTileElement(serviceDescription.Tile, srs, capabilities));
            }

            foreach (LayerBase layer in map.Layers)
            {
                layerRootNode.AppendChild(getWmtsLayerNode(serviceDescription, layer, capabilities));
            }

            CapabilityNode.AppendChild(layerRootNode);

            return(CapabilityNode);
        }
Example #10
0
        private static XmlNode GenerateTileMatrixInfo(WmtsServiceDescription serviceDescription, XmlDocument capabilities, int i)
        {
            XmlNode matrixInfo = capabilities.CreateNode(XmlNodeType.Element, "TileMatrix", wmtsNamespaceURI);

            matrixInfo.AppendChild(createElement("ows:Identifier", serviceDescription.ZoomLevel.Keys.ToList()[i].ToString(), capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("ScaleDenominator", serviceDescription.GetScaleDenominator(i).ToString(), capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("TopLeftCorner", "-180 90", capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("TileWidth", "256", capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("TileHeight", "256", capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("MatrixWidth", Math.Pow(2, i).ToString(), capabilities, false, wmtsNamespaceURI));
            matrixInfo.AppendChild(createElement("MatrixHeight", Math.Pow(2, i).ToString(), capabilities, false, wmtsNamespaceURI));

            return matrixInfo;
        }
Example #11
0
        private static XmlNode GenerateTileMatrixSet(WmtsServiceDescription serviceDescription, XmlDocument capabilities)
        {
            XmlNode tileMatrixSetLink = capabilities.CreateNode(XmlNodeType.Element, "TileMatrixSetLink", wmtsNamespaceURI);
            
            XmlNode tileMatrixSet = capabilities.CreateNode(XmlNodeType.Element, "TileMatrixSet", wmtsNamespaceURI);

            tileMatrixSet.AppendChild(createElement("Identifier", "EPSG:3857", capabilities, false, wmtsNamespaceURI));
            tileMatrixSet.AppendChild(createElement("WellKnownScaleSet", "EPSG", capabilities, false, wmtsNamespaceURI));

            for (int i = 0; i < serviceDescription.ZoomLevel.Count; i++)
            {
                tileMatrixSet.AppendChild(GenerateTileMatrixInfo(serviceDescription, capabilities, i));
            }

            tileMatrixSetLink.AppendChild(tileMatrixSet);

            return tileMatrixSetLink;
        }
Example #12
0
        private static XmlNode getWmtsLayerNode(WmtsServiceDescription serviceDescription, LayerBase layer, XmlDocument doc)
        {
            XmlNode layerNode = doc.CreateNode(XmlNodeType.Element, "Layer", wmtsNamespaceURI);
            layerNode.AppendChild(createElement("Name", layer.Alias, doc, false, wmtsNamespaceURI));
            layerNode.AppendChild(createElement("Title", layer.Title, doc, false, wmtsNamespaceURI));
            layerNode.Attributes.Append(doc.CreateAttribute("queryable")).Value = 
                layer is FeatureLayer && (layer as FeatureLayer).FeaturesSelectable ? "1" : "0";

            layerNode.AppendChild(GenerateTileMatrixSet(serviceDescription, doc));

            return layerNode;
        }
Example #13
0
        private static XmlNode GenerateCapabilityNode(Map map, WmtsServiceDescription serviceDescription, XmlDocument capabilities)
        {
            string OnlineResource = string.Empty; // !!!!!!!!!!!! Доработать!

            XmlNode CapabilityNode = capabilities.CreateNode(XmlNodeType.Element, "Capability", wmtsNamespaceURI);
            XmlNode RequestNode = capabilities.CreateNode(XmlNodeType.Element, "Request", wmtsNamespaceURI);
            XmlNode GetCapabilitiesNode = capabilities.CreateNode(XmlNodeType.Element, "GetCapabilities",
                                                                  wmtsNamespaceURI);

            GetCapabilitiesNode.AppendChild(createElement("Format", "text/xml", capabilities, false, wmtsNamespaceURI));
            GetCapabilitiesNode.AppendChild(GenerateDCPTypeNode(capabilities, OnlineResource));
            RequestNode.AppendChild(GetCapabilitiesNode);

            XmlNode getMapNode = capabilities.CreateNode(XmlNodeType.Element, "GetTile", wmtsNamespaceURI);

            // поддерживаемые форматы изображений
            foreach (ImageCodecInfo encoder in ImageCodecInfo.GetImageEncoders())
                getMapNode.AppendChild(createElement("Format", encoder.MimeType, capabilities, false, wmtsNamespaceURI));

            getMapNode.AppendChild(GenerateDCPTypeNode(capabilities, OnlineResource));

            RequestNode.AppendChild(getMapNode);
            CapabilityNode.AppendChild(RequestNode);
            XmlElement exceptionNode = capabilities.CreateElement("Exception", wmtsNamespaceURI);
            exceptionNode.AppendChild(createElement("Format", "text/xml", capabilities, false, wmtsNamespaceURI));
            CapabilityNode.AppendChild(exceptionNode); //Add supported exception types

            // список слоев
            XmlNode layerRootNode = capabilities.CreateNode(XmlNodeType.Element, "Layer", wmtsNamespaceURI);
            layerRootNode.AppendChild(createElement("Title", "MapAround", capabilities, false, wmtsNamespaceURI));

            string srs = "EPSG:-1";
            if (!string.IsNullOrEmpty(map.CoodrinateSystemWKT))
            {
                ICoordinateSystem coordinateSystem =
                    (ICoordinateSystem)CoordinateSystemWktDeserializer.Parse(map.CoodrinateSystemWKT);

                srs = coordinateSystem.Authority + ":" + coordinateSystem.AuthorityCode;
            }

            layerRootNode.AppendChild(createElement("SRS", srs, capabilities, false,
                                                    wmtsNamespaceURI));

            if (serviceDescription.Tile != null &&
                !serviceDescription.Tile.IsEmpty())
            {
                layerRootNode.AppendChild(GenerateTileElement(serviceDescription.Tile, srs, capabilities));
            }

            foreach (LayerBase layer in map.Layers)
                layerRootNode.AppendChild(getWmtsLayerNode(serviceDescription, layer, capabilities));

            CapabilityNode.AppendChild(layerRootNode);

            return CapabilityNode;
        }
Example #14
0
 /// <summary>
 /// Designer.
 /// </summary>
 public WMTSServer(WmtsServiceDescription description)
     : base("1.0.0", "wmts", description)
 {
     _description = description;
 }