Version 2.4.3: Some cleanup.

This commit is contained in:
ClemensF 2015-01-20 17:52:02 +01:00
parent f6a881c674
commit 9f9669ea00
82 changed files with 183 additions and 247 deletions

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("ObjectCache implementation based on EzTools FileDb")] [assembly: AssemblyDescription("ObjectCache implementation based on EzTools FileDb")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("IImageCache implementation based on EzTools FileDb")] [assembly: AssemblyDescription("IImageCache implementation based on EzTools FileDb")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("ObjectCache implementation based on local image files")] [assembly: AssemblyDescription("ObjectCache implementation based on local image files")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("IImageCache implementation based on local image files")] [assembly: AssemblyDescription("IImageCache implementation based on local image files")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
namespace MapControl namespace MapControl

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Collections.Generic; using System.Collections.Generic;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.IO; using System.IO;
@ -31,7 +31,6 @@ namespace MapControl
if (IsAsync) if (IsAsync)
{ {
var request = HttpWebRequest.CreateHttp(uri); var request = HttpWebRequest.CreateHttp(uri);
request.UserAgent = TileImageLoader.HttpUserAgent;
using (var response = (HttpWebResponse)request.GetResponse()) using (var response = (HttpWebResponse)request.GetResponse())
using (var responseStream = response.GetResponseStream()) using (var responseStream = response.GetResponseStream())

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
namespace MapControl namespace MapControl

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
@ -61,15 +61,15 @@ namespace MapControl
public static Location Parse(string s) public static Location Parse(string s)
{ {
var tokens = s.Split(new char[] { ',' }); var pair = s.Split(new char[] { ',' });
if (tokens.Length != 2) if (pair.Length != 2)
{ {
throw new FormatException("Location string must be a comma-separated pair of double values"); throw new FormatException("Location string must be a comma-separated pair of double values");
} }
return new Location( return new Location(
double.Parse(tokens[0], NumberStyles.Float, CultureInfo.InvariantCulture), double.Parse(pair[0], NumberStyles.Float, CultureInfo.InvariantCulture),
double.Parse(tokens[1], NumberStyles.Float, CultureInfo.InvariantCulture)); double.Parse(pair[1], NumberStyles.Float, CultureInfo.InvariantCulture));
} }
public static double NormalizeLongitude(double longitude) public static double NormalizeLongitude(double longitude)

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using Windows.Devices.Input; using Windows.Devices.Input;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
@ -31,6 +31,7 @@ namespace MapControl
{ {
private const double MaximumZoomLevel = 22d; private const double MaximumZoomLevel = 22d;
public static double ZoomLevelSwitchDelta = 0d;
public static TimeSpan TileUpdateInterval = TimeSpan.FromSeconds(0.5); public static TimeSpan TileUpdateInterval = TimeSpan.FromSeconds(0.5);
public static TimeSpan AnimationDuration = TimeSpan.FromSeconds(0.3); public static TimeSpan AnimationDuration = TimeSpan.FromSeconds(0.3);
public static EasingFunctionBase AnimationEasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseOut }; public static EasingFunctionBase AnimationEasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseOut };
@ -554,7 +555,6 @@ namespace MapControl
center = new Location( center = new Location(
Math.Min(Math.Max(center.Latitude, -mapTransform.MaxLatitude), mapTransform.MaxLatitude), Math.Min(Math.Max(center.Latitude, -mapTransform.MaxLatitude), mapTransform.MaxLatitude),
Location.NormalizeLongitude(center.Longitude)); Location.NormalizeLongitude(center.Longitude));
InternalSetValue(property, center); InternalSetValue(property, center);
} }
} }
@ -880,9 +880,7 @@ namespace MapControl
{ {
tileUpdateTimer.Stop(); tileUpdateTimer.Stop();
// relative size of scaled tile ranges from 0.75 to 1.5 (192 to 384 pixels) var zoomLevel = (int)Math.Round(ZoomLevel + ZoomLevelSwitchDelta);
var zoomLevelSwitchDelta = Math.Log(0.75, 2d);
var zoomLevel = (int)Math.Floor(ZoomLevel - zoomLevelSwitchDelta);
var transform = GetTileIndexMatrix((double)(1 << zoomLevel) / 360d); var transform = GetTileIndexMatrix((double)(1 << zoomLevel) / 360d);
// tile indices of visible rectangle // tile indices of visible rectangle

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Linq; using System.Linq;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Linq; using System.Linq;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Collections.Generic; using System.Collections.Generic;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
@ -28,6 +28,11 @@ namespace MapControl
public static Matrix Rotate(this Matrix matrix, double angle) public static Matrix Rotate(this Matrix matrix, double angle)
{ {
if (angle == 0d)
{
return matrix;
}
angle = (angle % 360d) / 180d * Math.PI; angle = (angle % 360d) / 180d * Math.PI;
var cos = Math.Cos(angle); var cos = Math.Cos(angle);
var sin = Math.Sin(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) public static Matrix RotateAt(this Matrix matrix, double angle, double centerX, double centerY)
{ {
if (angle == 0d)
{
return matrix;
}
angle = (angle % 360d) / 180d * Math.PI; angle = (angle % 360d) / 180d * Math.PI;
var cos = Math.Cos(angle); var cos = Math.Cos(angle);
var sin = Math.Sin(angle); var sin = Math.Sin(angle);
@ -51,8 +61,10 @@ namespace MapControl
var determinant = matrix.M11 * matrix.M22 - matrix.M12 * matrix.M21; var determinant = matrix.M11 * matrix.M22 - matrix.M12 * matrix.M21;
return new Matrix( return new Matrix(
matrix.M22 / determinant, -matrix.M12 / determinant, matrix.M22 / determinant,
-matrix.M21 / determinant, matrix.M11 / determinant, -matrix.M12 / determinant,
-matrix.M21 / determinant,
matrix.M11 / determinant,
(matrix.M21 * matrix.OffsetY - matrix.M22 * matrix.OffsetX) / determinant, (matrix.M21 * matrix.OffsetY - matrix.M22 * matrix.OffsetX) / determinant,
(matrix.M12 * matrix.OffsetX - matrix.M11 * matrix.OffsetY) / determinant); (matrix.M12 * matrix.OffsetX - matrix.M11 * matrix.OffsetY) / determinant);
} }

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -15,10 +15,10 @@ using System.Windows;
#endif #endif
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
@ -23,7 +23,9 @@ namespace MapControl
{ {
public void SetImage(ImageSource image, bool animateOpacity = true, bool isDownloading = true) 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) if (animateOpacity && OpacityAnimationDuration > TimeSpan.Zero)
{ {
@ -47,8 +49,6 @@ namespace MapControl
Image.Source = image; Image.Source = image;
} }
Pending = false;
} }
private void BitmapImageOpened(object sender, RoutedEventArgs e) private void BitmapImageOpened(object sender, RoutedEventArgs e)

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
@ -14,7 +14,9 @@ namespace MapControl
{ {
public void SetImage(ImageSource image, bool animateOpacity = true) public void SetImage(ImageSource image, bool animateOpacity = true)
{ {
if (image != null && Image.Source == null) Pending = false;
if (image != null)
{ {
if (animateOpacity && OpacityAnimationDuration > TimeSpan.Zero) if (animateOpacity && OpacityAnimationDuration > TimeSpan.Zero)
{ {
@ -38,8 +40,6 @@ namespace MapControl
Image.Source = image; Image.Source = image;
} }
Pending = false;
} }
private void BitmapDownloadCompleted(object sender, EventArgs e) private void BitmapDownloadCompleted(object sender, EventArgs e)

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
@ -57,7 +57,7 @@ namespace MapControl
public readonly Tile Tile; public readonly Tile Tile;
public readonly ImageSource CachedImage; public readonly ImageSource CachedImage;
public PendingTile(Tile tile, ImageSource cachedImage = null) public PendingTile(Tile tile, ImageSource cachedImage)
{ {
Tile = tile; Tile = tile;
CachedImage = cachedImage; CachedImage = cachedImage;
@ -85,7 +85,7 @@ namespace MapControl
} }
else else
{ {
var tileList = tiles.ToList(); // force immediate evaluation var tileList = tiles.ToList(); // evaluate immediately
var sourceName = tileLayer.SourceName; var sourceName = tileLayer.SourceName;
var maxDownloads = tileLayer.MaxParallelDownloads; var maxDownloads = tileLayer.MaxParallelDownloads;
@ -103,30 +103,22 @@ namespace MapControl
private void GetTiles(IEnumerable<Tile> tiles, Dispatcher dispatcher, TileSource tileSource, string sourceName, int maxDownloads) private void GetTiles(IEnumerable<Tile> tiles, Dispatcher dispatcher, TileSource tileSource, string sourceName, int maxDownloads)
{ {
if (Cache != null && var useCache = Cache != null
!string.IsNullOrWhiteSpace(sourceName) && && !string.IsNullOrWhiteSpace(sourceName)
!(tileSource is ImageTileSource) && && !(tileSource is ImageTileSource)
!tileSource.UriFormat.StartsWith("file:")) && !tileSource.UriFormat.StartsWith("file:");
{
foreach (var tile in tiles)
{
BitmapSource image;
if (GetCachedImage(GetCacheKey(sourceName, tile), out image))
{
dispatcher.BeginInvoke(new Action<Tile, ImageSource>((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)
{ {
pendingTiles.Enqueue(new PendingTile(tile)); BitmapSource cachedImage = null;
if (useCache && GetCachedImage(CacheKey(sourceName, tile), out cachedImage))
{
dispatcher.BeginInvoke(new Action<Tile, ImageSource>((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 != 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 else
{ {
HttpStatusCode statusCode; image = DownloadImage(uri, CacheKey(sourceName, tile))
?? pendingTile.CachedImage; // use possibly cached image if download failed
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;
}
} }
} }
} }
@ -211,7 +193,7 @@ namespace MapControl
return image; return image;
} }
private static ImageSource CreateImage(string path) private static ImageSource LoadImage(string path)
{ {
ImageSource image = null; ImageSource image = null;
@ -233,10 +215,9 @@ namespace MapControl
return image; return image;
} }
private static ImageSource DownloadImage(Uri uri, string cacheKey, out HttpStatusCode statusCode) private static ImageSource DownloadImage(Uri uri, string cacheKey)
{ {
BitmapSource image = null; BitmapSource image = null;
statusCode = HttpStatusCode.Unused;
try try
{ {
@ -245,8 +226,6 @@ namespace MapControl
using (var response = (HttpWebResponse)request.GetResponse()) using (var response = (HttpWebResponse)request.GetResponse())
{ {
statusCode = response.StatusCode;
using (var responseStream = response.GetResponseStream()) using (var responseStream = response.GetResponseStream())
using (var memoryStream = new MemoryStream()) using (var memoryStream = new MemoryStream())
{ {
@ -263,12 +242,6 @@ namespace MapControl
} }
catch (WebException ex) 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); Debug.WriteLine("Downloading {0} failed: {1}: {2}", uri, ex.Status, ex.Message);
} }
catch (Exception ex) catch (Exception ex)
@ -279,14 +252,14 @@ namespace MapControl
return image; 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 string.Format("{0:X}/{1:X}/{2:X}/{3:X}", tileSource.GetHashCode(), tile.ZoomLevel, tile.XIndex, tile.Y);
{
return null;
} }
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) private static bool GetCachedImage(string cacheKey, out BitmapSource image)

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
@ -125,8 +125,8 @@ namespace MapControl
while (pendingTiles.TryDequeue(out pendingTile)) while (pendingTiles.TryDequeue(out pendingTile))
{ {
var tile = pendingTile.Tile; var tile = pendingTile.Tile;
var image = pendingTile.Image;
var uri = pendingTile.Uri; var uri = pendingTile.Uri;
var image = pendingTile.Image;
var extension = Path.GetExtension(uri.LocalPath); var extension = Path.GetExtension(uri.LocalPath);
if (string.IsNullOrEmpty(extension) || extension == ".jpeg") 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 cacheKey = string.Format(@"{0}\{1}\{2}\{3}{4}", sourceName, tile.ZoomLevel, tile.XIndex, tile.Y, extension);
var cacheItem = await Cache.GetAsync(cacheKey); 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)
{ {
tileSource.IgnoreTile(tile.XIndex, tile.Y, tile.ZoomLevel); // do not request again using (var stream = new InMemoryRandomAccessStream())
{
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); Interlocked.Decrement(ref taskCount);
} }
private async Task<HttpStatusCode> DownloadImage(Tile tile, BitmapSource image, Uri uri, string cacheKey, IBuffer cachedBuffer) private async Task<bool> DownloadImage(Tile tile, BitmapSource image, Uri uri, string cacheKey)
{ {
HttpStatusCode result = HttpStatusCode.None;
try try
{ {
using (var httpClient = new HttpClient(new HttpBaseProtocolFilter { AllowAutoRedirect = false })) using (var httpClient = new HttpClient(new HttpBaseProtocolFilter { AllowAutoRedirect = false }))
using (var response = await httpClient.GetAsync(uri)) using (var response = await httpClient.GetAsync(uri))
{ {
result = response.StatusCode;
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
await LoadImageFromHttpResponse(response, tile, image, cacheKey); return await LoadImageFromHttpResponse(response, tile, image, cacheKey);
return result;
} }
Debug.WriteLine("{0}: ({1}) {2}", uri, (int)response.StatusCode, response.ReasonPhrase); Debug.WriteLine("{0}: ({1}) {2}", uri, (int)response.StatusCode, response.ReasonPhrase);
@ -181,15 +179,10 @@ namespace MapControl
Debug.WriteLine("{0}: {1}", uri, ex.Message); Debug.WriteLine("{0}: {1}", uri, ex.Message);
} }
if (cachedBuffer != null) return false;
{
await LoadImageFromBuffer(tile, image, cachedBuffer);
} }
return result; private async Task<bool> 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()) using (var stream = new InMemoryRandomAccessStream())
{ {
@ -220,18 +213,8 @@ namespace MapControl
await Cache.SetAsync(cacheKey, buffer, DateTime.UtcNow.Add(maxAge)); await Cache.SetAsync(cacheKey, buffer, DateTime.UtcNow.Add(maxAge));
} }
}
}
private async Task<bool> LoadImageFromBuffer(Tile tile, BitmapSource image, IBuffer buffer) return loaded;
{
using (var stream = new InMemoryRandomAccessStream())
{
await stream.WriteAsync(buffer);
await stream.FlushAsync();
stream.Seek(0);
return await LoadImageFromStream(tile, image, stream);
} }
} }

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
namespace MapControl namespace MapControl

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Windows; using System.Windows;

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
@ -43,7 +43,7 @@ namespace MapControl
public static readonly DependencyProperty TileSourceProperty = DependencyProperty.Register( public static readonly DependencyProperty TileSourceProperty = DependencyProperty.Register(
"TileSource", typeof(TileSource), typeof(TileLayer), "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( public static readonly DependencyProperty SourceNameProperty = DependencyProperty.Register(
"SourceName", typeof(string), typeof(TileLayer), new PropertyMetadata(null)); "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) if (tiles.Count > 0)
{ {
tileImageLoader.CancelLoadTiles(this); tileImageLoader.CancelLoadTiles(this);
} }
if (clearTiles)
{
tiles.Clear();
}
SelectTiles(); SelectTiles();
Children.Clear(); Children.Clear();
if (tiles.Count > 0) if (tiles.Count > 0)
@ -241,7 +247,7 @@ namespace MapControl
tile = new Tile(z, x, y); tile = new Tile(z, x, y);
var equivalentTile = tiles.FirstOrDefault( 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) if (equivalentTile != null)
{ {

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View file

@ -1,9 +1,8 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
#if WINDOWS_RUNTIME #if WINDOWS_RUNTIME
using Windows.Foundation; using Windows.Foundation;
@ -21,8 +20,6 @@ namespace MapControl
public const int TileSize = 256; public const int TileSize = 256;
public const double MetersPerDegree = 6378137d * Math.PI / 180d; // WGS 84 semi major axis public const double MetersPerDegree = 6378137d * Math.PI / 180d; // WGS 84 semi major axis
protected readonly HashSet<long> IgnoredTiles = new HashSet<long>();
private Func<int, int, int, Uri> getUri; private Func<int, int, int, Uri> getUri;
private string uriFormat = string.Empty; private string uriFormat = string.Empty;
@ -87,38 +84,7 @@ namespace MapControl
public virtual Uri GetUri(int x, int y, int zoomLevel) public virtual Uri GetUri(int x, int y, int zoomLevel)
{ {
if (getUri == null) return getUri != null ? getUri(x, y, zoomLevel) : 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);
} }
private Uri GetBasicUri(int x, int y, int zoomLevel) private Uri GetBasicUri(int x, int y, int zoomLevel)

View file

@ -1,5 +1,5 @@
// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © 2014 Clemens Fischer // © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("XAML Map Control Library for Windows Runtime")] [assembly: AssemblyDescription("XAML Map Control Library for Windows Runtime")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("XAML Map Control Windows Phone Sample Application")] [assembly: AssemblyDescription("XAML Map Control Windows Phone Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("XAML Map Control Silverlight/Web Sample Application")] [assembly: AssemblyDescription("XAML Map Control Silverlight/Web Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("XAML Map Control Silverlight Sample Application")] [assembly: AssemblyDescription("XAML Map Control Silverlight Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("XAML Map Control Windows Runtime Sample Application")] [assembly: AssemblyDescription("XAML Map Control Windows Runtime Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -12,7 +12,6 @@ namespace WpfApplication
{ {
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder); //TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder);
//TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder); //TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder);
//TileImageLoader.HttpUserAgent = "...";
//BingMapsTileLayer.ApiKey = "..."; //BingMapsTileLayer.ApiKey = "...";
InitializeComponent(); InitializeComponent();

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("XAML Map Control WPF Sample Application")] [assembly: AssemblyDescription("XAML Map Control WPF Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.4.2")] [assembly: AssemblyVersion("2.4.3")]
[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyFileVersion("2.4.3")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]