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/
// Copyright © 2014 Clemens Fischer
// © 2015 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;

View file

@ -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)]

View file

@ -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;

View file

@ -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)]

View file

@ -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;

View file

@ -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)]

View file

@ -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;

View file

@ -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)]

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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())

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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);
}

View file

@ -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;

View file

@ -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

View file

@ -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)]

View file

@ -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

View file

@ -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;

View file

@ -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)

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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<Tile> 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<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)
BitmapSource cachedImage = null;
if (useCache && GetCachedImage(CacheKey(sourceName, tile), out cachedImage))
{
pendingTiles.Enqueue(new PendingTile(tile));
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.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)

View file

@ -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<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
{
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<bool> 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<bool> 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;
}
}

View file

@ -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

View file

@ -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;

View file

@ -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)
{

View file

@ -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;

View file

@ -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<long> IgnoredTiles = new HashSet<long>();
private Func<int, int, int, Uri> 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)

View file

@ -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;

View file

@ -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)]

View file

@ -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)]

View file

@ -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)]

View file

@ -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)]

View file

@ -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)]

View file

@ -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();

View file

@ -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)]