.Net Convert Windows.Devices.Geolocation.Geocoordinate to System.Device.Location.GeoCoordinate

今天寫的其中一個功能需要把 Windows.Devices.Geolocation.Geocoordinate 轉換成 System.Device.Location.GeoCoordinate

以下便是這個功能了


        /// <summary>
        /// This function convert the  Windows.Devices.Geolocation.Geocoordinate to
        /// System.Device.Location.GeoCoordinate
        /// </summary>
        /// <param name="geocoordinate">Geocoordinate in type Windows.Devices.Geolocation.Geocoordinate </param>
        /// <returns>GeoCoordinate in type System.Device.Location.GeoCoordinate</returns>
        private static GeoCoordinate ConvertGeocoordinate(Geocoordinate geocoordinate)
        {
            return new GeoCoordinate(
                                        geocoordinate.Latitude,
                                        geocoordinate.Longitude,
                                        geocoordinate.Altitude ?? double.NaN,
                                        geocoordinate.Accuracy,
                                        geocoordinate.AltitudeAccuracy ?? double.NaN,
                                        geocoordinate.Speed ?? double.NaN,
                                        geocoordinate.Heading ?? double.NaN);
        }

Hope you find it useful

Leave a Reply