Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public struct GeoCoordinate : IEquatable<GeoCoordinate>
- {
- private const float SecondsInDegree = 3600f;
- private readonly float latitude; // Expressed in seconds of degree, positive values for north
- private readonly float longitude; // Expressed in seconds of degree, positive values for east
- /// <summary>
- /// Initializes a new instance of the <see cref="GeoCoordinate"/> class with the specified latitude and longitude.
- /// </summary>
- /// <param name="latitude">The latitude in degrees.</param>
- /// <param name="longitude">The longitude in degrees.</param>
- public GeoCoordinate(float latitude, float longitude) : this()
- {
- this.latitude = latitude * SecondsInDegree;
- this.longitude = longitude * SecondsInDegree;
- }
- public float Latitude
- {
- get { return latitude; }
- }
- public float Longitude
- {
- get { return longitude; }
- }
- public override bool Equals(object other)
- {
- if (other == null || other.GetType() != typeof(GeoCoordinate)) {
- return false;
- }
- return this.Equals((GeoCoordinate)other);
- }
- public bool Equals(GeoCoordinate other)
- {
- return this.latitude == other.latitude && this.longitude == other.longitude;
- }
- public override int GetHashCode()
- {
- return latitude.GetHashCode() ^ longitude.GetHashCode();
- }
- public static bool operator==(GeoCoordinate lhs, GeoCoordinate rhs)
- {
- return lhs.Equals(rhs);
- }
- public static bool operator!=(GeoCoordinate lhs, GeoCoordinate rhs)
- {
- return !lhs.Equals(rhs);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment