Updated MapProjections

This commit is contained in:
ClemensFischer 2025-12-13 07:28:45 +01:00
parent e268be2948
commit 4db96b9e83
3 changed files with 9 additions and 9 deletions

View file

@ -96,21 +96,21 @@ namespace MapControl.Projections
public IMathTransform MapToLocationTransform { get; private set; }
public override Point GetRelativeScale(Location location)
public override Point GetRelativeScale(double latitude, double longitude)
{
var k = coordinateSystem?.Projection?.GetParameter("scale_factor")?.Value ?? 1d;
return new Point(k, k);
}
public override Point? LocationToMap(Location location)
public override Point? LocationToMap(double latitude, double longitude)
{
if (LocationToMapTransform == null)
{
throw new InvalidOperationException("The CoordinateSystem property is not set.");
}
var coordinate = LocationToMapTransform.Transform(new Coordinate(location.Longitude, location.Latitude));
var coordinate = LocationToMapTransform.Transform(new Coordinate(longitude, latitude));
if (coordinate == null)
{
@ -120,14 +120,14 @@ namespace MapControl.Projections
return new Point(coordinate.X, coordinate.Y);
}
public override Location MapToLocation(Point point)
public override Location MapToLocation(double x, double y)
{
if (MapToLocationTransform == null)
{
throw new InvalidOperationException("The CoordinateSystem property is not set.");
}
var coordinate = MapToLocationTransform.Transform(new Coordinate(point.X, point.Y));
var coordinate = MapToLocationTransform.Transform(new Coordinate(x, y));
return new Location(coordinate.Y, coordinate.X);
}

View file

@ -19,9 +19,9 @@ namespace MapControl.Projections
CoordinateSystem = ProjectedCoordinateSystem.WebMercator;
}
public override Point GetRelativeScale(Location location)
public override Point GetRelativeScale(double latitude, double longitude)
{
var k = 1d / Math.Cos(location.Latitude * Math.PI / 180d); // p.44 (7-3)
var k = 1d / Math.Cos(latitude * Math.PI / 180d); // p.44 (7-3)
return new Point(k, k);
}

View file

@ -40,9 +40,9 @@ namespace MapControl.Projections
+ "AUTHORITY[\"EPSG\",\"3395\"]]";
}
public override Point GetRelativeScale(Location location)
public override Point GetRelativeScale(double latitude, double longitude)
{
var lat = location.Latitude * Math.PI / 180d;
var lat = latitude * Math.PI / 180d;
var eSinLat = Wgs84Eccentricity * Math.Sin(lat);
var k = Math.Sqrt(1d - eSinLat * eSinLat) / Math.Cos(lat); // p.44 (7-8)