mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-08 16:05:50 +00:00
Avoid unnecessary Location and Point allocations
This commit is contained in:
parent
f44d2207e5
commit
e268be2948
20 changed files with 205 additions and 172 deletions
|
|
@ -1,4 +1,6 @@
|
|||
#if WPF
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml;
|
||||
|
|
@ -93,12 +95,7 @@ namespace MapControl
|
|||
|
||||
protected Point? LocationToMap(Location location, double longitudeOffset)
|
||||
{
|
||||
if (longitudeOffset != 0d)
|
||||
{
|
||||
location = new Location(location.Latitude, location.Longitude + longitudeOffset);
|
||||
}
|
||||
|
||||
var point = parentMap.MapProjection.LocationToMap(location);
|
||||
var point = parentMap.MapProjection.LocationToMap(location.Latitude, location.Longitude + longitudeOffset);
|
||||
|
||||
if (point.HasValue)
|
||||
{
|
||||
|
|
@ -126,5 +123,21 @@ namespace MapControl
|
|||
|
||||
return point;
|
||||
}
|
||||
|
||||
protected IEnumerable<Point> LocationsToMap(IEnumerable<Location> locations, double longitudeOffset)
|
||||
{
|
||||
return locations
|
||||
.Select(location => LocationToMap(location, longitudeOffset))
|
||||
.Where(point => point.HasValue)
|
||||
.Select(point => point.Value);
|
||||
}
|
||||
|
||||
protected IEnumerable<Point> LocationsToView(IEnumerable<Location> locations, double longitudeOffset)
|
||||
{
|
||||
return locations
|
||||
.Select(location => LocationToView(location, longitudeOffset))
|
||||
.Where(point => point.HasValue)
|
||||
.Select(point => point.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue