Version 4.10.0: Simplified MapProjection.

This commit is contained in:
ClemensF 2018-08-25 17:54:09 +02:00
parent bbd952b955
commit b06c9065af
11 changed files with 41 additions and 101 deletions

View file

@ -19,12 +19,6 @@ namespace MapControl
{
public Location ProjectionCenter { get; private set; } = new Location();
public AzimuthalProjection()
{
IsContinuous = false;
IsAzimuthal = true;
}
public override Vector GetMapScale(Location location)
{
return new Vector(ViewportScale, ViewportScale);

View file

@ -18,12 +18,13 @@ namespace MapControl
public EquirectangularProjection()
: this("EPSG:4326")
{
TrueScale = 1;
}
public EquirectangularProjection(string crsId)
{
CrsId = crsId;
IsCylindrical = true;
TrueScale = 1;
}
public override Vector GetMapScale(Location location)

View file

@ -338,16 +338,7 @@ namespace MapControl
if (TargetZoomLevel != zoomLevel)
{
SetTransformCenter(center);
if (MapProjection.IsAzimuthal)
{
ZoomLevel = zoomLevel;
ResetTransformCenter();
}
else
{
TargetZoomLevel = zoomLevel;
}
TargetZoomLevel = zoomLevel;
}
}
@ -417,11 +408,8 @@ namespace MapControl
private void ProjectionCenterPropertyChanged()
{
if (MapProjection.IsAzimuthal)
{
ResetTransformCenter();
UpdateTransform();
}
ResetTransformCenter();
UpdateTransform();
}
private void AdjustCenterProperty(DependencyProperty property, ref Location center)
@ -463,7 +451,7 @@ namespace MapControl
if (!targetCenter.Equals(Center))
{
var targetCenterLongitude = MapProjection.IsContinuous
var targetCenterLongitude = MapProjection.IsCylindrical
? Location.NearestLongitude(targetCenter.Longitude, Center.Longitude)
: targetCenter.Longitude;

View file

@ -246,7 +246,7 @@ namespace MapControl
{
pos = parentMap.MapProjection.LocationToViewportPoint(location);
if (parentMap.MapProjection.IsContinuous &&
if (parentMap.MapProjection.IsCylindrical &&
(pos.X < 0d || pos.X > parentMap.RenderSize.Width ||
pos.Y < 0d || pos.Y > parentMap.RenderSize.Height))
{
@ -310,7 +310,7 @@ namespace MapControl
var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
var pos = projection.ViewportTransform.Transform(center);
if (parentMap.MapProjection.IsContinuous &&
if (parentMap.MapProjection.IsCylindrical &&
(pos.X < 0d || pos.X > parentMap.RenderSize.Width ||
pos.Y < 0d || pos.Y > parentMap.RenderSize.Height))
{

View file

@ -28,19 +28,14 @@ namespace MapControl
private Matrix inverseViewportTransformMatrix;
/// <summary>
/// Gets or sets the WMS 1.3.0 CRS Identifier.
/// Gets the WMS 1.3.0 CRS Identifier.
/// </summary>
public string CrsId { get; set; }
public string CrsId { get; protected set; }
/// <summary>
/// Indicates if the map can be moved infinitely in longitudinal direction.
/// Indicates if this is a normal cylindrical projection.
/// </summary>
public bool IsContinuous { get; protected set; } = true;
/// <summary>
/// Indicates if this is an azimuthal projection.
/// </summary>
public bool IsAzimuthal { get; protected set; } = false;
public bool IsCylindrical { get; protected set; } = false;
/// <summary>
/// Indicates if this is a web mercator projection, i.e. compatible with MapTileLayer.
@ -48,8 +43,8 @@ namespace MapControl
public bool IsWebMercator { get; protected set; } = false;
/// <summary>
/// Gets the scale factor from geographic to cartesian coordinates, on the line of true scale
/// of a cylindrical projection, or at the projection center of an azimuthal projection.
/// Gets the scale factor from geographic to cartesian coordinates, on the line of true scale of a
/// cylindrical projection (usually the equator), or at the projection center of an azimuthal projection.
/// </summary>
public double TrueScale { get; protected set; } = MetersPerDegree;

View file

@ -106,7 +106,7 @@ namespace MapControl
{
var longitudeOffset = 0d;
if (parentMap.MapProjection.IsContinuous && Location != null)
if (parentMap.MapProjection.IsCylindrical && Location != null)
{
var viewportPosition = LocationToViewportPoint(Location);

View file

@ -25,6 +25,7 @@ namespace MapControl
public WebMercatorProjection(string crsId)
{
CrsId = crsId;
IsCylindrical = true;
IsWebMercator = true;
MaxLatitude = YToLatitude(180d);
}

View file

@ -31,6 +31,7 @@ namespace MapControl
public WorldMercatorProjection(string crsId)
{
CrsId = crsId;
IsCylindrical = true;
MaxLatitude = YToLatitude(180d);
}

View file

@ -26,7 +26,7 @@ namespace MapControl
{
var projection = ParentMap.MapProjection;
if (!projection.IsAzimuthal)
if (projection.IsCylindrical)
{
if (path == null)
{

View file

@ -44,13 +44,13 @@ namespace MapControl
var lineDistance = GetLineDistance();
var labelFormat = GetLabelFormat(lineDistance);
if (projection.IsAzimuthal)
if (projection.IsCylindrical)
{
DrawCylindricalGraticule(drawingContext, projection, lineDistance, labelFormat);
}
else
{
DrawCylindricalGraticule(drawingContext, projection, lineDistance, labelFormat);
// todo
}
}
}