mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-23 00:46:39 +00:00
make structure
add tests
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
namespace SatelliteProvider.Common.DTO;
|
||||
|
||||
public class Direction
|
||||
{
|
||||
public double Distance { get; set; }
|
||||
public double Azimuth { get; set; }
|
||||
|
||||
public Direction() { }
|
||||
|
||||
public Direction(double distance, double azimuth)
|
||||
{
|
||||
Distance = distance;
|
||||
Azimuth = azimuth;
|
||||
}
|
||||
|
||||
public override string ToString() => $"{Distance:F2}, {Azimuth:F1} deg";
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace SatelliteProvider.Common.DTO;
|
||||
|
||||
public class GeoPoint
|
||||
{
|
||||
const double PRECISION_TOLERANCE = 0.00005;
|
||||
public double Lat { get; }
|
||||
public double Lon { get; }
|
||||
|
||||
public GeoPoint() { }
|
||||
|
||||
public GeoPoint(double lat, double lon)
|
||||
{
|
||||
Lat = lat;
|
||||
Lon = lon;
|
||||
}
|
||||
|
||||
public override string ToString() => $"{Lat:F4}, {Lon:F4}";
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is not GeoPoint point) return false;
|
||||
return ReferenceEquals(this, obj) || Equals(point);
|
||||
}
|
||||
|
||||
private bool Equals(GeoPoint point) =>
|
||||
Math.Abs(Lat - point.Lat) < PRECISION_TOLERANCE && Math.Abs(Lon - point.Lon) < PRECISION_TOLERANCE;
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(Lat, Lon);
|
||||
|
||||
public static bool operator ==(GeoPoint left, GeoPoint right) => Equals(left, right);
|
||||
public static bool operator !=(GeoPoint left, GeoPoint right) => !Equals(left, right);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using SatelliteProvider.Common.Utils;
|
||||
|
||||
namespace SatelliteProvider.Common.DTO;
|
||||
|
||||
public class SatTile
|
||||
{
|
||||
public int X { get; }
|
||||
public int Y { get; }
|
||||
public int Zoom { get; }
|
||||
public GeoPoint LeftTop { get; }
|
||||
public GeoPoint BottomRight { get; }
|
||||
public string Url { get; set; }
|
||||
|
||||
|
||||
public SatTile(int x, int y, int zoom, string url)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Zoom = zoom;
|
||||
Url = url;
|
||||
|
||||
LeftTop = GeoUtils.TileToWorldPos(x, y, zoom);
|
||||
BottomRight = GeoUtils.TileToWorldPos(x + 1, y + 1, zoom);
|
||||
}
|
||||
|
||||
public string FileName => $"{X}.{Y}.{Zoom}.jpg";
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Tile[X={X}, Y={Y}, TL=({LeftTop.Lat:F6}, {LeftTop.Lon:F6}), BR=({BottomRight.Lat:F6}, {BottomRight.Lon:F6})]";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user