mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 22:18:56 +00:00
Version 4.4.1: MapPolygon for UWP in progress
This commit is contained in:
parent
66a97b3fa2
commit
54c924f9e7
15 changed files with 497 additions and 125 deletions
|
|
@ -86,12 +86,18 @@
|
|||
<Compile Include="..\Shared\HyperlinkText.cs">
|
||||
<Link>HyperlinkText.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\Intersections.cs">
|
||||
<Link>Intersections.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\Location.cs">
|
||||
<Link>Location.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\LocationCollection.cs">
|
||||
<Link>LocationCollection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\LocationEx.cs">
|
||||
<Link>LocationEx.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\MapBase.cs">
|
||||
<Link>MapBase.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -39,62 +39,75 @@ namespace MapControl
|
|||
{
|
||||
var projection = ParentMap?.MapProjection;
|
||||
|
||||
if (projection != null && !projection.IsAzimuthal)
|
||||
if (projection != null)
|
||||
{
|
||||
var bounds = projection.ViewportRectToBoundingBox(new Rect(ParentMap.RenderSize));
|
||||
var lineDistance = GetLineDistance();
|
||||
var labelFormat = GetLabelFormat(lineDistance);
|
||||
|
||||
if (bounds.HasValidBounds)
|
||||
if (projection.IsAzimuthal)
|
||||
{
|
||||
var lineDistance = GetLineDistance();
|
||||
var labelFormat = GetLabelFormat(lineDistance);
|
||||
var latLabelStart = Math.Ceiling(bounds.South / lineDistance) * lineDistance;
|
||||
var lonLabelStart = Math.Ceiling(bounds.West / lineDistance) * lineDistance;
|
||||
var latLabels = new List<Label>((int)((bounds.North - latLabelStart) / lineDistance) + 1);
|
||||
var lonLabels = new List<Label>((int)((bounds.East - lonLabelStart) / lineDistance) + 1);
|
||||
var typeface = new Typeface(FontFamily, FontStyle, FontWeight, FontStretch);
|
||||
var pen = new Pen
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawCylindricalGraticule(drawingContext, projection, lineDistance, labelFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCylindricalGraticule(DrawingContext drawingContext, MapProjection projection, double lineDistance, string labelFormat)
|
||||
{
|
||||
var boundingBox = projection.ViewportRectToBoundingBox(new Rect(ParentMap.RenderSize));
|
||||
|
||||
if (boundingBox.HasValidBounds)
|
||||
{
|
||||
var latLabelStart = Math.Ceiling(boundingBox.South / lineDistance) * lineDistance;
|
||||
var lonLabelStart = Math.Ceiling(boundingBox.West / lineDistance) * lineDistance;
|
||||
var latLabels = new List<Label>((int)((boundingBox.North - latLabelStart) / lineDistance) + 1);
|
||||
var lonLabels = new List<Label>((int)((boundingBox.East - lonLabelStart) / lineDistance) + 1);
|
||||
var typeface = new Typeface(FontFamily, FontStyle, FontWeight, FontStretch);
|
||||
var pen = new Pen
|
||||
{
|
||||
Brush = Stroke,
|
||||
Thickness = StrokeThickness,
|
||||
DashStyle = new DashStyle(StrokeDashArray, StrokeDashOffset),
|
||||
DashCap = StrokeDashCap
|
||||
};
|
||||
|
||||
for (var lat = latLabelStart; lat <= boundingBox.North; lat += lineDistance)
|
||||
{
|
||||
latLabels.Add(new Label(lat, new FormattedText(
|
||||
GetLabelText(lat, labelFormat, "NS"),
|
||||
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground)));
|
||||
|
||||
drawingContext.DrawLine(pen,
|
||||
projection.LocationToViewportPoint(new Location(lat, boundingBox.West)),
|
||||
projection.LocationToViewportPoint(new Location(lat, boundingBox.East)));
|
||||
}
|
||||
|
||||
for (var lon = lonLabelStart; lon <= boundingBox.East; lon += lineDistance)
|
||||
{
|
||||
lonLabels.Add(new Label(lon, new FormattedText(
|
||||
GetLabelText(Location.NormalizeLongitude(lon), labelFormat, "EW"),
|
||||
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground)));
|
||||
|
||||
drawingContext.DrawLine(pen,
|
||||
projection.LocationToViewportPoint(new Location(boundingBox.South, lon)),
|
||||
projection.LocationToViewportPoint(new Location(boundingBox.North, lon)));
|
||||
}
|
||||
|
||||
foreach (var latLabel in latLabels)
|
||||
{
|
||||
foreach (var lonLabel in lonLabels)
|
||||
{
|
||||
Brush = Stroke,
|
||||
Thickness = StrokeThickness,
|
||||
DashStyle = new DashStyle(StrokeDashArray, StrokeDashOffset),
|
||||
DashCap = StrokeDashCap
|
||||
};
|
||||
var position = projection.LocationToViewportPoint(new Location(latLabel.Position, lonLabel.Position));
|
||||
|
||||
for (var lat = latLabelStart; lat <= bounds.North; lat += lineDistance)
|
||||
{
|
||||
latLabels.Add(new Label(lat, new FormattedText(
|
||||
GetLabelText(lat, labelFormat, "NS"),
|
||||
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground)));
|
||||
|
||||
drawingContext.DrawLine(pen,
|
||||
projection.LocationToViewportPoint(new Location(lat, bounds.West)),
|
||||
projection.LocationToViewportPoint(new Location(lat, bounds.East)));
|
||||
}
|
||||
|
||||
for (var lon = lonLabelStart; lon <= bounds.East; lon += lineDistance)
|
||||
{
|
||||
lonLabels.Add(new Label(lon, new FormattedText(
|
||||
GetLabelText(Location.NormalizeLongitude(lon), labelFormat, "EW"),
|
||||
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground)));
|
||||
|
||||
drawingContext.DrawLine(pen,
|
||||
projection.LocationToViewportPoint(new Location(bounds.South, lon)),
|
||||
projection.LocationToViewportPoint(new Location(bounds.North, lon)));
|
||||
}
|
||||
|
||||
foreach (var latLabel in latLabels)
|
||||
{
|
||||
foreach (var lonLabel in lonLabels)
|
||||
{
|
||||
var position = projection.LocationToViewportPoint(new Location(latLabel.Position, lonLabel.Position));
|
||||
|
||||
drawingContext.PushTransform(new RotateTransform(ParentMap.Heading, position.X, position.Y));
|
||||
drawingContext.DrawText(latLabel.Text,
|
||||
new Point(position.X + StrokeThickness / 2d + 2d, position.Y - StrokeThickness / 2d - latLabel.Text.Height));
|
||||
drawingContext.DrawText(lonLabel.Text,
|
||||
new Point(position.X + StrokeThickness / 2d + 2d, position.Y + StrokeThickness / 2d));
|
||||
drawingContext.Pop();
|
||||
}
|
||||
drawingContext.PushTransform(new RotateTransform(ParentMap.Heading, position.X, position.Y));
|
||||
drawingContext.DrawText(latLabel.Text,
|
||||
new Point(position.X + StrokeThickness / 2d + 2d, position.Y - StrokeThickness / 2d - latLabel.Text.Height));
|
||||
drawingContext.DrawText(lonLabel.Text,
|
||||
new Point(position.X + StrokeThickness / 2d + 2d, position.Y + StrokeThickness / 2d));
|
||||
drawingContext.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Windows;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("4.4.0")]
|
||||
[assembly: AssemblyFileVersion("4.4.0")]
|
||||
[assembly: AssemblyVersion("4.4.1")]
|
||||
[assembly: AssemblyFileVersion("4.4.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue