@@ -23,6 +23,20 @@ public GeoLocation(double latitude, double longitude)
23
23
{
24
24
Latitude = latitude ;
25
25
Longitude = longitude ;
26
+ Altitude = null ;
27
+ }
28
+
29
+ /// <summary>
30
+ /// Initialises an instance of <see cref="GeoLocation"/>.
31
+ /// </summary>
32
+ /// <param name="latitude">the latitude, in degrees</param>
33
+ /// <param name="longitude">the longitude, in degrees</param>
34
+ /// <param name="altitude">the altitude, in meters</param>
35
+ public GeoLocation ( double latitude , double longitude , double ? altitude )
36
+ {
37
+ Latitude = latitude ;
38
+ Longitude = longitude ;
39
+ Altitude = altitude ;
26
40
}
27
41
28
42
/// <value>the latitudinal angle of this location, in degrees.</value>
@@ -31,6 +45,9 @@ public GeoLocation(double latitude, double longitude)
31
45
/// <value>the longitudinal angle of this location, in degrees.</value>
32
46
public double Longitude { get ; }
33
47
48
+ /// <value>the altitude of this location, in meters, null indicates there is no altitude present in exif</value>
49
+ public double ? Altitude { get ; }
50
+
34
51
/// <value>true, if both latitude and longitude are equal to zero</value>
35
52
public bool IsZero => Latitude == 0 && Longitude == 0 ;
36
53
@@ -82,7 +99,8 @@ public static double[] DecimalToDegreesMinutesSeconds(double value)
82
99
#region Equality and Hashing
83
100
84
101
private bool Equals ( GeoLocation other ) => Latitude . Equals ( other . Latitude ) &&
85
- Longitude . Equals ( other . Longitude ) ;
102
+ Longitude . Equals ( other . Longitude ) &&
103
+ Altitude . Equals ( other . Altitude ) ;
86
104
87
105
public override bool Equals ( object ? obj )
88
106
{
@@ -93,17 +111,17 @@ public override bool Equals(object? obj)
93
111
return obj is GeoLocation location && Equals ( location ) ;
94
112
}
95
113
96
- public override int GetHashCode ( ) => unchecked ( ( Latitude . GetHashCode ( ) * 397 ) ^ Longitude . GetHashCode ( ) ) ;
114
+ public override int GetHashCode ( ) => unchecked ( ( ( Latitude . GetHashCode ( ) * 397 ) + ( Altitude . GetHashCode ( ) * 14 ) ) ^ Longitude . GetHashCode ( ) ) ;
97
115
98
116
#endregion
99
117
100
118
#region ToString
101
119
102
120
/// <returns>
103
121
/// Returns a string representation of this object, of format:
104
- /// <c>1.23, 4.56</c>
122
+ /// <c>1.23, 4.56, 8M </c>
105
123
/// </returns>
106
- public override string ToString ( ) => Latitude + ", " + Longitude ;
124
+ public override string ToString ( ) => Latitude + ", " + Longitude + ( Altitude == null ? string . Empty : $ ", { Altitude } M" ) ;
107
125
108
126
/// <returns>
109
127
/// a string representation of this location, of format:
0 commit comments