Index: Core/Components/src/Core.Components.BruTile/Configurations/ITileSourceFactory.cs =================================================================== diff -u -r99f9004206bfb9de084275d749b7aeccafd6da18 -rfcf14f1da32f6de8d99c7f446ec27fbe30a6abe8 --- Core/Components/src/Core.Components.BruTile/Configurations/ITileSourceFactory.cs (.../ITileSourceFactory.cs) (revision 99f9004206bfb9de084275d749b7aeccafd6da18) +++ Core/Components/src/Core.Components.BruTile/Configurations/ITileSourceFactory.cs (.../ITileSourceFactory.cs) (revision fcf14f1da32f6de8d99c7f446ec27fbe30a6abe8) @@ -19,8 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using BruTile; +using BruTile.Predefined; using BruTile.Wmts; using Core.Components.Gis.Exceptions; @@ -41,5 +43,13 @@ /// Thrown when unable to retrieve /// tile sources from the given service. IEnumerable GetWmtsTileSources(string capabilitiesUrl); + + /// + /// Returns the tile source for . + /// + /// The known tile services to get the tile source for. + /// The tile source for . + /// Thrown when is not supported. + ITileSource GetKnownTileSources(KnownTileSource knownTileSource); } } \ No newline at end of file Index: Core/Components/src/Core.Components.BruTile/Configurations/TileSourceFactory.cs =================================================================== diff -u -r99f9004206bfb9de084275d749b7aeccafd6da18 -rfcf14f1da32f6de8d99c7f446ec27fbe30a6abe8 --- Core/Components/src/Core.Components.BruTile/Configurations/TileSourceFactory.cs (.../TileSourceFactory.cs) (revision 99f9004206bfb9de084275d749b7aeccafd6da18) +++ Core/Components/src/Core.Components.BruTile/Configurations/TileSourceFactory.cs (.../TileSourceFactory.cs) (revision fcf14f1da32f6de8d99c7f446ec27fbe30a6abe8) @@ -25,6 +25,7 @@ using System.Linq; using System.Net; using BruTile; +using BruTile.Predefined; using BruTile.Wmts; using Core.Components.BruTile.Properties; using Core.Components.Gis.Exceptions; @@ -57,13 +58,18 @@ public IEnumerable GetWmtsTileSources(string capabilitiesUrl) { ITileSource[] wmtsTileSources = ParseWmtsTileSources(capabilitiesUrl).ToArray(); - if(wmtsTileSources.Any(ts => !(ts.Schema is WmtsTileSchema))) + if (wmtsTileSources.Any(ts => !(ts.Schema is WmtsTileSchema))) { throw new CannotFindTileSourceException(Resources.TileSourceFactory_GetWmtsTileSources_TileSource_without_WmtsTileSchema_error); } return wmtsTileSources; } + public ITileSource GetKnownTileSources(KnownTileSource knownTileSource) + { + return KnownTileSources.Create(knownTileSource); + } + /// /// Parses the capabilities XML provided by the WMTS. /// Index: Core/Components/test/Core.Components.BruTile.TestUtil.Test/TestTileSourceFactoryTest.cs =================================================================== diff -u -r99f9004206bfb9de084275d749b7aeccafd6da18 -rfcf14f1da32f6de8d99c7f446ec27fbe30a6abe8 --- Core/Components/test/Core.Components.BruTile.TestUtil.Test/TestTileSourceFactoryTest.cs (.../TestTileSourceFactoryTest.cs) (revision 99f9004206bfb9de084275d749b7aeccafd6da18) +++ Core/Components/test/Core.Components.BruTile.TestUtil.Test/TestTileSourceFactoryTest.cs (.../TestTileSourceFactoryTest.cs) (revision fcf14f1da32f6de8d99c7f446ec27fbe30a6abe8) @@ -19,9 +19,12 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Linq; using BruTile; +using BruTile.Predefined; +using Core.Common.TestUtil; using Core.Components.BruTile.Configurations; using Core.Components.Gis.Data; using NUnit.Framework; @@ -82,5 +85,36 @@ Assert.IsInstanceOf(tileSource); Assert.AreEqual(mapData.PreferredFormat, tileSource.Schema.Format); } + + [Test] + public void Constructor_ForWellKnownTileSourceMapData_ExpectedValues() + { + // Setup + var mapData = new WellKnownTileSourceMapData(new Random(341).NextEnumValue()); + + // Call + var factory = new TestTileSourceFactory(mapData); + + // Assert + Assert.IsInstanceOf(factory); + } + + [Test] + public void GetWellKnownTileSources_FromConfiguredWellKnownTileSourceMapData_ReturnTileSource() + { + // Setup + var mapData = new WellKnownTileSourceMapData(new Random(341).NextEnumValue()); + + // Precondition + Assert.IsTrue(mapData.IsConfigured); + + var factory = new TestTileSourceFactory(mapData); + + // Call + ITileSource tileSource = factory.GetKnownTileSources(new Random(341).NextEnumValue()); + + // Assert + Assert.IsInstanceOf(tileSource); + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.BruTile.TestUtil.Test/UseCustomTileSourceFactoryConfigTest.cs =================================================================== diff -u -r99f9004206bfb9de084275d749b7aeccafd6da18 -rfcf14f1da32f6de8d99c7f446ec27fbe30a6abe8 --- Core/Components/test/Core.Components.BruTile.TestUtil.Test/UseCustomTileSourceFactoryConfigTest.cs (.../UseCustomTileSourceFactoryConfigTest.cs) (revision 99f9004206bfb9de084275d749b7aeccafd6da18) +++ Core/Components/test/Core.Components.BruTile.TestUtil.Test/UseCustomTileSourceFactoryConfigTest.cs (.../UseCustomTileSourceFactoryConfigTest.cs) (revision fcf14f1da32f6de8d99c7f446ec27fbe30a6abe8) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.TestUtil; using Core.Components.BruTile.Configurations; using Core.Components.Gis.Data; using NUnit.Framework; @@ -50,7 +52,7 @@ } [Test] - public void GivenTileSourceFactoryInstance_WhenConfigForMapData_ThenSingletonInstanceTemporarilyChanged() + public void GivenTileSourceFactoryInstance_WhenConfigForWmtsMapData_ThenSingletonInstanceTemporarilyChanged() { // Given ITileSourceFactory originalFactory = TileSourceFactory.Instance; @@ -65,5 +67,22 @@ } Assert.AreSame(originalFactory, TileSourceFactory.Instance); } + + [Test] + public void GivenTileSourceFactoryInstance_WhenConfigForWellKnownTileSourceMapData_ThenSingletonInstanceTemporarilyChanged() + { + // Given + ITileSourceFactory originalFactory = TileSourceFactory.Instance; + + var mapData = new WellKnownTileSourceMapData(new Random(341).NextEnumValue()); + + // When + using (new UseCustomTileSourceFactoryConfig(mapData)) + { + // Then + Assert.IsInstanceOf(TileSourceFactory.Instance); + } + Assert.AreSame(originalFactory, TileSourceFactory.Instance); + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.BruTile.TestUtil/TestTileSourceFactory.cs =================================================================== diff -u -r99f9004206bfb9de084275d749b7aeccafd6da18 -rfcf14f1da32f6de8d99c7f446ec27fbe30a6abe8 --- Core/Components/test/Core.Components.BruTile.TestUtil/TestTileSourceFactory.cs (.../TestTileSourceFactory.cs) (revision 99f9004206bfb9de084275d749b7aeccafd6da18) +++ Core/Components/test/Core.Components.BruTile.TestUtil/TestTileSourceFactory.cs (.../TestTileSourceFactory.cs) (revision fcf14f1da32f6de8d99c7f446ec27fbe30a6abe8) @@ -21,6 +21,7 @@ using System.Collections.Generic; using BruTile; +using BruTile.Predefined; using Core.Components.BruTile.Configurations; using Core.Components.Gis.Data; @@ -32,6 +33,7 @@ public class TestTileSourceFactory : ITileSourceFactory { private readonly TestWmtsTileSource wmtsTileSource; + private readonly TestWellKnownTileSource wellKnownTileSource; /// /// Initializes a new instance of for a given @@ -48,12 +50,27 @@ } } + /// + /// Initializes a new instance of for a given + /// . + /// + /// The map data to work for. + public TestTileSourceFactory(WellKnownTileSourceMapData backgroundMapData) + { + wellKnownTileSource = new TestWellKnownTileSource(backgroundMapData); + } + public IEnumerable GetWmtsTileSources(string capabilitiesUrl) { if (wmtsTileSource != null) { yield return wmtsTileSource; } } + + public ITileSource GetKnownTileSources(KnownTileSource knownTileSource) + { + return wellKnownTileSource; + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.BruTile.TestUtil/UseCustomTileSourceFactoryConfig.cs =================================================================== diff -u -r99f9004206bfb9de084275d749b7aeccafd6da18 -rfcf14f1da32f6de8d99c7f446ec27fbe30a6abe8 --- Core/Components/test/Core.Components.BruTile.TestUtil/UseCustomTileSourceFactoryConfig.cs (.../UseCustomTileSourceFactoryConfig.cs) (revision 99f9004206bfb9de084275d749b7aeccafd6da18) +++ Core/Components/test/Core.Components.BruTile.TestUtil/UseCustomTileSourceFactoryConfig.cs (.../UseCustomTileSourceFactoryConfig.cs) (revision fcf14f1da32f6de8d99c7f446ec27fbe30a6abe8) @@ -48,10 +48,17 @@ /// initializes test stubs to work for a instance. /// /// The map data to work with. - public UseCustomTileSourceFactoryConfig(WmtsMapData backgroundMapData) : this(new TestTileSourceFactory(backgroundMapData)) - { - } + public UseCustomTileSourceFactoryConfig(WmtsMapData backgroundMapData) + : this(new TestTileSourceFactory(backgroundMapData)) {} + /// + /// Creates a new instance of that + /// initializes test stubs to work for a instance. + /// + /// The map data to work with. + public UseCustomTileSourceFactoryConfig(WellKnownTileSourceMapData backgroundMapData) + : this(new TestTileSourceFactory(backgroundMapData)) {} + public void Dispose() { TileSourceFactory.Instance = originalFactory;