2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2013-05-07 18:12:25 +02:00
|
|
|
|
// Copyright © Clemens Fischer 2012-2013
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
internal partial class TileContainer : ContainerVisual
|
|
|
|
|
|
{
|
|
|
|
|
|
private Matrix GetTransformMatrix(Matrix transform, double scale)
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Scale(scale, scale);
|
|
|
|
|
|
transform.Translate(offset.X, offset.Y);
|
|
|
|
|
|
transform.RotateAt(rotation, origin.X, origin.Y);
|
|
|
|
|
|
return transform;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Matrix GetTileIndexMatrix(int numTiles)
|
|
|
|
|
|
{
|
|
|
|
|
|
var mapToTileScale = (double)numTiles / 360d;
|
|
|
|
|
|
var transform = ViewportTransform.Matrix;
|
|
|
|
|
|
transform.Invert(); // view to map coordinates
|
|
|
|
|
|
transform.Translate(180d, -180d);
|
|
|
|
|
|
transform.Scale(mapToTileScale, -mapToTileScale); // map coordinates to tile indices
|
|
|
|
|
|
return transform;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|