mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update MapProjections
This commit is contained in:
parent
218a85316c
commit
1ccfbb28a4
|
|
@ -3,6 +3,7 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using ProjNet.CoordinateSystems;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace MapControl.Projections
|
||||
|
|
@ -21,7 +22,7 @@ namespace MapControl.Projections
|
|||
|
||||
public bool UseZoneCrsId { get; set; }
|
||||
|
||||
public override Point LocationToMap(Location location)
|
||||
public override Point? LocationToMap(Location location)
|
||||
{
|
||||
UpdateZone();
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ namespace MapControl.Projections
|
|||
{
|
||||
var north = Center.Latitude >= 0d;
|
||||
var lon = Location.NormalizeLongitude(Center.Longitude);
|
||||
var zone = (int)(lon + 180d) / 6 + 1;
|
||||
var zone = (int)Math.Floor(lon / 6d) + 31;
|
||||
|
||||
if (ZoneNumber != zone || ZoneIsNorth != north)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ namespace MapControl.Projections
|
|||
|
||||
public IMathTransform MapToLocationTransform { get; private set; }
|
||||
|
||||
public override Point LocationToMap(Location location)
|
||||
public override Point? LocationToMap(Location location)
|
||||
{
|
||||
if (LocationToMapTransform == null)
|
||||
{
|
||||
|
|
@ -126,6 +126,11 @@ namespace MapControl.Projections
|
|||
var coordinate = LocationToMapTransform.Transform(
|
||||
new Coordinate(location.Longitude, location.Latitude));
|
||||
|
||||
if (coordinate == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Point(coordinate.X * scaleFactor, coordinate.Y * scaleFactor);
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +147,7 @@ namespace MapControl.Projections
|
|||
return new Location(coordinate.Y, coordinate.X);
|
||||
}
|
||||
|
||||
public override string GetBboxValue(Rect rect)
|
||||
public override string GetBboxValue(MapRect rect)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, bboxFormat,
|
||||
rect.X / scaleFactor, rect.Y / scaleFactor,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace MapControl.Projections
|
|||
FalseNorthing = falseNorthing;
|
||||
}
|
||||
|
||||
public override Vector GetRelativeScale(Location location)
|
||||
public override Scale GetRelativeScale(Location location)
|
||||
{
|
||||
var lat = (IsNorth ? location.Latitude : -location.Latitude) * Math.PI / 180d;
|
||||
var a = Wgs84EquatorialRadius;
|
||||
|
|
@ -45,10 +45,10 @@ namespace MapControl.Projections
|
|||
var m = Math.Cos(lat) / Math.Sqrt(1d - eSinLat * eSinLat);
|
||||
var k = rho / (a * m);
|
||||
|
||||
return new Vector(k, k);
|
||||
return new Scale(k, k);
|
||||
}
|
||||
|
||||
public override Point LocationToMap(Location location)
|
||||
public override Point? LocationToMap(Location location)
|
||||
{
|
||||
var lat = location.Latitude * Math.PI / 180d;
|
||||
var lon = location.Longitude * Math.PI / 180d;
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ namespace MapControl.Projections
|
|||
CoordinateSystem = ProjectedCoordinateSystem.WebMercator;
|
||||
}
|
||||
|
||||
public override Vector GetRelativeScale(Location location)
|
||||
public override Scale GetRelativeScale(Location location)
|
||||
{
|
||||
var k = 1d / Math.Cos(location.Latitude * Math.PI / 180d); // p.44 (7-3)
|
||||
|
||||
return new Vector(k, k);
|
||||
return new Scale(k, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,13 +42,13 @@ namespace MapControl.Projections
|
|||
+ "AUTHORITY[\"EPSG\",\"3395\"]]";
|
||||
}
|
||||
|
||||
public override Vector GetRelativeScale(Location location)
|
||||
public override Scale GetRelativeScale(Location location)
|
||||
{
|
||||
var lat = location.Latitude * Math.PI / 180d;
|
||||
var eSinLat = Wgs84Eccentricity * Math.Sin(lat);
|
||||
var k = Math.Sqrt(1d - eSinLat * eSinLat) / Math.Cos(lat); // p.44 (7-8)
|
||||
|
||||
return new Vector(k, k);
|
||||
return new Scale(k, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue