From e22e7e6377833862db2eab556bd1b60a95a20076 Mon Sep 17 00:00:00 2001 From: Stefan Gheorghe Date: Sun, 3 May 2020 12:31:56 +0200 Subject: [PATCH] New SwissTopo map provider+projection --- GMap.NET.Core/GMap.NET.Core.csproj | 2 + .../Etc/SwissTopoProvider.cs | 71 ++++++++ .../GMap.NET.MapProviders/GMapProvider.cs | 158 ++++++++---------- .../SwissTopoProjection.cs | 118 +++++++++++++ 4 files changed, 258 insertions(+), 91 deletions(-) create mode 100644 GMap.NET.Core/GMap.NET.MapProviders/Etc/SwissTopoProvider.cs create mode 100644 GMap.NET.Core/GMap.NET.Projections/SwissTopoProjection.cs diff --git a/GMap.NET.Core/GMap.NET.Core.csproj b/GMap.NET.Core/GMap.NET.Core.csproj index 7a5f8f57..e7fbe7cc 100644 --- a/GMap.NET.Core/GMap.NET.Core.csproj +++ b/GMap.NET.Core/GMap.NET.Core.csproj @@ -236,6 +236,7 @@ + @@ -294,6 +295,7 @@ + diff --git a/GMap.NET.Core/GMap.NET.MapProviders/Etc/SwissTopoProvider.cs b/GMap.NET.Core/GMap.NET.MapProviders/Etc/SwissTopoProvider.cs new file mode 100644 index 00000000..ef3d2b0f --- /dev/null +++ b/GMap.NET.Core/GMap.NET.MapProviders/Etc/SwissTopoProvider.cs @@ -0,0 +1,71 @@ +namespace GMap.NET.MapProviders +{ + using System; + using GMap.NET.Projections; + + public class SwissTopoProvider : GMapProvider + { + private readonly Guid _id = new Guid("0F1F1EC5-B297-4B5B-8EB4-27AA403D1860"); + private readonly string _name = "SwissTopo"; + private readonly Random _randomGen; + + public override Guid Id + { + get { return _id; } + } + + public static readonly SwissTopoProvider Instance; + + SwissTopoProvider() + { + // Terms of use: https://api3.geo.admin.ch/api/terms_of_use.html + + MaxZoom = null; + _randomGen = new Random(); + } + + private GMapProvider[] _overlays; + + string MakeTileImageUrl(GPoint pos, int zoom) + { + int serverMaxDigits = 10; // from wmts[0-9].geo.admin.ch + var serverDigit = _randomGen.Next() % serverMaxDigits; + var layerName = "ch.swisstopo.pixelkarte-farbe"; + var tileMatrixSet = "2056"; + var time = "current"; + + // ://////