mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 2.4.8: Fixed issue when MapPath.Data is frozen.
This commit is contained in:
parent
e9868a993d
commit
ba45aa5901
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreApplication", "SampleA
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfApplication", "SampleApps\WpfApplication\WpfApplication.csproj", "{9949326E-9261-4F95-89B1-151F60498951}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SampleApps", "SampleApps", "{100879CC-8910-459E-856E-253D629E45DE}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Caching", "Caching", "{AE8A7E02-0F7D-41B0-AB23-15394150ED17}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -89,4 +93,15 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{C7BF2B18-CC74-430B-BCB2-600304EFA3D8} = {AE8A7E02-0F7D-41B0-AB23-15394150ED17}
|
||||
{EF44F661-B98A-4676-927F-85D138F82300} = {AE8A7E02-0F7D-41B0-AB23-15394150ED17}
|
||||
{F789647E-96F7-43E3-A895-FA3FE8D01260} = {AE8A7E02-0F7D-41B0-AB23-15394150ED17}
|
||||
{86470440-FEE2-4120-AF5A-3762FB9C536F} = {AE8A7E02-0F7D-41B0-AB23-15394150ED17}
|
||||
{8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9} = {100879CC-8910-459E-856E-253D629E45DE}
|
||||
{CBA8C535-CCA3-4F60-8D3E-0E25791CBD21} = {100879CC-8910-459E-856E-253D629E45DE}
|
||||
{177C4EF8-0B0A-426E-BDCC-168DC10AC1C1} = {100879CC-8910-459E-856E-253D629E45DE}
|
||||
{747A3F84-E11F-4EC8-9463-98BBB1E0D0A4} = {100879CC-8910-459E-856E-253D629E45DE}
|
||||
{9949326E-9261-4F95-89B1-151F60498951} = {100879CC-8910-459E-856E-253D629E45DE}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -16,15 +16,20 @@ namespace MapControl
|
|||
{
|
||||
public partial class MapPath : Path
|
||||
{
|
||||
private Geometry data;
|
||||
|
||||
public MapPath()
|
||||
{
|
||||
MapPanel.AddParentMapHandlers(this);
|
||||
}
|
||||
|
||||
private Geometry data;
|
||||
|
||||
protected override Size MeasureOverride(Size constraint)
|
||||
{
|
||||
if (Stretch != Stretch.None)
|
||||
{
|
||||
Stretch = Stretch.None;
|
||||
}
|
||||
|
||||
// Work-around for missing PropertyChangedCallback for the Data property.
|
||||
if (data != Data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,14 @@ namespace MapControl
|
|||
{
|
||||
public static readonly DependencyProperty DataProperty = DependencyProperty.Register(
|
||||
"Data", typeof(Geometry), typeof(MapPath), new FrameworkPropertyMetadata(
|
||||
null, FrameworkPropertyMetadataOptions.AffectsRender, (o, e) => ((MapPath)o).UpdateData()));
|
||||
null, FrameworkPropertyMetadataOptions.AffectsRender,
|
||||
(o, e) => ((MapPath)o).UpdateData(), CoerceDataProperty));
|
||||
|
||||
static MapPath()
|
||||
{
|
||||
StretchProperty.OverrideMetadata(typeof(MapPath),
|
||||
new FrameworkPropertyMetadata { CoerceValueCallback = (o, v) => Stretch.None });
|
||||
}
|
||||
|
||||
public Geometry Data
|
||||
{
|
||||
|
|
@ -30,5 +37,11 @@ namespace MapControl
|
|||
// Shape.MeasureOverride sometimes returns an empty Size.
|
||||
return new Size(1, 1);
|
||||
}
|
||||
|
||||
private static object CoerceDataProperty(DependencyObject obj, object value)
|
||||
{
|
||||
var data = (Geometry)value;
|
||||
return data != null && data.IsFrozen ? data.CloneCurrentValue() : data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Base class for map shapes. The shape geometry is given by the Data property,
|
||||
/// which must contain a Geometry defined in cartesian (projected) map coordinates.
|
||||
/// The Stretch property is meaningless for MapPath, it will be reset to None.
|
||||
/// </summary>
|
||||
public partial class MapPath : IMapElement
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,54 +17,62 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class MercatorTransform : MapTransform
|
||||
{
|
||||
private static readonly double maxLatitude = Math.Atan(Math.Sinh(Math.PI)) / Math.PI * 180d;
|
||||
public static readonly double MaxLatitudeValue = Math.Atan(Math.Sinh(Math.PI)) / Math.PI * 180d;
|
||||
|
||||
public override double MaxLatitude
|
||||
public static double RelativeScale(double latitude)
|
||||
{
|
||||
get { return maxLatitude; }
|
||||
}
|
||||
|
||||
public override double RelativeScale(Location location)
|
||||
{
|
||||
if (location.Latitude <= -90d)
|
||||
if (latitude <= -90d)
|
||||
{
|
||||
return double.NegativeInfinity;
|
||||
}
|
||||
|
||||
if (location.Latitude >= 90d)
|
||||
if (latitude >= 90d)
|
||||
{
|
||||
return double.PositiveInfinity;
|
||||
}
|
||||
|
||||
return 1d / Math.Cos(location.Latitude * Math.PI / 180d);
|
||||
return 1d / Math.Cos(latitude * Math.PI / 180d);
|
||||
}
|
||||
|
||||
public static double LatitudeToY(double latitude)
|
||||
{
|
||||
if (latitude <= -90d)
|
||||
{
|
||||
return double.NegativeInfinity;
|
||||
}
|
||||
|
||||
if (latitude >= 90d)
|
||||
{
|
||||
return double.PositiveInfinity;
|
||||
}
|
||||
|
||||
latitude *= Math.PI / 180d;
|
||||
return Math.Log(Math.Tan(latitude) + 1d / Math.Cos(latitude)) / Math.PI * 180d;
|
||||
}
|
||||
|
||||
public static double YToLatitude(double y)
|
||||
{
|
||||
return Math.Atan(Math.Sinh(y * Math.PI / 180d)) / Math.PI * 180d;
|
||||
}
|
||||
|
||||
public override double MaxLatitude
|
||||
{
|
||||
get { return MaxLatitudeValue; }
|
||||
}
|
||||
|
||||
public override double RelativeScale(Location location)
|
||||
{
|
||||
return RelativeScale(location.Latitude);
|
||||
}
|
||||
|
||||
public override Point Transform(Location location)
|
||||
{
|
||||
double latitude;
|
||||
|
||||
if (location.Latitude <= -90d)
|
||||
{
|
||||
latitude = double.NegativeInfinity;
|
||||
}
|
||||
else if (location.Latitude >= 90d)
|
||||
{
|
||||
latitude = double.PositiveInfinity;
|
||||
}
|
||||
else
|
||||
{
|
||||
latitude = location.Latitude * Math.PI / 180d;
|
||||
latitude = Math.Log(Math.Tan(latitude) + 1d / Math.Cos(latitude)) / Math.PI * 180d;
|
||||
}
|
||||
|
||||
return new Point(location.Longitude, latitude);
|
||||
return new Point(location.Longitude, LatitudeToY(location.Latitude));
|
||||
}
|
||||
|
||||
public override Location Transform(Point point)
|
||||
{
|
||||
var latitude = Math.Atan(Math.Sinh(point.Y * Math.PI / 180d)) / Math.PI * 180d;
|
||||
|
||||
return new Location(latitude, point.X);
|
||||
return new Location(YToLatitude(point.Y), point.X);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ using System.Windows;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -4,11 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
#if WINDOWS_RUNTIME
|
||||
using Windows.Foundation;
|
||||
#else
|
||||
using System.Windows;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
|
|
@ -159,35 +154,32 @@ namespace MapControl
|
|||
|
||||
private Uri GetBoundingBoxUri(int x, int y, int zoomLevel)
|
||||
{
|
||||
var n = (double)(1 << zoomLevel);
|
||||
var x1 = MetersPerDegree * ((double)x * 360d / n - 180d);
|
||||
var x2 = MetersPerDegree * ((double)(x + 1) * 360d / n - 180d);
|
||||
var y1 = MetersPerDegree * (180d - (double)(y + 1) * 360d / n);
|
||||
var y2 = MetersPerDegree * (180d - (double)y * 360d / n);
|
||||
var numTiles = (double)(1 << zoomLevel);
|
||||
var west = MetersPerDegree * ((double)x * 360d / numTiles - 180d);
|
||||
var east = MetersPerDegree * ((double)(x + 1) * 360d / numTiles - 180d);
|
||||
var south = MetersPerDegree * (180d - (double)(y + 1) * 360d / numTiles);
|
||||
var north = MetersPerDegree * (180d - (double)y * 360d / numTiles);
|
||||
|
||||
return new Uri(uriFormat.
|
||||
Replace("{W}", x1.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{S}", y1.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{E}", x2.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{N}", y2.ToString(CultureInfo.InvariantCulture)));
|
||||
Replace("{W}", west.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{S}", south.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{E}", east.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{N}", north.ToString(CultureInfo.InvariantCulture)));
|
||||
}
|
||||
|
||||
private Uri GetLatLonBoundingBoxUri(int x, int y, int zoomLevel)
|
||||
{
|
||||
var t = new MercatorTransform();
|
||||
var n = (double)(1 << zoomLevel);
|
||||
var x1 = (double)x * 360d / n - 180d;
|
||||
var x2 = (double)(x + 1) * 360d / n - 180d;
|
||||
var y1 = 180d - (double)(y + 1) * 360d / n;
|
||||
var y2 = 180d - (double)y * 360d / n;
|
||||
var p1 = t.Transform(new Point(x1, y1));
|
||||
var p2 = t.Transform(new Point(x2, y2));
|
||||
var numTiles = (double)(1 << zoomLevel);
|
||||
var west = (double)x * 360d / numTiles - 180d;
|
||||
var east = (double)(x + 1) * 360d / numTiles - 180d;
|
||||
var south = MercatorTransform.YToLatitude(180d - (double)(y + 1) * 360d / numTiles);
|
||||
var north = MercatorTransform.YToLatitude(180d - (double)y * 360d / numTiles);
|
||||
|
||||
return new Uri(uriFormat.
|
||||
Replace("{w}", p1.Longitude.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{s}", p1.Latitude.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{e}", p2.Longitude.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{n}", p2.Latitude.ToString(CultureInfo.InvariantCulture)));
|
||||
Replace("{w}", west.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{s}", south.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{e}", east.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{n}", north.ToString(CultureInfo.InvariantCulture)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@
|
|||
</Path.Data>
|
||||
</Path>
|
||||
|
||||
<map:MapPath Fill="Aqua" Opacity="0.5">
|
||||
<map:MapPath Stroke="Blue" Fill="Aqua" Opacity="0.5">
|
||||
<map:MapPath.Data>
|
||||
<GeometryGroup FillRule="EvenOdd">
|
||||
<EllipseGeometry Center="8.2,63.5" RadiusX="0.025" RadiusY="0.025"/>
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@
|
|||
</Path.Data>
|
||||
</Path>
|
||||
|
||||
<map:MapPath Fill="Aqua" Opacity="0.5">
|
||||
<map:MapPath Stroke="Blue" Fill="Aqua" Opacity="0.5">
|
||||
<map:MapPath.Data>
|
||||
<GeometryGroup FillRule="EvenOdd">
|
||||
<EllipseGeometry Center="8.2,63.5" RadiusX="0.025" RadiusY="0.025"/>
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.4.7")]
|
||||
[assembly: AssemblyFileVersion("2.4.7")]
|
||||
[assembly: AssemblyVersion("2.4.8")]
|
||||
[assembly: AssemblyFileVersion("2.4.8")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue