Version 1.7.0. Signed assemblies, marked Location as serializable, simplified LocationCollection.

This commit is contained in:
ClemensF 2013-11-05 18:00:03 +01:00
parent 8c97d771ac
commit 8eedb82a9d
20 changed files with 135 additions and 85 deletions

View file

@ -33,6 +33,12 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\MapControl.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="FileDb, Version=3.10.0.0, Culture=neutral, PublicKeyToken=68cc942b9efb3282, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@ -50,6 +56,11 @@
<Content Include="FileDb\FileDb.dll" />
<Content Include="FileDb\FileDb.txt" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\MapControl.snk">
<Link>MapControl.snk</Link>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -33,6 +33,12 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\MapControl.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -42,6 +48,11 @@
<Compile Include="ImageFileCache.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\MapControl.snk">
<Link>MapControl.snk</Link>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

BIN
MapControl.snk Normal file

Binary file not shown.

View file

@ -8,13 +8,24 @@ using System.Globalization;
namespace MapControl
{
/// <summary>
/// A geographic location given as latitude and longitude.
/// A geographic location with latitude and longitude values in degrees.
/// </summary>
public partial class Location : IEquatable<Location>
#if !SILVERLIGHT && !NETFX_CORE
[Serializable]
#endif
public partial class Location
{
/// <summary>
/// TransformedLatitude is set by the Transform methods in MercatorTransform.
/// It holds the transformed latitude value to avoid redundant recalculation.
/// </summary>
#if !SILVERLIGHT && !NETFX_CORE
[NonSerialized]
#endif
internal double TransformedLatitude;
private double latitude;
private double longitude;
internal double Y;
public Location()
{
@ -32,7 +43,7 @@ namespace MapControl
set
{
latitude = Math.Min(Math.Max(value, -90d), 90d);
Y = double.NaN;
TransformedLatitude = double.NaN;
}
}
@ -42,21 +53,6 @@ namespace MapControl
set { longitude = value; }
}
public bool Equals(Location other)
{
return other != null && other.latitude == latitude && other.longitude == longitude;
}
public override bool Equals(object obj)
{
return Equals(obj as Location);
}
public override int GetHashCode()
{
return latitude.GetHashCode() ^ longitude.GetHashCode();
}
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "{0:F5},{1:F5}", latitude, longitude);

View file

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace MapControl
{
@ -18,23 +19,20 @@ namespace MapControl
}
public LocationCollection(IEnumerable<Location> locations)
: base(locations)
{
}
public LocationCollection(List<Location> locations)
: base(locations)
{
foreach (var location in locations)
{
Add(location);
}
}
public static LocationCollection Parse(string s)
{
LocationCollection locations = new LocationCollection();
var strings = s.Split(new char[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var locString in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
{
locations.Add(Location.Parse(locString));
}
return locations;
return new LocationCollection(strings.Select(l => Location.Parse(l)));
}
}
}

View file

@ -51,6 +51,12 @@
<PropertyGroup>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\MapControl.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System.Windows" />
@ -81,10 +87,10 @@
<Compile Include="MapPanel.cs" />
<Compile Include="MapPanel.Silverlight.WinRT.cs" />
<Compile Include="MapPath.cs" />
<Compile Include="MapRectangle.cs" />
<Compile Include="MapPath.Silverlight.WinRT.cs" />
<Compile Include="MapPolyline.cs" />
<Compile Include="MapPolyline.Silverlight.WinRT.cs" />
<Compile Include="MapPath.Silverlight.WinRT.cs" />
<Compile Include="MapRectangle.cs" />
<Compile Include="MapTransform.cs" />
<Compile Include="MatrixEx.cs" />
<Compile Include="MercatorTransform.cs" />
@ -101,13 +107,17 @@
<Compile Include="TileSource.cs" />
<Compile Include="TileSourceConverter.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="Themes\Generic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="..\MapControl.snk">
<Link>MapControl.snk</Link>
</None>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>

View file

