// constructor from CoreLocation location internal Geoposition(CLLocation location) { Coordinate = new Geocoordinate(); if (location != null) { Coordinate.Point = new Geopoint(new BasicGeoposition() { Latitude = location.Coordinate.Latitude, Longitude = location.Coordinate.Longitude, Altitude = location.Altitude }); Coordinate.Accuracy = location.HorizontalAccuracy; if (!double.IsNaN(location.VerticalAccuracy)) { Coordinate.AltitudeAccuracy = location.VerticalAccuracy; } #if __IOS__ || __MAC__ if (!double.IsNaN(location.Course) && location.Course != -1) { Coordinate.Heading = location.Course; } if (!double.IsNaN(location.Speed) && location.Speed != -1) { Coordinate.Speed = location.Speed; } #endif Coordinate.Timestamp = InTheHand.DateTimeOffsetHelper.FromNSDate(location.Timestamp); } }
// constructor from CoreLocation location internal Geoposition(CLLocation location) { Coordinate = new Geocoordinate(); if (location != null) { Coordinate.Point = new Geopoint(new BasicGeoposition() { Latitude = location.Coordinate.Latitude, Longitude = location.Coordinate.Longitude, Altitude = location.Altitude }); Coordinate.Accuracy = location.HorizontalAccuracy; if (!double.IsNaN(location.VerticalAccuracy)) { Coordinate.AltitudeAccuracy = location.VerticalAccuracy; } #if __IOS__ || __MAC__ if (!double.IsNaN(location.Course) && location.Course != -1) { Coordinate.Heading = location.Course; } if (!double.IsNaN(location.Speed) && location.Speed != -1) { Coordinate.Speed = location.Speed; } #endif Coordinate.Timestamp = InTheHand.DateTimeOffsetHelper.FromNSDate(location.Timestamp); } }
/// <summary> /// Returns the distance between the latitude and longitude coordinates that are specified by this <see cref="Geocoordinate"/> and another specified <see cref="Geocoordinate"/>. /// </summary> /// <param name="g"></param> /// <param name="other">The <see cref="Geocoordinate"/> for the location to calculate the distance to.</param> /// <returns>The distance between the two coordinates, in meters.</returns> public static double GetDistanceTo(this Geocoordinate g, Geocoordinate other) { if (g == null) { throw new ArgumentNullException("g"); } if (other == null) { throw new ArgumentNullException("other"); } return g.Point.Position.GetDistanceTo(other.Point.Position); }
/// <summary> /// Returns the distance between the latitude and longitude coordinates that are specified by this <see cref="Geocoordinate"/> and another specified <see cref="Geocoordinate"/>. /// </summary> /// <param name="g"></param> /// <param name="other">The <see cref="Geocoordinate"/> for the location to calculate the distance to.</param> /// <returns>The distance between the two coordinates, in meters.</returns> public static double GetDistanceTo(this Geocoordinate g, Geocoordinate other) { if (g == null) { throw new ArgumentNullException("g"); } if (other == null) { throw new ArgumentNullException("other"); } return(g.Point.Position.GetDistanceTo(other.Point.Position)); }
internal Geoposition(GeoPosition<GeoCoordinate> position) { Coordinate = new Geocoordinate(); Coordinate.Point = new Geopoint(new BasicGeoposition() { Latitude = position.Location.Latitude, Longitude = position.Location.Longitude, Altitude = position.Location.Altitude }); Coordinate.Accuracy = position.Location.HorizontalAccuracy; Coordinate.Timestamp = position.Timestamp; Coordinate.AltitudeAccuracy = position.Location.VerticalAccuracy; Coordinate.Heading = position.Location.Course; Coordinate.Speed = position.Location.Speed; Coordinate.PositionSource = PositionSource.Unknown; }