mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 09:26:39 +00:00
geo fences - wip
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SatelliteProvider.Common.DTO;
|
||||
|
||||
public class CreateRouteRequest
|
||||
@@ -7,7 +9,12 @@ public class CreateRouteRequest
|
||||
public string? Description { get; set; }
|
||||
public double RegionSizeMeters { get; set; }
|
||||
public int ZoomLevel { get; set; }
|
||||
|
||||
public List<RoutePoint> Points { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("geofences")]
|
||||
public Geofences? Geofences { get; set; }
|
||||
|
||||
public bool RequestMaps { get; set; } = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SatelliteProvider.Common.DTO;
|
||||
|
||||
public class GeoPoint
|
||||
{
|
||||
const double PRECISION_TOLERANCE = 0.00005;
|
||||
public double Lat { get; }
|
||||
public double Lon { get; }
|
||||
|
||||
[JsonPropertyName("lat")]
|
||||
public double Lat { get; set; }
|
||||
|
||||
[JsonPropertyName("lon")]
|
||||
public double Lon { get; set; }
|
||||
|
||||
public GeoPoint() { }
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SatelliteProvider.Common.DTO;
|
||||
|
||||
public class GeofencePolygon
|
||||
{
|
||||
[JsonPropertyName("northWest")]
|
||||
public GeoPoint? NorthWest { get; set; }
|
||||
|
||||
[JsonPropertyName("southEast")]
|
||||
public GeoPoint? SouthEast { get; set; }
|
||||
}
|
||||
|
||||
public class Geofences
|
||||
{
|
||||
[JsonPropertyName("polygons")]
|
||||
public List<GeofencePolygon> Polygons { get; set; } = new();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SatelliteProvider.Common.DTO;
|
||||
|
||||
public class RoutePoint
|
||||
{
|
||||
[JsonPropertyName("lat")]
|
||||
public double Latitude { get; set; }
|
||||
|
||||
[JsonPropertyName("lon")]
|
||||
public double Longitude { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -118,4 +118,16 @@ public static class GeoUtils
|
||||
{
|
||||
return p1.DirectionTo(p2).Distance;
|
||||
}
|
||||
|
||||
public static GeoPoint CalculateCenter(GeoPoint northWest, GeoPoint southEast)
|
||||
{
|
||||
var centerLat = (northWest.Lat + southEast.Lat) / 2.0;
|
||||
var centerLon = (northWest.Lon + southEast.Lon) / 2.0;
|
||||
return new GeoPoint(centerLat, centerLon);
|
||||
}
|
||||
|
||||
public static double CalculatePolygonDiagonalDistance(GeoPoint northWest, GeoPoint southEast)
|
||||
{
|
||||
return CalculateDistance(northWest, southEast);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user