mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Minor fixes
This commit is contained in:
parent
1b77bcd8e1
commit
d52dba0729
|
|
@ -16,7 +16,6 @@ namespace MapControl
|
||||||
public class Location : IEquatable<Location>
|
public class Location : IEquatable<Location>
|
||||||
{
|
{
|
||||||
private double latitude;
|
private double latitude;
|
||||||
private double longitude;
|
|
||||||
|
|
||||||
public Location()
|
public Location()
|
||||||
{
|
{
|
||||||
|
|
@ -34,17 +33,13 @@ namespace MapControl
|
||||||
set { latitude = Math.Min(Math.Max(value, -90d), 90d); }
|
set { latitude = Math.Min(Math.Max(value, -90d), 90d); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Longitude
|
public double Longitude { get; set; }
|
||||||
{
|
|
||||||
get { return longitude; }
|
|
||||||
set { longitude = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(Location location)
|
public bool Equals(Location location)
|
||||||
{
|
{
|
||||||
return location != null
|
return location != null
|
||||||
&& Math.Abs(location.latitude - latitude) < 1e-9
|
&& Math.Abs(location.Latitude - Latitude) < 1e-9
|
||||||
&& Math.Abs(location.longitude - longitude) < 1e-9;
|
&& Math.Abs(location.Longitude - Longitude) < 1e-9;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
@ -54,12 +49,12 @@ namespace MapControl
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return latitude.GetHashCode() ^ longitude.GetHashCode();
|
return Latitude.GetHashCode() ^ Longitude.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format(CultureInfo.InvariantCulture, "{0:F5},{1:F5}", latitude, longitude);
|
return string.Format(CultureInfo.InvariantCulture, "{0:F5},{1:F5}", Latitude, Longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location Parse(string locationString)
|
public static Location Parse(string locationString)
|
||||||
|
|
@ -109,10 +104,10 @@ namespace MapControl
|
||||||
public double GetDistance(
|
public double GetDistance(
|
||||||
Location location, double earthRadius = MapProjection.Wgs84EquatorialRadius)
|
Location location, double earthRadius = MapProjection.Wgs84EquatorialRadius)
|
||||||
{
|
{
|
||||||
var lat1 = latitude * Math.PI / 180d;
|
var lat1 = Latitude * Math.PI / 180d;
|
||||||
var lon1 = longitude * Math.PI / 180d;
|
var lon1 = Longitude * Math.PI / 180d;
|
||||||
var lat2 = location.latitude * Math.PI / 180d;
|
var lat2 = location.Latitude * Math.PI / 180d;
|
||||||
var lon2 = location.longitude * Math.PI / 180d;
|
var lon2 = location.Longitude * Math.PI / 180d;
|
||||||
var sinLat1 = Math.Sin(lat1);
|
var sinLat1 = Math.Sin(lat1);
|
||||||
var cosLat1 = Math.Cos(lat1);
|
var cosLat1 = Math.Cos(lat1);
|
||||||
var sinLat2 = Math.Sin(lat2);
|
var sinLat2 = Math.Sin(lat2);
|
||||||
|
|
@ -136,8 +131,8 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
var s12 = distance / earthRadius;
|
var s12 = distance / earthRadius;
|
||||||
var az1 = azimuth * Math.PI / 180d;
|
var az1 = azimuth * Math.PI / 180d;
|
||||||
var lat1 = latitude * Math.PI / 180d;
|
var lat1 = Latitude * Math.PI / 180d;
|
||||||
var lon1 = longitude * Math.PI / 180d;
|
var lon1 = Longitude * Math.PI / 180d;
|
||||||
var sinS12 = Math.Sin(s12);
|
var sinS12 = Math.Sin(s12);
|
||||||
var cosS12 = Math.Cos(s12);
|
var cosS12 = Math.Cos(s12);
|
||||||
var sinAz1 = Math.Sin(az1);
|
var sinAz1 = Math.Sin(az1);
|
||||||
|
|
@ -145,7 +140,7 @@ namespace MapControl
|
||||||
var sinLat1 = Math.Sin(lat1);
|
var sinLat1 = Math.Sin(lat1);
|
||||||
var cosLat1 = Math.Cos(lat1);
|
var cosLat1 = Math.Cos(lat1);
|
||||||
var lat2 = Math.Asin(sinLat1 * cosS12 + cosLat1 * sinS12 * cosAz1);
|
var lat2 = Math.Asin(sinLat1 * cosS12 + cosLat1 * sinS12 * cosAz1);
|
||||||
var lon2 = lon1 + Math.Atan2(sinS12 * sinAz1, (cosLat1 * cosS12 - sinLat1 * sinS12 * cosAz1));
|
var lon2 = lon1 + Math.Atan2(sinS12 * sinAz1, cosLat1 * cosS12 - sinLat1 * sinS12 * cosAz1);
|
||||||
|
|
||||||
return new Location(lat2 * 180d / Math.PI, lon2 * 180d / Math.PI);
|
return new Location(lat2 * 180d / Math.PI, lon2 * 180d / Math.PI);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@
|
||||||
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
||||||
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
|
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
|
||||||
|
|
||||||
<map:Pushpin AutoCollapse="True" Content="N 53° 30' E 8° 12'">
|
<map:Pushpin AutoCollapse="True" Content="N 53°30' E 8°12'">
|
||||||
<map:Pushpin.Location>
|
<map:Pushpin.Location>
|
||||||
<map:Location Latitude="53.5" Longitude="8.2"/>
|
<map:Location Latitude="53.5" Longitude="8.2"/>
|
||||||
</map:Pushpin.Location>
|
</map:Pushpin.Location>
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.ProjectReunion" Version="0.8.1">
|
<PackageReference Include="Microsoft.ProjectReunion" Version="[0.8.1]">
|
||||||
<IncludeAssets>build</IncludeAssets>
|
<IncludeAssets>build</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.8.1">
|
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="[0.8.1]">
|
||||||
<IncludeAssets>build</IncludeAssets>
|
<IncludeAssets>build</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@
|
||||||
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
||||||
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
|
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
|
||||||
|
|
||||||
<map:Pushpin AutoCollapse="True" Content="N 53° 30' E 8° 12'">
|
<map:Pushpin AutoCollapse="True" Content="N 53°30' E 8°12'">
|
||||||
<map:Pushpin.Location>
|
<map:Pushpin.Location>
|
||||||
<map:Location Latitude="53.5" Longitude="8.2"/>
|
<map:Location Latitude="53.5" Longitude="8.2"/>
|
||||||
</map:Pushpin.Location>
|
</map:Pushpin.Location>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue