86 lines
1.7 KiB
C#
86 lines
1.7 KiB
C#
namespace OperationControl.Mapas.Interaction
|
|
{
|
|
public readonly struct MapaPontoWgs84
|
|
{
|
|
public double Latitude
|
|
{
|
|
get;
|
|
}
|
|
|
|
public double Longitude
|
|
{
|
|
get;
|
|
}
|
|
|
|
|
|
public MapaPontoWgs84(
|
|
double latitude,
|
|
double longitude)
|
|
{
|
|
if (
|
|
!double.IsFinite(latitude) ||
|
|
!double.IsFinite(longitude) ||
|
|
latitude < -90 ||
|
|
latitude > 90 ||
|
|
longitude < -180 ||
|
|
longitude > 180
|
|
)
|
|
{
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(latitude),
|
|
"Coordenada WGS84 inválida."
|
|
);
|
|
}
|
|
|
|
|
|
Latitude =
|
|
latitude;
|
|
|
|
Longitude =
|
|
longitude;
|
|
}
|
|
}
|
|
|
|
|
|
public sealed class MapaPoligonoRecorte
|
|
{
|
|
public IReadOnlyList<MapaPontoWgs84>
|
|
Pontos
|
|
{
|
|
get;
|
|
}
|
|
|
|
|
|
public int QuantidadePontos =>
|
|
Pontos.Count;
|
|
|
|
|
|
public MapaPoligonoRecorte(
|
|
IEnumerable<MapaPontoWgs84> pontos)
|
|
{
|
|
if (pontos == null)
|
|
{
|
|
throw new ArgumentNullException(
|
|
nameof(pontos)
|
|
);
|
|
}
|
|
|
|
|
|
var lista =
|
|
pontos.ToList();
|
|
|
|
|
|
if (lista.Count < 3)
|
|
{
|
|
throw new ArgumentException(
|
|
"O polígono precisa de pelo menos 3 pontos.",
|
|
nameof(pontos)
|
|
);
|
|
}
|
|
|
|
|
|
Pontos =
|
|
lista;
|
|
}
|
|
}
|
|
} |