Version 4.4.0: Fixed MapPolyline performance on UWP. Added MapPolygon and MapMultiPolygon for WPF.

This commit is contained in:
ClemensF 2018-02-09 17:43:47 +01:00
parent cce5d6e0b4
commit d1552506f6
80 changed files with 673 additions and 550 deletions

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Windows.Foundation;

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Windows.Foundation;

View file

@ -91,18 +91,15 @@
<Compile Include="..\Shared\MapPanel.cs">
<Link>MapPanel.cs</Link>
</Compile>
<Compile Include="..\Shared\MapPath.cs">
<Link>MapPath.cs</Link>
</Compile>
<Compile Include="..\Shared\MapPolyline.cs">
<Link>MapPolyline.cs</Link>
</Compile>
<Compile Include="..\Shared\MapProjection.cs">
<Link>MapProjection.cs</Link>
</Compile>
<Compile Include="..\Shared\MapScale.cs">
<Link>MapScale.cs</Link>
</Compile>
<Compile Include="..\Shared\MapShape.cs">
<Link>MapShape.cs</Link>
</Compile>
<Compile Include="..\Shared\MapTileLayer.cs">
<Link>MapTileLayer.cs</Link>
</Compile>
@ -147,8 +144,8 @@
<Compile Include="MapGraticule.UWP.cs" />
<Compile Include="MapOverlay.UWP.cs" />
<Compile Include="MapPanel.UWP.cs" />
<Compile Include="MapPath.UWP.cs" />
<Compile Include="MapPolyline.UWP.cs" />
<Compile Include="MapShape.UWP.cs" />
<Compile Include="MatrixEx.UWP.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tile.UWP.cs" />

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
@ -28,7 +28,7 @@ namespace MapControl
{
var projection = ParentMap.MapProjection;
if (!double.IsNaN(projection.LongitudeScale))
if (!projection.IsAzimuthal)
{
if (path == null)
{

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Windows.UI.Text;

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Windows.UI.Xaml;

View file

@ -1,41 +0,0 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Windows.Foundation;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;
namespace MapControl
{
public partial class MapPath : Path
{
private Geometry data;
protected override Size MeasureOverride(Size availableSize)
{
if (Stretch != Stretch.None)
{
Stretch = Stretch.None;
}
// Workaround for missing PropertyChangedCallback for the Data property.
if (data != Data)
{
if (data != null)
{
data.ClearValue(Geometry.TransformProperty);
}
data = Data;
if (data != null)
{
data.Transform = viewportTransform;
}
}
return new Size();
}
}
}

View file

@ -1,28 +1,26 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;
namespace MapControl
{
public partial class MapPolyline
/// <summary>
/// A polyline defined by a collection of Locations.
/// </summary>
public class MapPolyline : MapShape
{
public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register(
nameof(FillRule), typeof(FillRule), typeof(MapPolyline),
new PropertyMetadata(FillRule.EvenOdd, (o, e) => ((PathGeometry)((MapPolyline)o).Data).FillRule = (FillRule)e.NewValue));
public MapPolyline()
{
Data = new PathGeometry();
}
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
nameof(Locations), typeof(IEnumerable<Location>), typeof(MapPolyline),
new PropertyMetadata(null, (o, e) => ((MapPolyline)o).LocationsPropertyChanged(e)));
/// <summary>
/// Gets or sets the locations that define the polyline points.
/// Gets or sets the Locations that define the polyline points.
/// </summary>
public IEnumerable<Location> Locations
{
@ -37,25 +35,67 @@ namespace MapControl
if (ParentMap != null && Locations != null && Locations.Any())
{
var points = Locations.Select(l => ParentMap.MapProjection.LocationToPoint(l));
PathFigure figure = null;
PolyLineSegment segment = null;
var size = ParentMap.RenderSize;
var offset = GetLongitudeOffset();
var locations = Locations;
var figure = new PathFigure
if (offset != 0d)
{
StartPoint = points.First(),
IsClosed = IsClosed,
IsFilled = IsClosed
};
var segment = new PolyLineSegment();
foreach (var point in points.Skip(1))
{
segment.Points.Add(point);
locations = locations.Select(loc => new Location(loc.Latitude, loc.Longitude + offset));
}
figure.Segments.Add(segment);
geometry.Figures.Add(figure);
var points = locations.Select(loc => ParentMap.MapProjection.LocationToViewportPoint(loc));
var p1 = points.First();
foreach (var p2 in points.Skip(1))
{
if ((p1.X <= 0 && p2.X <= 0) || (p1.X >= size.Width && p2.X >= size.Width) ||
(p1.Y <= 0 && p2.Y <= 0) || (p1.Y >= size.Height && p2.Y >= size.Height))
{
// line (p1,p2) is out of visible bounds, end figure
figure = null;
}
else
{
if (figure == null)
{
figure = new PathFigure { StartPoint = p1, IsClosed = false, IsFilled = false };
segment = new PolyLineSegment();
figure.Segments.Add(segment);
geometry.Figures.Add(figure);
}
segment.Points.Add(p2);
}
p1 = p2;
}
}
}
private void LocationsPropertyChanged(DependencyPropertyChangedEventArgs e)
{
var oldCollection = e.OldValue as INotifyCollectionChanged;
var newCollection = e.NewValue as INotifyCollectionChanged;
if (oldCollection != null)
{
oldCollection.CollectionChanged -= LocationCollectionChanged;
}
if (newCollection != null)
{
newCollection.CollectionChanged += LocationCollectionChanged;
}
UpdateData();
}
private void LocationCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
UpdateData();
}
}
}

View file

@ -0,0 +1,21 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Windows.UI.Xaml.Shapes;
namespace MapControl
{
public abstract partial class MapShape : Path
{
private void ParentMapChanged()
{
UpdateData();
}
private void OnViewportChanged(object sender, ViewportChangedEventArgs e)
{
UpdateData();
}
}
}

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;

View file

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("XAML Map Control Library")]
[assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("4.3.0")]
[assembly: AssemblyFileVersion("4.3.0")]
[assembly: AssemblyVersion("4.4.0")]
[assembly: AssemblyFileVersion("4.4.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;

View file

@ -1,5 +1,5 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2017 Clemens Fischer
// © 2018 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;