Fixed Heading rotation direction

This commit is contained in:
ClemensFischer 2022-11-07 21:10:10 +01:00
parent 1ce4bbda56
commit 7fbdbf74b9
3 changed files with 11 additions and 11 deletions

View file

@ -29,7 +29,7 @@ namespace MapControl
/// <summary> /// <summary>
/// The map control. Displays map content provided by one or more tile or image layers, /// The map control. Displays map content provided by one or more tile or image layers,
/// i.e. MapTileLayerBase or MapImageLayer instances. /// such as MapTileLayerBase or MapImageLayer instances.
/// The visible map area is defined by the Center and ZoomLevel properties. /// The visible map area is defined by the Center and ZoomLevel properties.
/// The map can be rotated by an angle that is given by the Heading property. /// The map can be rotated by an angle that is given by the Heading property.
/// MapBase can contain map overlay child elements like other MapPanels or MapItemsControls. /// MapBase can contain map overlay child elements like other MapPanels or MapItemsControls.
@ -178,7 +178,7 @@ namespace MapControl
} }
/// <summary> /// <summary>
/// Gets or sets the map heading, i.e. a clockwise rotation angle in degrees. /// Gets or sets the map heading, a counter-clockwise rotation angle in degrees.
/// </summary> /// </summary>
public double Heading public double Heading
{ {
@ -217,7 +217,7 @@ namespace MapControl
/// <summary> /// <summary>
/// Gets the scaling factor from projected map coordinates to view coordinates, /// Gets the scaling factor from projected map coordinates to view coordinates,
/// i.e. pixels per meter. /// as pixels per meter.
/// </summary> /// </summary>
public double ViewScale => (double)GetValue(ViewScaleProperty); public double ViewScale => (double)GetValue(ViewScaleProperty);
@ -228,8 +228,8 @@ namespace MapControl
public ViewTransform ViewTransform { get; } = new ViewTransform(); public ViewTransform ViewTransform { get; } = new ViewTransform();
/// <summary> /// <summary>
/// Gets the map scale, i.e. the horizontal and vertical scaling factors from geographic /// Gets the map scale as the horizontal and vertical scaling factors from geographic
/// coordinates to view coordinates at the specified location, in pixels per meter. /// coordinates to view coordinates at the specified location, as pixels per meter.
/// </summary> /// </summary>
public Vector GetScale(Location location) public Vector GetScale(Location location)
{ {
@ -324,7 +324,7 @@ namespace MapControl
if (rotation != 0d) if (rotation != 0d)
{ {
var heading = (((Heading + rotation) % 360d) + 360d) % 360d; var heading = (((Heading - rotation) % 360d) + 360d) % 360d;
SetValueInternal(HeadingProperty, heading); SetValueInternal(HeadingProperty, heading);
SetValueInternal(TargetHeadingProperty, heading); SetValueInternal(TargetHeadingProperty, heading);
@ -737,7 +737,7 @@ namespace MapControl
if (MapProjection.IsValid(mapCenter)) if (MapProjection.IsValid(mapCenter))
{ {
ViewTransform.SetTransform(mapCenter, viewCenter, viewScale, Heading); ViewTransform.SetTransform(mapCenter, viewCenter, viewScale, -Heading);
if (transformCenter != null) if (transformCenter != null)
{ {
@ -770,7 +770,7 @@ namespace MapControl
if (MapProjection.IsValid(mapCenter)) if (MapProjection.IsValid(mapCenter))
{ {
ViewTransform.SetTransform(mapCenter, viewCenter, viewScale, Heading); ViewTransform.SetTransform(mapCenter, viewCenter, viewScale, -Heading);
} }
} }
} }

View file

@ -34,7 +34,7 @@ namespace MapControl
/// <summary> /// <summary>
/// Gets the scaling factor from projected map coordinates to view coordinates, /// Gets the scaling factor from projected map coordinates to view coordinates,
/// i.e. pixels per meter. /// as pixels per meter.
/// </summary> /// </summary>
public double Scale { get; private set; } public double Scale { get; private set; }

View file

@ -15,8 +15,8 @@ namespace MapControl
} }
/// <summary> /// <summary>
/// Indicates if the map projection has changed, i.e. if a MapTileLayer or MapImageLayer should /// Indicates if the map projection has changed. Used to control when a MapTileLayer or MapImageLayer
/// be updated immediately, or MapPath Data in projected map coordinates should be recalculated. /// should be updated immediately, or MapPath Data in projected map coordinates should be recalculated.
/// </summary> /// </summary>
public bool ProjectionChanged { get; } public bool ProjectionChanged { get; }