Beispiel #1
0
 public static TileMatrixSetLink[] GetTileMatrixSetLinks(string projectName)
 {
     TileMatrixSetLink[] tileMatrixSetLinks = new TileMatrixSetLink[]
     {
         new TileMatrixSetLink()
         {
             TileMatrixSet = projectName
         }
     };
     return(tileMatrixSetLinks);
 }
Beispiel #2
0
        public virtual void RemoveContent(Capabilities capabilities, string contentIdentifier)
        {
            //remove content
            DatasetDescriptionSummaryBaseType[] srcContents = capabilities?.Contents?.DatasetDescriptionSummary;
            if (srcContents == null || string.IsNullOrWhiteSpace(contentIdentifier))
            {
                return;
            }
            LayerType content = null;

            for (int i = 0; i < srcContents.Length; i++)
            {
                if (srcContents[i].Identifier.Value == contentIdentifier)
                {
                    content = srcContents[i] as LayerType;
                    break;
                }
            }
            if (content == null)
            {
                return;
            }
            DatasetDescriptionSummaryBaseType[] destContents = srcContents.Remove(content);
            capabilities.Contents.DatasetDescriptionSummary = destContents;
            if (content.TileMatrixSetLink == null || content.TileMatrixSetLink.Length == 0)
            {
                return;
            }
            //remove tileMatrixSet
            TileMatrixSetLink tileMatrixSetLink = content.TileMatrixSetLink[0];
            string            tileMatrixSetName = tileMatrixSetLink.TileMatrixSet;

            TileMatrixSet[] tileMatrixSets = capabilities.Contents.TileMatrixSet;
            TileMatrixSet   tileMatrixSet  = null;

            for (int i = 0; i < tileMatrixSets.Length; i++)
            {
                if (tileMatrixSets[i].Identifier.Value == tileMatrixSetName)
                {
                    tileMatrixSet = tileMatrixSets[i];
                    break;
                }
            }
            if (tileMatrixSet == null)
            {
                return;
            }
            bool isReferenced = false;

            for (int i = 0; i < destContents.Length; i++)
            {
                if (destContents[i] is LayerType layerType)
                {
                    if (layerType.TileMatrixSetLink == null || layerType.TileMatrixSetLink.Length == 0)
                    {
                        continue;
                    }
                    if (layerType.TileMatrixSetLink[0].TileMatrixSet == tileMatrixSetName)
                    {
                        isReferenced = true;
                        break;
                    }
                }
            }
            if (!isReferenced)
            {
                capabilities.Contents.TileMatrixSet = capabilities.Contents.TileMatrixSet.Remove(tileMatrixSet);
            }
        }
Beispiel #3
0
        public static LayerType GetLayerType(IDataSet dataSet)
        {
            LayerType layerType = null;

            if (dataSet == null)
            {
                return(layerType);
            }
            LanguageStringType[] titles = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = dataSet.Name
                }
            };
            LanguageStringType[] abstracts = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = dataSet.Name
                }
            };
            var extent = dataSet.Extent;

            BoundingBoxType[]      boundingBoxs       = null;
            WGS84BoundingBoxType[] WGS84BoundingBoxes = null;
            ProjectionInfo         wgs84PrjInfo       = KnownCoordinateSystems.Geographic.World.WGS1984;

            if (dataSet.Projection.Equals(wgs84PrjInfo))//wgs84
            {
                WGS84BoundingBoxes = new WGS84BoundingBoxType[]
                {
                    new WGS84BoundingBoxType()
                    {
                        LowerCorner = $"{extent.MinX} {extent.MinY}",
                        UpperCorner = $"{extent.MaxX} {extent.MaxY}"
                    }
                };
            }
            else
            {
                boundingBoxs = new BoundingBoxType[]
                {
                    new BoundingBoxType()
                    {
                        LowerCorner = $"{extent.MinX} {extent.MinY}",
                        UpperCorner = $"{extent.MaxX} {extent.MaxY}"
                    }
                };
                using (IDataSet tmpDs = DataManager.DefaultDataManager.OpenFile(dataSet.Filename))
                {
                    tmpDs.Reproject(wgs84PrjInfo);
                    WGS84BoundingBoxes = new WGS84BoundingBoxType[]
                    {
                        new WGS84BoundingBoxType()
                        {
                            LowerCorner = $"{tmpDs.Extent.MinX} {tmpDs.Extent.MinY}",
                            UpperCorner = $"{tmpDs.Extent.MaxX} {tmpDs.Extent.MaxY}"
                        }
                    };
                }
            }
            CodeType identifier = new CodeType()
            {
                Value = dataSet.Name
            };
            Style style = new Style()
            {
                isDefault  = true,
                Identifier = new CodeType()
                {
                    Value = "default"
                }
            };

            Style[] styles = new Style[]
            {
                style
            };
            string[] formats = new string[]
            {
                "image/png", "image/jpg"
            };
            TileMatrixSetLink[] tileMatrixSetLinks = new TileMatrixSetLink[]
            {
                new TileMatrixSetLink()
                {
                    TileMatrixSet = dataSet.Projection.Name
                }
            };
            layerType = new LayerType()
            {
                Title             = titles,
                Abstract          = abstracts,
                BoundingBox       = boundingBoxs,
                WGS84BoundingBox  = WGS84BoundingBoxes,
                Identifier        = identifier,
                Style             = styles,
                Format            = formats,
                TileMatrixSetLink = tileMatrixSetLinks
            };
            return(layerType);
        }