mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 5.0.1: Dropped MapProjection.UnitsPerDegree
This commit is contained in:
parent
2b41d298f4
commit
43c33c2564
|
|
@ -18,19 +18,19 @@ namespace MapControl
|
|||
|
||||
public override Point LocationToMap(Location location)
|
||||
{
|
||||
var xScale = UnitsPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d);
|
||||
var xScale = Wgs84MetersPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d);
|
||||
|
||||
return new Point(
|
||||
xScale * (location.Longitude - Center.Longitude),
|
||||
UnitsPerDegree * location.Latitude);
|
||||
Wgs84MetersPerDegree * location.Latitude);
|
||||
}
|
||||
|
||||
public override Location MapToLocation(Point point)
|
||||
{
|
||||
var xScale = UnitsPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d);
|
||||
var xScale = Wgs84MetersPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d);
|
||||
|
||||
return new Location(
|
||||
point.Y / UnitsPerDegree,
|
||||
point.Y / Wgs84MetersPerDegree,
|
||||
point.X / xScale + Center.Longitude);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace MapControl
|
|||
|
||||
GetAzimuthDistance(Center, location, out azimuth, out distance);
|
||||
|
||||
var mapDistance = distance * UnitsPerDegree * 180d / Math.PI;
|
||||
var mapDistance = distance * Wgs84EquatorialRadius;
|
||||
|
||||
return new Point(mapDistance * Math.Sin(azimuth), mapDistance * Math.Cos(azimuth));
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ namespace MapControl
|
|||
var azimuth = Math.Atan2(point.X, point.Y);
|
||||
var mapDistance = Math.Sqrt(point.X * point.X + point.Y * point.Y);
|
||||
|
||||
var distance = mapDistance / (UnitsPerDegree * 180d / Math.PI);
|
||||
var distance = mapDistance / Wgs84EquatorialRadius;
|
||||
|
||||
return GetLocation(Center, azimuth, distance);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,23 +33,23 @@ namespace MapControl
|
|||
public override Point LocationToMap(Location location)
|
||||
{
|
||||
return new Point(
|
||||
location.Longitude * UnitsPerDegree,
|
||||
location.Latitude * UnitsPerDegree);
|
||||
Wgs84MetersPerDegree * location.Longitude,
|
||||
Wgs84MetersPerDegree * location.Latitude);
|
||||
}
|
||||
|
||||
public override Location MapToLocation(Point point)
|
||||
{
|
||||
return new Location(
|
||||
point.Y / UnitsPerDegree,
|
||||
point.X / UnitsPerDegree);
|
||||
point.Y / Wgs84MetersPerDegree,
|
||||
point.X / Wgs84MetersPerDegree);
|
||||
}
|
||||
|
||||
public override string GetBboxValue(Rect rect)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture,
|
||||
CrsId == "CRS:84" ? "{0},{1},{2},{3}" : "{1},{0},{3},{2}",
|
||||
rect.X / UnitsPerDegree, rect.Y / UnitsPerDegree,
|
||||
(rect.X + rect.Width) / UnitsPerDegree, (rect.Y + rect.Height) / UnitsPerDegree);
|
||||
rect.X / Wgs84MetersPerDegree, rect.Y / Wgs84MetersPerDegree,
|
||||
(rect.X + rect.Width) / Wgs84MetersPerDegree, (rect.Y + rect.Height) / Wgs84MetersPerDegree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace MapControl
|
|||
GetAzimuthDistance(Center, location, out azimuth, out distance);
|
||||
|
||||
var mapDistance = distance < Math.PI / 2d
|
||||
? Math.Tan(distance) * UnitsPerDegree * 180d / Math.PI
|
||||
? Math.Tan(distance) * Wgs84EquatorialRadius
|
||||
: double.PositiveInfinity;
|
||||
|
||||
return new Point(mapDistance * Math.Sin(azimuth), mapDistance * Math.Cos(azimuth));
|
||||
|
|
@ -47,7 +47,7 @@ namespace MapControl
|
|||
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 / (UnitsPerDegree * 180d / Math.PI));
|
||||
var distance = Math.Atan(mapDistance / Wgs84EquatorialRadius);
|
||||
|
||||
return GetLocation(Center, azimuth, distance);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace MapControl
|
|||
|
||||
private double GetLineDistance()
|
||||
{
|
||||
var pixelPerDegree = ParentMap.ViewTransform.Scale * ParentMap.MapProjection.UnitsPerDegree;
|
||||
var pixelPerDegree = ParentMap.ViewTransform.Scale * MapProjection.Wgs84MetersPerDegree;
|
||||
var minDistance = MinLineDistance / pixelPerDegree;
|
||||
var scale = 1d;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,15 +56,6 @@ namespace MapControl
|
|||
get { return 90d; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale factor from geographic to cartesian coordinates, on the line of true scale of a
|
||||
/// cylindrical projection (usually the equator), or at the projection center of an azimuthal projection.
|
||||
/// </summary>
|
||||
public virtual double UnitsPerDegree
|
||||
{
|
||||
get { return Wgs84MetersPerDegree; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the relative map scale at the specified Location.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -29,11 +29,10 @@ namespace MapControl
|
|||
var lat0 = Center.Latitude * Math.PI / 180d;
|
||||
var lat = location.Latitude * Math.PI / 180d;
|
||||
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)));
|
||||
Wgs84EquatorialRadius * Math.Cos(lat) * Math.Sin(dLon),
|
||||
Wgs84EquatorialRadius * (Math.Cos(lat0) * Math.Sin(lat) - Math.Sin(lat0) * Math.Cos(lat) * Math.Cos(dLon)));
|
||||
}
|
||||
|
||||
public override Location MapToLocation(Point point)
|
||||
|
|
@ -43,9 +42,8 @@ namespace MapControl
|
|||
return new Location(Center.Latitude, Center.Longitude);
|
||||
}
|
||||
|
||||
var s = UnitsPerDegree * 180d / Math.PI;
|
||||
var x = point.X / s;
|
||||
var y = point.Y / s;
|
||||
var x = point.X / Wgs84EquatorialRadius;
|
||||
var y = point.Y / Wgs84EquatorialRadius;
|
||||
var r2 = x * x + y * y;
|
||||
|
||||
if (r2 > 1d)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace MapControl
|
|||
|
||||
GetAzimuthDistance(Center, location, out azimuth, out distance);
|
||||
|
||||
var mapDistance = Math.Tan(distance / 2d) * 2d * UnitsPerDegree * 180d / Math.PI;
|
||||
var mapDistance = Math.Tan(distance / 2d) * 2d * Wgs84EquatorialRadius;
|
||||
|
||||
return new Point(mapDistance * Math.Sin(azimuth), mapDistance * Math.Cos(azimuth));
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ namespace MapControl
|
|||
var azimuth = Math.Atan2(point.X, point.Y);
|
||||
var mapDistance = Math.Sqrt(point.X * point.X + point.Y * point.Y);
|
||||
|
||||
var distance = 2d * Math.Atan(mapDistance / (2d * UnitsPerDegree * 180d / Math.PI));
|
||||
var distance = 2d * Math.Atan(mapDistance / (2d * Wgs84EquatorialRadius));
|
||||
|
||||
return GetLocation(Center, azimuth, distance);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,15 +42,15 @@ namespace MapControl
|
|||
public override Point LocationToMap(Location location)
|
||||
{
|
||||
return new Point(
|
||||
UnitsPerDegree * location.Longitude,
|
||||
UnitsPerDegree * LatitudeToY(location.Latitude));
|
||||
Wgs84MetersPerDegree * location.Longitude,
|
||||
Wgs84MetersPerDegree * LatitudeToY(location.Latitude));
|
||||
}
|
||||
|
||||
public override Location MapToLocation(Point point)
|
||||
{
|
||||
return new Location(
|
||||
YToLatitude(point.Y / UnitsPerDegree),
|
||||
point.X / UnitsPerDegree);
|
||||
YToLatitude(point.Y / Wgs84MetersPerDegree),
|
||||
point.X / Wgs84MetersPerDegree);
|
||||
}
|
||||
|
||||
public static double LatitudeToY(double latitude)
|
||||
|
|
|
|||
|
|
@ -42,15 +42,15 @@ namespace MapControl
|
|||
public override Point LocationToMap(Location location)
|
||||
{
|
||||
return new Point(
|
||||
UnitsPerDegree * location.Longitude,
|
||||
UnitsPerDegree * LatitudeToY(location.Latitude));
|
||||
Wgs84MetersPerDegree * location.Longitude,
|
||||
Wgs84MetersPerDegree * LatitudeToY(location.Latitude));
|
||||
}
|
||||
|
||||
public override Location MapToLocation(Point point)
|
||||
{
|
||||
return new Location(
|
||||
YToLatitude(point.Y / UnitsPerDegree),
|
||||
point.X / UnitsPerDegree);
|
||||
YToLatitude(point.Y / Wgs84MetersPerDegree),
|
||||
point.X / Wgs84MetersPerDegree);
|
||||
}
|
||||
|
||||
public static double LatitudeToY(double latitude)
|
||||
|
|
|
|||
|
|
@ -110,11 +110,6 @@ namespace MapControl.Projections
|
|||
get { return isWebMercator; }
|
||||
}
|
||||
|
||||
public override double UnitsPerDegree
|
||||
{
|
||||
get { return unitsPerDegree; }
|
||||
}
|
||||
|
||||
public override Point LocationToMap(Location location)
|
||||
{
|
||||
if (LocationToMapTransform == null)
|
||||
|
|
|
|||
|
|
@ -33,11 +33,6 @@ namespace MapControl.Projections
|
|||
this.falseNorthing = falseNorthing;
|
||||
}
|
||||
|
||||
public override double UnitsPerDegree
|
||||
{
|
||||
get { return scaleFactor * Wgs84MetersPerDegree; }
|
||||
}
|
||||
|
||||
public override Vector GetRelativeScale(Location location)
|
||||
{
|
||||
var lat = (north ? location.Latitude : -location.Latitude) * Math.PI / 180d;
|
||||
|
|
|
|||
Loading…
Reference in a new issue