Avoid unnecessary Location and Point allocations

This commit is contained in:
ClemensFischer 2025-12-12 21:28:45 +01:00
parent f44d2207e5
commit e268be2948
20 changed files with 205 additions and 172 deletions

View file

@ -27,25 +27,25 @@ namespace MapControl
CrsId = crsId;
}
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);
}
public override Point? LocationToMap(Location location)
public override Point? LocationToMap(double latitude, double longitude)
{
return new Point(
Wgs84MeterPerDegree * location.Longitude,
Wgs84MeterPerDegree * LatitudeToY(location.Latitude));
Wgs84MeterPerDegree * longitude,
Wgs84MeterPerDegree * LatitudeToY(latitude));
}
public override Location MapToLocation(Point point)
public override Location MapToLocation(double x, double y)
{
return new Location(
YToLatitude(point.Y / Wgs84MeterPerDegree),
point.X / Wgs84MeterPerDegree);
YToLatitude(y / Wgs84MeterPerDegree),
x / Wgs84MeterPerDegree);
}
public static double LatitudeToY(double latitude)