mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Removed incorrect TransverseMercatorProjection
This commit is contained in:
parent
47ff9096d1
commit
954451fb34
|
|
@ -32,6 +32,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||
Directory.Build.props = Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MapProjections", "MapProjections", "{06F11C1C-FDA0-4873-A32E-04E3711505B3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapProjections.UWP", "MapProjections\UWP\MapProjections.UWP.csproj", "{9EE69591-5EDC-45E3-893E-2F9A4B82D538}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapProjections.WinUI", "MapProjections\WinUI\MapProjections.WinUI.csproj", "{CA8CC262-58A2-41E6-B435-7648E6EB030E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapProjections.WPF", "MapProjections\WPF\MapProjections.WPF.csproj", "{32648D70-5950-4DD4-B46C-154409A98504}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -120,6 +128,30 @@ Global
|
|||
{DFFE8E49-AA07-457E-A459-99326B44F828}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DFFE8E49-AA07-457E-A459-99326B44F828}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DFFE8E49-AA07-457E-A459-99326B44F828}.Release|x64.Build.0 = Release|Any CPU
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538}.Release|x64.Build.0 = Release|Any CPU
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{32648D70-5950-4DD4-B46C-154409A98504}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{32648D70-5950-4DD4-B46C-154409A98504}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{32648D70-5950-4DD4-B46C-154409A98504}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{32648D70-5950-4DD4-B46C-154409A98504}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{32648D70-5950-4DD4-B46C-154409A98504}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{32648D70-5950-4DD4-B46C-154409A98504}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{32648D70-5950-4DD4-B46C-154409A98504}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{32648D70-5950-4DD4-B46C-154409A98504}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -134,6 +166,9 @@ Global
|
|||
{9B2886B0-D2A8-479B-B52E-1C7B63CAB97E} = {ABFA5526-FCE4-47C9-94F4-84D5F59EECA8}
|
||||
{A877A741-9FF5-453D-89C8-3BE7A94D74C1} = {ABFA5526-FCE4-47C9-94F4-84D5F59EECA8}
|
||||
{DFFE8E49-AA07-457E-A459-99326B44F828} = {ABFA5526-FCE4-47C9-94F4-84D5F59EECA8}
|
||||
{9EE69591-5EDC-45E3-893E-2F9A4B82D538} = {06F11C1C-FDA0-4873-A32E-04E3711505B3}
|
||||
{CA8CC262-58A2-41E6-B435-7648E6EB030E} = {06F11C1C-FDA0-4873-A32E-04E3711505B3}
|
||||
{32648D70-5950-4DD4-B46C-154409A98504} = {06F11C1C-FDA0-4873-A32E-04E3711505B3}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {458346DD-B23F-4FDC-8F9D-A10F1882A4DB}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// ETRS89 UTM Projection with zone number.
|
||||
/// </summary>
|
||||
public class Etrs89UtmProjection : TransverseMercatorProjection
|
||||
{
|
||||
public const int FirstZone = 28;
|
||||
public const int LastZone = 38;
|
||||
public const int FirstZoneEpsgCode = 25800 + FirstZone;
|
||||
public const int LastZoneEpsgCode = 25800 + LastZone;
|
||||
|
||||
public int Zone { get; }
|
||||
|
||||
public Etrs89UtmProjection(int zone)
|
||||
{
|
||||
if (zone < FirstZone || zone > LastZone)
|
||||
{
|
||||
throw new ArgumentException($"Invalid ETRS89 UTM zone {zone}.", nameof(zone));
|
||||
}
|
||||
|
||||
Zone = zone;
|
||||
CrsId = $"EPSG:{25800 + Zone}";
|
||||
|
||||
// GRS 1980
|
||||
EquatorialRadius = 6378137d;
|
||||
Flattening = 1d / 298.257222101;
|
||||
ScaleFactor = DefaultScaleFactor;
|
||||
CentralMeridian = Zone * 6d - 183d;
|
||||
FalseEasting = 5e5;
|
||||
FalseNorthing = 0d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -126,8 +126,6 @@ namespace MapControl
|
|||
var r1 = (Math.Atan2(dy1, dx1) * 180d / Math.PI + 180d) % 360d - 180d;
|
||||
var r2 = (Math.Atan2(-dx2, dy2) * 180d / Math.PI + 180d) % 360d - 180d;
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"{r1}, {r2}");
|
||||
|
||||
rotatedRect = new Tuple<Rect, double>(new Rect(x, y, width, height), latLonBox.Rotation + (r1 + r2) / 2d);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,9 +35,6 @@ namespace MapControl
|
|||
case UpsSouthProjection.DefaultCrsId:
|
||||
return new UpsSouthProjection();
|
||||
|
||||
case Wgs84AutoUtmProjection.DefaultCrsId:
|
||||
return new Wgs84AutoUtmProjection();
|
||||
|
||||
case OrthographicProjection.DefaultCrsId:
|
||||
return new OrthographicProjection();
|
||||
|
||||
|
|
@ -53,29 +50,6 @@ namespace MapControl
|
|||
case AzimuthalEquidistantProjection.DefaultCrsId:
|
||||
return new AzimuthalEquidistantProjection();
|
||||
|
||||
default:
|
||||
return crsId.StartsWith("EPSG:") && int.TryParse(crsId.Substring(5), out int epsgCode)
|
||||
? GetProjection(epsgCode)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual MapProjection GetProjection(int epsgCode)
|
||||
{
|
||||
switch (epsgCode)
|
||||
{
|
||||
case var c when c >= Etrs89UtmProjection.FirstZoneEpsgCode && c <= Etrs89UtmProjection.LastZoneEpsgCode:
|
||||
return new Etrs89UtmProjection(epsgCode % 100);
|
||||
|
||||
case var c when c >= Nad83UtmProjection.FirstZoneEpsgCode && c <= Nad83UtmProjection.LastZoneEpsgCode:
|
||||
return new Nad83UtmProjection(epsgCode % 100);
|
||||
|
||||
case var c when c >= Wgs84UtmProjection.FirstZoneNorthEpsgCode && c <= Wgs84UtmProjection.LastZoneNorthEpsgCode:
|
||||
return new Wgs84UtmProjection(epsgCode % 100, true);
|
||||
|
||||
case var c when c >= Wgs84UtmProjection.FirstZoneSouthEpsgCode && c <= Wgs84UtmProjection.LastZoneSouthEpsgCode:
|
||||
return new Wgs84UtmProjection(epsgCode % 100, false);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// NAD83 UTM Projection with zone number.
|
||||
/// </summary>
|
||||
public class Nad83UtmProjection : TransverseMercatorProjection
|
||||
{
|
||||
public const int FirstZone = 1;
|
||||
public const int LastZone = 23;
|
||||
public const int FirstZoneEpsgCode = 26900 + FirstZone;
|
||||
public const int LastZoneEpsgCode = 26900 + LastZone;
|
||||
|
||||
public int Zone { get; }
|
||||
|
||||
public Nad83UtmProjection(int zone)
|
||||
{
|
||||
if (zone < FirstZone || zone > LastZone)
|
||||
{
|
||||
throw new ArgumentException($"Invalid NAD83 UTM zone {zone}.", nameof(zone));
|
||||
}
|
||||
|
||||
Zone = zone;
|
||||
CrsId = $"EPSG:{26900 + Zone}";
|
||||
|
||||
// GRS 1980
|
||||
EquatorialRadius = 6378137d;
|
||||
Flattening = 1d / 298.257222101;
|
||||
ScaleFactor = DefaultScaleFactor;
|
||||
CentralMeridian = Zone * 6d - 183d;
|
||||
FalseEasting = 5e5;
|
||||
FalseNorthing = 0d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Universal Transverse Mercator Projection.
|
||||
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/pp/1395/report.pdf), p.57-64.
|
||||
/// </summary>
|
||||
public class TransverseMercatorProjection : MapProjection
|
||||
{
|
||||
public const double DefaultScaleFactor = 0.9996;
|
||||
|
||||
public TransverseMercatorProjection()
|
||||
{
|
||||
Type = MapProjectionType.TransverseCylindrical;
|
||||
}
|
||||
|
||||
public double EquatorialRadius { get; set; } = Wgs84EquatorialRadius;
|
||||
public double Flattening { get; set; } = Wgs84Flattening;
|
||||
public double ScaleFactor { get; set; } = DefaultScaleFactor;
|
||||
public double CentralMeridian { get; set; }
|
||||
public double FalseEasting { get; set; }
|
||||
public double FalseNorthing { get; set; }
|
||||
|
||||
public override Point GetRelativeScale(Location location)
|
||||
{
|
||||
var k = ScaleFactor;
|
||||
|
||||
if (location.Latitude > -90d && location.Latitude < 90d)
|
||||
{
|
||||
var lat = location.Latitude * Math.PI / 180d;
|
||||
var lon = (location.Longitude - CentralMeridian) * Math.PI / 180d;
|
||||
var cosLat = Math.Cos(lat);
|
||||
var tanLat = Math.Tan(lat);
|
||||
|
||||
var e_2 = (2d - Flattening) * Flattening;
|
||||
var E_2 = e_2 / (1d - e_2); // p.61 (8-12)
|
||||
var T = tanLat * tanLat; // p.61 (8-13)
|
||||
var C = E_2 * cosLat * cosLat; // p.61 (8-14)
|
||||
var A = lon * cosLat; // p.61 (8-15)
|
||||
|
||||
var T_2 = T * T;
|
||||
var C_2 = C * C;
|
||||
var A_2 = A * A;
|
||||
var A_4 = A_2 * A_2;
|
||||
var A_6 = A_2 * A_4;
|
||||
|
||||
k = ScaleFactor * (1d
|
||||
+ (1d + C) * A_2 / 2d
|
||||
+ (5d - 4d * T + 42d * C + 13d * C_2 + 28d * E_2) * A_4 / 24d
|
||||
+ (61d - 148d * T + 16d * T_2) * A_6 / 720d); // p.61 (8-11)
|
||||
}
|
||||
|
||||
return new Point(k, k);
|
||||
}
|
||||
|
||||
public override Point? LocationToMap(Location location)
|
||||
{
|
||||
double x, y;
|
||||
|
||||
var lat = location.Latitude * Math.PI / 180d;
|
||||
var e_2 = (2d - Flattening) * Flattening;
|
||||
var e_4 = e_2 * e_2;
|
||||
var e_6 = e_2 * e_4;
|
||||
var M = EquatorialRadius * (1d - e_2 / 4d - 3d * e_4 / 64d - 5d * e_6 / 256d) * lat; // p.61 (3-21)
|
||||
|
||||
if (lat > -Math.PI / 2d && lat < Math.PI / 2d)
|
||||
{
|
||||
var lon = (location.Longitude - CentralMeridian) * Math.PI / 180d;
|
||||
var sinLat = Math.Sin(lat);
|
||||
var cosLat = Math.Cos(lat);
|
||||
var tanLat = Math.Tan(lat);
|
||||
|
||||
var E_2 = e_2 / (1d - e_2); // p.61 (8-12)
|
||||
var T = tanLat * tanLat; // p.61 (8-13)
|
||||
var C = E_2 * cosLat * cosLat; // p.61 (8-14)
|
||||
var A = lon * cosLat; // p.61 (8-15)
|
||||
|
||||
var N = EquatorialRadius / Math.Sqrt(1d - e_2 * sinLat * sinLat); // p.61 (4-20)
|
||||
|
||||
M += EquatorialRadius *
|
||||
(-(3d * e_2 / 8d + 3d * e_4 / 32d + 45d * e_6 / 1024d) * Math.Sin(2d * lat)
|
||||
+ (15d * e_4 / 256d + 45d * e_6 / 1024d) * Math.Sin(4d * lat)
|
||||
- (35d * e_6 / 3072d) * Math.Sin(6d * lat)); // p.61 (3-21)
|
||||
|
||||
var T_2 = T * T;
|
||||
var C_2 = C * C;
|
||||
var A_2 = A * A;
|
||||
var A_3 = A * A_2;
|
||||
var A_4 = A * A_3;
|
||||
var A_5 = A * A_4;
|
||||
var A_6 = A * A_5;
|
||||
|
||||
x = ScaleFactor * N * (A
|
||||
+ (1d - T + C) * A_3 / 6d
|
||||
+ (5d - 18d * T + T_2 + 72d * C - 58d * E_2) * A_5 / 120d); // p.61 (8-9)
|
||||
|
||||
y = ScaleFactor * (M + N * tanLat * (A_2 / 2d
|
||||
+ (5d - T + 9d * C + 4d * C_2) * A_4 / 24d
|
||||
+ (61d - 58d * T + T_2 + 600d * C - 330d * E_2) * A_6 / 720d)); // p.61 (8-10)
|
||||
}
|
||||
else
|
||||
{
|
||||
x = 0d;
|
||||
y = ScaleFactor * M;
|
||||
}
|
||||
|
||||
return new Point(x + FalseEasting, y + FalseNorthing);
|
||||
}
|
||||
|
||||
public override Location MapToLocation(Point point)
|
||||
{
|
||||
var x = point.X - FalseEasting;
|
||||
var y = point.Y - FalseNorthing;
|
||||
|
||||
var e_2 = (2d - Flattening) * Flattening;
|
||||
var e_4 = e_2 * e_2;
|
||||
var e_6 = e_2 * e_4;
|
||||
|
||||
var M = y / ScaleFactor; // p.63 (8-20)
|
||||
var mu = M / (EquatorialRadius * (1d - e_2 / 4d - 3d * e_4 / 64d - 5d * e_6 / 256d)); // p.63 (7-19)
|
||||
var e1 = (1d - Math.Sqrt(1d - e_2)) / (1d + Math.Sqrt(1d - e_2)); // p.63 (3-24)
|
||||
var e1_2 = e1 * e1;
|
||||
var e1_3 = e1 * e1_2;
|
||||
var e1_4 = e1 * e1_3;
|
||||
|
||||
var lat1 = mu
|
||||
+ (3d * e1 / 2d - 27d * e1_3 / 32d) * Math.Sin(2d * mu)
|
||||
+ (21d * e1_2 / 16d - 55d * e1_4 / 32d) * Math.Sin(4d * mu)
|
||||
+ (151d * e1_3 / 96d) * Math.Sin(6d * mu)
|
||||
+ (1097d * e1_4 / 512d) * Math.Sin(8d * mu); // p.63 (3-26)
|
||||
|
||||
var sinLat1 = Math.Sin(lat1);
|
||||
var cosLat1 = Math.Cos(lat1);
|
||||
var tanLat1 = Math.Tan(lat1);
|
||||
|
||||
var E_2 = e_2 / (1d - e_2); // p.64 (8-12)
|
||||
var C1 = E_2 * cosLat1 * cosLat1; // p.64 (8-21)
|
||||
var T1 = tanLat1 * tanLat1; // p.64 (8-22)
|
||||
var N1 = EquatorialRadius / Math.Sqrt(1d - e_2 * sinLat1 * sinLat1); // p.64 (8-23)
|
||||
var R1 = EquatorialRadius * (1d - e_2) / Math.Pow(1d - e_2 * sinLat1 * sinLat1, 1.5); // p.64 (8-24)
|
||||
var D = x / (N1 * ScaleFactor); // p.64 (8-25)
|
||||
|
||||
var C1_2 = C1 * C1;
|
||||
var T1_2 = T1 * T1;
|
||||
var D_2 = D * D;
|
||||
var D_3 = D * D_2;
|
||||
var D_4 = D * D_3;
|
||||
var D_5 = D * D_4;
|
||||
var D_6 = D * D_5;
|
||||
|
||||
var lat = lat1 - (N1 * tanLat1 / R1) * (D_2 / 2d
|
||||
- (5d + 3d * T1 + 10d * C1 - 4d * C1_2 - 9d * E_2) * D_4 / 24d
|
||||
+ (61d + 90d * T1 + 298d * C1 + 45d * T1_2 - 252d * E_2 - 3d * C1_2) * D_6 / 720d); // p.63 (8-17)
|
||||
|
||||
var lon = (D
|
||||
- (1d + 2d * T1 + C1) * D_3 / 6d
|
||||
+ (5d - 2d * C1 + 28d * T1 - 3d * C1_2 + 8d * E_2 + 24d * T1_2) * D_5 / 120d)
|
||||
/ cosLat1; // p.63 (8-18)
|
||||
|
||||
return new Location(lat * 180d / Math.PI, lon * 180d / Math.PI + CentralMeridian);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// WGS84 UTM Projection with zone number and north/south flag.
|
||||
/// </summary>
|
||||
public class Wgs84UtmProjection : TransverseMercatorProjection
|
||||
{
|
||||
public const int FirstZone = 1;
|
||||
public const int LastZone = 60;
|
||||
public const int FirstZoneNorthEpsgCode = 32600 + FirstZone;
|
||||
public const int LastZoneNorthEpsgCode = 32600 + LastZone;
|
||||
public const int FirstZoneSouthEpsgCode = 32700 + FirstZone;
|
||||
public const int LastZoneSouthEpsgCode = 32700 + LastZone;
|
||||
|
||||
public int Zone { get; private set; }
|
||||
public bool IsNorth { get; private set; }
|
||||
|
||||
public Wgs84UtmProjection(int zone, bool north)
|
||||
{
|
||||
SetZone(zone, north);
|
||||
}
|
||||
|
||||
protected void SetZone(int zone, bool north)
|
||||
{
|
||||
if (zone < FirstZone || zone > LastZone)
|
||||
{
|
||||
throw new ArgumentException($"Invalid WGS84 UTM zone {zone}.", nameof(zone));
|
||||
}
|
||||
|
||||
Zone = zone;
|
||||
IsNorth = north;
|
||||
CrsId = $"EPSG:{(north ? 32600 : 32700) + zone}";
|
||||
EquatorialRadius = Wgs84EquatorialRadius;
|
||||
Flattening = Wgs84Flattening;
|
||||
ScaleFactor = DefaultScaleFactor;
|
||||
CentralMeridian = Zone * 6d - 183d;
|
||||
FalseEasting = 5e5;
|
||||
FalseNorthing = IsNorth ? 0d : 1e7;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WGS84 UTM Projection with automatic zone selection from projection center.
|
||||
/// </summary>
|
||||
public class Wgs84AutoUtmProjection : Wgs84UtmProjection
|
||||
{
|
||||
public const string DefaultCrsId = "AUTO2:42001";
|
||||
|
||||
private readonly string autoCrsId;
|
||||
|
||||
public Wgs84AutoUtmProjection()
|
||||
: this(DefaultCrsId)
|
||||
{
|
||||
// XAML needs parameterless constructor
|
||||
}
|
||||
|
||||
public Wgs84AutoUtmProjection(string crsId)
|
||||
: base(31, true)
|
||||
{
|
||||
autoCrsId = crsId;
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
CrsId = autoCrsId;
|
||||
}
|
||||
}
|
||||
|
||||
public override Location Center
|
||||
{
|
||||
get => base.Center;
|
||||
protected internal set
|
||||
{
|
||||
if (!Equals(base.Center, value))
|
||||
{
|
||||
base.Center = value;
|
||||
|
||||
var lon = Location.NormalizeLongitude(value.Longitude);
|
||||
var zone = (int)Math.Floor(lon / 6d) + 31;
|
||||
var north = value.Latitude >= 0d;
|
||||
|
||||
if (Zone != zone || IsNorth != north)
|
||||
{
|
||||
SetZone(zone, north);
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
CrsId = autoCrsId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,9 +68,6 @@
|
|||
<Compile Include="..\Shared\EquirectangularProjection.cs">
|
||||
<Link>EquirectangularProjection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\Etrs89UtmProjection.cs">
|
||||
<Link>Etrs89UtmProjection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\FilePath.cs">
|
||||
<Link>FilePath.cs</Link>
|
||||
</Compile>
|
||||
|
|
@ -143,9 +140,6 @@
|
|||
<Compile Include="..\Shared\MapTileLayerBase.cs">
|
||||
<Link>MapTileLayerBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\Nad83UtmProjection.cs">
|
||||
<Link>Nad83UtmProjection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\OrthographicProjection.cs">
|
||||
<Link>OrthographicProjection.cs</Link>
|
||||
</Compile>
|
||||
|
|
@ -179,9 +173,6 @@
|
|||
<Compile Include="..\Shared\Timer.cs">
|
||||
<Link>Timer.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\TransverseMercatorProjection.cs">
|
||||
<Link>TransverseMercatorProjection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\ViewportChangedEventArgs.cs">
|
||||
<Link>ViewportChangedEventArgs.cs</Link>
|
||||
</Compile>
|
||||
|
|
@ -191,9 +182,6 @@
|
|||
<Compile Include="..\Shared\WebMercatorProjection.cs">
|
||||
<Link>WebMercatorProjection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\Wgs84UtmProjection.cs">
|
||||
<Link>Wgs84UtmProjection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\WmsImageLayer.cs">
|
||||
<Link>WmsImageLayer.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -21,23 +21,36 @@ namespace MapControl.Projections
|
|||
|
||||
public override MapProjection GetProjection(string crsId)
|
||||
{
|
||||
MapProjection projection = null;
|
||||
|
||||
switch (crsId)
|
||||
{
|
||||
case MapControl.WebMercatorProjection.DefaultCrsId:
|
||||
return new WebMercatorProjection();
|
||||
projection = new WebMercatorProjection();
|
||||
break;
|
||||
|
||||
case MapControl.WorldMercatorProjection.DefaultCrsId:
|
||||
return new WorldMercatorProjection();
|
||||
projection = new WorldMercatorProjection();
|
||||
break;
|
||||
|
||||
case MapControl.Wgs84AutoUtmProjection.DefaultCrsId:
|
||||
return new Wgs84AutoUtmProjection();
|
||||
case Wgs84AutoUtmProjection.DefaultCrsId:
|
||||
projection = new Wgs84AutoUtmProjection();
|
||||
break;
|
||||
|
||||
default:
|
||||
return base.GetProjection(crsId);
|
||||
}
|
||||
projection = base.GetProjection(crsId);
|
||||
break;
|
||||
}
|
||||
|
||||
public override MapProjection GetProjection(int epsgCode)
|
||||
if (projection == null && crsId.StartsWith("EPSG:") && int.TryParse(crsId.Substring(5), out int epsgCode))
|
||||
{
|
||||
projection = GetProjection(epsgCode);
|
||||
}
|
||||
|
||||
return projection;
|
||||
}
|
||||
|
||||
public virtual MapProjection GetProjection(int epsgCode)
|
||||
{
|
||||
switch (epsgCode)
|
||||
{
|
||||
|
|
@ -62,7 +75,7 @@ namespace MapControl.Projections
|
|||
default:
|
||||
return CoordinateSystemWkts.TryGetValue(epsgCode, out string wkt)
|
||||
? new GeoApiProjection(wkt)
|
||||
: base.GetProjection(epsgCode);
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,11 @@ namespace MapControl.Projections
|
|||
/// </summary>
|
||||
public class Wgs84AutoUtmProjection : Wgs84UtmProjection
|
||||
{
|
||||
public const string DefaultCrsId = "AUTO2:42001";
|
||||
|
||||
private readonly string autoCrsId;
|
||||
|
||||
public Wgs84AutoUtmProjection(string crsId = MapControl.Wgs84AutoUtmProjection.DefaultCrsId)
|
||||
public Wgs84AutoUtmProjection(string crsId = DefaultCrsId)
|
||||
: base(31, true)
|
||||
{
|
||||
autoCrsId = crsId;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ namespace SampleApplication
|
|||
{
|
||||
static MainPage()
|
||||
{
|
||||
MapProjectionFactory.Instance = new MapControl.Projections.GeoApiProjectionFactory();
|
||||
|
||||
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(ApplicationData.Current.LocalCacheFolder);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@
|
|||
<Project>{951bc5d2-d653-42d9-9a91-21dc50de0182}</Project>
|
||||
<Name>MapControl.UWP</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\MapProjections\UWP\MapProjections.UWP.csproj">
|
||||
<Project>{9ee69591-5edc-45e3-893e-2f9a4b82d538}</Project>
|
||||
<Name>MapProjections.UWP</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\MapUiTools\UWP\MapUiTools.UWP.csproj">
|
||||
<Project>{dffe8e49-aa07-457e-a459-99326b44f828}</Project>
|
||||
<Name>MapUiTools.UWP</Name>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ namespace SampleApplication
|
|||
{
|
||||
static MainWindow()
|
||||
{
|
||||
MapProjectionFactory.Instance = new MapControl.Projections.GeoApiProjectionFactory();
|
||||
|
||||
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MapControl\WinUI\MapControl.WinUI.csproj" />
|
||||
<ProjectReference Include="..\..\MapProjections\WinUI\MapProjections.WinUI.csproj" />
|
||||
<ProjectReference Include="..\..\MapUiTools\WinUI\MapUiTools.WinUI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ namespace SampleApplication
|
|||
{
|
||||
static MainWindow()
|
||||
{
|
||||
MapProjectionFactory.Instance = new MapControl.Projections.GeoApiProjectionFactory();
|
||||
|
||||
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MapControl\WPF\MapControl.WPF.csproj" />
|
||||
<ProjectReference Include="..\..\MapProjections\WPF\MapProjections.WPF.csproj" />
|
||||
<ProjectReference Include="..\..\MapUiTools\WPF\MapUiTools.WPF.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue