コード例 #1
0
        public static LayerType AddToCapabilities(this DataSource dataSource, string name, Capabilities capabilities)
        {
            string projectionStr;
            double xMin, yMin, xMax, yMax;
            string tileMatrixSet = null;

            using (var layer = dataSource.GetLayerByIndex(0))
            {
                string layerName = layer.GetName();//todo 调试是否乱码
                using (var spatialReference = layer.GetSpatialRef())
                {
                    tileMatrixSet = spatialReference.GetAttrValue("GEOGCS", 0);
                    var ret = spatialReference.ExportToWkt(out projectionStr);
                }
                layer.GetExtent(out xMin, out yMin, out xMax, out yMax);
            }
            int minZoom = 0;
            int maxZoom = 19;

            dataSource.GetSuitableZoom(ref minZoom, ref maxZoom);
            LayerType       layerType           = CapabilitiesHelper.AddToCapabilities(capabilities, name, projectionStr, xMin, yMin, xMax, yMax, minZoom, maxZoom);
            string          href                = capabilities.GetHref(WmtsOperationType.GetTile, WmtsRequestType.REST);
            URLTemplateType tileTemplate        = CapabilitiesHelper.CreateTileResourceURL(href, name, tileMatrixSet);
            URLTemplateType featureInfoTemplate = CapabilitiesHelper.CreateFeatureInfoResourceURL(href, name, tileMatrixSet);

            layerType.ResourceURL = new URLTemplateType[] { tileTemplate, featureInfoTemplate };
            return(layerType);
        }
コード例 #2
0
        public static URLTemplateType CreateFeatureInfoResourceURL(string href, string name, string tileMatrixSet, string style = "default")
        {
            URLTemplateType getFeatureInfoResourceURL = new URLTemplateType()
            {
                format       = "application/gml+xml; version=3.1",
                resourceType = "FeatureInfo",
                template     = $"{href}/{name}/{style}/{tileMatrixSet}/{{TileMatrix}}/{{TileRow}}/{{TileCol}}/{{J}}/{{I}}.xml"
            };

            return(getFeatureInfoResourceURL);
        }
コード例 #3
0
        public static URLTemplateType CreateTileResourceURL(string href, string name, string tileMatrixSet, string style = "default", string format = "png")
        {
            URLTemplateType getTileResourceURL = new URLTemplateType()
            {
                format       = $"image/{format}",
                resourceType = "tile",
                template     = $"{href}/{name}/{style}/{tileMatrixSet}/{{TileMatrix}}/{{TileRow}}/{{TileCol}}.{format}"
            };

            return(getTileResourceURL);
        }
コード例 #4
0
        public static ResourceUrl GetTileResourceUrl(this LayerType layerType)
        {
            ResourceUrl     resourceUrl  = null;
            URLTemplateType templateType = layerType.ResourceURL?.FirstOrDefault(x => x.resourceType == URLTemplateTypeResourceType.tile);

            if (templateType != null)
            {
                resourceUrl = new ResourceUrl()
                {
                    Template     = templateType.template,
                    Format       = templateType.format,
                    ResourceType = templateType.resourceType
                };
            }
            return(resourceUrl);
        }
コード例 #5
0
        public static LayerType AddToCapabilities(this Dataset dataset, string name, Capabilities capabilities)
        {
            string projectionStr = dataset.GetProjection();

            dataset.GetExtent(out double xMin, out double yMin, out double xMax, out double yMax);
            int minLevel = 0;
            int maxLevel = 19;

            dataset.GetSuitableZoom(ref minLevel, ref maxLevel);
            LayerType layerType     = CapabilitiesHelper.AddToCapabilities(capabilities, name, projectionStr, xMin, yMin, xMax, yMax, minLevel, maxLevel);
            string    href          = capabilities.GetHref(WmtsOperationType.GetTile, WmtsRequestType.REST);
            string    tileMatrixSet = null;

            using (var spatialReference = dataset.GetSpatialReference())
            {
                tileMatrixSet = spatialReference.GetAttrValue("GEOGCS", 0);
            }
            URLTemplateType tileTemplate = CapabilitiesHelper.CreateTileResourceURL(href, name, tileMatrixSet);

            layerType.ResourceURL = new URLTemplateType[] { tileTemplate };
            return(layerType);
        }