mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Simplified WmsImageLayer
This commit is contained in:
parent
03ac94a002
commit
6b7fd84c7b
|
|
@ -187,7 +187,7 @@ namespace MapControl
|
||||||
return finalSize;
|
return finalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Point? GetViewPosition(Location location)
|
private Point? GetViewPosition(Location location)
|
||||||
{
|
{
|
||||||
var position = parentMap.LocationToView(location);
|
var position = parentMap.LocationToView(location);
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ namespace MapControl
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Rect? GetViewRect(BoundingBox boundingBox)
|
private Rect? GetViewRect(BoundingBox boundingBox)
|
||||||
{
|
{
|
||||||
var mapRect = parentMap.MapProjection.BoundingBoxToMap(boundingBox);
|
var mapRect = parentMap.MapProjection.BoundingBoxToMap(boundingBox);
|
||||||
|
|
||||||
|
|
@ -218,16 +218,15 @@ namespace MapControl
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Rect GetViewRect(Rect mapRect)
|
private Rect GetViewRect(Rect mapRect)
|
||||||
{
|
{
|
||||||
var center = new Point(mapRect.X + mapRect.Width / 2d, mapRect.Y + mapRect.Height / 2d);
|
var center = new Point(mapRect.X + mapRect.Width / 2d, mapRect.Y + mapRect.Height / 2d);
|
||||||
var position = parentMap.ViewTransform.MapToView(center);
|
var position = parentMap.ViewTransform.MapToView(center);
|
||||||
var projection = parentMap.MapProjection;
|
|
||||||
|
|
||||||
if (projection.Type <= MapProjectionType.NormalCylindrical &&
|
if (parentMap.MapProjection.Type <= MapProjectionType.NormalCylindrical &&
|
||||||
!parentMap.InsideViewBounds(position))
|
!parentMap.InsideViewBounds(position))
|
||||||
{
|
{
|
||||||
var location = projection.MapToLocation(center);
|
var location = parentMap.MapProjection.MapToLocation(center);
|
||||||
|
|
||||||
if (location != null)
|
if (location != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,8 @@ namespace MapControl
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewScale = ParentMap.ViewTransform.Scale;
|
var width = ParentMap.ViewTransform.Scale * mapRect.Value.Width;
|
||||||
|
var height = ParentMap.ViewTransform.Scale * mapRect.Value.Height;
|
||||||
|
|
||||||
return GetRequestUri(new Dictionary<string, string>
|
return GetRequestUri(new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
|
@ -248,8 +249,8 @@ namespace MapControl
|
||||||
{ "FORMAT", "image/png" },
|
{ "FORMAT", "image/png" },
|
||||||
{ "CRS", GetCrsValue() },
|
{ "CRS", GetCrsValue() },
|
||||||
{ "BBOX", GetBboxValue(mapRect.Value) },
|
{ "BBOX", GetBboxValue(mapRect.Value) },
|
||||||
{ "WIDTH", Math.Round(viewScale * mapRect.Value.Width).ToString("F0") },
|
{ "WIDTH", Math.Round(width).ToString("F0") },
|
||||||
{ "HEIGHT", Math.Round(viewScale * mapRect.Value.Height).ToString("F0") }
|
{ "HEIGHT", Math.Round(height).ToString("F0") }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,12 +268,13 @@ namespace MapControl
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewRect = GetViewRect(mapRect.Value);
|
var width = ParentMap.ViewTransform.Scale * mapRect.Value.Width;
|
||||||
|
var height = ParentMap.ViewTransform.Scale * mapRect.Value.Height;
|
||||||
|
|
||||||
var transform = ViewTransform.CreateTransformMatrix(
|
var transform = ViewTransform.CreateTransformMatrix(
|
||||||
-viewport.Width / 2d, -viewport.Height / 2d,
|
-viewport.Width / 2d, -viewport.Height / 2d,
|
||||||
-ParentMap.ViewTransform.Rotation,
|
-ParentMap.ViewTransform.Rotation,
|
||||||
viewRect.Width / 2d, viewRect.Height / 2d);
|
width / 2d, height / 2d);
|
||||||
|
|
||||||
var imagePos = transform.Transform(position);
|
var imagePos = transform.Transform(position);
|
||||||
|
|
||||||
|
|
@ -287,8 +289,8 @@ namespace MapControl
|
||||||
{ "INFO_FORMAT", format },
|
{ "INFO_FORMAT", format },
|
||||||
{ "CRS", GetCrsValue() },
|
{ "CRS", GetCrsValue() },
|
||||||
{ "BBOX", GetBboxValue(mapRect.Value) },
|
{ "BBOX", GetBboxValue(mapRect.Value) },
|
||||||
{ "WIDTH", Math.Round(viewRect.Width).ToString("F0") },
|
{ "WIDTH", Math.Round(width).ToString("F0") },
|
||||||
{ "HEIGHT", Math.Round(viewRect.Height).ToString("F0") },
|
{ "HEIGHT", Math.Round(height).ToString("F0") },
|
||||||
{ "I", Math.Round(imagePos.X).ToString("F0") },
|
{ "I", Math.Round(imagePos.X).ToString("F0") },
|
||||||
{ "J", Math.Round(imagePos.Y).ToString("F0") }
|
{ "J", Math.Round(imagePos.Y).ToString("F0") }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue