mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
Use Matrix for projection relative scale
This commit is contained in:
parent
2c9e478095
commit
ab155a26e7
21 changed files with 93 additions and 104 deletions
|
|
@ -75,12 +75,14 @@ namespace MapControl
|
|||
set => SetValue(FontSizeProperty, value);
|
||||
}
|
||||
|
||||
private double PixelPerDegree => Math.Max(1d, ParentMap.ViewTransform.Scale * MapProjection.Wgs84MeterPerDegree);
|
||||
|
||||
private double lineDistance;
|
||||
private string labelFormat;
|
||||
|
||||
private void SetLineDistance()
|
||||
{
|
||||
var minDistance = MinLineDistance / PixelPerLongitudeDegree(ParentMap.Center.Latitude, ParentMap.Center.Longitude);
|
||||
var minDistance = MinLineDistance / PixelPerDegree;
|
||||
var scale = minDistance < 1d / 60d ? 3600d : minDistance < 1d ? 60d : 1d;
|
||||
minDistance *= scale;
|
||||
|
||||
|
|
@ -98,14 +100,6 @@ namespace MapControl
|
|||
: lineDistance < 1d ? "{0} {1}°{2:00}'" : "{0} {1}°";
|
||||
}
|
||||
|
||||
private double PixelPerLongitudeDegree(double latitude, double longitude)
|
||||
{
|
||||
var scale = ParentMap.GetMapScale(latitude, longitude);
|
||||
|
||||
return Math.Max(1d, // a reasonable lower limit
|
||||
scale.X * Math.Cos(latitude * Math.PI / 180d) * MapProjection.Wgs84MeterPerDegree);
|
||||
}
|
||||
|
||||
private string GetLabelText(double value, string hemispheres)
|
||||
{
|
||||
var hemisphere = hemispheres[0];
|
||||
|
|
@ -131,7 +125,7 @@ namespace MapControl
|
|||
{
|
||||
// Get rotation from second location with same latitude.
|
||||
//
|
||||
var pos = ParentMap.LocationToView(latitude, longitude + 10d / PixelPerLongitudeDegree(latitude, longitude));
|
||||
var pos = ParentMap.LocationToView(latitude, longitude + 10d / PixelPerDegree);
|
||||
|
||||
if (pos.HasValue)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue