Index: Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj
===================================================================
diff -u -r8a885188327983ccc75c5ae70c6abf91fb6cdac1 -r0c12771ae0e121220a94b6f50c1bc1c4ac7a844c
--- Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj (.../Core.Components.DotSpatial.Forms.csproj) (revision 8a885188327983ccc75c5ae70c6abf91fb6cdac1)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj (.../Core.Components.DotSpatial.Forms.csproj) (revision 0c12771ae0e121220a94b6f50c1bc1c4ac7a844c)
@@ -90,6 +90,7 @@
True
Resources.resx
+
Index: Core/Components/src/Core.Components.DotSpatial.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -rcfb8cddfe064c4aa4a1843846968554c918ba58f -r0c12771ae0e121220a94b6f50c1bc1c4ac7a844c
--- Core/Components/src/Core.Components.DotSpatial.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision cfb8cddfe064c4aa4a1843846968554c918ba58f)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0c12771ae0e121220a94b6f50c1bc1c4ac7a844c)
@@ -181,5 +181,14 @@
return ResourceManager.GetString("WmtsConnectionInfoReader_Unable_To_Create_WmtsConnectionInfo", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Web Map Tile Service (WMTS).
+ ///
+ internal static string WmtsLocationControl_DisplayName {
+ get {
+ return ResourceManager.GetString("WmtsLocationControl_DisplayName", resourceCulture);
+ }
+ }
}
}
Index: Core/Components/src/Core.Components.DotSpatial.Forms/Properties/Resources.resx
===================================================================
diff -u -rcfb8cddfe064c4aa4a1843846968554c918ba58f -r0c12771ae0e121220a94b6f50c1bc1c4ac7a844c
--- Core/Components/src/Core.Components.DotSpatial.Forms/Properties/Resources.resx (.../Resources.resx) (revision cfb8cddfe064c4aa4a1843846968554c918ba58f)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/Properties/Resources.resx (.../Resources.resx) (revision 0c12771ae0e121220a94b6f50c1bc1c4ac7a844c)
@@ -151,4 +151,7 @@
..\resources\mapsicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ Web Map Tile Service (WMTS)
+
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial.Forms/Views/IHasMapData.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.DotSpatial.Forms/Views/IHasMapData.cs (revision 0)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/Views/IHasMapData.cs (revision 0c12771ae0e121220a94b6f50c1bc1c4ac7a844c)
@@ -0,0 +1,41 @@
+// 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 Core.Components.Gis.Data;
+
+namespace Core.Components.DotSpatial.Forms.Views
+{
+ ///
+ /// Interface for a user control that has a MapData.
+ ///
+ public interface IHasMapData
+ {
+ ///
+ /// Gets the display name of the user control;
+ ///
+ string DisplayName { get; }
+
+ ///
+ /// Gets the selected or null if none selected.
+ ///
+ MapData GetSelectedMapData();
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsCapabilityRow.cs
===================================================================
diff -u -rcfb8cddfe064c4aa4a1843846968554c918ba58f -r0c12771ae0e121220a94b6f50c1bc1c4ac7a844c
--- Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsCapabilityRow.cs (.../WmtsCapabilityRow.cs) (revision cfb8cddfe064c4aa4a1843846968554c918ba58f)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsCapabilityRow.cs (.../WmtsCapabilityRow.cs) (revision 0c12771ae0e121220a94b6f50c1bc1c4ac7a844c)
@@ -28,8 +28,6 @@
///
public class WmtsCapabilityRow
{
- private readonly WmtsCapability wmtsCapability;
-
///
/// Creates new instance of .
///
@@ -42,7 +40,7 @@
{
throw new ArgumentNullException(nameof(wmtsCapability));
}
- this.wmtsCapability = wmtsCapability;
+ WmtsCapability = wmtsCapability;
}
///
@@ -52,7 +50,7 @@
{
get
{
- return wmtsCapability.Id;
+ return WmtsCapability.Id;
}
}
@@ -63,7 +61,7 @@
{
get
{
- return wmtsCapability.Format;
+ return WmtsCapability.Format;
}
}
@@ -74,7 +72,7 @@
{
get
{
- return wmtsCapability.Title;
+ return WmtsCapability.Title;
}
}
@@ -85,8 +83,13 @@
{
get
{
- return wmtsCapability.CoordinateSystem;
+ return WmtsCapability.CoordinateSystem;
}
}
+
+ ///
+ /// Gets the this row contains.
+ ///
+ public WmtsCapability WmtsCapability { get; }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs
===================================================================
diff -u -r25b9b0e94d71419d3a2f2f92c810f81e1b90a628 -r0c12771ae0e121220a94b6f50c1bc1c4ac7a844c
--- Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 25b9b0e94d71419d3a2f2f92c810f81e1b90a628)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 0c12771ae0e121220a94b6f50c1bc1c4ac7a844c)
@@ -23,10 +23,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
-using Core.Common.Controls.Views;
using Core.Components.DotSpatial.Forms.IO;
using Core.Components.DotSpatial.Forms.Properties;
using Core.Components.DotSpatial.Layer.BruTile.Configurations;
+using Core.Components.Gis.Data;
using log4net;
using BaseResources = Core.Common.Base.Properties.Resources;
@@ -35,11 +35,11 @@
///
/// This class represents a where WMTS locations can be administrated.
///
- public partial class WmtsLocationControl : UserControl, IView
+ public partial class WmtsLocationControl : UserControl, IHasMapData
{
private static readonly ILog log = LogManager.GetLogger(typeof(WmtsLocationControl));
private readonly List wmtsConnectionInfos;
- private List capabilities;
+ private readonly List capabilities;
///
/// Creates a new instance of .
@@ -55,17 +55,29 @@
InitializeEventHandlers();
}
- public object Data
+ public string DisplayName
{
get
{
- return capabilities;
+ return Resources.WmtsLocationControl_DisplayName;
}
- set
+ }
+
+ public MapData GetSelectedMapData()
+ {
+ WmtsCapabilityRow currentRow = GetSelectedWmtsCapabilityRow();
+ if (currentRow == null)
{
- capabilities = value as List;
- UpdateDataGridViewDataSource();
+ return null;
}
+
+ WmtsConnectionInfo selectedWmtsConnectionInfo = GetSelectedWmtsConnectionInfo();
+ if (selectedWmtsConnectionInfo == null)
+ {
+ return null;
+ }
+
+ return currentRow.WmtsCapability.ToWmtsMapdata(selectedWmtsConnectionInfo.Name, selectedWmtsConnectionInfo.Url);
}
protected override void Dispose(bool disposing)
@@ -122,6 +134,11 @@
dataGridViewControl.SetDataSource(capabilities);
}
+ private WmtsCapabilityRow GetSelectedWmtsCapabilityRow()
+ {
+ return dataGridViewControl.CurrentRow?.DataBoundItem as WmtsCapabilityRow;
+ }
+
#endregion
#region ComboBox
@@ -146,6 +163,11 @@
UpdateConnectToButton();
}
+ private WmtsConnectionInfo GetSelectedWmtsConnectionInfo()
+ {
+ return urlLocationComboBox.SelectedItem as WmtsConnectionInfo;
+ }
+
#endregion
#region Event handlers
Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsCapabilityRowTest.cs
===================================================================
diff -u -rcfb8cddfe064c4aa4a1843846968554c918ba58f -r0c12771ae0e121220a94b6f50c1bc1c4ac7a844c
--- Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsCapabilityRowTest.cs (.../WmtsCapabilityRowTest.cs) (revision cfb8cddfe064c4aa4a1843846968554c918ba58f)
+++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsCapabilityRowTest.cs (.../WmtsCapabilityRowTest.cs) (revision 0c12771ae0e121220a94b6f50c1bc1c4ac7a844c)
@@ -57,6 +57,7 @@
Assert.AreEqual(format, row.Format);
Assert.AreEqual(title, row.Title);
Assert.AreEqual(coordinateSystem, row.CoordinateSystem);
+ Assert.AreSame(wmtsCapability, row.WmtsCapability);
}
}
}
\ No newline at end of file
Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs
===================================================================
diff -u -r25b9b0e94d71419d3a2f2f92c810f81e1b90a628 -r0c12771ae0e121220a94b6f50c1bc1c4ac7a844c
--- Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 25b9b0e94d71419d3a2f2f92c810f81e1b90a628)
+++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 0c12771ae0e121220a94b6f50c1bc1c4ac7a844c)
@@ -24,7 +24,6 @@
using System.Linq;
using System.Windows.Forms;
using Core.Common.Controls.DataGrid;
-using Core.Common.Controls.Views;
using Core.Common.TestUtil;
using Core.Components.DotSpatial.Forms.Views;
using Core.Components.DotSpatial.Layer.BruTile.Configurations;
@@ -52,8 +51,9 @@
{
// Assert
Assert.IsInstanceOf(control);
- Assert.IsInstanceOf(control);
- Assert.IsInstanceOf>(control.Data);
+ Assert.IsInstanceOf(control);
+ Assert.AreEqual("Web Map Tile Service (WMTS)", control.DisplayName);
+ Assert.IsNull(control.GetSelectedMapData());
}
}
@@ -145,61 +145,85 @@
}
[Test]
- public void Data_WmtsCapabilityRow_DataSet()
+ public void WmtsLocationControl_WithData_DataGridViewCorrectlyInitialized()
{
- // Setup
- using (var view = new WmtsLocationControl())
+ // Setup & Call
+ using (WmtsLocationControl control = ShowFullyConfiguredWmtsLocationControl())
{
- var capabilityRows = new List();
+ Form form = control.FindForm();
- // Call
- view.Data = capabilityRows;
-
// Assert
- Assert.AreSame(capabilityRows, view.Data);
+ var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject;
+ DataGridViewRowCollection rows = dataGridViewControl.Rows;
+ Assert.AreEqual(2, rows.Count);
+
+ DataGridViewCellCollection cells = rows[0].Cells;
+ Assert.AreEqual(4, cells.Count);
+ Assert.AreEqual("-", cells[mapLayerIdColumnIndex].FormattedValue);
+ Assert.AreEqual("image/png", cells[mapLayerFormatColumnIndex].FormattedValue);
+ Assert.AreEqual("-", cells[mapLayerTitleColumnIndex].FormattedValue);
+ Assert.AreEqual("-", cells[mapLayerCoordinateSystemColumnIndex].FormattedValue);
+
+ cells = rows[1].Cells;
+ Assert.AreEqual(4, cells.Count);
+ Assert.AreEqual("brtachtergrondkaart(EPSG:28992)", cells[mapLayerIdColumnIndex].FormattedValue);
+ Assert.AreEqual("image/png8", cells[mapLayerFormatColumnIndex].FormattedValue);
+ Assert.AreEqual("brtachtergrondkaart", cells[mapLayerTitleColumnIndex].FormattedValue);
+ Assert.AreEqual("EPSG:28992", cells[mapLayerCoordinateSystemColumnIndex].FormattedValue);
}
}
[Test]
- public void Data_OtherThanWmtsCapabilityRow_DataNull()
+ public void GetSelectedMapData_WithoutSelectedData_ReturnsNull()
{
// Setup
- using (var view = new WmtsLocationControl())
+ using (var form = new Form())
+ using (var control = new WmtsLocationControl())
{
- var data = new object();
+ form.Controls.Add(control);
+ form.Show();
// Call
- view.Data = data;
+ MapData selectedMapData = control.GetSelectedMapData();
// Assert
- Assert.IsNull(view.Data);
+ Assert.IsNull(selectedMapData);
}
}
[Test]
- public void WmtsLocationControl_WithData_DataGridViewCorrectlyInitialized()
+ public void GetSelectedMapData_WithSelectedComboBoxWithoutSelectedRow_ReturnsNull()
{
// Setup & Call
- using (Form form = ShowFullyConfiguredWmtsLocationControl())
+ using (WmtsLocationControl control = ShowFullyConfiguredWmtsLocationControl())
{
- // Assert
+ // Assert
+ MapData selectedMapData = control.GetSelectedMapData();
+ Assert.IsNull(selectedMapData);
+ }
+ }
+
+ [Test]
+ public void GetSelectedMapData_WithSelectedData_ReturnsSelectedMapData()
+ {
+ // Setup
+ using (WmtsLocationControl control = ShowFullyConfiguredWmtsLocationControl())
+ {
+ Form form = control.FindForm();
var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject;
- var rows = dataGridViewControl.Rows;
- Assert.AreEqual(2, rows.Count);
+ var dataGridView = dataGridViewControl.Controls.OfType().First();
+ dataGridView.CurrentCell = dataGridView.Rows[1].Cells[0];
- var cells = rows[0].Cells;
- Assert.AreEqual(4, cells.Count);
- Assert.AreEqual("-", cells[mapLayerIdColumnIndex].FormattedValue);
- Assert.AreEqual("image/png", cells[mapLayerFormatColumnIndex].FormattedValue);
- Assert.AreEqual("-", cells[mapLayerTitleColumnIndex].FormattedValue);
- Assert.AreEqual("-", cells[mapLayerCoordinateSystemColumnIndex].FormattedValue);
+ // Call
+ WmtsMapData selectedMapData = control.GetSelectedMapData() as WmtsMapData;
- cells = rows[1].Cells;
- Assert.AreEqual(4, cells.Count);
- Assert.AreEqual("brtachtergrondkaart(EPSG:28992)", cells[mapLayerIdColumnIndex].FormattedValue);
- Assert.AreEqual("image/png8", cells[mapLayerFormatColumnIndex].FormattedValue);
- Assert.AreEqual("brtachtergrondkaart", cells[mapLayerTitleColumnIndex].FormattedValue);
- Assert.AreEqual("EPSG:28992", cells[mapLayerCoordinateSystemColumnIndex].FormattedValue);
+ // Assert
+ Assert.IsNotNull(selectedMapData);
+ Assert.AreEqual("PDOK achtergrondkaart", selectedMapData.Name);
+ Assert.AreEqual("brtachtergrondkaart(EPSG:28992)", selectedMapData.SelectedCapabilityIdentifier);
+ Assert.AreEqual("https://geodata.nationaalgeoregister.nl/wmts/top10nlv2?VERSION=1.0.0&request=GetCapabilities",
+ selectedMapData.SourceCapabilitiesUrl);
+ Assert.AreEqual("image/png8", selectedMapData.PreferredFormat);
}
}
@@ -365,9 +389,10 @@
WmtsMapData backgroundMapData = WmtsMapData.CreateDefaultPdokMapData();
using (new UseCustomTileSourceFactoryConfig(backgroundMapData))
- using (Form form = ShowValidWmtsLocationControl())
+ using (WmtsLocationControl control = ShowValidWmtsLocationControl())
{
- form.Show();
+ Form form = control.FindForm();
+ form?.Show();
var connectToButton = new ButtonTester("connectToButton", form);
@@ -376,10 +401,10 @@
// Then
var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject;
- var rows = dataGridViewControl.Rows;
+ DataGridViewRowCollection rows = dataGridViewControl.Rows;
Assert.AreEqual(1, rows.Count);
- var cells = rows[0].Cells;
+ DataGridViewCellCollection cells = rows[0].Cells;
Assert.AreEqual(4, cells.Count);
Assert.AreEqual("brtachtergrondkaart(EPSG:28992)", cells[mapLayerIdColumnIndex].FormattedValue);
Assert.AreEqual("image/png", cells[mapLayerFormatColumnIndex].FormattedValue);
@@ -410,9 +435,10 @@
};
using (new UseCustomTileSourceFactoryConfig(tileFactory))
- using (Form form = ShowValidWmtsLocationControl())
+ using (WmtsLocationControl control = ShowValidWmtsLocationControl())
{
- form.Show();
+ Form form = control.FindForm();
+ form?.Show();
var connectToButton = new ButtonTester("connectToButton", form);
@@ -443,24 +469,24 @@
Assert.DoesNotThrow(call);
}
- private static Form ShowFullyConfiguredWmtsLocationControl()
+ private static WmtsLocationControl ShowFullyConfiguredWmtsLocationControl()
{
- var form = new Form();
- var control = new WmtsLocationControl();
+ var control = ShowValidWmtsLocationControl();
+ Form form = control.FindForm();
var capabilities = new List
{
new WmtsCapabilityRow(new WmtsCapability("-", "image/png", "-", "-")),
new WmtsCapabilityRow(new WmtsCapability("brtachtergrondkaart(EPSG:28992)", "image/png8", "brtachtergrondkaart", "EPSG:28992"))
};
- control.Data = capabilities;
+ var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject;
+ dataGridViewControl.SetDataSource(capabilities);
- form.Controls.Add(control);
- return form;
+ return control;
}
- private static Form ShowValidWmtsLocationControl()
+ private static WmtsLocationControl ShowValidWmtsLocationControl()
{
var form = new Form();
var control = new WmtsLocationControl();
@@ -474,7 +500,7 @@
var connectToButton = (Button) new ButtonTester("connectToButton", form).TheObject;
connectToButton.Enabled = true;
- return form;
+ return control;
}
}
}
\ No newline at end of file