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

@ -28,25 +28,19 @@ namespace MapControl
CrsId = crsId;
}
public override Point GetRelativeScale(Location location)
public override Point GetRelativeScale(double latitude, double longitude)
{
return new Point(
1d / Math.Cos(location.Latitude * Math.PI / 180d),
1d);
return new Point(1d / Math.Cos(latitude * Math.PI / 180d), 1d);
}
public override Point? LocationToMap(Location location)
public override Point? LocationToMap(double latitude, double longitude)
{
return new Point(
Wgs84MeterPerDegree * location.Longitude,
Wgs84MeterPerDegree * location.Latitude);
return new Point(Wgs84MeterPerDegree * longitude, Wgs84MeterPerDegree * latitude);
}
public override Location MapToLocation(Point point)
public override Location MapToLocation(double x, double y)
{
return new Location(
point.Y / Wgs84MeterPerDegree,
point.X / Wgs84MeterPerDegree);
return new Location(y / Wgs84MeterPerDegree, x / Wgs84MeterPerDegree);
}
}
}