diff --git a/MapControl/Shared/AzimuthalEquidistantProjection.cs b/MapControl/Shared/AzimuthalEquidistantProjection.cs index 732c3ce1..f915cdd8 100644 --- a/MapControl/Shared/AzimuthalEquidistantProjection.cs +++ b/MapControl/Shared/AzimuthalEquidistantProjection.cs @@ -28,14 +28,14 @@ namespace MapControl public override Point LocationToPoint(Location location) { - if (location.Equals(projectionCenter)) + if (location.Equals(ProjectionCenter)) { return new Point(); } double azimuth, distance; - GetAzimuthDistance(projectionCenter, location, out azimuth, out distance); + GetAzimuthDistance(ProjectionCenter, location, out azimuth, out distance); distance *= Wgs84EquatorialRadius; @@ -46,13 +46,13 @@ namespace MapControl { if (point.X == 0d && point.Y == 0d) { - return projectionCenter; + return ProjectionCenter; } var azimuth = Math.Atan2(point.X, point.Y); var distance = Math.Sqrt(point.X * point.X + point.Y * point.Y) / Wgs84EquatorialRadius; - return GetLocation(projectionCenter, azimuth, distance); + return GetLocation(ProjectionCenter, azimuth, distance); } } } diff --git a/MapControl/Shared/AzimuthalProjection.cs b/MapControl/Shared/AzimuthalProjection.cs index 1de51917..faa3b663 100644 --- a/MapControl/Shared/AzimuthalProjection.cs +++ b/MapControl/Shared/AzimuthalProjection.cs @@ -17,7 +17,7 @@ namespace MapControl /// public abstract class AzimuthalProjection : MapProjection { - protected Location projectionCenter = new Location(); + public Location ProjectionCenter { get; private set; } = new Location(); public AzimuthalProjection() { @@ -70,7 +70,7 @@ namespace MapControl public override void SetViewportTransform(Location projectionCenter, Location mapCenter, Point viewportCenter, double zoomLevel, double heading) { - this.projectionCenter = projectionCenter; + ProjectionCenter = projectionCenter; base.SetViewportTransform(projectionCenter, mapCenter, viewportCenter, zoomLevel, heading); } @@ -89,7 +89,7 @@ namespace MapControl return string.Format(CultureInfo.InvariantCulture, "{0}={1},1,{2},{3}&BBOX={4},{5},{6},{7}&WIDTH={8}&HEIGHT={9}", - crs, CrsId, projectionCenter.Longitude, projectionCenter.Latitude, + crs, CrsId, ProjectionCenter.Longitude, ProjectionCenter.Latitude, rect.X, rect.Y, (rect.X + rect.Width), (rect.Y + rect.Height), width, height); } diff --git a/MapControl/Shared/GnomonicProjection.cs b/MapControl/Shared/GnomonicProjection.cs index d44e274c..09859756 100644 --- a/MapControl/Shared/GnomonicProjection.cs +++ b/MapControl/Shared/GnomonicProjection.cs @@ -28,14 +28,14 @@ namespace MapControl public override Point LocationToPoint(Location location) { - if (location.Equals(projectionCenter)) + if (location.Equals(ProjectionCenter)) { return new Point(); } double azimuth, distance; - GetAzimuthDistance(projectionCenter, location, out azimuth, out distance); + GetAzimuthDistance(ProjectionCenter, location, out azimuth, out distance); var mapDistance = distance < Math.PI / 2d ? Wgs84EquatorialRadius * Math.Tan(distance) @@ -48,14 +48,14 @@ namespace MapControl { if (point.X == 0d && point.Y == 0d) { - return projectionCenter; + return ProjectionCenter; } var azimuth = Math.Atan2(point.X, point.Y); var mapDistance = Math.Sqrt(point.X * point.X + point.Y * point.Y); var distance = Math.Atan(mapDistance / Wgs84EquatorialRadius); - return GetLocation(projectionCenter, azimuth, distance); + return GetLocation(ProjectionCenter, azimuth, distance); } } } diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs index f8e9f62a..3b387dac 100644 --- a/MapControl/Shared/MapImageLayer.cs +++ b/MapControl/Shared/MapImageLayer.cs @@ -295,12 +295,12 @@ namespace MapControl /// protected abstract bool UpdateImage(BoundingBox boundingBox); - private void SetTopImage(BitmapSource bitmapSource) + private void SetTopImage(ImageSource imageSource) { topImageIndex = (topImageIndex + 1) % 2; var topImage = (Image)Children[topImageIndex]; - topImage.Source = bitmapSource; + topImage.Source = imageSource; SetBoundingBox(topImage, boundingBox?.Clone()); } diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs index bf94b35d..76e53ced 100644 --- a/MapControl/Shared/MapProjection.cs +++ b/MapControl/Shared/MapProjection.cs @@ -37,7 +37,7 @@ namespace MapControl public string CrsId { get; set; } /// - /// Indicates if this is a web mercator projection, i.e. compatible with map tile layers. + /// Indicates if this is a web mercator projection, i.e. compatible with MapTileLayer. /// public bool IsWebMercator { get; protected set; } = false; diff --git a/MapControl/Shared/OrthographicProjection.cs b/MapControl/Shared/OrthographicProjection.cs index 79c7eaf7..80faeffb 100644 --- a/MapControl/Shared/OrthographicProjection.cs +++ b/MapControl/Shared/OrthographicProjection.cs @@ -28,14 +28,14 @@ namespace MapControl public override Point LocationToPoint(Location location) { - if (location.Equals(projectionCenter)) + if (location.Equals(ProjectionCenter)) { return new Point(); } - var lat0 = projectionCenter.Latitude * Math.PI / 180d; + var lat0 = ProjectionCenter.Latitude * Math.PI / 180d; var lat = location.Latitude * Math.PI / 180d; - var dLon = (location.Longitude - projectionCenter.Longitude) * Math.PI / 180d; + var dLon = (location.Longitude - ProjectionCenter.Longitude) * Math.PI / 180d; return new Point( Wgs84EquatorialRadius * Math.Cos(lat) * Math.Sin(dLon), @@ -46,7 +46,7 @@ namespace MapControl { if (point.X == 0d && point.Y == 0d) { - return projectionCenter; + return ProjectionCenter; } var x = point.X / Wgs84EquatorialRadius; @@ -62,13 +62,13 @@ namespace MapControl var sinC = r; var cosC = Math.Sqrt(1 - r2); - var lat0 = projectionCenter.Latitude * Math.PI / 180d; + var lat0 = ProjectionCenter.Latitude * Math.PI / 180d; var cosLat0 = Math.Cos(lat0); var sinLat0 = Math.Sin(lat0); return new Location( 180d / Math.PI * Math.Asin(cosC * sinLat0 + y * sinC * cosLat0 / r), - 180d / Math.PI * Math.Atan2(x * sinC, r * cosC * cosLat0 - y * sinC * sinLat0) + projectionCenter.Longitude); + 180d / Math.PI * Math.Atan2(x * sinC, r * cosC * cosLat0 - y * sinC * sinLat0) + ProjectionCenter.Longitude); } } } diff --git a/MapControl/Shared/StereographicProjection.cs b/MapControl/Shared/StereographicProjection.cs index 7be1bb89..f22f400c 100644 --- a/MapControl/Shared/StereographicProjection.cs +++ b/MapControl/Shared/StereographicProjection.cs @@ -28,14 +28,14 @@ namespace MapControl public override Point LocationToPoint(Location location) { - if (location.Equals(projectionCenter)) + if (location.Equals(ProjectionCenter)) { return new Point(); } double azimuth, distance; - GetAzimuthDistance(projectionCenter, location, out azimuth, out distance); + GetAzimuthDistance(ProjectionCenter, location, out azimuth, out distance); var mapDistance = 2d * Wgs84EquatorialRadius * Math.Tan(distance / 2d); @@ -46,14 +46,14 @@ namespace MapControl { if (point.X == 0d && point.Y == 0d) { - return projectionCenter; + return ProjectionCenter; } var azimuth = Math.Atan2(point.X, point.Y); var mapDistance = Math.Sqrt(point.X * point.X + point.Y * point.Y); var distance = 2d * Math.Atan(mapDistance / (2d * Wgs84EquatorialRadius)); - return GetLocation(projectionCenter, azimuth, distance); + return GetLocation(ProjectionCenter, azimuth, distance); } } } diff --git a/MapControl/UWP/MapImageLayer.UWP.cs b/MapControl/UWP/MapImageLayer.UWP.cs index aa2141e6..6f505e75 100644 --- a/MapControl/UWP/MapImageLayer.UWP.cs +++ b/MapControl/UWP/MapImageLayer.UWP.cs @@ -5,6 +5,7 @@ using System; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Imaging; namespace MapControl @@ -16,11 +17,11 @@ namespace MapControl UpdateImage(uri != null ? new BitmapImage(uri) : null); } - protected void UpdateImage(BitmapSource bitmapSource) + protected void UpdateImage(ImageSource imageSource) { - SetTopImage(bitmapSource); + SetTopImage(imageSource); - var bitmapImage = bitmapSource as BitmapImage; + var bitmapImage = imageSource as BitmapImage; if (bitmapImage != null) { diff --git a/MapControl/WPF/MapImageLayer.WPF.cs b/MapControl/WPF/MapImageLayer.WPF.cs index 4c2ee22e..ecdc2b9f 100644 --- a/MapControl/WPF/MapImageLayer.WPF.cs +++ b/MapControl/WPF/MapImageLayer.WPF.cs @@ -18,9 +18,11 @@ namespace MapControl : null); } - protected void UpdateImage(BitmapSource bitmapSource) + protected void UpdateImage(ImageSource imageSource) { - SetTopImage(bitmapSource); + SetTopImage(imageSource); + + var bitmapSource = imageSource as BitmapSource; if (bitmapSource != null && !bitmapSource.IsFrozen && bitmapSource.IsDownloading) {