diff --git a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs index e0da461e..47d332df 100644 --- a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs @@ -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)] diff --git a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs index baea7b3c..ed26c175 100644 --- a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs @@ -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)] diff --git a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs index b7192d88..9ce4054e 100644 --- a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs @@ -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)] diff --git a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs index 046658e5..ac29d783 100644 --- a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs @@ -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)] diff --git a/MapControl.sln b/MapControl.sln index 622a4edd..542e3931 100644 --- a/MapControl.sln +++ b/MapControl.sln @@ -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 diff --git a/MapControl/MapPath.Silverlight.WinRT.cs b/MapControl/MapPath.Silverlight.WinRT.cs index 77359bd0..a3e70c8b 100644 --- a/MapControl/MapPath.Silverlight.WinRT.cs +++ b/MapControl/MapPath.Silverlight.WinRT.cs @@ -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) { diff --git a/MapControl/MapPath.WPF.cs b/MapControl/MapPath.WPF.cs index f59181ae..af6a86d4 100644 --- a/MapControl/MapPath.WPF.cs +++ b/MapControl/MapPath.WPF.cs @@ -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; + } } } diff --git a/MapControl/MapPath.cs b/MapControl/MapPath.cs index 9c05d7f8..64aaa38f 100644 --- a/MapControl/MapPath.cs +++ b/MapControl/MapPath.cs @@ -13,6 +13,7 @@ namespace MapControl /// /// 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. /// public partial class MapPath : IMapElement { diff --git a/MapControl/MercatorTransform.cs b/MapControl/MercatorTransform.cs index b40b6279..21e4a9d5 100644 --- a/MapControl/MercatorTransform.cs +++ b/MapControl/MercatorTransform.cs @@ -17,54 +17,62 @@ namespace MapControl /// 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); } } } diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index 211cc239..17f27412 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -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)] diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs index d2bea1a9..2624c836 100644 --- a/MapControl/TileSource.cs +++ b/MapControl/TileSource.cs @@ -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))); } } } diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 3ae655e5..7805fc23 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -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)] diff --git a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs index ee1f8971..a57dc605 100644 --- a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs @@ -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)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index eaff58fa..c07d6c31 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -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)] diff --git a/SampleApps/SilverlightApplication/MainPage.xaml b/SampleApps/SilverlightApplication/MainPage.xaml index d9ff4cf8..3117ea42 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml +++ b/SampleApps/SilverlightApplication/MainPage.xaml @@ -167,7 +167,7 @@ - + diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 0f150a42..13cf230d 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -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)] diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index b76d3467..99768f1d 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -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)] diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index 27208847..4c5762de 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -218,7 +218,7 @@ - + diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index fd9b813d..e3f0aabe 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -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)]