it is fairly straightforward to write a loop to get both minimum and maximum in each direction
public static (LatLong min, LatLong max) MinMax(IEnumerable<LatLong> points)
{
using (var iter = points.GetEnumerator())
{
if (!iter.MoveNext())
{
throw new InvalidOperationException("No coordinates");
}
var min = iter.Current;
var max = iter.Current;
while (iter.MoveNext())
{
min = min.Min(iter.Current);
max = max.Max(iter.Current);
}
return (min, max);
}
}
where Min/Max returns the minimum/maximum value for each component of the two coordinates.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…