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,37 +19,37 @@ namespace MapControl
|
|||
CrsId = "AUTO2:97001"; // GeoServer non-standard CRS ID
|
||||
}
|
||||
|
||||
public override Point LocationToPoint(Location location)
|
||||
public override Point LocationToMap(Location location)
|
||||
{
|
||||
if (location.Equals(ProjectionCenter))
|
||||
if (location.Equals(Center))
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
||||
double azimuth, distance;
|
||||
|
||||
GetAzimuthDistance(ProjectionCenter, location, out azimuth, out distance);
|
||||
GetAzimuthDistance(Center, location, out azimuth, out distance);
|
||||
|
||||
var mapDistance = distance < Math.PI / 2d
|
||||
? Math.Tan(distance) * TrueScale * 180d / Math.PI
|
||||
? Math.Tan(distance) * UnitsPerDegree * 180d / Math.PI
|
||||
: double.PositiveInfinity;
|
||||
|
||||
return new Point(mapDistance * Math.Sin(azimuth), mapDistance * Math.Cos(azimuth));
|
||||
}
|
||||
|
||||
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 azimuth = Math.Atan2(point.X, point.Y);
|
||||
var mapDistance = Math.Sqrt(point.X * point.X + point.Y * point.Y);
|
||||
|
||||
var distance = Math.Atan(mapDistance / (TrueScale * 180d / Math.PI));
|
||||
var distance = Math.Atan(mapDistance / (UnitsPerDegree * 180d / Math.PI));
|
||||
|
||||
return GetLocation(ProjectionCenter, azimuth, distance);
|
||||
return GetLocation(Center, azimuth, distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue