Index: Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseApache2.txt
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseApache2.txt (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseApache2.txt (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -0,0 +1,53 @@
+Apache License
+
+Version 2.0, January 2004
+
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+You must give any other recipients of the Work or Derivative Works a copy of this License; and
+You must cause any modified files to carry prominent notices stating that You changed the files; and
+You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseBruTile.txt
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseBruTile.txt (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseBruTile.txt (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -0,0 +1,15 @@
+Copyright (c) BruTile developers team. All rights reserved.
+
+For the list of contributors see: http://brutile.codeplex.com/team/view
+
+Licensed under the Apache License, Version 2.0 (the "License"); you
+may not use this file except in compliance with the License. You may
+obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied. See the License for the specific language governing permissions
+and limitations under the License.
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseDotSpatialPlugins.txt
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseDotSpatialPlugins.txt (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseDotSpatialPlugins.txt (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -0,0 +1,2 @@
+Ringtoets uses code based on DotSpatial.Plugins, whose source code can be found at: https://github.com/FObermaier/DotSpatial.Plugins
+The original work has been released under Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html)
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseSmartThreadPool.txt
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseSmartThreadPool.txt (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Setup/licenses/LicenseSmartThreadPool.txt (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -0,0 +1,21 @@
+Microsoft Public License (MS-PL)
+This license governs use of the accompanying software. If you use the software, you
+accept this license. If you do not accept the license, do not use the software.
+
+1. Definitions
+The terms "reproduce," "reproduction," "derivative works," and "distribution" have the
+same meaning here as under U.S. copyright law.
+A "contribution" is the original software, or any additions or changes to the software.
+A "contributor" is any person that distributes its contribution under this license.
+"Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+2. Grant of Rights
+(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+3. Conditions and Limitations
+(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
+(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
+(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
+(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
\ No newline at end of file
Index: Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj
===================================================================
diff -u -r16bd8076863c03907abeee60b16704aba1bdb1a0 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj (.../Core.Common.Utils.csproj) (revision 16bd8076863c03907abeee60b16704aba1bdb1a0)
+++ Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj (.../Core.Common.Utils.csproj) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -94,6 +94,7 @@
+
Index: Core/Common/src/Core.Common.Utils/Drawing/ColorAccess.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Utils/Drawing/ColorAccess.cs (revision 0)
+++ Core/Common/src/Core.Common.Utils/Drawing/ColorAccess.cs (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -0,0 +1,256 @@
+// 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;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Runtime.InteropServices;
+
+namespace Core.Common.Utils.Drawing
+{
+ ///
+ /// Facade class for easy access to the color data of a .
+ ///
+ ///
+ ///
+ /// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Reprojection/TileReprojector.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
+ ///
+ ///
+ /// This class uses a copy of the image buffer. Therefore it isn't possible to
+ /// use this class directly to change the source image.
+ ///
+ ///
+ public class ColorAccess
+ {
+ private static readonly byte[] bitMask =
+ {
+ 1,
+ 2,
+ 4,
+ 8,
+ 16,
+ 32,
+ 64,
+ 128
+ };
+
+ private readonly int stride;
+
+ private readonly PixelFormat format;
+ private readonly int bitsPerPixel;
+
+ private readonly ColorPalette palette;
+ private readonly Rectangle validRange;
+
+ private ColorAccess(BitmapData data, ColorPalette palette, Rectangle validRange)
+ {
+ stride = data.Stride;
+
+ Buffer = new byte[stride * data.Height];
+ Marshal.Copy(data.Scan0, Buffer, 0, Buffer.Length);
+ format = data.PixelFormat;
+ bitsPerPixel = GetPixelSize(format);
+ this.palette = palette;
+ this.validRange = validRange;
+ }
+
+ ///
+ /// Gets or sets the of the pixel at the given coordinates.
+ ///
+ /// The x-coordinate.
+ /// The y-coordinate.
+ ///
+ public Color this[int x, int y]
+ {
+ get
+ {
+ ValidateIndices(x, y);
+
+ int mod;
+ int pIndex;
+ var index = GetIndex(x, y, out mod);
+ switch (format)
+ {
+ case PixelFormat.Format1bppIndexed:
+ return palette.Entries[(Buffer[index] & bitMask[mod]) == 0 ? 0 : 1];
+
+ case PixelFormat.Format4bppIndexed:
+ pIndex = Buffer[index];
+ mod /= 4;
+ if (mod != 0)
+ {
+ pIndex >>= 4;
+ }
+ return palette.Entries[pIndex & 0x7];
+
+ case PixelFormat.Format8bppIndexed:
+ pIndex = Buffer[index];
+ return palette.Entries[pIndex];
+
+ case PixelFormat.Format24bppRgb:
+ return Color.FromArgb(Buffer[index + 2], Buffer[index + 1],
+ Buffer[index]);
+
+ case PixelFormat.Format32bppArgb:
+ case PixelFormat.Format32bppRgb:
+ return Color.FromArgb(Buffer[index + 3], Buffer[index + 2],
+ Buffer[index + 1], Buffer[index]);
+ default:
+ throw new NotImplementedException();
+ }
+ }
+
+ set
+ {
+ if (format != PixelFormat.Format32bppArgb)
+ {
+ throw new NotImplementedException();
+ }
+ ValidateIndices(x, y);
+
+ int mod;
+ int index = GetIndex(x, y, out mod);
+ Buffer[index++] = value.B;
+ Buffer[index++] = value.G;
+ Buffer[index++] = value.R;
+ Buffer[index] = value.A;
+ }
+ }
+
+ ///
+ /// The image data buffer. This can be changed with and
+ /// can be used to create a new image with the changed data (for example using
+ /// ).
+ ///
+ public byte[] Buffer { get; }
+
+ ///
+ /// Sets the current image back at the original location in
+ /// an image.
+ ///
+ /// The image to update.
+ /// Thrown when unable to access the image data of .
+ public void SetBufferToImageAtOriginalLocation(Bitmap bitmap)
+ {
+ if (bitmap == null)
+ {
+ throw new ArgumentNullException(nameof(bitmap));
+ }
+
+ BitmapData bitmapData = bitmap.LockBits(validRange, ImageLockMode.WriteOnly, bitmap.PixelFormat);
+ Marshal.Copy(Buffer, 0, bitmapData.Scan0, Buffer.Length);
+ bitmap.UnlockBits(bitmapData);
+ }
+
+ ///
+ /// Creates a new instance of for a given image.
+ ///
+ /// The image to gain access to.
+ /// Optional: The area of
+ /// to provide access to. When not specified, the whole image is accessible.
+ ///
+ /// Thrown when
+ /// is null.
+ /// Thrown when
+ /// does not fully fit within the bounds of .
+ /// Thrown when unable to connect to the data buffers
+ /// of .
+ public static ColorAccess Create(Bitmap bitmap, Rectangle? accessibleArea = null)
+ {
+ if (bitmap == null)
+ {
+ throw new ArgumentNullException(nameof(bitmap));
+ }
+
+ var fullBitmapArea = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
+ if (accessibleArea == null)
+ {
+ accessibleArea = fullBitmapArea;
+ }
+ else if (!fullBitmapArea.Contains(accessibleArea.Value))
+ {
+ throw new ArgumentException("Accessible area must be within the bounds of the image.", nameof(accessibleArea));
+ }
+
+ BitmapData imageData = bitmap.LockBits(accessibleArea.Value, ImageLockMode.ReadOnly, bitmap.PixelFormat);
+ ColorAccess res = new ColorAccess(imageData, bitmap.Palette, accessibleArea.Value);
+ bitmap.UnlockBits(imageData);
+
+ return res;
+ }
+
+ private void ValidateIndices(int x, int y)
+ {
+ if (!IsInValidRange(x, y))
+ {
+ throw new ArgumentOutOfRangeException("indices", $"Index must be in range x:[{validRange.Left},{validRange.Right - 1}], y:[{validRange.Top},{validRange.Bottom - 1}].");
+ }
+ }
+
+ private bool IsInValidRange(int x, int y)
+ {
+ return validRange.Contains(x, y);
+ }
+
+ private int GetIndex(int x, int y, out int mod)
+ {
+ int offsetRow = y * stride;
+ int offsetColBits = x * bitsPerPixel;
+ int offsetCol = offsetColBits / 8;
+ mod = offsetColBits - offsetCol * 8;
+
+ return offsetRow + offsetCol;
+ }
+
+ private static int GetPixelSize(PixelFormat pixelFormat)
+ {
+ switch (pixelFormat)
+ {
+ case PixelFormat.Format8bppIndexed:
+ return 8;
+ case PixelFormat.Format16bppArgb1555:
+ case PixelFormat.Format16bppGrayScale:
+ case PixelFormat.Format16bppRgb555:
+ case PixelFormat.Format16bppRgb565:
+ return 16;
+ case PixelFormat.Format24bppRgb:
+ return 24;
+ case PixelFormat.Format32bppArgb:
+ case PixelFormat.Format32bppPArgb:
+ case PixelFormat.Format32bppRgb:
+ return 32;
+ case PixelFormat.Format48bppRgb:
+ return 48;
+ case PixelFormat.Format64bppArgb:
+ case PixelFormat.Format64bppPArgb:
+ return 64;
+ case PixelFormat.Format4bppIndexed:
+ return 4;
+ case PixelFormat.Format1bppIndexed:
+ return 1;
+ default:
+ throw new InvalidEnumArgumentException(nameof(pixelFormat), (int) pixelFormat, typeof(PixelFormat));
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj
===================================================================
diff -u -r16bd8076863c03907abeee60b16704aba1bdb1a0 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj (.../Core.Common.Utils.Test.csproj) (revision 16bd8076863c03907abeee60b16704aba1bdb1a0)
+++ Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj (.../Core.Common.Utils.Test.csproj) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -87,6 +87,7 @@
+
@@ -173,6 +174,7 @@
+
Index: Core/Common/test/Core.Common.Utils.Test/Drawing/ColorAccessTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.Utils.Test/Drawing/ColorAccessTest.cs (revision 0)
+++ Core/Common/test/Core.Common.Utils.Test/Drawing/ColorAccessTest.cs (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -0,0 +1,181 @@
+// 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;
+using System.Drawing;
+using Core.Common.TestUtil;
+using Core.Common.Utils.Drawing;
+using Core.Common.Utils.Test.Properties;
+using NUnit.Framework;
+
+namespace Core.Common.Utils.Test.Drawing
+{
+ [TestFixture]
+ public class ColorAccessTest
+ {
+ [Test]
+ public void Create_BitmapNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ColorAccess.Create(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("bitmap", paramName);
+ }
+
+ [Test]
+ [TestCase(0, 0, 3, 2)]
+ [TestCase(0, 0, 2, 3)]
+ [TestCase(-1, 0, 2, 2)]
+ [TestCase(0, -1, 2, 2)]
+ public void Create_RectangleNotFullyWithinImage_ThrowArgumentException(int leftX, int topY, int rightX, int bottomY)
+ {
+ // Setup
+ var rect = Rectangle.FromLTRB(leftX, topY, rightX, bottomY);
+
+ // Call
+ TestDelegate call = () => ColorAccess.Create(Resources.Black2x2, rect);
+
+ // Assert
+ string message = "Accessible area must be within the bounds of the image.";
+ string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message).ParamName;
+ Assert.AreEqual("accessibleArea", paramName);
+ }
+
+ [Test]
+ public void Index_ValidIndices_ReturnColor()
+ {
+ // Setup
+ ColorAccess colorAccess = ColorAccess.Create(Resources.acorn);
+
+ // Call
+ Color color1 = colorAccess[0, 0];
+ Color color2 = colorAccess[8, 8];
+ Color color3 = colorAccess[12, 6];
+
+ // Assert
+ Color expectedColor1 = Color.FromArgb(0, 110, 55, 2);
+ Color expectedColor2 = Color.FromArgb(255, 137, 69, 18);
+ Color expectedColor3 = Color.FromArgb(255, 197, 171, 146);
+
+ Assert.AreEqual(expectedColor1, color1);
+ Assert.AreEqual(expectedColor2, color2);
+ Assert.AreEqual(expectedColor3, color3);
+ }
+
+ [Test]
+ [TestCase(-1, 0)]
+ [TestCase(0, -1)]
+ [TestCase(3, 2)]
+ [TestCase(2, 3)]
+ public void Index_GetAtInvalidIndices_ThrowArgumentOutOfRangeException(int x, int y)
+ {
+ // Setup
+ ColorAccess colorAccess = ColorAccess.Create(Resources.Black2x2);
+
+ // Call
+ Color c;
+ TestDelegate call = () => c = colorAccess[x, y];
+
+ // Assert
+ string message = "Index must be in range x:[0,1], y:[0,1].";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message);
+ }
+
+ [Test]
+ public void Index_SetAtValidIndices_BufferUpdated()
+ {
+ // Setup
+ using (var image = (Bitmap) Resources.acorn.Clone())
+ {
+ var colorAccess = ColorAccess.Create(image);
+
+ // Call
+ colorAccess[8, 8] = Color.AliceBlue;
+
+ // Assert
+ const int expectedBufferStartIndex = 544;
+ Assert.AreEqual(Color.AliceBlue.B, colorAccess.Buffer[expectedBufferStartIndex]);
+ Assert.AreEqual(Color.AliceBlue.G, colorAccess.Buffer[expectedBufferStartIndex + 1]);
+ Assert.AreEqual(Color.AliceBlue.R, colorAccess.Buffer[expectedBufferStartIndex + 2]);
+ Assert.AreEqual(Color.AliceBlue.A, colorAccess.Buffer[expectedBufferStartIndex + 3]);
+
+ // ColorAccess should not be capable of changing the source image:
+ TestHelper.AssertImagesAreEqual(Resources.acorn, image);
+ }
+ }
+
+ [Test]
+ [TestCase(-1, 0)]
+ [TestCase(0, -1)]
+ [TestCase(16, 15)]
+ [TestCase(15, 16)]
+ public void Index_SetAtInvalidIndices_ThrowArgumentOutOfRangeException(int x, int y)
+ {
+ // Setup
+ ColorAccess colorAccess = ColorAccess.Create(Resources.acorn);
+
+ // Call
+ TestDelegate call = () => colorAccess[x, y] = Color.AliceBlue;
+
+ // Assert
+ string message = "Index must be in range x:[0,15], y:[0,15].";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message);
+ }
+
+ [Test]
+ public void SetBufferToImageAtOriginalLocation_AfterModificationsToBuffer_TargetImageUpdated()
+ {
+ // Setup
+ ColorAccess colorAccess = ColorAccess.Create(Resources.acorn);
+
+ for (int i = 0; i < 16; i++)
+ {
+ colorAccess[i, i] = Color.Red;
+ colorAccess[i, 15-i] = Color.Red;
+ }
+
+ using (var targetImage = (Bitmap) Resources.acorn.Clone())
+ {
+ // Call
+ colorAccess.SetBufferToImageAtOriginalLocation(targetImage);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(Resources.acornWithCross, targetImage);
+ }
+ }
+
+ [Test]
+ public void SetBufferToImageAtOriginalLocation_BitmapNull_ThrowArgumentNullException()
+ {
+ // Setup
+ ColorAccess colorAccess = ColorAccess.Create(Resources.acorn);
+
+ // Call
+ TestDelegate call = () => colorAccess.SetBufferToImageAtOriginalLocation(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("bitmap", paramName);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Utils.Test/Properties/Resources.Designer.cs
===================================================================
diff -u -r97fd85a69fb9570efb56640cb3c301f4af9f3b62 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Common/test/Core.Common.Utils.Test/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 97fd85a69fb9570efb56640cb3c301f4af9f3b62)
+++ Core/Common/test/Core.Common.Utils.Test/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -104,6 +104,16 @@
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
+ internal static System.Drawing.Bitmap acornWithCross {
+ get {
+ object obj = ResourceManager.GetObject("acornWithCross", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
internal static System.Drawing.Bitmap Black2x2 {
get {
object obj = ResourceManager.GetObject("Black2x2", resourceCulture);
Index: Core/Common/test/Core.Common.Utils.Test/Properties/Resources.resx
===================================================================
diff -u -r97fd85a69fb9570efb56640cb3c301f4af9f3b62 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Common/test/Core.Common.Utils.Test/Properties/Resources.resx (.../Resources.resx) (revision 97fd85a69fb9570efb56640cb3c301f4af9f3b62)
+++ Core/Common/test/Core.Common.Utils.Test/Properties/Resources.resx (.../Resources.resx) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -157,4 +157,7 @@
<second>
+
+ ..\Resources\acornWithCross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
Index: Core/Common/test/Core.Common.Utils.Test/Resources/acornWithCross.png
===================================================================
diff -u
Binary files differ
Index: Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj (.../Core.Components.DotSpatial.csproj) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj (.../Core.Components.DotSpatial.csproj) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -151,9 +151,6 @@
-
-
-
ResXFileCodeGenerator
Resources.Designer.cs
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/BruTileLayer.cs
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/BruTileLayer.cs (.../BruTileLayer.cs) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/BruTileLayer.cs (.../BruTileLayer.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -19,6 +19,33 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+// ********************************************************************************************************
+// Product Name: DotSpatial.Plugins.BruTileLayer
+// Description: Adds BruTile functionality to DotSpatial
+// ********************************************************************************************************
+// The contents of this file are subject to the GNU Library General Public License (LGPL).
+// You may not use this file except in compliance with the License. You may obtain a copy of the License at
+// http://dotspatial.codeplex.com/license
+//
+// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+// ANY KIND, either expressed or implied. See the License for the specific language governing rights and
+// limitations under the License.
+//
+// The Initial Developer of this Original Code is Felix Obermaier. Created 2011.01.05
+//
+// Contributor(s): (Open source contributors should list themselves and their modifications here).
+// | Name | Date | Comments
+// |----------------------|-------------|-----------------------------------------------------------------
+// | Felix Obermaier | 2011.01.05 | Initial commit
+// | Felix Obermaier | 2013.02.15 | All sorts of configuration code and user interfaces,
+// | | | making BruTileLayer work in sync- or async mode
+// | Felix Obermaier | 2013.09.19 | Making deserialization work by adding AssemblyResolve event,
+// | | | handler
+// -------------------------------------------------------------------------------------------------------
+// Changes upon original work have been implemented to suit functional requirements for Ringtoets.
+// These changes have been implemented as of 13 Januari 2017.
+// ********************************************************************************************************
+
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -51,6 +78,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/BruTileLayer.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
public class BruTileLayer : DotSpatialLayer, IMapLayer
{
@@ -482,8 +510,8 @@
return;
}
- Point lt = args.ProjToPixel(outWorldFile.ToGround(0, 0));
- Point rb = args.ProjToPixel(outWorldFile.ToGround(outBitmap.Width, outBitmap.Height));
+ Point lt = args.ProjToPixel(outWorldFile.ToWorldCoordinates(0, 0));
+ Point rb = args.ProjToPixel(outWorldFile.ToWorldCoordinates(outBitmap.Width, outBitmap.Height));
var rect = new Rectangle(lt, Size.Subtract(new Size(rb), new Size(lt)));
args.Device.DrawImage(outBitmap, rect, 0, 0, outBitmap.Width, outBitmap.Height,
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/BruTileSettings.cs
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/BruTileSettings.cs (.../BruTileSettings.cs) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/BruTileSettings.cs (.../BruTileSettings.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -31,6 +31,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/BruTileLayerSettings.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
public static class BruTileSettings
{
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/BruTileReflectionHelper.cs
===================================================================
diff -u -r16bd8076863c03907abeee60b16704aba1bdb1a0 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/BruTileReflectionHelper.cs (.../BruTileReflectionHelper.cs) (revision 16bd8076863c03907abeee60b16704aba1bdb1a0)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/BruTileReflectionHelper.cs (.../BruTileReflectionHelper.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -31,6 +31,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Configuration/ReflectionHelper.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
internal static class BruTileReflectionHelper
{
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/IConfiguration.cs
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/IConfiguration.cs (.../IConfiguration.cs) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/IConfiguration.cs (.../IConfiguration.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -29,6 +29,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Configuration/IConfiguration.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
public interface IConfiguration
{
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/PersistentCacheConfiguration.cs
===================================================================
diff -u -r16bd8076863c03907abeee60b16704aba1bdb1a0 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/PersistentCacheConfiguration.cs (.../PersistentCacheConfiguration.cs) (revision 16bd8076863c03907abeee60b16704aba1bdb1a0)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/PersistentCacheConfiguration.cs (.../PersistentCacheConfiguration.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -33,6 +33,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Configuration/CacheConfiguration.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
public abstract class PersistentCacheConfiguration
{
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/PersistentCacheStrategy.cs
===================================================================
diff -u -r7cc1fd960a912443ccc3c6995eccb5673d1d8d22 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/PersistentCacheStrategy.cs (.../PersistentCacheStrategy.cs) (revision 7cc1fd960a912443ccc3c6995eccb5673d1d8d22)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/PersistentCacheStrategy.cs (.../PersistentCacheStrategy.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -26,6 +26,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Configuration/PermaCacheType.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
public enum PersistentCacheStrategy
{
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/WmtsLayerConfiguration.cs
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/WmtsLayerConfiguration.cs (.../WmtsLayerConfiguration.cs) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Configurations/WmtsLayerConfiguration.cs (.../WmtsLayerConfiguration.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -36,6 +36,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Configuration/WmtsLayerConfiguration.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
public class WmtsLayerConfiguration : PersistentCacheConfiguration, IConfiguration
{
Fisheye: Tag c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd refers to a dead (removed) revision in file `Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Notice.txt'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/ReprojectExtensions.cs
===================================================================
diff -u -r7cc1fd960a912443ccc3c6995eccb5673d1d8d22 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/ReprojectExtensions.cs (.../ReprojectExtensions.cs) (revision 7cc1fd960a912443ccc3c6995eccb5673d1d8d22)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/ReprojectExtensions.cs (.../ReprojectExtensions.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -33,6 +33,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Reprojection/ReprojectExtensions.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
internal static class ReprojectExtensions
{
@@ -46,28 +47,63 @@
/// The returned object is specified in a higher resolution than .
/// This is done as a straight edge in can lead to a curved
/// edge in .
+ /// Thrown when any input argument is null.
+ /// Thrown when has less
+ /// than 3 coordinates.
public static ILinearRing Reproject(this ILinearRing ring, ProjectionInfo source, ProjectionInfo target)
{
- var seq = Reproject(ring.Coordinates.Densify(36), source, target);
+ if (ring == null)
+ {
+ throw new ArgumentNullException(nameof(ring));
+ }
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+ if (target == null)
+ {
+ throw new ArgumentNullException(nameof(target));
+ }
+ if (ring.Coordinates.Count < 3)
+ {
+ throw new ArgumentException("Ring must contain at least 3 coordinates.",
+ nameof(ring));
+ }
+
+ IList seq = Reproject(ring.Coordinates.Densify(36), source, target);
return ring.Factory.CreateLinearRing(seq);
}
///
/// Reprojects a .
///
/// The object to be reprojected.
- /// The coordinate system corresponding to .
+ /// The coordinate system corresponding to .
/// The target coordinate system.
/// The reprojected .
+ /// Thrown when any input argument is null.
public static Extent Reproject(this Extent extent, ProjectionInfo source, ProjectionInfo target)
{
+ if (extent == null)
+ {
+ throw new ArgumentNullException(nameof(extent));
+ }
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+ if (target == null)
+ {
+ throw new ArgumentNullException(nameof(target));
+ }
+
if (target.Transform == null)
{
return extent;
}
double[] xy = ToSequence(extent);
- DotSpatialReproject.ReprojectPoints(xy, null, source, target, 0, xy.Length/2);
+ DotSpatialReproject.ReprojectPoints(xy, null, source, target, 0, xy.Length / 2);
return ToExtent(xy);
}
@@ -78,99 +114,99 @@
return coordinates;
}
- var ords = new double[coordinates.Count*2];
+ var xy = new double[coordinates.Count * 2];
var z = new double[coordinates.Count];
var j = 0;
for (var i = 0; i < coordinates.Count; i++)
{
Coordinate c = coordinates[i];
- ords[j++] = c.X;
- ords[j++] = c.Y;
+ xy[j++] = c.X;
+ xy[j++] = c.Y;
z[i] = double.IsNaN(c.Z) ? 0 : c.Z;
}
- DotSpatialReproject.ReprojectPoints(ords, z, source, target, 0, coordinates.Count);
+ DotSpatialReproject.ReprojectPoints(xy, z, source, target, 0, coordinates.Count);
- var lst = new List(coordinates.Count);
+ var result = new List(coordinates.Count);
j = 0;
for (var i = 0; i < coordinates.Count; i++)
{
- lst.Add(new Coordinate(ords[j++], ords[j++]));
+ result.Add(new Coordinate(xy[j++], xy[j++]));
}
- return lst;
+ return result;
}
///
/// Returns a collection of that has the same shape as
/// the target, but with more points set 'edge' (effectively increasing its resolution).
///
- /// The original collection of .
+ /// The original collection of .
/// The number of segments each 'edge' should be subdivided in.
- ///
+ /// Return the densified version based on .
/// A value of 4 of means that 3 equally spaced
/// points are introduced along the line between two instances
- /// in .
- private static IList Densify(this IList self, int intervals)
+ /// in .
+ private static IList Densify(this IList original, int intervals)
{
- if (self.Count < 2)
+ return GetDensifiedCoordinates(original, intervals - 1);
+ }
+
+ private static IList GetDensifiedCoordinates(IList original, int numberOfAdditionalPoints)
+ {
+ int numberOfEdges = original.Count - 1;
+ var resultList = new List(numberOfEdges * (numberOfAdditionalPoints + 1) + 1);
+ resultList.Add(original[0]);
+ for (int i = 1; i <= numberOfEdges; i++)
{
- return self;
+ resultList.AddRange(GetEdgePointsExcludingStart(original[i - 1], original[i], numberOfAdditionalPoints));
}
+ return resultList;
+ }
- var res = new List(intervals*(self.Count - 1) + 1);
- Coordinate start = self[0];
-
- for (var i = 1; i < self.Count; i++)
+ private static IEnumerable GetEdgePointsExcludingStart(Coordinate start, Coordinate end, int numberOfAdditionalPoints)
+ {
+ if (numberOfAdditionalPoints < 0)
{
- res.Add(start);
- Coordinate end = self[i];
+ throw new ArgumentOutOfRangeException(nameof(numberOfAdditionalPoints),
+ "Number of additional points cannot be negative.");
+ }
- double dx = (end.X - start.X)/intervals;
- double dy = (end.Y - start.Y)/intervals;
+ double dx = (end.X - start.X) / (numberOfAdditionalPoints + 1);
+ double dy = (end.Y - start.Y) / (numberOfAdditionalPoints + 1);
- for (var j = 0; j < intervals - 1; j++)
- {
- start = new Coordinate(start.X + dx, start.Y + dy);
- res.Add(start);
- }
- res.Add(end);
- start = end;
+ for (int i = 1; i <= numberOfAdditionalPoints; i++)
+ {
+ yield return new Coordinate(start.X + i * dx, start.Y + i * dy);
}
- return res;
+ yield return end;
}
- ///
- /// Transforms the coordinates of an to a sequence of xy pairs.
- ///
- /// The extent.
- /// The xy sequence.
- /// The resolution of the edges of are increased
- /// as a straight edge in the source coordinate system can lead to a curved edge in
- /// the target coordinate system.
private static double[] ToSequence(Extent extent)
{
- const int horizontal = 72;
- const int vertical = 36;
- var result = new double[horizontal*vertical*2];
+ const int horizontalResolution = 72;
+ const int verticalResolution = 36;
+ var xy = new double[horizontalResolution * verticalResolution * 2];
- double dx = extent.Width/(horizontal - 1);
- double dy = extent.Height/(vertical - 1);
+ double dx = extent.Width / (horizontalResolution - 1);
+ double dy = extent.Height / (verticalResolution - 1);
- double minY = extent.MinY;
+ // Define a lattice of points, because there exist coordinate transformations
+ // that place original center-points to edge-point in the target coordinate system:
+ double y = extent.MinY;
var k = 0;
- for (var i = 0; i < vertical; i++)
+ for (var i = 0; i < verticalResolution; i++)
{
- double minX = extent.MinX;
- for (var j = 0; j < horizontal; j++)
+ double x = extent.MinX;
+ for (var j = 0; j < horizontalResolution; j++)
{
- result[k++] = minX;
- result[k++] = minY;
- minX += dx;
+ xy[k++] = x;
+ xy[k++] = y;
+ x += dx;
}
- minY += dy;
+ y += dy;
}
- return result;
+ return xy;
}
private static Extent ToExtent(double[] xyOrdinates)
@@ -181,31 +217,19 @@
var i = 0;
while (i < xyOrdinates.Length)
{
- double xyOrdinate = xyOrdinates[i];
- if (!double.IsNaN(xyOrdinate) &&
- (double.MinValue < xyOrdinate && xyOrdinate < double.MaxValue))
+ double x = xyOrdinates[i];
+ if (!double.IsNaN(x) && double.MinValue < x && x < double.MaxValue)
{
- if (minX > xyOrdinate)
- {
- minX = xyOrdinate;
- }
- if (maxX < xyOrdinate)
- {
- maxX = xyOrdinate;
- }
+ minX = Math.Min(minX, x);
+ maxX = Math.Max(maxX, x);
}
i += 1;
- if (!double.IsNaN(xyOrdinate) &&
- (double.MinValue < xyOrdinate && xyOrdinate < double.MaxValue))
+
+ double y = xyOrdinates[i];
+ if (!double.IsNaN(y) && double.MinValue < y && y < double.MaxValue)
{
- if (minY > xyOrdinate)
- {
- minY = xyOrdinate;
- }
- if (maxY < xyOrdinate)
- {
- maxY = xyOrdinate;
- }
+ minY = Math.Min(minY, y);
+ maxY = Math.Max(maxY, y);
}
i += 1;
}
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/TileReprojector.cs
===================================================================
diff -u -r7cc1fd960a912443ccc3c6995eccb5673d1d8d22 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/TileReprojector.cs (.../TileReprojector.cs) (revision 7cc1fd960a912443ccc3c6995eccb5673d1d8d22)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/TileReprojector.cs (.../TileReprojector.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -21,10 +21,9 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
-using System.Runtime.InteropServices;
+using Core.Common.Utils.Drawing;
using DotSpatial.Controls;
using DotSpatial.Data;
using DotSpatial.Projections;
@@ -40,6 +39,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Reprojection/TileReprojector.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
internal class TileReprojector
{
@@ -84,24 +84,24 @@
return;
}
- Rectangle ptRect = GetSourceExtentInPixelCoordinates(sourceReference, sourceTile);
+ Rectangle targetTileExtentInPixelCoordinates = GetTargetExtentInPixelCoordinates(sourceReference, sourceTile);
// Get the intersection with the current viewport
- ptRect.Intersect(mapArgs.ImageRectangle);
+ targetTileExtentInPixelCoordinates.Intersect(mapArgs.ImageRectangle);
// Is it empty, don't return anything
- if (ptRect.Width == 0 || ptRect.Height == 0)
+ if (targetTileExtentInPixelCoordinates.Width == 0 || targetTileExtentInPixelCoordinates.Height == 0)
{
targetTile = null;
targetReference = null;
return;
}
- int offsetX = ptRect.X;
- int offsetY = ptRect.Y;
+ int offsetX = targetTileExtentInPixelCoordinates.X;
+ int offsetY = targetTileExtentInPixelCoordinates.Y;
// Prepare the result tile
- targetTile = new Bitmap(ptRect.Size.Width, ptRect.Size.Height,
+ targetTile = new Bitmap(targetTileExtentInPixelCoordinates.Size.Width, targetTileExtentInPixelCoordinates.Size.Height,
PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(targetTile))
{
@@ -123,37 +123,29 @@
}
}
// Copy to output tile
- SetBitmapBuffer(targetTile, targetTileColorAccess.Buffer);
+ targetTileColorAccess.SetBufferToImageAtOriginalLocation(targetTile);
// Compute the reference
- Extent outExtent = mapArgs.PixelToProj(ptRect);
+ Extent outExtent = mapArgs.PixelToProj(targetTileExtentInPixelCoordinates);
targetReference = new WorldFile(
- outExtent.Width/ptRect.Width, 0,
- 0, -outExtent.Height/ptRect.Height,
+ outExtent.Width / targetTileExtentInPixelCoordinates.Width, 0,
+ 0, -outExtent.Height / targetTileExtentInPixelCoordinates.Height,
outExtent.X, outExtent.Y);
}
- private Rectangle GetSourceExtentInPixelCoordinates(WorldFile sourceReference, Bitmap sourceTile)
+ private Rectangle GetTargetExtentInPixelCoordinates(WorldFile sourceReference, Bitmap sourceTile)
{
- // Bounding polygon on the ground
- IPolygon ps = sourceReference.ToGroundBounds(sourceTile.Width, sourceTile.Height);
-
- // Bounding polygon on the ground in target projection
- ILinearRing pt = ps.Shell.Reproject(source, target);
-
- // The target extent
- Extent ptExtent = pt.EnvelopeInternal.ToExtent();
-
- // The target extent projected to the current viewport
- Rectangle ptRect = mapArgs.ProjToPixel(ptExtent);
- return ptRect;
+ IPolygon sourceTileCircumference = sourceReference.BoundingOrdinatesToWorldCoordinates(sourceTile.Width, sourceTile.Height);
+ ILinearRing targetTileCircumference = sourceTileCircumference.Shell.Reproject(source, target);
+ Extent targetTileExtent = targetTileCircumference.EnvelopeInternal.ToExtent();
+ return mapArgs.ProjToPixel(targetTileExtent);
}
private IEnumerable> GetValidPoints(int y, int offsetY, int x1, int x2,
WorldFile sourceReference, Size sourceTileSize)
{
- int len = (x2 - x1);
- double[] xy = new double[len*2];
+ int len = x2 - x1;
+ double[] xy = new double[len * 2];
int i = 0;
for (int x = x1; x < x2; x++)
{
@@ -169,7 +161,7 @@
for (var x = 0; x < len; x++)
{
Coordinate coord = new Coordinate(xy[i++], xy[i++]);
- Point sourcePixelLocation = sourceReference.ToRaster(coord);
+ Point sourcePixelLocation = sourceReference.ToScreenCoordinates(coord);
if (IsSourcePointInsideArea(sourceTileSize, sourcePixelLocation))
{
@@ -178,14 +170,6 @@
}
}
- private static void SetBitmapBuffer(Bitmap bitmap, byte[] buffer)
- {
- Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
- BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.WriteOnly, bitmap.PixelFormat);
- Marshal.Copy(buffer, 0, bitmapData.Scan0, buffer.Length);
- bitmap.UnlockBits(bitmapData);
- }
-
private static bool IsSourcePointInsideArea(Size area, Point sourcePixelLocation)
{
if (sourcePixelLocation.X < 0 || sourcePixelLocation.Y < 0)
@@ -201,155 +185,5 @@
}
return false;
}
-
- ///
- /// Facade class for easy access to the color data of a .
- ///
- private class ColorAccess
- {
- private static readonly byte[] bitMask;
-
- static ColorAccess()
- {
- bitMask = new[]
- {
- (byte) 1,
- (byte) 2,
- (byte) 4,
- (byte) 8,
- (byte) 16,
- (byte) 32,
- (byte) 64,
- (byte) 128
- };
- }
-
- private readonly int stride;
-
- private readonly PixelFormat format;
- private readonly int bitsPerPixel;
-
- private readonly ColorPalette palette;
-
- private ColorAccess(BitmapData data, ColorPalette palette)
- {
- stride = data.Stride;
-
- Buffer = new byte[stride*data.Height];
- Marshal.Copy(data.Scan0, Buffer, 0, Buffer.Length);
- format = data.PixelFormat;
- bitsPerPixel = GetPixelSize(format);
- this.palette = palette;
- }
-
- public Color this[int x, int y]
- {
- get
- {
- int mod;
- int pIndex;
- var index = GetIndex(x, y, out mod);
- switch (format)
- {
- case PixelFormat.Format1bppIndexed:
- return palette.Entries[(Buffer[index] & bitMask[mod]) == 0 ? 0 : 1];
-
- case PixelFormat.Format4bppIndexed:
- pIndex = Buffer[index];
- mod /= 4;
- if (mod != 0)
- {
- pIndex >>= 4;
- }
- return palette.Entries[pIndex & 0x7];
-
- case PixelFormat.Format8bppIndexed:
- pIndex = Buffer[index];
- return palette.Entries[pIndex];
-
- case PixelFormat.Format24bppRgb:
- return Color.FromArgb(Buffer[index + 2], Buffer[index + 1],
- Buffer[index]);
-
- case PixelFormat.Format32bppRgb:
- return Color.FromArgb(Buffer[index + 3], Buffer[index + 2],
- Buffer[index + 1], Buffer[index]);
- }
- return Color.Transparent;
- }
-
- set
- {
- if (format != PixelFormat.Format32bppArgb)
- {
- throw new NotSupportedException();
- }
-
- int mod;
- int index = GetIndex(x, y, out mod);
- Buffer[index++] = value.B;
- Buffer[index++] = value.G;
- Buffer[index++] = value.R;
- Buffer[index] = value.A;
- }
- }
-
- public byte[] Buffer { get; }
-
- public static ColorAccess Create(Bitmap bitmap, Rectangle? rect = null)
- {
- if (rect == null)
- {
- rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
- }
- BitmapData bmData = bitmap.LockBits(rect.Value, ImageLockMode.ReadOnly, bitmap.PixelFormat);
- ColorAccess res = new ColorAccess(bmData, bitmap.Palette);
- bitmap.UnlockBits(bmData);
-
- return res;
- }
-
- private int GetIndex(int x, int y, out int mod)
- {
- int offsetRow = y*stride;
- int offsetColBits = x*bitsPerPixel;
- int offsetCol = offsetColBits/8;
- mod = offsetColBits - offsetCol*8;
-
- return offsetRow + offsetCol;
- }
-
- private static int GetPixelSize(PixelFormat pixelFormat)
- {
- switch (pixelFormat)
- {
- case PixelFormat.Format8bppIndexed:
- return 8;
- case PixelFormat.Format16bppArgb1555:
- case PixelFormat.Format16bppGrayScale:
- case PixelFormat.Format16bppRgb555:
- case PixelFormat.Format16bppRgb565:
- return 16;
- case PixelFormat.Format24bppRgb:
- return 24;
- case PixelFormat.Format32bppArgb:
- case PixelFormat.Format32bppPArgb:
- case PixelFormat.Format32bppRgb:
- return 32;
- case PixelFormat.Format48bppRgb:
- return 48;
- case PixelFormat.Format64bppArgb:
- case PixelFormat.Format64bppPArgb:
- return 64;
- case PixelFormat.Format4bppIndexed:
- return 4;
- case PixelFormat.Format1bppIndexed:
- return 1;
-
- default:
- throw new InvalidEnumArgumentException(nameof(pixelFormat), (int) pixelFormat, typeof(PixelFormat));
- }
- }
- }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/WorldFile.cs
===================================================================
diff -u -r7cc1fd960a912443ccc3c6995eccb5673d1d8d22 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/WorldFile.cs (.../WorldFile.cs) (revision 7cc1fd960a912443ccc3c6995eccb5673d1d8d22)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/Projections/WorldFile.cs (.../WorldFile.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -1,249 +1,290 @@
-// 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;
-using System.Collections.Generic;
-using DotSpatial.Topology;
-using Point = System.Drawing.Point;
-
-namespace Core.Components.DotSpatial.Layer.BruTile.Projections
-{
- ///
- /// WorldFiles complement images, giving georeferenced information for those images.
- /// The basic idea is to calculate everything based on the top left corner of the image.
+// 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;
+using System.Collections.Generic;
+using Core.Components.DotSpatial.Properties;
+using DotSpatial.Topology;
+using Point = System.Drawing.Point;
+
+namespace Core.Components.DotSpatial.Layer.BruTile.Projections
+{
+ ///
+ /// WorldFiles complement images, giving georeferenced information for those images.
+ /// The basic idea is to calculate everything based on the top left corner of the image.
///
///
+ ///
/// Original file: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/Reprojection/WorldFile.cs
- ///
- internal class WorldFile
- {
- private readonly Matrix2D matrix = new Matrix2D();
- private readonly Matrix2D inverse;
-
- ///
- /// Creates an instance of .
- ///
- /// X-component of the pixel width.
- /// Y-component of the pixel width.
- /// X-component of the pixel height.
- /// Y-component of the pixel height.
- /// X-ordinate of the center of the top left pixel.
- /// Y-ordinate of the center of the top left pixel.
- public WorldFile(double a11 = 1d, double a21 = 0d, double a12 = 0d, double a22 = -1, double b1 = 0d, double b2 = 0d)
- {
- matrix.A11 = a11;
- matrix.A21 = a21;
- matrix.A12 = a12;
- matrix.A22 = a22;
- inverse = matrix.Inverse();
-
- B1 = b1;
- B2 = b2;
- }
-
- ///
- /// Gets the X-component of the pixel width.
- ///
- public double A11
- {
- get
- {
- return matrix.A11;
- }
- }
-
- ///
- /// Gets the Y-component of the pixel width.
- ///
- public double A21
- {
- get
- {
- return matrix.A21;
- }
- }
-
- ///
- /// Gets the X-component of the pixel height.
- ///
- public double A12
- {
- get
- {
- return matrix.A12;
- }
- }
-
- ///
- /// Gets the Y-component of the pixel height.
- ///
- /// This value is negative most of the time.
- public double A22
- {
- get
- {
- return matrix.A22;
- }
- }
-
- ///
- /// Gets the X-ordinate of the center of the top left pixel.
- ///
- public double B1 { get; }
-
- ///
- /// Gets the Y-ordinate of the center of the top left pixel.
- ///
- public double B2 { get; }
-
- ///
- /// Determines the ground coordinate for a given , pair.
- ///
- /// The X pixel.
- /// The Y pixel.
- /// The ground coordinate.
- public Coordinate ToGround(int x, int y)
- {
- double resX = B1 + (A11*x + A21*y);
- double resY = B2 + (A12*x + A22*y);
-
- return new Coordinate(resX, resY);
- }
-
- ///
- /// Determines the ground bounding-ordinate for a given width and height pair.
- ///
- /// The width pixel.
- /// The height pixel.
- /// The ground bounding-ordinate.
- public IPolygon ToGroundBounds(int width, int height)
- {
- var ringCoordinates = new List(5);
- var leftTop = ToGround(0, 0);
- ringCoordinates.AddRange(new[]
- {
- leftTop,
- ToGround(0, height),
- ToGround(width, 0),
- ToGround(width, height),
- leftTop
- });
-
- ILinearRing ring = GeometryFactory.Default.CreateLinearRing(ringCoordinates);
- return GeometryFactory.Default.CreatePolygon(ring, null);
- }
-
- ///
- /// Transforms the coordinate to pixel coordinates.
- ///
- /// The coordinate.
- /// The location in pixel coordinates.
- /// Throws when
- /// is null.
- public Point ToRaster(Coordinate point)
- {
- if (point == null)
- {
- throw new ArgumentNullException(nameof(point));
- }
-
- double px = point.X - B1;
- double py = point.Y - B2;
-
- int x = (int) Math.Round(inverse.A11*px + inverse.A21*py,
- MidpointRounding.AwayFromZero);
- int y = (int) Math.Round(inverse.A12*px + inverse.A22*py,
- MidpointRounding.AwayFromZero);
-
- return new Point(x, y);
- }
-
- private class Matrix2D
- {
- ///
- /// Gets the X-component of the pixel width.
- ///
- public double A11 { get; set; }
-
- ///
- /// Gets the Y-component of the pixel width.
- ///
- public double A21 { get; set; }
-
- ///
- /// Gets the X-component of the pixel height.
- ///
- public double A12 { get; set; }
-
- ///
- /// Gets the Y-component of the pixel height (negative most of the time).
- ///
- public double A22 { get; set; }
-
- ///
- /// Calculates the inverse of this instance.
- ///
- /// The inverse matrix
- /// Thrown when
- /// is false.
- ///
- public Matrix2D Inverse()
- {
- if (!IsInvertible)
- {
- throw new InvalidOperationException("Matrix not invertible");
- }
-
- double det = Determinant;
-
- return new Matrix2D
- {
- A11 = A22/det,
- A21 = -A21/det,
- A12 = -A12/det,
- A22 = A11/det
- };
- }
-
- ///
- /// Gets a value indicating the determinant of this matrix.
- ///
- private double Determinant
- {
- get
- {
- return A22*A11 - A21*A12;
- }
- }
-
- ///
- /// Gets a value indicating that can be computed.
- ///
- private bool IsInvertible
- {
- get
- {
- return Determinant != 0d;
- }
- }
- }
- }
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
+ ///
+ ///
+ /// Parameters in this object correspond to those of an affine transformation expressed
+ /// in homogeneous coordinates. For mathematical background, see: https://en.wikipedia.org/wiki/Transformation_matrix
+ /// and https://en.wikipedia.org/wiki/Affine_transformation
+ ///
+ ///
+ internal class WorldFile
+ {
+ private readonly Matrix2D matrix = new Matrix2D();
+ private readonly Matrix2D inverse;
+
+ ///
+ /// Creates an instance of , capturing the variables for the
+ /// affine transformation of screen coordinate into world coordinates.
+ ///
+ /// X-component of the pixel width (Sum of scaling along the X-axis
+ /// and rotation components).
+ /// Y-component of the pixel width (Sum of rotation and shear components).
+ /// X-component of the pixel height (Sum of rotation and shear components).
+ /// Y-component of the pixel height (Sum of scaling along the Y-axis
+ /// and rotation components).
+ /// X-ordinate of the center of the top left pixel (Translation
+ /// along the X-axis).
+ /// Y-ordinate of the center of the top left pixel. (Translation
+ /// along the Y-axis)
+ public WorldFile(double a11, double a21, double a12, double a22, double b1, double b2)
+ {
+ matrix.A11 = a11;
+ matrix.A21 = a21;
+ matrix.A12 = a12;
+ matrix.A22 = a22;
+
+ if (!matrix.IsInvertible)
+ {
+ throw new ArgumentException(Resources.WorldFile_Not_invertable_transformation_arguments_error);
+ }
+ inverse = matrix.Inverse();
+
+ B1 = b1;
+ B2 = b2;
+ }
+
+ ///
+ /// Gets the X-component of the pixel width.
+ ///
+ /// This is often the sum of the following components:
+ ///
+ /// - Scaling along the X-axis.
+ /// - Rotation about the origin.
+ ///
+ public double A11
+ {
+ get
+ {
+ return matrix.A11;
+ }
+ }
+
+ ///
+ /// Gets the Y-component of the pixel width.
+ ///
+ /// This is often the sum of the following components:
+ ///
+ /// - Shear in the direction of the X-axis.
+ /// - Rotation about the origin.
+ ///
+ public double A21
+ {
+ get
+ {
+ return matrix.A21;
+ }
+ }
+
+ ///
+ /// Gets the X-component of the pixel height.
+ ///
+ /// This is often the sum of the following components:
+ ///
+ /// - Shear in the direction of the Y-axis.
+ /// - Rotation about the origin.
+ ///
+ public double A12
+ {
+ get
+ {
+ return matrix.A12;
+ }
+ }
+
+ ///
+ /// Gets the Y-component of the pixel height.
+ ///
+ /// Typically this value is negative due to the orientation of the Y-axis
+ /// in screen-coordinates being inverted compared to that of the map.
+ /// This is often the sum of the following components:
+ ///
+ /// - Scaling along the Y-axis.
+ /// - Rotation about the origin.
+ ///
+ public double A22
+ {
+ get
+ {
+ return matrix.A22;
+ }
+ }
+
+ ///
+ /// Gets the X-ordinate of the center of the top left pixel.
+ ///
+ /// This value is often the translation in the direction of the X-axis.
+ public double B1 { get; }
+
+ ///
+ /// Gets the Y-ordinate of the center of the top left pixel.
+ ///
+ /// This value is often the translation in the direction of the Y-axis.
+ public double B2 { get; }
+
+ ///
+ /// Determines the ground coordinate for a given , pair.
+ ///
+ /// The X pixel.
+ /// The Y pixel.
+ /// The ground coordinate.
+ public Coordinate ToWorldCoordinates(int x, int y)
+ {
+ double resX = B1 + (A11 * x + A21 * y);
+ double resY = B2 + (A12 * x + A22 * y);
+
+ return new Coordinate(resX, resY);
+ }
+
+ ///
+ /// Determines the ground bounding-ordinate for a given width and height pair.
+ ///
+ /// The width pixel.
+ /// The height pixel.
+ /// The ground bounding-ordinate.
+ public IPolygon BoundingOrdinatesToWorldCoordinates(int width, int height)
+ {
+ var ringCoordinates = new List(5);
+ var leftTop = ToWorldCoordinates(0, 0);
+ ringCoordinates.AddRange(new[]
+ {
+ leftTop,
+ ToWorldCoordinates(0, height),
+ ToWorldCoordinates(width, 0),
+ ToWorldCoordinates(width, height),
+ leftTop
+ });
+
+ ILinearRing ring = GeometryFactory.Default.CreateLinearRing(ringCoordinates);
+ return GeometryFactory.Default.CreatePolygon(ring, null);
+ }
+
+ ///
+ /// Transforms the coordinate to pixel coordinates.
+ ///
+ /// The coordinate.
+ /// The location in pixel coordinates.
+ /// Throws when
+ /// is null.
+ public Point ToScreenCoordinates(Coordinate point)
+ {
+ if (point == null)
+ {
+ throw new ArgumentNullException(nameof(point));
+ }
+
+ double px = point.X - B1;
+ double py = point.Y - B2;
+
+ int x = (int) Math.Round(inverse.A11 * px + inverse.A21 * py,
+ MidpointRounding.AwayFromZero);
+ int y = (int) Math.Round(inverse.A12 * px + inverse.A22 * py,
+ MidpointRounding.AwayFromZero);
+
+ return new Point(x, y);
+ }
+
+ private class Matrix2D
+ {
+ ///
+ /// Gets the X-component of the pixel width.
+ ///
+ public double A11 { get; set; }
+
+ ///
+ /// Gets the Y-component of the pixel width.
+ ///
+ public double A21 { get; set; }
+
+ ///
+ /// Gets the X-component of the pixel height.
+ ///
+ public double A12 { get; set; }
+
+ ///
+ /// Gets the Y-component of the pixel height (negative most of the time).
+ ///
+ public double A22 { get; set; }
+
+ ///
+ /// Gets a value indicating that can be computed.
+ ///
+ public bool IsInvertible
+ {
+ get
+ {
+ return Determinant != 0d;
+ }
+ }
+
+ ///
+ /// Calculates the inverse of this instance.
+ ///
+ /// The inverse matrix
+ /// Thrown when
+ /// is false.
+ public Matrix2D Inverse()
+ {
+ if (!IsInvertible)
+ {
+ throw new InvalidOperationException("Matrix not invertable");
+ }
+
+ double det = Determinant;
+
+ return new Matrix2D
+ {
+ A11 = A22 / det,
+ A21 = -A21 / det,
+ A12 = -A12 / det,
+ A22 = A11 / det
+ };
+ }
+
+ ///
+ /// Gets a value indicating the determinant of this matrix.
+ ///
+ private double Determinant
+ {
+ get
+ {
+ return A22 * A11 - A21 * A12;
+ }
+ }
+ }
+ }
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/AsyncTileFetcher.cs
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/AsyncTileFetcher.cs (.../AsyncTileFetcher.cs) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/AsyncTileFetcher.cs (.../AsyncTileFetcher.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -34,6 +34,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/TileFetcher.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
public class AsyncTileFetcher : IDisposable
{
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/NoopTileCache.cs
===================================================================
diff -u -r7cc1fd960a912443ccc3c6995eccb5673d1d8d22 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/NoopTileCache.cs (.../NoopTileCache.cs) (revision 7cc1fd960a912443ccc3c6995eccb5673d1d8d22)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/NoopTileCache.cs (.../NoopTileCache.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -29,6 +29,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/TileFetcher.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
internal class NoopTileCache : ITileCache
{
Index: Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/TileReceivedEventArgs.cs
===================================================================
diff -u -r7cc1fd960a912443ccc3c6995eccb5673d1d8d22 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/TileReceivedEventArgs.cs (.../TileReceivedEventArgs.cs) (revision 7cc1fd960a912443ccc3c6995eccb5673d1d8d22)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/BruTile/TileFetching/TileReceivedEventArgs.cs (.../TileReceivedEventArgs.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -29,6 +29,7 @@
///
///
/// Original source: https://github.com/FObermaier/DotSpatial.Plugins/blob/master/DotSpatial.Plugins.BruTileLayer/TileReceivedEventArgs.cs
+ /// Original license: http://www.apache.org/licenses/LICENSE-2.0.html
///
public class TileReceivedEventArgs : EventArgs
{
Index: Core/Components/src/Core.Components.DotSpatial/Properties/Resources.Designer.cs
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/src/Core.Components.DotSpatial/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -99,5 +99,14 @@
return ResourceManager.GetString("AsyncTileFetcher_Number_of_tiles_for_memory_cache_cannot_be_negative", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Ongeldige transformatie parameters: transformatie moet omkeerbaar zijn..
+ ///
+ internal static string WorldFile_Not_invertable_transformation_arguments_error {
+ get {
+ return ResourceManager.GetString("WorldFile_Not_invertable_transformation_arguments_error", resourceCulture);
+ }
+ }
}
}
Index: Core/Components/src/Core.Components.DotSpatial/Properties/Resources.resx
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/src/Core.Components.DotSpatial/Properties/Resources.resx (.../Resources.resx) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/src/Core.Components.DotSpatial/Properties/Resources.resx (.../Resources.resx) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -104,4 +104,7 @@
Het minimale aantal kaart tegels voor de geheugen cache moet kleiner zijn dan het maximale aantal kaart tegels.
+
+ Ongeldige transformatie parameters: transformatie moet omkeerbaar zijn.
+
\ No newline at end of file
Index: Core/Components/test/Core.Components.DotSpatial.Test/Core.Components.DotSpatial.Test.csproj
===================================================================
diff -u -r8416d930ad31ae0548ebbab33449567fb0bb8168 -rc0ec9f5dc0c96437c4088eea1284fe2cc33bfddd
--- Core/Components/test/Core.Components.DotSpatial.Test/Core.Components.DotSpatial.Test.csproj (.../Core.Components.DotSpatial.Test.csproj) (revision 8416d930ad31ae0548ebbab33449567fb0bb8168)
+++ Core/Components/test/Core.Components.DotSpatial.Test/Core.Components.DotSpatial.Test.csproj (.../Core.Components.DotSpatial.Test.csproj) (revision c0ec9f5dc0c96437c4088eea1284fe2cc33bfddd)
@@ -92,6 +92,9 @@
+
+
+
@@ -103,6 +106,11 @@
+
+ True
+ True
+ Resources.resx
+
@@ -135,6 +143,21 @@
Designer
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\Resources\source.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\target.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\abacus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
Index: Core/Components/test/Core.Components.DotSpatial.Test/Resources/abacus.png
===================================================================
diff -u
Binary files differ
Index: Core/Components/test/Core.Components.DotSpatial.Test/Resources/source.png
===================================================================
diff -u
Binary files differ
Index: Core/Components/test/Core.Components.DotSpatial.Test/Resources/target.png
===================================================================
diff -u
Binary files differ