From 9f9669ea005ea1f872a46a9623d923dc1b785c4c Mon Sep 17 00:00:00 2001 From: ClemensF Date: Tue, 20 Jan 2015 17:52:02 +0100 Subject: [PATCH] Version 2.4.3: Some cleanup. --- Caching/FileDbCache.WPF/FileDbCache.cs | 2 +- .../Properties/AssemblyInfo.cs | 6 +- Caching/FileDbCache.WinRT/FileDbCache.cs | 2 +- .../Properties/AssemblyInfo.cs | 6 +- Caching/ImageFileCache.WPF/ImageFileCache.cs | 2 +- .../Properties/AssemblyInfo.cs | 6 +- .../ImageFileCache.WinRT/ImageFileCache.cs | 2 +- .../Properties/AssemblyInfo.cs | 6 +- MapControl/BingMapsTileLayer.cs | 2 +- MapControl/BingMapsTileSource.cs | 2 +- MapControl/Extensions.Silverlight.cs | 2 +- MapControl/Extensions.WinRT.cs | 2 +- MapControl/GlyphRunText.cs | 2 +- MapControl/HyperlinkText.cs | 2 +- MapControl/IMapElement.cs | 2 +- MapControl/ITileImageLoader.cs | 2 +- MapControl/ImageCache.WinRT.cs | 2 +- .../ImageTileSource.Silverlight.WinRT.cs | 2 +- MapControl/ImageTileSource.WPF.cs | 3 +- MapControl/Int32Rect.cs | 2 +- MapControl/Location.cs | 10 +-- MapControl/LocationCollection.cs | 2 +- MapControl/LocationCollectionConverter.cs | 2 +- MapControl/LocationConverter.cs | 2 +- MapControl/Map.Silverlight.cs | 2 +- MapControl/Map.WPF.cs | 2 +- MapControl/Map.WinRT.cs | 2 +- MapControl/MapBase.Silverlight.WinRT.cs | 2 +- MapControl/MapBase.WPF.cs | 2 +- MapControl/MapBase.cs | 8 +- MapControl/MapGraticule.Silverlight.WinRT.cs | 2 +- MapControl/MapGraticule.WPF.cs | 2 +- MapControl/MapGraticule.cs | 2 +- MapControl/MapImage.cs | 2 +- MapControl/MapImageLayer.Silverlight.WinRT.cs | 2 +- MapControl/MapImageLayer.WPF.cs | 2 +- MapControl/MapImageLayer.cs | 2 +- MapControl/MapItem.Silverlight.WinRT.cs | 2 +- MapControl/MapItem.WPF.cs | 2 +- .../MapItemsControl.Silverlight.WinRT.cs | 2 +- MapControl/MapItemsControl.WPF.cs | 2 +- MapControl/MapOverlay.Silverlight.WinRT.cs | 2 +- MapControl/MapOverlay.WPF.cs | 2 +- MapControl/MapOverlay.cs | 2 +- MapControl/MapPanel.Silverlight.WinRT.cs | 2 +- MapControl/MapPanel.WPF.cs | 2 +- MapControl/MapPanel.cs | 2 +- MapControl/MapPath.Silverlight.WinRT.cs | 2 +- MapControl/MapPath.WPF.cs | 2 +- MapControl/MapPath.cs | 2 +- MapControl/MapPolyline.Silverlight.WinRT.cs | 2 +- MapControl/MapPolyline.WPF.cs | 2 +- MapControl/MapPolyline.cs | 2 +- MapControl/MapRectangle.WPF.cs | 2 +- MapControl/MapRectangle.cs | 2 +- MapControl/MapScale.cs | 2 +- MapControl/MapTransform.cs | 2 +- MapControl/MatrixEx.cs | 18 +++- MapControl/MercatorTransform.cs | 2 +- MapControl/PanelBase.cs | 2 +- MapControl/Properties/AssemblyInfo.cs | 6 +- MapControl/Pushpin.Silverlight.WinRT.cs | 2 +- MapControl/Pushpin.WPF.cs | 2 +- MapControl/Tile.Silverlight.WinRT.cs | 8 +- MapControl/Tile.WPF.cs | 8 +- MapControl/Tile.cs | 2 +- MapControl/TileImageLoader.Silverlight.cs | 2 +- MapControl/TileImageLoader.WPF.cs | 83 +++++++------------ MapControl/TileImageLoader.WinRT.cs | 53 ++++-------- MapControl/TileLayer.Silverlight.WinRT.cs | 2 +- MapControl/TileLayer.WPF.cs | 2 +- MapControl/TileLayer.cs | 14 +++- MapControl/TileLayerCollection.cs | 2 +- MapControl/TileSource.cs | 38 +-------- MapControl/TileSourceConverter.cs | 2 +- MapControl/WinRT/Properties/AssemblyInfo.cs | 6 +- .../Properties/AssemblyInfo.cs | 6 +- .../Properties/AssemblyInfo.cs | 6 +- .../Properties/AssemblyInfo.cs | 6 +- .../Properties/AssemblyInfo.cs | 6 +- SampleApps/WpfApplication/MainWindow.xaml.cs | 1 - .../WpfApplication/Properties/AssemblyInfo.cs | 6 +- 82 files changed, 183 insertions(+), 247 deletions(-) diff --git a/Caching/FileDbCache.WPF/FileDbCache.cs b/Caching/FileDbCache.WPF/FileDbCache.cs index 13e00e02..1bd55a4b 100644 --- a/Caching/FileDbCache.WPF/FileDbCache.cs +++ b/Caching/FileDbCache.WPF/FileDbCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs index 5c79b760..544b17b3 100644 --- a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("ObjectCache implementation based on EzTools FileDb")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/FileDbCache.WinRT/FileDbCache.cs b/Caching/FileDbCache.WinRT/FileDbCache.cs index ba288ca9..fde88fa7 100644 --- a/Caching/FileDbCache.WinRT/FileDbCache.cs +++ b/Caching/FileDbCache.WinRT/FileDbCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs index 0476ecf8..019bdf55 100644 --- a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("IImageCache implementation based on EzTools FileDb")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WPF/ImageFileCache.cs b/Caching/ImageFileCache.WPF/ImageFileCache.cs index bf3bab36..621501f7 100644 --- a/Caching/ImageFileCache.WPF/ImageFileCache.cs +++ b/Caching/ImageFileCache.WPF/ImageFileCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs index c78cc7c1..5de975a9 100644 --- a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("ObjectCache implementation based on local image files")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WinRT/ImageFileCache.cs b/Caching/ImageFileCache.WinRT/ImageFileCache.cs index 97296348..0ad8d8cc 100644 --- a/Caching/ImageFileCache.WinRT/ImageFileCache.cs +++ b/Caching/ImageFileCache.WinRT/ImageFileCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs index b5437bad..b64ebd7b 100644 --- a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("IImageCache implementation based on local image files")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/BingMapsTileLayer.cs b/MapControl/BingMapsTileLayer.cs index 6d01b779..ff962fc8 100644 --- a/MapControl/BingMapsTileLayer.cs +++ b/MapControl/BingMapsTileLayer.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/BingMapsTileSource.cs b/MapControl/BingMapsTileSource.cs index 046705ca..1e57f245 100644 --- a/MapControl/BingMapsTileSource.cs +++ b/MapControl/BingMapsTileSource.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/Extensions.Silverlight.cs b/MapControl/Extensions.Silverlight.cs index 0da06791..b9fb1793 100644 --- a/MapControl/Extensions.Silverlight.cs +++ b/MapControl/Extensions.Silverlight.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/Extensions.WinRT.cs b/MapControl/Extensions.WinRT.cs index cdc02ee1..a1118ff4 100644 --- a/MapControl/Extensions.WinRT.cs +++ b/MapControl/Extensions.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/GlyphRunText.cs b/MapControl/GlyphRunText.cs index dcf933c1..6e199a41 100644 --- a/MapControl/GlyphRunText.cs +++ b/MapControl/GlyphRunText.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/HyperlinkText.cs b/MapControl/HyperlinkText.cs index 6ffbb646..6c92b683 100644 --- a/MapControl/HyperlinkText.cs +++ b/MapControl/HyperlinkText.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/IMapElement.cs b/MapControl/IMapElement.cs index 33faaa3b..cd583703 100644 --- a/MapControl/IMapElement.cs +++ b/MapControl/IMapElement.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) namespace MapControl diff --git a/MapControl/ITileImageLoader.cs b/MapControl/ITileImageLoader.cs index 72b719ad..88bf0f76 100644 --- a/MapControl/ITileImageLoader.cs +++ b/MapControl/ITileImageLoader.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Collections.Generic; diff --git a/MapControl/ImageCache.WinRT.cs b/MapControl/ImageCache.WinRT.cs index 6e0f9cea..f74912c7 100644 --- a/MapControl/ImageCache.WinRT.cs +++ b/MapControl/ImageCache.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/ImageTileSource.Silverlight.WinRT.cs b/MapControl/ImageTileSource.Silverlight.WinRT.cs index 8c7cfcc9..a1ecfa5e 100644 --- a/MapControl/ImageTileSource.Silverlight.WinRT.cs +++ b/MapControl/ImageTileSource.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/ImageTileSource.WPF.cs b/MapControl/ImageTileSource.WPF.cs index 4ff5eaa1..5fa0df05 100644 --- a/MapControl/ImageTileSource.WPF.cs +++ b/MapControl/ImageTileSource.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.IO; @@ -31,7 +31,6 @@ namespace MapControl if (IsAsync) { var request = HttpWebRequest.CreateHttp(uri); - request.UserAgent = TileImageLoader.HttpUserAgent; using (var response = (HttpWebResponse)request.GetResponse()) using (var responseStream = response.GetResponseStream()) diff --git a/MapControl/Int32Rect.cs b/MapControl/Int32Rect.cs index 6dea4511..8649a489 100644 --- a/MapControl/Int32Rect.cs +++ b/MapControl/Int32Rect.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) namespace MapControl diff --git a/MapControl/Location.cs b/MapControl/Location.cs index 23265abc..6e6cd7bc 100644 --- a/MapControl/Location.cs +++ b/MapControl/Location.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -61,15 +61,15 @@ namespace MapControl public static Location Parse(string s) { - var tokens = s.Split(new char[] { ',' }); - if (tokens.Length != 2) + var pair = s.Split(new char[] { ',' }); + if (pair.Length != 2) { throw new FormatException("Location string must be a comma-separated pair of double values"); } return new Location( - double.Parse(tokens[0], NumberStyles.Float, CultureInfo.InvariantCulture), - double.Parse(tokens[1], NumberStyles.Float, CultureInfo.InvariantCulture)); + double.Parse(pair[0], NumberStyles.Float, CultureInfo.InvariantCulture), + double.Parse(pair[1], NumberStyles.Float, CultureInfo.InvariantCulture)); } public static double NormalizeLongitude(double longitude) diff --git a/MapControl/LocationCollection.cs b/MapControl/LocationCollection.cs index 1a327d14..8b3f2599 100644 --- a/MapControl/LocationCollection.cs +++ b/MapControl/LocationCollection.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/LocationCollectionConverter.cs b/MapControl/LocationCollectionConverter.cs index 136d1738..24069b9f 100644 --- a/MapControl/LocationCollectionConverter.cs +++ b/MapControl/LocationCollectionConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/LocationConverter.cs b/MapControl/LocationConverter.cs index e8f48463..2037d812 100644 --- a/MapControl/LocationConverter.cs +++ b/MapControl/LocationConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/Map.Silverlight.cs b/MapControl/Map.Silverlight.cs index 2d0dc797..1a6b4852 100644 --- a/MapControl/Map.Silverlight.cs +++ b/MapControl/Map.Silverlight.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/Map.WPF.cs b/MapControl/Map.WPF.cs index d111b249..73b5f509 100644 --- a/MapControl/Map.WPF.cs +++ b/MapControl/Map.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/Map.WinRT.cs b/MapControl/Map.WinRT.cs index bf163201..80b151fd 100644 --- a/MapControl/Map.WinRT.cs +++ b/MapControl/Map.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using Windows.Devices.Input; diff --git a/MapControl/MapBase.Silverlight.WinRT.cs b/MapControl/MapBase.Silverlight.WinRT.cs index fb41c2cf..b1ca4cf0 100644 --- a/MapControl/MapBase.Silverlight.WinRT.cs +++ b/MapControl/MapBase.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapBase.WPF.cs b/MapControl/MapBase.WPF.cs index 0f710aab..6627a265 100644 --- a/MapControl/MapBase.WPF.cs +++ b/MapControl/MapBase.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapBase.cs b/MapControl/MapBase.cs index 96322b79..2048174e 100644 --- a/MapControl/MapBase.cs +++ b/MapControl/MapBase.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -31,6 +31,7 @@ namespace MapControl { private const double MaximumZoomLevel = 22d; + public static double ZoomLevelSwitchDelta = 0d; public static TimeSpan TileUpdateInterval = TimeSpan.FromSeconds(0.5); public static TimeSpan AnimationDuration = TimeSpan.FromSeconds(0.3); public static EasingFunctionBase AnimationEasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseOut }; @@ -554,7 +555,6 @@ namespace MapControl center = new Location( Math.Min(Math.Max(center.Latitude, -mapTransform.MaxLatitude), mapTransform.MaxLatitude), Location.NormalizeLongitude(center.Longitude)); - InternalSetValue(property, center); } } @@ -880,9 +880,7 @@ namespace MapControl { tileUpdateTimer.Stop(); - // relative size of scaled tile ranges from 0.75 to 1.5 (192 to 384 pixels) - var zoomLevelSwitchDelta = Math.Log(0.75, 2d); - var zoomLevel = (int)Math.Floor(ZoomLevel - zoomLevelSwitchDelta); + var zoomLevel = (int)Math.Round(ZoomLevel + ZoomLevelSwitchDelta); var transform = GetTileIndexMatrix((double)(1 << zoomLevel) / 360d); // tile indices of visible rectangle diff --git a/MapControl/MapGraticule.Silverlight.WinRT.cs b/MapControl/MapGraticule.Silverlight.WinRT.cs index 5bac310e..e0a691d6 100644 --- a/MapControl/MapGraticule.Silverlight.WinRT.cs +++ b/MapControl/MapGraticule.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapGraticule.WPF.cs b/MapControl/MapGraticule.WPF.cs index 8111b850..b16c2330 100644 --- a/MapControl/MapGraticule.WPF.cs +++ b/MapControl/MapGraticule.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapGraticule.cs b/MapControl/MapGraticule.cs index e75f439a..a89d1974 100644 --- a/MapControl/MapGraticule.cs +++ b/MapControl/MapGraticule.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapImage.cs b/MapControl/MapImage.cs index 75e991cb..79ed5694 100644 --- a/MapControl/MapImage.cs +++ b/MapControl/MapImage.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapImageLayer.Silverlight.WinRT.cs b/MapControl/MapImageLayer.Silverlight.WinRT.cs index 4dfb45f5..8497fcc7 100644 --- a/MapControl/MapImageLayer.Silverlight.WinRT.cs +++ b/MapControl/MapImageLayer.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapImageLayer.WPF.cs b/MapControl/MapImageLayer.WPF.cs index 791d3922..2d6c82c5 100644 --- a/MapControl/MapImageLayer.WPF.cs +++ b/MapControl/MapImageLayer.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapImageLayer.cs b/MapControl/MapImageLayer.cs index 3205a4f1..25e4cbd9 100644 --- a/MapControl/MapImageLayer.cs +++ b/MapControl/MapImageLayer.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapItem.Silverlight.WinRT.cs b/MapControl/MapItem.Silverlight.WinRT.cs index 13faa675..079da02b 100644 --- a/MapControl/MapItem.Silverlight.WinRT.cs +++ b/MapControl/MapItem.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapItem.WPF.cs b/MapControl/MapItem.WPF.cs index 9fcac044..dcaf6490 100644 --- a/MapControl/MapItem.WPF.cs +++ b/MapControl/MapItem.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapItemsControl.Silverlight.WinRT.cs b/MapControl/MapItemsControl.Silverlight.WinRT.cs index f9cade87..96787344 100644 --- a/MapControl/MapItemsControl.Silverlight.WinRT.cs +++ b/MapControl/MapItemsControl.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapItemsControl.WPF.cs b/MapControl/MapItemsControl.WPF.cs index e368d87c..d3e5380e 100644 --- a/MapControl/MapItemsControl.WPF.cs +++ b/MapControl/MapItemsControl.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapOverlay.Silverlight.WinRT.cs b/MapControl/MapOverlay.Silverlight.WinRT.cs index caba01f1..8c216ae4 100644 --- a/MapControl/MapOverlay.Silverlight.WinRT.cs +++ b/MapControl/MapOverlay.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapOverlay.WPF.cs b/MapControl/MapOverlay.WPF.cs index bce2be5f..3cafd706 100644 --- a/MapControl/MapOverlay.WPF.cs +++ b/MapControl/MapOverlay.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapOverlay.cs b/MapControl/MapOverlay.cs index 9e853ca6..2b1e561b 100644 --- a/MapControl/MapOverlay.cs +++ b/MapControl/MapOverlay.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapPanel.Silverlight.WinRT.cs b/MapControl/MapPanel.Silverlight.WinRT.cs index dc6b0352..fcbf7e41 100644 --- a/MapControl/MapPanel.Silverlight.WinRT.cs +++ b/MapControl/MapPanel.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapPanel.WPF.cs b/MapControl/MapPanel.WPF.cs index b49645f0..d146bb07 100644 --- a/MapControl/MapPanel.WPF.cs +++ b/MapControl/MapPanel.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapPanel.cs b/MapControl/MapPanel.cs index 00699a1a..2bd2f6f3 100644 --- a/MapControl/MapPanel.cs +++ b/MapControl/MapPanel.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapPath.Silverlight.WinRT.cs b/MapControl/MapPath.Silverlight.WinRT.cs index 37c59a0f..aa4607bb 100644 --- a/MapControl/MapPath.Silverlight.WinRT.cs +++ b/MapControl/MapPath.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapPath.WPF.cs b/MapControl/MapPath.WPF.cs index 4160b8c7..c02af5ba 100644 --- a/MapControl/MapPath.WPF.cs +++ b/MapControl/MapPath.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapPath.cs b/MapControl/MapPath.cs index ec59aea4..665b3016 100644 --- a/MapControl/MapPath.cs +++ b/MapControl/MapPath.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapPolyline.Silverlight.WinRT.cs b/MapControl/MapPolyline.Silverlight.WinRT.cs index 65a85d32..6a9d8df4 100644 --- a/MapControl/MapPolyline.Silverlight.WinRT.cs +++ b/MapControl/MapPolyline.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Linq; diff --git a/MapControl/MapPolyline.WPF.cs b/MapControl/MapPolyline.WPF.cs index 31a37b3b..4cb7970e 100644 --- a/MapControl/MapPolyline.WPF.cs +++ b/MapControl/MapPolyline.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Linq; diff --git a/MapControl/MapPolyline.cs b/MapControl/MapPolyline.cs index e2c91594..fd38a4e5 100644 --- a/MapControl/MapPolyline.cs +++ b/MapControl/MapPolyline.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Collections.Generic; diff --git a/MapControl/MapRectangle.WPF.cs b/MapControl/MapRectangle.WPF.cs index 8f567505..7ee45fe6 100644 --- a/MapControl/MapRectangle.WPF.cs +++ b/MapControl/MapRectangle.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapRectangle.cs b/MapControl/MapRectangle.cs index 9a5099af..7a03012e 100644 --- a/MapControl/MapRectangle.cs +++ b/MapControl/MapRectangle.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MapScale.cs b/MapControl/MapScale.cs index 2b6428e4..efbc2d7b 100644 --- a/MapControl/MapScale.cs +++ b/MapControl/MapScale.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapTransform.cs b/MapControl/MapTransform.cs index 03ac5854..c78d468d 100644 --- a/MapControl/MapTransform.cs +++ b/MapControl/MapTransform.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/MatrixEx.cs b/MapControl/MatrixEx.cs index 388d50bb..443e5991 100644 --- a/MapControl/MatrixEx.cs +++ b/MapControl/MatrixEx.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -28,6 +28,11 @@ namespace MapControl public static Matrix Rotate(this Matrix matrix, double angle) { + if (angle == 0d) + { + return matrix; + } + angle = (angle % 360d) / 180d * Math.PI; var cos = Math.Cos(angle); var sin = Math.Sin(angle); @@ -37,6 +42,11 @@ namespace MapControl public static Matrix RotateAt(this Matrix matrix, double angle, double centerX, double centerY) { + if (angle == 0d) + { + return matrix; + } + angle = (angle % 360d) / 180d * Math.PI; var cos = Math.Cos(angle); var sin = Math.Sin(angle); @@ -51,8 +61,10 @@ namespace MapControl var determinant = matrix.M11 * matrix.M22 - matrix.M12 * matrix.M21; return new Matrix( - matrix.M22 / determinant, -matrix.M12 / determinant, - -matrix.M21 / determinant, matrix.M11 / determinant, + matrix.M22 / determinant, + -matrix.M12 / determinant, + -matrix.M21 / determinant, + matrix.M11 / determinant, (matrix.M21 * matrix.OffsetY - matrix.M22 * matrix.OffsetX) / determinant, (matrix.M12 * matrix.OffsetX - matrix.M11 * matrix.OffsetY) / determinant); } diff --git a/MapControl/MercatorTransform.cs b/MapControl/MercatorTransform.cs index 4c4b558f..b40b6279 100644 --- a/MapControl/MercatorTransform.cs +++ b/MapControl/MercatorTransform.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/PanelBase.cs b/MapControl/PanelBase.cs index e73efd0d..ea723bb0 100644 --- a/MapControl/PanelBase.cs +++ b/MapControl/PanelBase.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index 70d0caf6..953fe01d 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -15,10 +15,10 @@ using System.Windows; #endif [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/Pushpin.Silverlight.WinRT.cs b/MapControl/Pushpin.Silverlight.WinRT.cs index 7f5279bb..c3509e3d 100644 --- a/MapControl/Pushpin.Silverlight.WinRT.cs +++ b/MapControl/Pushpin.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if WINDOWS_RUNTIME diff --git a/MapControl/Pushpin.WPF.cs b/MapControl/Pushpin.WPF.cs index 2bef1f8a..7a66b4a5 100644 --- a/MapControl/Pushpin.WPF.cs +++ b/MapControl/Pushpin.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/Tile.Silverlight.WinRT.cs b/MapControl/Tile.Silverlight.WinRT.cs index c4418345..22811504 100644 --- a/MapControl/Tile.Silverlight.WinRT.cs +++ b/MapControl/Tile.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -23,7 +23,9 @@ namespace MapControl { public void SetImage(ImageSource image, bool animateOpacity = true, bool isDownloading = true) { - if (image != null && Image.Source == null) + Pending = false; + + if (image != null) { if (animateOpacity && OpacityAnimationDuration > TimeSpan.Zero) { @@ -47,8 +49,6 @@ namespace MapControl Image.Source = image; } - - Pending = false; } private void BitmapImageOpened(object sender, RoutedEventArgs e) diff --git a/MapControl/Tile.WPF.cs b/MapControl/Tile.WPF.cs index 7f579971..0246eb15 100644 --- a/MapControl/Tile.WPF.cs +++ b/MapControl/Tile.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -14,7 +14,9 @@ namespace MapControl { public void SetImage(ImageSource image, bool animateOpacity = true) { - if (image != null && Image.Source == null) + Pending = false; + + if (image != null) { if (animateOpacity && OpacityAnimationDuration > TimeSpan.Zero) { @@ -38,8 +40,6 @@ namespace MapControl Image.Source = image; } - - Pending = false; } private void BitmapDownloadCompleted(object sender, EventArgs e) diff --git a/MapControl/Tile.cs b/MapControl/Tile.cs index 85706745..f1ebfe30 100644 --- a/MapControl/Tile.cs +++ b/MapControl/Tile.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileImageLoader.Silverlight.cs b/MapControl/TileImageLoader.Silverlight.cs index 7b56c3d0..46be5dcf 100644 --- a/MapControl/TileImageLoader.Silverlight.cs +++ b/MapControl/TileImageLoader.Silverlight.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileImageLoader.WPF.cs b/MapControl/TileImageLoader.WPF.cs index b5d5b937..71a85864 100644 --- a/MapControl/TileImageLoader.WPF.cs +++ b/MapControl/TileImageLoader.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -57,7 +57,7 @@ namespace MapControl public readonly Tile Tile; public readonly ImageSource CachedImage; - public PendingTile(Tile tile, ImageSource cachedImage = null) + public PendingTile(Tile tile, ImageSource cachedImage) { Tile = tile; CachedImage = cachedImage; @@ -85,7 +85,7 @@ namespace MapControl } else { - var tileList = tiles.ToList(); // force immediate evaluation + var tileList = tiles.ToList(); // evaluate immediately var sourceName = tileLayer.SourceName; var maxDownloads = tileLayer.MaxParallelDownloads; @@ -103,30 +103,22 @@ namespace MapControl private void GetTiles(IEnumerable tiles, Dispatcher dispatcher, TileSource tileSource, string sourceName, int maxDownloads) { - if (Cache != null && - !string.IsNullOrWhiteSpace(sourceName) && - !(tileSource is ImageTileSource) && - !tileSource.UriFormat.StartsWith("file:")) - { - foreach (var tile in tiles) - { - BitmapSource image; + var useCache = Cache != null + && !string.IsNullOrWhiteSpace(sourceName) + && !(tileSource is ImageTileSource) + && !tileSource.UriFormat.StartsWith("file:"); - if (GetCachedImage(GetCacheKey(sourceName, tile), out image)) - { - dispatcher.BeginInvoke(new Action((t, i) => t.SetImage(i)), tile, image); - } - else - { - pendingTiles.Enqueue(new PendingTile(tile, image)); - } - } - } - else + foreach (var tile in tiles) { - foreach (var tile in tiles) + BitmapSource cachedImage = null; + + if (useCache && GetCachedImage(CacheKey(sourceName, tile), out cachedImage)) { - pendingTiles.Enqueue(new PendingTile(tile)); + dispatcher.BeginInvoke(new Action((t, i) => t.SetImage(i)), tile, cachedImage); + } + else + { + pendingTiles.Enqueue(new PendingTile(tile, cachedImage)); } } @@ -160,24 +152,14 @@ namespace MapControl if (uri != null) { - if (uri.Scheme == "file") // create from FileStream because creating from Uri leaves the file open + if (uri.Scheme == "file") // load from FileStream as loading from Uri leaves file open { - image = CreateImage(uri.LocalPath); + image = LoadImage(uri.LocalPath); } else { - HttpStatusCode statusCode; - - image = DownloadImage(uri, GetCacheKey(sourceName, tile), out statusCode); - - if (statusCode == HttpStatusCode.NotFound) - { - tileSource.IgnoreTile(tile.XIndex, tile.Y, tile.ZoomLevel); // do not request again - } - else if (image == null) // download failed, use cached image if available - { - image = pendingTile.CachedImage; - } + image = DownloadImage(uri, CacheKey(sourceName, tile)) + ?? pendingTile.CachedImage; // use possibly cached image if download failed } } } @@ -211,7 +193,7 @@ namespace MapControl return image; } - private static ImageSource CreateImage(string path) + private static ImageSource LoadImage(string path) { ImageSource image = null; @@ -233,10 +215,9 @@ namespace MapControl return image; } - private static ImageSource DownloadImage(Uri uri, string cacheKey, out HttpStatusCode statusCode) + private static ImageSource DownloadImage(Uri uri, string cacheKey) { BitmapSource image = null; - statusCode = HttpStatusCode.Unused; try { @@ -245,8 +226,6 @@ namespace MapControl using (var response = (HttpWebResponse)request.GetResponse()) { - statusCode = response.StatusCode; - using (var responseStream = response.GetResponseStream()) using (var memoryStream = new MemoryStream()) { @@ -263,12 +242,6 @@ namespace MapControl } catch (WebException ex) { - var response = ex.Response as HttpWebResponse; - if (response != null) - { - statusCode = response.StatusCode; - } - Debug.WriteLine("Downloading {0} failed: {1}: {2}", uri, ex.Status, ex.Message); } catch (Exception ex) @@ -279,14 +252,14 @@ namespace MapControl return image; } - private static string GetCacheKey(string sourceName, Tile tile) + private static string TileKey(TileSource tileSource, Tile tile) { - if (Cache == null || string.IsNullOrWhiteSpace(sourceName)) - { - return null; - } + return string.Format("{0:X}/{1:X}/{2:X}/{3:X}", tileSource.GetHashCode(), tile.ZoomLevel, tile.XIndex, tile.Y); + } - return string.Format("{0}/{1}/{2}/{3}", sourceName, tile.ZoomLevel, tile.XIndex, tile.Y); + private static string CacheKey(string sourceName, Tile tile) + { + return string.IsNullOrEmpty(sourceName) ? null : string.Format("{0}/{1}/{2}/{3}", sourceName, tile.ZoomLevel, tile.XIndex, tile.Y); } private static bool GetCachedImage(string cacheKey, out BitmapSource image) diff --git a/MapControl/TileImageLoader.WinRT.cs b/MapControl/TileImageLoader.WinRT.cs index 9b470050..c189b16a 100644 --- a/MapControl/TileImageLoader.WinRT.cs +++ b/MapControl/TileImageLoader.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -125,8 +125,8 @@ namespace MapControl while (pendingTiles.TryDequeue(out pendingTile)) { var tile = pendingTile.Tile; - var image = pendingTile.Image; var uri = pendingTile.Uri; + var image = pendingTile.Image; var extension = Path.GetExtension(uri.LocalPath); if (string.IsNullOrEmpty(extension) || extension == ".jpeg") @@ -136,19 +136,22 @@ namespace MapControl var cacheKey = string.Format(@"{0}\{1}\{2}\{3}{4}", sourceName, tile.ZoomLevel, tile.XIndex, tile.Y, extension); var cacheItem = await Cache.GetAsync(cacheKey); - var cachedBuffer = cacheItem != null ? cacheItem.Buffer : null; + var loaded = false; - if (cachedBuffer != null && cacheItem.Expires > DateTime.UtcNow) + if (cacheItem == null || cacheItem.Expires <= DateTime.UtcNow) { - await LoadImageFromBuffer(tile, image, cachedBuffer); + loaded = await DownloadImage(tile, image, uri, cacheKey); } - else - { - var statusCode = await DownloadImage(tile, image, uri, cacheKey, cachedBuffer); - if (statusCode == HttpStatusCode.NotFound) + if (!loaded && cacheItem != null && cacheItem.Buffer != null) + { + using (var stream = new InMemoryRandomAccessStream()) { - tileSource.IgnoreTile(tile.XIndex, tile.Y, tile.ZoomLevel); // do not request again + await stream.WriteAsync(cacheItem.Buffer); + await stream.FlushAsync(); + stream.Seek(0); + + await LoadImageFromStream(tile, image, stream); } } } @@ -156,21 +159,16 @@ namespace MapControl Interlocked.Decrement(ref taskCount); } - private async Task DownloadImage(Tile tile, BitmapSource image, Uri uri, string cacheKey, IBuffer cachedBuffer) + private async Task DownloadImage(Tile tile, BitmapSource image, Uri uri, string cacheKey) { - HttpStatusCode result = HttpStatusCode.None; - try { using (var httpClient = new HttpClient(new HttpBaseProtocolFilter { AllowAutoRedirect = false })) using (var response = await httpClient.GetAsync(uri)) { - result = response.StatusCode; - if (response.IsSuccessStatusCode) { - await LoadImageFromHttpResponse(response, tile, image, cacheKey); - return result; + return await LoadImageFromHttpResponse(response, tile, image, cacheKey); } Debug.WriteLine("{0}: ({1}) {2}", uri, (int)response.StatusCode, response.ReasonPhrase); @@ -181,15 +179,10 @@ namespace MapControl Debug.WriteLine("{0}: {1}", uri, ex.Message); } - if (cachedBuffer != null) - { - await LoadImageFromBuffer(tile, image, cachedBuffer); - } - - return result; + return false; } - private async Task LoadImageFromHttpResponse(HttpResponseMessage response, Tile tile, BitmapSource image, string cacheKey) + private async Task LoadImageFromHttpResponse(HttpResponseMessage response, Tile tile, BitmapSource image, string cacheKey) { using (var stream = new InMemoryRandomAccessStream()) { @@ -220,18 +213,8 @@ namespace MapControl await Cache.SetAsync(cacheKey, buffer, DateTime.UtcNow.Add(maxAge)); } - } - } - private async Task LoadImageFromBuffer(Tile tile, BitmapSource image, IBuffer buffer) - { - using (var stream = new InMemoryRandomAccessStream()) - { - await stream.WriteAsync(buffer); - await stream.FlushAsync(); - stream.Seek(0); - - return await LoadImageFromStream(tile, image, stream); + return loaded; } } diff --git a/MapControl/TileLayer.Silverlight.WinRT.cs b/MapControl/TileLayer.Silverlight.WinRT.cs index cc389e5b..aac95484 100644 --- a/MapControl/TileLayer.Silverlight.WinRT.cs +++ b/MapControl/TileLayer.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) namespace MapControl diff --git a/MapControl/TileLayer.WPF.cs b/MapControl/TileLayer.WPF.cs index ef74f4a4..ab864f11 100644 --- a/MapControl/TileLayer.WPF.cs +++ b/MapControl/TileLayer.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/TileLayer.cs b/MapControl/TileLayer.cs index 17cedf76..321c25dd 100644 --- a/MapControl/TileLayer.cs +++ b/MapControl/TileLayer.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -43,7 +43,7 @@ namespace MapControl public static readonly DependencyProperty TileSourceProperty = DependencyProperty.Register( "TileSource", typeof(TileSource), typeof(TileLayer), - new PropertyMetadata(null, (o, e) => ((TileLayer)o).UpdateTiles())); + new PropertyMetadata(null, (o, e) => ((TileLayer)o).UpdateTiles(true))); public static readonly DependencyProperty SourceNameProperty = DependencyProperty.Register( "SourceName", typeof(string), typeof(TileLayer), new PropertyMetadata(null)); @@ -179,14 +179,20 @@ namespace MapControl } } - protected virtual void UpdateTiles() + protected virtual void UpdateTiles(bool clearTiles = false) { if (tiles.Count > 0) { tileImageLoader.CancelLoadTiles(this); } + if (clearTiles) + { + tiles.Clear(); + } + SelectTiles(); + Children.Clear(); if (tiles.Count > 0) @@ -241,7 +247,7 @@ namespace MapControl tile = new Tile(z, x, y); var equivalentTile = tiles.FirstOrDefault( - t => t.Image.Source != null && t.ZoomLevel == z && t.XIndex == tile.XIndex && t.Y == y); + t => t.ZoomLevel == z && t.XIndex == tile.XIndex && t.Y == y && t.Image.Source != null); if (equivalentTile != null) { diff --git a/MapControl/TileLayerCollection.cs b/MapControl/TileLayerCollection.cs index b86bcb93..5dbee361 100644 --- a/MapControl/TileLayerCollection.cs +++ b/MapControl/TileLayerCollection.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Collections.ObjectModel; diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs index 9dd80fb2..d2bea1a9 100644 --- a/MapControl/TileSource.cs +++ b/MapControl/TileSource.cs @@ -1,9 +1,8 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; -using System.Collections.Generic; using System.Globalization; #if WINDOWS_RUNTIME using Windows.Foundation; @@ -21,8 +20,6 @@ namespace MapControl public const int TileSize = 256; public const double MetersPerDegree = 6378137d * Math.PI / 180d; // WGS 84 semi major axis - protected readonly HashSet IgnoredTiles = new HashSet(); - private Func getUri; private string uriFormat = string.Empty; @@ -87,38 +84,7 @@ namespace MapControl public virtual Uri GetUri(int x, int y, int zoomLevel) { - if (getUri == null) - { - return null; - } - - if (IgnoredTiles.Count > 0) - { - lock (IgnoredTiles) - { - if (IgnoredTiles.Contains(GetHashCode(x, y, zoomLevel))) - { - return null; - } - } - } - - return getUri(x, y, zoomLevel); - } - - public void IgnoreTile(int x, int y, int zoomLevel) - { - lock (IgnoredTiles) - { - IgnoredTiles.Add(GetHashCode(x, y, zoomLevel)); - } - } - - protected static long GetHashCode(int x, int y, int zoomLevel) - { - return (long)(x & 0xFFFFFF) - + ((long)(y & 0xFFFFFF) << 24) - + ((long)(zoomLevel & 0xFF) << 48); + return getUri != null ? getUri(x, y, zoomLevel) : null; } private Uri GetBasicUri(int x, int y, int zoomLevel) diff --git a/MapControl/TileSourceConverter.cs b/MapControl/TileSourceConverter.cs index 50aa3b54..8d4dc6f8 100644 --- a/MapControl/TileSourceConverter.cs +++ b/MapControl/TileSourceConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer +// © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index d3f996b6..0865a506 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Library for Windows Runtime")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs index 2e8e6a1b..a07a0c44 100644 --- a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Windows Phone Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index c2ceff4a..06e5e2f9 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Silverlight/Web Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 6a584bd3..19d1aee2 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Silverlight Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index ee828a0a..224aba4c 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Windows Runtime Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/MainWindow.xaml.cs b/SampleApps/WpfApplication/MainWindow.xaml.cs index 5410ffb9..311a5ef4 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml.cs +++ b/SampleApps/WpfApplication/MainWindow.xaml.cs @@ -12,7 +12,6 @@ namespace WpfApplication { //TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder); //TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder); - //TileImageLoader.HttpUserAgent = "..."; //BingMapsTileLayer.ApiKey = "..."; InitializeComponent(); diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index 542597ff..20a0a0e0 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control WPF Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.2")] -[assembly: AssemblyFileVersion("2.4.2")] +[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyFileVersion("2.4.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)]