summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Maps/Position.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Maps/Position.cs')
-rw-r--r--Xamarin.Forms.Maps/Position.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Xamarin.Forms.Maps/Position.cs b/Xamarin.Forms.Maps/Position.cs
new file mode 100644
index 00000000..17a86523
--- /dev/null
+++ b/Xamarin.Forms.Maps/Position.cs
@@ -0,0 +1,47 @@
+using System;
+
+namespace Xamarin.Forms.Maps
+{
+ public struct Position
+ {
+ public Position(double latitude, double longitude)
+ {
+ Latitude = Math.Min(Math.Max(latitude, -90.0), 90.0);
+ Longitude = Math.Min(Math.Max(longitude, -180.0), 180.0);
+ }
+
+ public double Latitude { get; }
+
+ public double Longitude { get; }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ return false;
+ if (obj.GetType() != GetType())
+ return false;
+ var other = (Position)obj;
+ return Latitude == other.Latitude && Longitude == other.Longitude;
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = Latitude.GetHashCode();
+ hashCode = (hashCode * 397) ^ Longitude.GetHashCode();
+ return hashCode;
+ }
+ }
+
+ public static bool operator ==(Position left, Position right)
+ {
+ return Equals(left, right);
+ }
+
+ public static bool operator !=(Position left, Position right)
+ {
+ return !Equals(left, right);
+ }
+ }
+} \ No newline at end of file