Version 3.0.381

This commit is contained in:
Anja 2024-04-09 12:53:23 +02:00
parent f963c0a219
commit 3a363acf3a
1525 changed files with 60589 additions and 125098 deletions

View file

@ -0,0 +1,14 @@
namespace ShareeBike.Model.Map
{
public interface IMapSpan
{
/// <summary> Center of map displayed area.</summary>
IPosition Center { get; }
/// <summary> Radius of displayed map area. </summary>
double Radius { get; }
/// <summary> Gets if map span is valid or not. </summary>
bool IsValid { get; }
}
}

View file

@ -0,0 +1,30 @@
using System;
namespace ShareeBike.Model.Map
{
/// <summary> Holds the displayed map area. </summary>
public class MapSpan : IMapSpan
{
internal MapSpan(IPosition center, double radius)
{
if (!GetIsValid(center, radius))
throw new ArgumentNullException();
Center = center;
Radius = radius;
}
/// <summary> Center of map displayed area.</summary>
public IPosition Center { get; }
/// <summary> Radius of displayed map area. </summary>
public double Radius { get; }
public bool IsValid => GetIsValid(Center, Radius);
public static bool GetIsValid(IPosition center, double radius)
=> center != null
&& center.IsValid
&& !double.IsNaN(radius);
}
}

View file

@ -0,0 +1,11 @@

namespace ShareeBike.Model.Map
{
public static class MapSpanFactory
{
public static IMapSpan Create(IPosition position = null, double radius = double.NaN)
=> MapSpan.GetIsValid(position, radius)
? new MapSpan(position, radius) as IMapSpan
: new NullMapSpan();
}
}

View file

@ -0,0 +1,16 @@

namespace ShareeBike.Model.Map
{
public class NullMapSpan : IMapSpan
{
internal NullMapSpan() { }
/// <summary> Center of map displayed area.</summary>
public IPosition Center { get; } = PositionFactory.Create();
/// <summary> Radius of displayed map area. </summary>
public double Radius => double.NaN;
public bool IsValid => MapSpan.GetIsValid(Center, Radius);
}
}