From aa04fd0551ab55be0a39211dc8d62c7cf0379bd0 Mon Sep 17 00:00:00 2001 From: ClemensF Date: Thu, 29 Aug 2013 15:49:48 +0200 Subject: [PATCH] Version 1.3.10: Minor improvements in TileImageLoader. Removed SurfaceApplication from VS Solution. --- .../FileDbCache/Properties/AssemblyInfo.cs | 4 ++-- .../ImageFileCache/Properties/AssemblyInfo.cs | 4 ++-- MapControl.sln | 6 ------ MapControl/Properties/AssemblyInfo.cs | 4 ++-- .../TileImageLoader.Silverlight.WinRT.cs | 9 +++++--- MapControl/TileImageLoader.WPF.cs | 21 +++++++++++-------- MapControl/TileLayer.cs | 2 +- MapControl/TileSource.cs | 7 +++---- MapControl/WinRT/Properties/AssemblyInfo.cs | 4 ++-- .../Properties/AssemblyInfo.cs | 4 ++-- .../SilverlightApplication/MainPage.xaml | 2 +- .../SilverlightApplication/MainPage.xaml.cs | 10 ++++----- .../Properties/AssemblyInfo.cs | 4 ++-- SampleApps/StoreApplication/MainPage.xaml | 2 +- SampleApps/StoreApplication/MainPage.xaml.cs | 10 ++++----- .../Properties/AssemblyInfo.cs | 4 ++-- .../Properties/AssemblyInfo.cs | 4 ++-- SampleApps/WpfApplication/MainWindow.xaml | 4 ++-- .../WpfApplication/Properties/AssemblyInfo.cs | 4 ++-- .../Properties/Settings.Designer.cs | 2 +- 20 files changed, 53 insertions(+), 58 deletions(-) diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs index 2794ffbc..bd669f9a 100644 --- a/Caching/FileDbCache/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs index 8edbc738..41cc9659 100644 --- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl.sln b/MapControl.sln index 38634825..abec6eea 100644 --- a/MapControl.sln +++ b/MapControl.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileDbCache", "Caching\FileDbCache\FileDbCache.csproj", "{EF44F661-B98A-4676-927F-85D138F82300}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SurfaceApplication", "SampleApps\SurfaceApplication\SurfaceApplication.csproj", "{6285FB9D-B7EA-469A-B464-224077967167}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageFileCache", "Caching\ImageFileCache\ImageFileCache.csproj", "{86470440-FEE2-4120-AF5A-3762FB9C536F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightApplication", "SampleApps\SilverlightApplication\SilverlightApplication.csproj", "{CBA8C535-CCA3-4F60-8D3E-0E25791CBD21}" @@ -31,10 +29,6 @@ Global {EF44F661-B98A-4676-927F-85D138F82300}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF44F661-B98A-4676-927F-85D138F82300}.Release|Any CPU.ActiveCfg = Release|Any CPU {EF44F661-B98A-4676-927F-85D138F82300}.Release|Any CPU.Build.0 = Release|Any CPU - {6285FB9D-B7EA-469A-B464-224077967167}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6285FB9D-B7EA-469A-B464-224077967167}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6285FB9D-B7EA-469A-B464-224077967167}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6285FB9D-B7EA-469A-B464-224077967167}.Release|Any CPU.Build.0 = Release|Any CPU {86470440-FEE2-4120-AF5A-3762FB9C536F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {86470440-FEE2-4120-AF5A-3762FB9C536F}.Debug|Any CPU.Build.0 = Debug|Any CPU {86470440-FEE2-4120-AF5A-3762FB9C536F}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index 7d886deb..7ef58096 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -15,8 +15,8 @@ using System.Windows; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/TileImageLoader.Silverlight.WinRT.cs b/MapControl/TileImageLoader.Silverlight.WinRT.cs index 68036a7a..45958433 100644 --- a/MapControl/TileImageLoader.Silverlight.WinRT.cs +++ b/MapControl/TileImageLoader.Silverlight.WinRT.cs @@ -24,13 +24,16 @@ namespace MapControl this.tileLayer = tileLayer; } - internal void BeginGetTiles(IEnumerable tiles) + internal void StartGetTiles(IEnumerable tiles) { - foreach (var tile in tiles.Where(t => !t.HasImage)) + foreach (var tile in tiles) { var uri = tileLayer.TileSource.GetUri(tile.XIndex, tile.Y, tile.ZoomLevel); - tile.SetImageSource(new BitmapImage(uri), true); + if (uri != null) + { + tile.SetImageSource(new BitmapImage(uri), tileLayer.AnimateTileOpacity); + } } } diff --git a/MapControl/TileImageLoader.WPF.cs b/MapControl/TileImageLoader.WPF.cs index 013d6a44..171b2652 100644 --- a/MapControl/TileImageLoader.WPF.cs +++ b/MapControl/TileImageLoader.WPF.cs @@ -71,9 +71,12 @@ namespace MapControl this.tileLayer = tileLayer; } - internal void BeginGetTiles(IEnumerable tiles) + internal void StartGetTiles(IEnumerable tiles) { - ThreadPool.QueueUserWorkItem(BeginGetTilesAsync, new List(tiles.Where(t => !t.HasImage))); + if (tiles.Any()) + { + ThreadPool.QueueUserWorkItem(GetTilesAsync, tiles.ToList()); + } } internal void CancelGetTiles() @@ -87,15 +90,15 @@ namespace MapControl return string.Format("{0}/{1}/{2}/{3}", tileLayer.SourceName, tile.ZoomLevel, tile.XIndex, tile.Y); } - private void BeginGetTilesAsync(object newTilesList) + private void GetTilesAsync(object tileList) { - var newTiles = (List)newTilesList; + var tiles = (List)tileList; var imageTileSource = tileLayer.TileSource as ImageTileSource; var animateOpacity = tileLayer.AnimateTileOpacity; if (imageTileSource != null && !imageTileSource.CanLoadAsync) { - foreach (var tile in newTiles) + foreach (var tile in tiles) { tileLayer.Dispatcher.BeginInvoke( (Action)((t, ts) => t.SetImageSource(ts.LoadImage(t.XIndex, t.Y, t.ZoomLevel), animateOpacity)), @@ -108,9 +111,9 @@ namespace MapControl !tileLayer.TileSource.UriFormat.StartsWith("file://") && !string.IsNullOrWhiteSpace(tileLayer.SourceName)) { - var outdatedTiles = new List(newTiles.Count); + var outdatedTiles = new List(tiles.Count); - foreach (var tile in newTiles) + foreach (var tile in tiles) { var key = GetCacheKey(tile); var buffer = Cache.Get(key) as byte[]; @@ -136,10 +139,10 @@ namespace MapControl } } - newTiles = outdatedTiles; // enqueue outdated tiles at last + tiles = outdatedTiles; // enqueue outdated tiles at last } - foreach (var tile in newTiles) + foreach (var tile in tiles) { pendingTiles.Enqueue(tile); } diff --git a/MapControl/TileLayer.cs b/MapControl/TileLayer.cs index 8d9e120d..e7049644 100644 --- a/MapControl/TileLayer.cs +++ b/MapControl/TileLayer.cs @@ -96,7 +96,7 @@ namespace MapControl { SelectTiles(); RenderTiles(); - tileImageLoader.BeginGetTiles(tiles); + tileImageLoader.StartGetTiles(tiles.Where(t => !t.HasImage)); } } diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs index a6ff4a41..365a6838 100644 --- a/MapControl/TileSource.cs +++ b/MapControl/TileSource.cs @@ -23,7 +23,6 @@ namespace MapControl private Func getUri; private string uriFormat = string.Empty; - private int hostIndex = -1; public TileSource() { @@ -103,7 +102,7 @@ namespace MapControl private Uri GetOpenStreetMapUri(int x, int y, int zoomLevel) { - hostIndex = (hostIndex + 1) % 3; + var hostIndex = (x + y + zoomLevel) % 3; return new Uri(UriFormat. Replace("{c}", "abc".Substring(hostIndex, 1)). @@ -114,7 +113,7 @@ namespace MapControl private Uri GetGoogleMapsUri(int x, int y, int zoomLevel) { - hostIndex = (hostIndex + 1) % 4; + var hostIndex = (x + y + zoomLevel) % 4; return new Uri(UriFormat. Replace("{i}", hostIndex.ToString()). @@ -125,7 +124,7 @@ namespace MapControl private Uri GetMapQuestUri(int x, int y, int zoomLevel) { - hostIndex = (hostIndex % 4) + 1; + var hostIndex = (x + y + zoomLevel) % 4 + 1; return new Uri(UriFormat. Replace("{n}", hostIndex.ToString()). diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 6daee3f9..23dc9fc0 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index 49e8845c..74fe4944 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/MainPage.xaml b/SampleApps/SilverlightApplication/MainPage.xaml index 3e9e132e..1901d701 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml +++ b/SampleApps/SilverlightApplication/MainPage.xaml @@ -157,7 +157,7 @@ Value="{Binding Opacity, ElementName=mapImage, Mode=TwoWay}"/> - + OpenStreetMap OpenCycleMap OCM Transport diff --git a/SampleApps/SilverlightApplication/MainPage.xaml.cs b/SampleApps/SilverlightApplication/MainPage.xaml.cs index e7b88774..e8008c0a 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml.cs +++ b/SampleApps/SilverlightApplication/MainPage.xaml.cs @@ -20,6 +20,7 @@ namespace SilverlightApplication public MainPage() { InitializeComponent(); + tileLayerComboBox.SelectedIndex = 0; var polylines = (ICollection)Resources["Polylines"]; polylines.Add( @@ -134,12 +135,9 @@ namespace SilverlightApplication private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e) { - if (map != null) - { - var comboBox = (ComboBox)sender; - var tileLayers = (TileLayerCollection)Resources["TileLayers"]; - map.TileLayer = tileLayers[(string)comboBox.SelectedItem]; - } + var comboBox = (ComboBox)sender; + var tileLayers = (TileLayerCollection)Resources["TileLayers"]; + map.TileLayer = tileLayers[(string)comboBox.SelectedItem]; } private void SeamarksClick(object sender, RoutedEventArgs e) diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index c510aa75..6cfba49c 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/MainPage.xaml b/SampleApps/StoreApplication/MainPage.xaml index c3093ae2..73beda53 100644 --- a/SampleApps/StoreApplication/MainPage.xaml +++ b/SampleApps/StoreApplication/MainPage.xaml @@ -185,7 +185,7 @@ - + OpenStreetMap OpenCycleMap OCM Transport diff --git a/SampleApps/StoreApplication/MainPage.xaml.cs b/SampleApps/StoreApplication/MainPage.xaml.cs index 36372cfb..66aa9794 100644 --- a/SampleApps/StoreApplication/MainPage.xaml.cs +++ b/SampleApps/StoreApplication/MainPage.xaml.cs @@ -23,6 +23,7 @@ namespace StoreApplication public MainPage() { this.InitializeComponent(); + tileLayerComboBox.SelectedIndex = 0; var polylines = (ICollection)Resources["Polylines"]; polylines.Add( @@ -143,12 +144,9 @@ namespace StoreApplication private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e) { - if (map != null) - { - var comboBox = (ComboBox)sender; - var tileLayers = (TileLayerCollection)Resources["TileLayers"]; - map.TileLayer = tileLayers[(string)((ComboBoxItem)comboBox.SelectedItem).Content]; - } + var comboBox = (ComboBox)sender; + var tileLayers = (TileLayerCollection)Resources["TileLayers"]; + map.TileLayer = tileLayers[(string)((ComboBoxItem)comboBox.SelectedItem).Content]; } } } diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index 86c56620..80d8c7be 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs index eadcd0dc..3d7bc3d9 100644 --- a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index 949dddf7..64e4ba7f 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -28,7 +28,7 @@ + UriFormat="http://watzmann-geog.urz.uni-heidelberg.de/cached/osm?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=osm_auto:all&STYLES=&SRS=EPSG:900913&BBOX={W},{S},{E},{N}&WIDTH={X}&HEIGHT={Y}&FORMAT=image/png"/>--> diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index 2f48bbe9..e82fe6a8 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.9")] -[assembly: AssemblyFileVersion("1.3.9")] +[assembly: AssemblyVersion("1.3.10")] +[assembly: AssemblyFileVersion("1.3.10")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/Properties/Settings.Designer.cs b/SampleApps/WpfApplication/Properties/Settings.Designer.cs index c4d3337e..00ec00df 100644 --- a/SampleApps/WpfApplication/Properties/Settings.Designer.cs +++ b/SampleApps/WpfApplication/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18046 +// Runtime Version:4.0.30319.18051 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated.