Version 1.11.1: Fixed MapImageLayer.

This commit is contained in:
ClemensF 2013-12-20 17:05:10 +01:00
parent e733e98443
commit 34aa59a8c4
16 changed files with 56 additions and 50 deletions

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -60,14 +60,14 @@ namespace MapControl
public static double NormalizeLongitude(double longitude) public static double NormalizeLongitude(double longitude)
{ {
if (longitude > 180) if (longitude < -180d)
{
longitude = ((longitude - 180d) % 360d) - 180d;
}
else if (longitude < -180d)
{ {
longitude = ((longitude + 180d) % 360d) + 180d; longitude = ((longitude + 180d) % 360d) + 180d;
} }
else if (longitude > 180d)
{
longitude = ((longitude - 180d) % 360d) - 180d;
}
return longitude; return longitude;
} }

View file

@ -59,9 +59,9 @@ namespace MapControl
UpdateTransform(); 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); rotateTransform.Matrix = Matrix.Identity.Rotate(Heading);
scaleRotateTransform.Matrix = scaleTransform.Matrix.Multiply(rotateTransform.Matrix); scaleRotateTransform.Matrix = scaleTransform.Matrix.Multiply(rotateTransform.Matrix);
} }

View file

@ -84,12 +84,12 @@ namespace MapControl
UpdateTransform(); UpdateTransform();
} }
private void SetTransformMatrixes(double scale) private void SetTransformMatrixes()
{ {
Matrix rotateMatrix = Matrix.Identity; Matrix rotateMatrix = Matrix.Identity;
rotateMatrix.Rotate(Heading); rotateMatrix.Rotate(Heading);
rotateTransform.Matrix = rotateMatrix; 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; scaleRotateTransform.Matrix = scaleTransform.Matrix * rotateMatrix;
} }
} }

View file

@ -51,9 +51,6 @@ namespace MapControl
"MaxZoomLevel", typeof(double), typeof(MapBase), new PropertyMetadata(18d, "MaxZoomLevel", typeof(double), typeof(MapBase), new PropertyMetadata(18d,
(o, e) => ((MapBase)o).MaxZoomLevelPropertyChanged((double)e.NewValue))); (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( internal static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register(
"CenterPoint", typeof(Point), typeof(MapBase), new PropertyMetadata(new Point(), "CenterPoint", typeof(Point), typeof(MapBase), new PropertyMetadata(new Point(),
(o, e) => ((MapBase)o).CenterPointPropertyChanged((Point)e.NewValue))); (o, e) => ((MapBase)o).CenterPointPropertyChanged((Point)e.NewValue)));
@ -201,13 +198,14 @@ namespace MapControl
} }
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
public double CenterScale public double ViewportScale { get; private set; }
{
get { return (double)GetValue(CenterScaleProperty); } /// <summary>
private set { SetValue(CenterScaleProperty, value); } /// Gets the scaling factor from meters to viewport coordinate units (pixels) at the Center location.
} /// </summary>
public double CenterScale { get; private set; }
/// <summary> /// <summary>
/// Gets the transformation from geographic coordinates to cartesian map coordinates. /// Gets the transformation from geographic coordinates to cartesian map coordinates.
@ -226,8 +224,7 @@ namespace MapControl
} }
/// <summary> /// <summary>
/// Gets the scaling transformation from meters to viewport coordinate units (pixels) /// Gets the scaling transformation from meters to viewport coordinate units (pixels) at the Center location.
/// at the viewport center point.
/// </summary> /// </summary>
public Transform ScaleTransform public Transform ScaleTransform
{ {
@ -725,7 +722,7 @@ namespace MapControl
private void AdjustHeadingProperty(DependencyProperty property, ref double heading) private void AdjustHeadingProperty(DependencyProperty property, ref double heading)
{ {
if (heading < -180d || heading > 360d) if (heading < 0d || heading > 360d)
{ {
heading = ((heading % 360d) + 360d) % 360d; heading = ((heading % 360d) + 360d) % 360d;
InternalSetValue(property, heading); InternalSetValue(property, heading);
@ -801,7 +798,8 @@ namespace MapControl
private void UpdateTransform(bool resetTransformOrigin = false) private void UpdateTransform(bool resetTransformOrigin = false)
{ {
var center = Center; var center = Center;
var scale = SetViewportTransform(transformOrigin ?? center);
SetViewportTransform(transformOrigin ?? center);
if (transformOrigin != null) if (transformOrigin != null)
{ {
@ -825,20 +823,19 @@ namespace MapControl
if (resetTransformOrigin) if (resetTransformOrigin)
{ {
ResetTransformOrigin(); ResetTransformOrigin();
scale = SetViewportTransform(center); SetViewportTransform(center);
} }
} }
scale *= mapTransform.RelativeScale(center) / MetersPerDegree; // Pixels per meter at center latitude CenterScale = ViewportScale * mapTransform.RelativeScale(center) / MetersPerDegree; // Pixels per meter at center latitude
CenterScale = scale;
SetTransformMatrixes(scale);
SetTransformMatrixes();
OnViewportChanged(); 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);
} }
} }
} }

View file

@ -157,6 +157,7 @@ namespace MapControl
var height = ActualHeight * relativeSize; var height = ActualHeight * relativeSize;
var dx = (ActualWidth - width) / 2d; var dx = (ActualWidth - width) / 2d;
var dy = (ActualHeight - height) / 2d; var dy = (ActualHeight - height) / 2d;
var loc1 = ParentMap.ViewportPointToLocation(new Point(dx, dy)); var loc1 = ParentMap.ViewportPointToLocation(new Point(dx, dy));
var loc2 = ParentMap.ViewportPointToLocation(new Point(dx + width, dy)); var loc2 = ParentMap.ViewportPointToLocation(new Point(dx + width, dy));
var loc3 = ParentMap.ViewportPointToLocation(new Point(dx, dy + height)); 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 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 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 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; updateInProgress = false;
}); });

View file

@ -231,7 +231,8 @@ namespace MapControl
break; break;
} }
} }
else else if (frameworkElement.HorizontalAlignment != HorizontalAlignment.Left ||
frameworkElement.VerticalAlignment != VerticalAlignment.Top)
{ {
if (!panelSize.HasValue) if (!panelSize.HasValue)
{ {

View file

@ -15,8 +15,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -159,7 +159,7 @@
<!--<map:MapImageLayer Opacity="0.5" <!--<map:MapImageLayer Opacity="0.5"
UriFormat="http://watzmann-geog.urz.uni-heidelberg.de/cached/osm?SERVICE=WMS&amp;VERSION=1.1.1&amp;REQUEST=GetMap&amp;LAYERS=osm_auto:all&amp;STYLES=&amp;SRS=EPSG:900913&amp;BBOX={W},{S},{E},{N}&amp;WIDTH={X}&amp;HEIGHT={Y}&amp;FORMAT=image/png"/>--> UriFormat="http://watzmann-geog.urz.uni-heidelberg.de/cached/osm?SERVICE=WMS&amp;VERSION=1.1.1&amp;REQUEST=GetMap&amp;LAYERS=osm_auto:all&amp;STYLES=&amp;SRS=EPSG:900913&amp;BBOX={W},{S},{E},{N}&amp;WIDTH={X}&amp;HEIGHT={Y}&amp;FORMAT=image/png"/>-->
<!--<map:MapImageLayer Opacity="0.5" <!--<map:MapImageLayer Opacity="0.5"
UriFormat="http://ows.terrestris.de/osm-basemap/service?SERVICE=WMS&amp;VERSION=1.1.1&amp;REQUEST=GetMap&amp;LAYERS=OSM-WMS-Deutschland&amp;STYLES=&amp;SRS=EPSG:900913&amp;BBOX={W},{S},{E},{N}&amp;WIDTH={X}&amp;HEIGHT={Y}&amp;FORMAT=image/png"/>--> UriFormat="http://ows.terrestris.de/osm/service?SERVICE=WMS&amp;VERSION=1.1.1&amp;REQUEST=GetMap&amp;LAYERS=OSM-WMS&amp;STYLES=&amp;SRS=EPSG:900913&amp;BBOX={W},{S},{E},{N}&amp;WIDTH={X}&amp;HEIGHT={Y}&amp;FORMAT=image/png"/>-->
<map:MapImage x:Name="mapImage" South="53.54031" North="53.74871" West="8.08594" East="8.43750" <map:MapImage x:Name="mapImage" South="53.54031" North="53.74871" West="8.08594" East="8.43750"
Source="10_535_330.jpg" Opacity="0.5"/> Source="10_535_330.jpg" Opacity="0.5"/>

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.11.0")] [assembly: AssemblyVersion("1.11.1")]
[assembly: AssemblyFileVersion("1.11.0")] [assembly: AssemblyFileVersion("1.11.1")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]