@ -35,6 +35,12 @@
<PropertyGroup>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\MapControl.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
@ -45,27 +51,30 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Map.WPF.cs" />
<Compile Include="MapGraticule.WPF.cs" />
<Compile Include="GlyphRunText.cs" />
<Compile Include="ImageTileSource.cs" />
<Compile Include="Location.cs" />
<Compile Include="LocationCollection.cs" />
<Compile Include="LocationCollectionConverter.cs" />
<Compile Include="LocationConverter.cs" />
<Compile Include="MapBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Map.WPF.cs" />
<Compile Include="MapBase.cs" />
<Compile Include="MapBase.WPF.cs" />
<Compile Include="MapGraticule.cs" />
<Compile Include="MapGraticule.WPF.cs" />
<Compile Include="MapImage.cs" />
<Compile Include="MapImageLayer.cs" />
<Compile Include="MapItem.WPF.cs" />
<Compile Include="MapItemsControl.WPF.cs" />
<Compile Include="MapOverlay.cs" />
<Compile Include="MapPanel.cs" />
<Compile Include="MapPanel.WPF.cs" />
<Compile Include="MapPath.cs" />
<Compile Include="MapPath.WPF.cs" />
<Compile Include="MapPolyline.cs" />
<Compile Include="MapPolyline.WPF.cs" />
<Compile Include="MapRectangle.cs" />
<Compile Include="MapPath.cs" />
<Compile Include="MapPath.WPF.cs" />
<Compile Include="MapScale.cs" />
<Compile Include="MapTransform.cs" />
<Compile Include="MercatorTransform.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -74,17 +83,12 @@
<Compile Include="Tile.WPF.cs" />
<Compile Include="TileContainer.cs" />
<Compile Include="TileContainer.WPF.cs" />
<Compile Include="TileImageLoader.WPF.cs" />
<Compile Include="TileLayer.cs" />
<Compile Include="TileLayer.WPF.cs" />
<Compile Include="TileLayerCollection.cs" />
<Compile Include="TileSource.cs" />
<Compile Include="TileSourceConverter.cs" />
<Compile Include="GlyphRunText.cs" />
<Compile Include="ImageTileSource.cs" />
<Compile Include="MapGraticule.cs" />
<Compile Include="MapOverlay.cs" />
<Compile Include="MapScale.cs" />
<Compile Include="TileImageLoader.WPF.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="Themes\Generic.xaml">
@ -92,7 +96,11 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="..\MapControl.snk">
<Link>MapControl.snk</Link>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>

View file

@ -41,30 +41,30 @@ namespace MapControl
public override Point Transform(Location location)
{
if (double.IsNaN(location.Y))
if (double.IsNaN(location.TransformedLatitude))
{
if (location.Latitude <= -90d)
{
location.Y = double.NegativeInfinity;
location.TransformedLatitude = double.NegativeInfinity;
}
else if (location.Latitude >= 90d)
{
location.Y = double.PositiveInfinity;
location.TransformedLatitude = double.PositiveInfinity;
}
else
{
var lat = location.Latitude * Math.PI / 180d;
location.Y = Math.Log(Math.Tan(lat) + 1d / Math.Cos(lat)) / Math.PI * 180d;
location.TransformedLatitude = Math.Log(Math.Tan(lat) + 1d / Math.Cos(lat)) / Math.PI * 180d;
}
}
return new Point(location.Longitude, location.Y);
return new Point(location.Longitude, location.TransformedLatitude);
}
public override Location Transform(Point point)
{
var location = new Location(Math.Atan(Math.Sinh(point.Y * Math.PI / 180d)) / Math.PI * 180d, point.X);
location.Y = point.Y;
location.TransformedLatitude = point.Y;
return location;
}
}

View file

