-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoordinate.cs
50 lines (42 loc) · 1.37 KB
/
Coordinate.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
namespace AzUtil.Core
{
public struct Coordinate : IEquatable<Coordinate>
{
public Coordinate(double latitude, double longitude, bool isUnknown = false)
{
Latitude = latitude;
Longitude = longitude;
IsUnknown = isUnknown;
}
public double Latitude { get; }
public double Longitude { get; }
public bool IsUnknown { get; }
public static Coordinate Unknown => new(0, 0, true);
public override bool Equals(object obj)
{
return obj is Coordinate coordinate &&
Latitude == coordinate.Latitude &&
Longitude == coordinate.Longitude &&
IsUnknown == coordinate.IsUnknown;
}
public bool Equals(Coordinate other)
{
return Latitude == other.Latitude &&
Longitude == other.Longitude &&
IsUnknown == other.IsUnknown;
}
public override int GetHashCode()
{
return HashCode.Combine(Latitude, Longitude, IsUnknown);
}
public static bool operator == (Coordinate left, Coordinate right)
{
return left.Equals(right);
}
public static bool operator != (Coordinate left, Coordinate right)
{
return !(left == right);
}
}
}