Minor fixes

This commit is contained in:
Clemens 2021-07-18 13:33:11 +02:00
parent 1b77bcd8e1
commit d52dba0729
4 changed files with 70 additions and 75 deletions

View file

@ -16,7 +16,6 @@ namespace MapControl
public class Location : IEquatable<Location>
{
private double latitude;
private double longitude;
public Location()
{
@ -34,17 +33,13 @@ namespace MapControl
set { latitude = Math.Min(Math.Max(value, -90d), 90d); }
}
public double Longitude
{
get { return longitude; }
set { longitude = value; }
}
public double Longitude { get; set; }
public bool Equals(Location location)
{
return location != null
&& Math.Abs(location.latitude - latitude) < 1e-9
&& Math.Abs(location.longitude - longitude) < 1e-9;
&& Math.Abs(location.Latitude - Latitude) < 1e-9
&& Math.Abs(location.Longitude - Longitude) < 1e-9;
}
public override bool Equals(object obj)
@ -54,12 +49,12 @@ namespace MapControl
public override int GetHashCode()
{
return latitude.GetHashCode() ^ longitude.GetHashCode();
return Latitude.GetHashCode() ^ Longitude.GetHashCode();
}
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)
@ -109,10 +104,10 @@ namespace MapControl
public double GetDistance(
Location location, double earthRadius = MapProjection.Wgs84EquatorialRadius)
{
var lat1 = latitude * Math.PI / 180d;
var lon1 = longitude * Math.PI / 180d;
var lat2 = location.latitude * Math.PI / 180d;
var lon2 = location.longitude * Math.PI / 180d;
var lat1 = Latitude * Math.PI / 180d;
var lon1 = Longitude * Math.PI / 180d;
var lat2 = location.Latitude * Math.PI / 180d;
var lon2 = location.Longitude * Math.PI / 180d;
var sinLat1 = Math.Sin(lat1);
var cosLat1 = Math.Cos(lat1);
var sinLat2 = Math.Sin(lat2);
@ -136,8 +131,8 @@ namespace MapControl
{
var s12 = distance / earthRadius;
var az1 = azimuth * Math.PI / 180d;
var lat1 = latitude * Math.PI / 180d;
var lon1 = longitude * Math.PI / 180d;
var lat1 = Latitude * Math.PI / 180d;
var lon1 = Longitude * Math.PI / 180d;
var sinS12 = Math.Sin(s12);
var cosS12 = Math.Cos(s12);
var sinAz1 = Math.Sin(az1);
@ -145,7 +140,7 @@ namespace MapControl
var sinLat1 = Math.Sin(lat1);
var cosLat1 = Math.Cos(lat1);
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);
}

View file

@ -132,7 +132,7 @@
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
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:Location Latitude="53.5" Longitude="8.2"/>
</map:Pushpin.Location>

View file

@ -1,59 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
<PathToXAMLWinRTImplementations>WinUiApp\</PathToXAMLWinRTImplementations>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>2db6959f-1768-495c-8eed-4830ef185584</ProjectGuid>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<AssetTargetFallback>net5.0-windows$(TargetPlatformVersion);$(AssetTargetFallback)</AssetTargetFallback>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\WinUiApp\WinUiApp.csproj</EntryPointProjectUniqueName>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WinUiApp\WinUiApp.csproj">
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ProjectReunion" Version="0.8.1">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.8.1">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
<PathToXAMLWinRTImplementations>WinUiApp\</PathToXAMLWinRTImplementations>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>2db6959f-1768-495c-8eed-4830ef185584</ProjectGuid>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<AssetTargetFallback>net5.0-windows$(TargetPlatformVersion);$(AssetTargetFallback)</AssetTargetFallback>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\WinUiApp\WinUiApp.csproj</EntryPointProjectUniqueName>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WinUiApp\WinUiApp.csproj">
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ProjectReunion" Version="[0.8.1]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="[0.8.1]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>

View file

@ -124,7 +124,7 @@
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
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:Location Latitude="53.5" Longitude="8.2"/>
</map:Pushpin.Location>