Index: Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj =================================================================== diff -u -rcfb8cddfe064c4aa4a1843846968554c918ba58f -r8a885188327983ccc75c5ae70c6abf91fb6cdac1 --- Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj (.../Core.Components.DotSpatial.Forms.csproj) (revision cfb8cddfe064c4aa4a1843846968554c918ba58f) +++ Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj (.../Core.Components.DotSpatial.Forms.csproj) (revision 8a885188327983ccc75c5ae70c6abf91fb6cdac1) @@ -80,6 +80,7 @@ UserControl + Component Index: Core/Components/src/Core.Components.DotSpatial.Forms/IO/WmtsCapabilityFactory.cs =================================================================== diff -u --- Core/Components/src/Core.Components.DotSpatial.Forms/IO/WmtsCapabilityFactory.cs (revision 0) +++ Core/Components/src/Core.Components.DotSpatial.Forms/IO/WmtsCapabilityFactory.cs (revision 8a885188327983ccc75c5ae70c6abf91fb6cdac1) @@ -0,0 +1,54 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using BruTile; +using BruTile.Wmts; +using Core.Components.DotSpatial.Layer.BruTile.Configurations; + +namespace Core.Components.DotSpatial.Forms.IO +{ + /// + /// Class responsible for creating instances for a given + /// source. + /// + public static class WmtsCapabilityFactory + { + /// + /// Returns all based on the capabilities of a Web Map Tile Service. + /// + /// The URL to the 'GetCapabilities' part of the service. + /// The WMTS capabilities. + /// Thrown when unable to retrieve + /// tile sources from the given service. + public static IEnumerable GetWmtsCapabilities(string capabilitiesUrl) + { + IEnumerable tileSources = TileSourceFactory.Instance.GetWmtsTileSources(capabilitiesUrl); + + foreach (var tileSource in tileSources) + { + var wmtsTileSchema = (WmtsTileSchema) tileSource.Schema; + yield return new WmtsCapability(wmtsTileSchema.Identifier, wmtsTileSchema.Format, + tileSource.Name, wmtsTileSchema.Srs); + } + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj =================================================================== diff -u -r825240f8a4a6b63e3845195ff3366e4c58628c1b -r8a885188327983ccc75c5ae70c6abf91fb6cdac1 --- Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj (.../Core.Components.DotSpatial.csproj) (revision 825240f8a4a6b63e3845195ff3366e4c58628c1b) +++ Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj (.../Core.Components.DotSpatial.csproj) (revision 8a885188327983ccc75c5ae70c6abf91fb6cdac1) @@ -153,6 +153,7 @@ ResXFileCodeGenerator Resources.Designer.cs + Designer Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/Core.Components.DotSpatial.Forms.Test.csproj =================================================================== diff -u -rcfb8cddfe064c4aa4a1843846968554c918ba58f -r8a885188327983ccc75c5ae70c6abf91fb6cdac1 --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/Core.Components.DotSpatial.Forms.Test.csproj (.../Core.Components.DotSpatial.Forms.Test.csproj) (revision cfb8cddfe064c4aa4a1843846968554c918ba58f) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/Core.Components.DotSpatial.Forms.Test.csproj (.../Core.Components.DotSpatial.Forms.Test.csproj) (revision 8a885188327983ccc75c5ae70c6abf91fb6cdac1) @@ -83,6 +83,7 @@ + Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/IO/WmtsCapabilityFactoryTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/IO/WmtsCapabilityFactoryTest.cs (revision 0) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/IO/WmtsCapabilityFactoryTest.cs (revision 8a885188327983ccc75c5ae70c6abf91fb6cdac1) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Components.DotSpatial.Forms.IO; +using Core.Components.DotSpatial.Layer.BruTile.Configurations; +using Core.Components.DotSpatial.TestUtil; +using Core.Components.Gis.Data; +using NUnit.Framework; + +namespace Core.Components.DotSpatial.Forms.Test.IO +{ + [TestFixture] + public class WmtsCapabilityFactoryTest + { + [Test] + [TestCase("")] + [TestCase(null)] + public void GetWmtsCapabilities_CapabilitiesUrlInvalid_ThrowsCannotFindTileSourceException(string url) + { + // Call + TestDelegate call = () => WmtsCapabilityFactory.GetWmtsCapabilities(url).ToArray(); + + // Assert + CannotFindTileSourceException exception = Assert.Throws(call); + Assert.AreEqual($"Niet in staat om de databronnen op te halen bij de WMTS url '{url}'.", exception.Message); + } + + [Test] + public void GetWmtsCapabilities_ValidUrl_ReturnsWmtsCapabilities() + { + // Setup + string url = "validUrl"; + WmtsMapData backgroundMapData = WmtsMapData.CreateDefaultPdokMapData(); + + using (new UseCustomTileSourceFactoryConfig(backgroundMapData)) + { + // Call + WmtsCapability[] capabilities = WmtsCapabilityFactory.GetWmtsCapabilities(url).ToArray(); + + // Assert + Assert.AreEqual(1, capabilities.Length); + WmtsCapability capability = capabilities[0]; + Assert.AreEqual("brtachtergrondkaart(EPSG:28992)", capability.Id); + Assert.AreEqual("Stub schema", capability.Title); + Assert.AreEqual("image/png", capability.Format); + Assert.AreEqual("EPSG:28992", capability.CoordinateSystem); + } + } + } +} \ No newline at end of file