Contains the information for identifying a geographic location.
PlatformVersion supported iOSiOS 9.0 and later macOSOS X 10.7 and later tvOStvOS 9.0 and later TizenTizen 3.0 Windows UWPWindows 10 Windows StoreWindows 8.1 or later Windows Phone StoreWindows Phone 8.1 or later Windows Phone SilverlightWindows Phone 8.0 or later Windows (Desktop Apps)Windows Vista or later
예제 #1
0
        // 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);
            }
        }
예제 #2
0
        // 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);
            }
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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));
        }
예제 #5
0
 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;
 }