@ -15,8 +15,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -9,6 +9,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Cache;
using System.Runtime.Caching;
using System.Threading;
using System.Windows.Media;
@ -73,7 +74,7 @@ namespace MapControl
internal void StartGetTiles(IEnumerable<Tile> tiles)
{
if (tiles.Any())
if (tileLayer.TileSource != null && tiles.Any())
{
ThreadPool.QueueUserWorkItem(GetTilesAsync, tiles.ToList());
}
@ -94,22 +95,21 @@ namespace MapControl
{
var tiles = (List<Tile>)tileList;
var imageTileSource = tileLayer.TileSource as ImageTileSource;
var animateOpacity = tileLayer.AnimateTileOpacity;
if (imageTileSource != null && !imageTileSource.CanLoadAsync)
{
foreach (var tile in tiles)
{
tileLayer.Dispatcher.BeginInvoke(
(Action<Tile, ImageTileSource>)((t, ts) => t.SetImageSource(ts.LoadImage(t.XIndex, t.Y, t.ZoomLevel), animateOpacity)),
(Action<Tile, ImageTileSource>)((t, ts) => t.SetImageSource(ts.LoadImage(t.XIndex, t.Y, t.ZoomLevel), tileLayer.AnimateTileOpacity)),
DispatcherPriority.Background, tile, imageTileSource);
}
}
else
{
if (imageTileSource == null && Cache != null &&
!tileLayer.TileSource.UriFormat.StartsWith("file://") &&
!string.IsNullOrWhiteSpace(tileLayer.SourceName))
!string.IsNullOrWhiteSpace(tileLayer.SourceName) &&
!tileLayer.TileSource.UriFormat.StartsWith("file://"))
{
var outdatedTiles = new List<Tile>(tiles.Count);
@ -122,7 +122,7 @@ namespace MapControl
if (image != null)
{
tileLayer.Dispatcher.BeginInvoke(
(Action<Tile, ImageSource>)((t, i) => t.SetImageSource(i, animateOpacity)),
(Action<Tile, ImageSource>)((t, i) => t.SetImageSource(i, tileLayer.AnimateTileOpacity)),
DispatcherPriority.Background, tile, image);
long creationTime = BitConverter.ToInt64(buffer, 0);
@ -151,13 +151,14 @@ namespace MapControl
{
Interlocked.Increment(ref downloadThreadCount);
ThreadPool.QueueUserWorkItem(o => LoadTiles(imageTileSource, animateOpacity));
ThreadPool.QueueUserWorkItem(LoadTiles);
}
}
}
private void LoadTiles(ImageTileSource imageTileSource, bool animateOpacity)
private void LoadTiles(object o)
{
var imageTileSource = tileLayer.TileSource as ImageTileSource;
Tile tile;
while (pendingTiles.TryDequeue(out tile))
@ -197,7 +198,7 @@ namespace MapControl
if (image != null)
{
tileLayer.Dispatcher.BeginInvoke(
(Action<Tile, ImageSource>)((t, i) => t.SetImageSource(i, animateOpacity)),
(Action<Tile, ImageSource>)((t, i) => t.SetImageSource(i, tileLayer.AnimateTileOpacity)),
DispatcherPriority.Background, tile, image);
if (buffer != null && Cache != null)
@ -268,6 +269,11 @@ namespace MapControl
var request = (HttpWebRequest)WebRequest.Create(uri);
request.UserAgent = "XAML Map Control";
if (Cache != null)
{
request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
}
using (var response = (HttpWebResponse)request.GetResponse())
using (var responseStream = response.GetResponseStream())
{
@ -284,7 +290,7 @@ namespace MapControl
}
}
Trace.TraceInformation("Downloaded {0}", uri);
//Trace.TraceInformation("Downloaded {0}", uri);
}
catch (WebException ex)
{
@ -293,7 +299,7 @@ namespace MapControl
var statusCode = ((HttpWebResponse)ex.Response).StatusCode;
if (statusCode != HttpStatusCode.NotFound)
{
Trace.TraceInformation("Downloading {0} failed: {1}", uri, ex.Message);
Trace.TraceWarning("Downloading {0} failed: {1}", uri, ex.Message);
}
}
else

View file

@ -140,7 +140,11 @@
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="..\..\MapControl.snk">
<Link>MapControl.snk</Link>
</None>
</ItemGroup>
<ItemGroup>
<Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator>
@ -153,6 +157,12 @@
<PropertyGroup>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\MapControl.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.33440
// Runtime Version:4.0.30319.34003
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -12,7 +12,7 @@ namespace WpfApplication.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));