mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
Version 5.0: Separated map projection and view transform.
This commit is contained in:
parent
53723844a0
commit
c7cb2efcdb
47 changed files with 401 additions and 382 deletions
|
|
@ -19,31 +19,31 @@ namespace MapControl
|
|||
CrsId = "AUTO2:42003";
|
||||
}
|
||||
|
||||
public override Point LocationToPoint(Location location)
|
||||
public override Point LocationToMap(Location location)
|
||||
{
|
||||
if (location.Equals(ProjectionCenter))
|
||||
if (location.Equals(Center))
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
||||
var lat0 = ProjectionCenter.Latitude * Math.PI / 180d;
|
||||
var lat0 = Center.Latitude * Math.PI / 180d;
|
||||
var lat = location.Latitude * Math.PI / 180d;
|
||||
var dLon = (location.Longitude - ProjectionCenter.Longitude) * Math.PI / 180d;
|
||||
var s = TrueScale * 180d / Math.PI;
|
||||
var dLon = (location.Longitude - Center.Longitude) * Math.PI / 180d;
|
||||
var s = UnitsPerDegree * 180d / Math.PI;
|
||||
|
||||
return new Point(
|
||||
s * Math.Cos(lat) * Math.Sin(dLon),
|
||||
s * (Math.Cos(lat0) * Math.Sin(lat) - Math.Sin(lat0) * Math.Cos(lat) * Math.Cos(dLon)));
|
||||
}
|
||||
|
||||
public override Location PointToLocation(Point point)
|
||||
public override Location MapToLocation(Point point)
|
||||
{
|
||||
if (point.X == 0d && point.Y == 0d)
|
||||
{
|
||||
return new Location(ProjectionCenter.Latitude, ProjectionCenter.Longitude);
|
||||
return new Location(Center.Latitude, Center.Longitude);
|
||||
}
|
||||
|
||||
var s = TrueScale * 180d / Math.PI;
|
||||
var s = UnitsPerDegree * 180d / Math.PI;
|
||||
var x = point.X / s;
|
||||
var y = point.Y / s;
|
||||
var r2 = x * x + y * y;
|
||||
|
|
@ -57,13 +57,13 @@ namespace MapControl
|
|||
var sinC = r;
|
||||
var cosC = Math.Sqrt(1 - r2);
|
||||
|
||||
var lat0 = ProjectionCenter.Latitude * Math.PI / 180d;
|
||||
var lat0 = Center.Latitude * Math.PI / 180d;
|
||||
var cosLat0 = Math.Cos(lat0);
|
||||
var sinLat0 = Math.Sin(lat0);
|
||||
|
||||
return new Location(
|
||||
180d / Math.PI * Math.Asin(cosC * sinLat0 + y * sinC * cosLat0 / r),
|
||||
180d / Math.PI * Math.Atan2(x * sinC, r * cosC * cosLat0 - y * sinC * sinLat0) + ProjectionCenter.Longitude);
|
||||
180d / Math.PI * Math.Atan2(x * sinC, r * cosC * cosLat0 - y * sinC * sinLat0) + Center.Longitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue