From 34aa59a8c40a9c577e060bf797fd4d743d4a7c0f Mon Sep 17 00:00:00 2001 From: ClemensF Date: Fri, 20 Dec 2013 17:05:10 +0100 Subject: [PATCH] Version 1.11.1: Fixed MapImageLayer. --- .../FileDbCache/Properties/AssemblyInfo.cs | 4 +-- .../ImageFileCache/Properties/AssemblyInfo.cs | 4 +-- MapControl/Location.cs | 10 +++--- MapControl/MapBase.Silverlight.WinRT.cs | 4 +-- MapControl/MapBase.WPF.cs | 4 +-- MapControl/MapBase.cs | 35 +++++++++---------- MapControl/MapImageLayer.cs | 12 +++++-- MapControl/MapPanel.cs | 3 +- MapControl/Properties/AssemblyInfo.cs | 4 +-- MapControl/WinRT/Properties/AssemblyInfo.cs | 4 +-- .../Properties/AssemblyInfo.cs | 4 +-- .../Properties/AssemblyInfo.cs | 4 +-- .../Properties/AssemblyInfo.cs | 4 +-- .../Properties/AssemblyInfo.cs | 4 +-- SampleApps/WpfApplication/MainWindow.xaml | 2 +- .../WpfApplication/Properties/AssemblyInfo.cs | 4 +-- 16 files changed, 56 insertions(+), 50 deletions(-) diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs index d22a03bf..e8fda2c3 100644 --- a/Caching/FileDbCache/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs index 452ba23c..5735d16a 100644 --- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/Location.cs b/MapControl/Location.cs index d6aa1883..ffe1d91b 100644 --- a/MapControl/Location.cs +++ b/MapControl/Location.cs @@ -60,14 +60,14 @@ namespace MapControl public static double NormalizeLongitude(double longitude) { - if (longitude > 180) - { - longitude = ((longitude - 180d) % 360d) - 180d; - } - else if (longitude < -180d) + if (longitude < -180d) { longitude = ((longitude + 180d) % 360d) + 180d; } + else if (longitude > 180d) + { + longitude = ((longitude - 180d) % 360d) - 180d; + } return longitude; } diff --git a/MapControl/MapBase.Silverlight.WinRT.cs b/MapControl/MapBase.Silverlight.WinRT.cs index fffbd1a7..33097bd2 100644 --- a/MapControl/MapBase.Silverlight.WinRT.cs +++ b/MapControl/MapBase.Silverlight.WinRT.cs @@ -59,9 +59,9 @@ namespace MapControl UpdateTransform(); } - private void SetTransformMatrixes(double scale) + private void SetTransformMatrixes() { - scaleTransform.Matrix = new Matrix(scale, 0d, 0d, scale, 0d, 0d); + scaleTransform.Matrix = new Matrix(CenterScale, 0d, 0d, CenterScale, 0d, 0d); rotateTransform.Matrix = Matrix.Identity.Rotate(Heading); scaleRotateTransform.Matrix = scaleTransform.Matrix.Multiply(rotateTransform.Matrix); } diff --git a/MapControl/MapBase.WPF.cs b/MapControl/MapBase.WPF.cs index 710d1f7f..88d9c8fa 100644 --- a/MapControl/MapBase.WPF.cs +++ b/MapControl/MapBase.WPF.cs @@ -84,12 +84,12 @@ namespace MapControl UpdateTransform(); } - private void SetTransformMatrixes(double scale) + private void SetTransformMatrixes() { Matrix rotateMatrix = Matrix.Identity; rotateMatrix.Rotate(Heading); rotateTransform.Matrix = rotateMatrix; - scaleTransform.Matrix = new Matrix(scale, 0d, 0d, scale, 0d, 0d); + scaleTransform.Matrix = new Matrix(CenterScale, 0d, 0d, CenterScale, 0d, 0d); scaleRotateTransform.Matrix = scaleTransform.Matrix * rotateMatrix; } } diff --git a/MapControl/MapBase.cs b/MapControl/MapBase.cs index 9d4f4caf..5d33e139 100644 --- a/MapControl/MapBase.cs +++ b/MapControl/MapBase.cs @@ -51,9 +51,6 @@ namespace MapControl "MaxZoomLevel", typeof(double), typeof(MapBase), new PropertyMetadata(18d, (o, e) => ((MapBase)o).MaxZoomLevelPropertyChanged((double)e.NewValue))); - public static readonly DependencyProperty CenterScaleProperty = DependencyProperty.Register( - "CenterScale", typeof(double), typeof(MapBase), null); - internal static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register( "CenterPoint", typeof(Point), typeof(MapBase), new PropertyMetadata(new Point(), (o, e) => ((MapBase)o).CenterPointPropertyChanged((Point)e.NewValue))); @@ -201,13 +198,14 @@ namespace MapControl } /// - /// Gets the map scale at the Center location as viewport coordinate units (pixels) per meter. + /// Gets the scaling factor from cartesian map coordinates to viewport coordinates. /// - public double CenterScale - { - get { return (double)GetValue(CenterScaleProperty); } - private set { SetValue(CenterScaleProperty, value); } - } + public double ViewportScale { get; private set; } + + /// + /// Gets the scaling factor from meters to viewport coordinate units (pixels) at the Center location. + /// + public double CenterScale { get; private set; } /// /// Gets the transformation from geographic coordinates to cartesian map coordinates. @@ -226,8 +224,7 @@ namespace MapControl } /// - /// Gets the scaling transformation from meters to viewport coordinate units (pixels) - /// at the viewport center point. + /// Gets the scaling transformation from meters to viewport coordinate units (pixels) at the Center location. /// public Transform ScaleTransform { @@ -725,7 +722,7 @@ namespace MapControl private void AdjustHeadingProperty(DependencyProperty property, ref double heading) { - if (heading < -180d || heading > 360d) + if (heading < 0d || heading > 360d) { heading = ((heading % 360d) + 360d) % 360d; InternalSetValue(property, heading); @@ -801,7 +798,8 @@ namespace MapControl private void UpdateTransform(bool resetTransformOrigin = false) { var center = Center; - var scale = SetViewportTransform(transformOrigin ?? center); + + SetViewportTransform(transformOrigin ?? center); if (transformOrigin != null) { @@ -825,20 +823,19 @@ namespace MapControl if (resetTransformOrigin) { ResetTransformOrigin(); - scale = SetViewportTransform(center); + SetViewportTransform(center); } } - scale *= mapTransform.RelativeScale(center) / MetersPerDegree; // Pixels per meter at center latitude - CenterScale = scale; - SetTransformMatrixes(scale); + CenterScale = ViewportScale * mapTransform.RelativeScale(center) / MetersPerDegree; // Pixels per meter at center latitude + SetTransformMatrixes(); OnViewportChanged(); } - private double SetViewportTransform(Location origin) + private void SetViewportTransform(Location origin) { - return tileContainer.SetViewportTransform(ZoomLevel, Heading, mapTransform.Transform(origin), viewportOrigin, RenderSize); + ViewportScale = tileContainer.SetViewportTransform(ZoomLevel, Heading, mapTransform.Transform(origin), viewportOrigin, RenderSize); } } } diff --git a/MapControl/MapImageLayer.cs b/MapControl/MapImageLayer.cs index 36d6422b..f66aefeb 100644 --- a/MapControl/MapImageLayer.cs +++ b/MapControl/MapImageLayer.cs @@ -157,6 +157,7 @@ namespace MapControl var height = ActualHeight * relativeSize; var dx = (ActualWidth - width) / 2d; var dy = (ActualHeight - height) / 2d; + var loc1 = ParentMap.ViewportPointToLocation(new Point(dx, dy)); var loc2 = ParentMap.ViewportPointToLocation(new Point(dx + width, dy)); var loc3 = ParentMap.ViewportPointToLocation(new Point(dx, dy + height)); @@ -168,9 +169,16 @@ namespace MapControl var east = Math.Max(loc1.Longitude, Math.Max(loc2.Longitude, Math.Max(loc3.Longitude, loc4.Longitude))); var south = Math.Min(loc1.Latitude, Math.Min(loc2.Latitude, Math.Min(loc3.Latitude, loc4.Latitude))); var north = Math.Max(loc1.Latitude, Math.Max(loc2.Latitude, Math.Max(loc3.Latitude, loc4.Latitude))); - var image = GetImage(west, east, south, north, (int)Math.Round(width), (int)Math.Round(height)); - Dispatcher.BeginInvoke((Action)(() => UpdateImage(west, east, south, north, image))); + var p1 = ParentMap.MapTransform.Transform(new Location(south, west)); + var p2 = ParentMap.MapTransform.Transform(new Location(north, east)); + + width = Math.Round((p2.X - p1.X) * ParentMap.ViewportScale); + height = Math.Round((p2.Y - p1.Y) * ParentMap.ViewportScale); + + var image = GetImage(west, east, south, north, (int)width, (int)height); + + Dispatcher.BeginInvoke(new Action(() => UpdateImage(west, east, south, north, image))); updateInProgress = false; }); diff --git a/MapControl/MapPanel.cs b/MapControl/MapPanel.cs index d8056dc9..2c06e7a0 100644 --- a/MapControl/MapPanel.cs +++ b/MapControl/MapPanel.cs @@ -231,7 +231,8 @@ namespace MapControl break; } } - else + else if (frameworkElement.HorizontalAlignment != HorizontalAlignment.Left || + frameworkElement.VerticalAlignment != VerticalAlignment.Top) { if (!panelSize.HasValue) { diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index f033b948..cc094846 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -15,8 +15,8 @@ using System.Windows; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 5f0acb25..53f42f57 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index 3ae95416..a092b99f 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 55b9e6c3..e0220d38 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index 50b5c2a2..1a324ca0 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs index 4d1d676d..77f314e8 100644 --- a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index adcbb377..0014ef25 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -159,7 +159,7 @@ + UriFormat="http://ows.terrestris.de/osm/service?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=OSM-WMS&STYLES=&SRS=EPSG:900913&BBOX={W},{S},{E},{N}&WIDTH={X}&HEIGHT={Y}&FORMAT=image/png"/>--> diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index aacf4da6..f9f292d7 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.11.0")] -[assembly: AssemblyFileVersion("1.11.0")] +[assembly: AssemblyVersion("1.11.1")] +[assembly: AssemblyFileVersion("1.11.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)]