Exemplo n.º 1
0
        /// <summary>
        /// Parses the GPS data from the specified <paramref name="bmpMetadata" /> and returns the data in an instance of <see cref="GpsLocation" />.
        /// </summary>
        /// <param name="bmpMetadata">An object containing the metadata.</param>
        /// <returns>An instance of <see cref="GpsLocation" />.</returns>
        public static GpsLocation Parse(BitmapMetadata bmpMetadata)
        {
            GpsLocation gps = new GpsLocation();

            gps.Version       = GetVersion(bmpMetadata);
            gps.Latitude      = GetLatitude(bmpMetadata);
            gps.Longitude     = GetLongitude(bmpMetadata);
            gps.Altitude      = GetAltitude(bmpMetadata);
            gps.DestLatitude  = GetDestLatitude(bmpMetadata);
            gps.DestLongitude = GetDestLongitude(bmpMetadata);

            //// Combine date portion of gpsDate or gpsDate2 with time portion of gpsTime2
            //object gpsDate = bmpMetadata.GetQuery("System.GPS.Date"); // System.Runtime.InteropServices.ComTypes.FILETIME
            //object gpsDate2 = bmpMetadata.GetQuery("/app1/ifd/gps/{ushort=29}"); // 2010:08:08

            //DateTime gpsDate3 = Convert((System.Runtime.InteropServices.ComTypes.FILETIME)gpsDate);

            //ulong[] gpsTime2 = bmpMetadata.GetQuery("/app1/ifd/gps/{ushort=7}") as ulong[]; // ulong[3]
            //double hh = SplitLongAndDivide(gpsTime2[0]);
            //double mm = SplitLongAndDivide(gpsTime2[1]);
            //double ss = SplitLongAndDivide(gpsTime2[2]);

            //object satellites = bmpMetadata.GetQuery("System.GPS.Satellites"); //"05"
            //object satellites2 = bmpMetadata.GetQuery("/app1/ifd/gps/{ushort=8}"); //"05"

            //double longitude = ConvertCoordinate(longitudeArray);

            return(gps);
        }
        /// <summary>
        /// Adds GPS data from the <paramref name="bmpMetadata" /> to the <paramref name="metadataItems" /> collection.
        /// </summary>
        /// <param name="bmpMetadata">An object containing the metadata.</param>
        /// <param name="metadataItems">The metadata items.</param>
        private static void AddGpsMetadata(BitmapMetadata bmpMetadata, IGalleryObjectMetadataItemCollection metadataItems)
        {
            GpsLocation gps = GpsLocation.Parse(bmpMetadata);

            if (!String.IsNullOrEmpty(gps.Version))
            {
                metadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsVersion, GetResource(FormattedMetadataItemName.GpsVersion), gps.Version, true);
            }

            if ((gps.Latitude != null) && (gps.Longitude != null))
            {
                metadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsLocation, GetResource(FormattedMetadataItemName.GpsLocation), gps.ToLatitudeLongitudeDecimalString(), true);
                metadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsLatitude, GetResource(FormattedMetadataItemName.GpsLatitude), gps.Latitude.ToDouble().ToString("F6", CultureInfo.InvariantCulture), true);
                metadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsLongitude, GetResource(FormattedMetadataItemName.GpsLongitude), gps.Longitude.ToDouble().ToString("F6", CultureInfo.InvariantCulture), true);
            }

            if (gps.Altitude.HasValue)
            {
                string altitude = String.Concat(gps.Altitude.Value.ToString("N0", CultureInfo.CurrentCulture), " ", Resources.Metadata_meters);
                metadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsAltitude, GetResource(FormattedMetadataItemName.GpsAltitude), altitude, true);
            }

            if ((gps.DestLatitude != null) && (gps.DestLongitude != null))
            {
                metadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsDestLocation, GetResource(FormattedMetadataItemName.GpsDestLocation), gps.ToDestLatitudeLongitudeDecimalString(), true);
                metadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsDestLatitude, GetResource(FormattedMetadataItemName.GpsDestLatitude), gps.DestLatitude.ToDouble().ToString("F6", CultureInfo.InvariantCulture), true);
                metadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsDestLongitude, GetResource(FormattedMetadataItemName.GpsDestLongitude), gps.DestLongitude.ToDouble().ToString("F6", CultureInfo.InvariantCulture), true);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses the GPS data from the specified <paramref name="bmpMetadata" /> and returns the data in an instance of <see cref="GpsLocation" />.
        /// </summary>
        /// <param name="bmpMetadata">An object containing the metadata.</param>
        /// <returns>An instance of <see cref="GpsLocation" />.</returns>
        public static GpsLocation Parse(BitmapMetadata bmpMetadata)
        {
            GpsLocation gps = new GpsLocation();

            gps.Version = GetVersion(bmpMetadata);
            gps.Latitude = GetLatitude(bmpMetadata);
            gps.Longitude = GetLongitude(bmpMetadata);
            gps.Altitude = GetAltitude(bmpMetadata);
            gps.DestLatitude = GetDestLatitude(bmpMetadata);
            gps.DestLongitude = GetDestLongitude(bmpMetadata);

            //// Combine date portion of gpsDate or gpsDate2 with time portion of gpsTime2
            //object gpsDate = bmpMetadata.GetQuery("System.GPS.Date"); // System.Runtime.InteropServices.ComTypes.FILETIME
            //object gpsDate2 = bmpMetadata.GetQuery("/app1/ifd/gps/{ushort=29}"); // 2010:08:08

            //DateTime gpsDate3 = Convert((System.Runtime.InteropServices.ComTypes.FILETIME)gpsDate);

            //ulong[] gpsTime2 = bmpMetadata.GetQuery("/app1/ifd/gps/{ushort=7}") as ulong[]; // ulong[3]
            //double hh = SplitLongAndDivide(gpsTime2[0]);
            //double mm = SplitLongAndDivide(gpsTime2[1]);
            //double ss = SplitLongAndDivide(gpsTime2[2]);

            //object satellites = bmpMetadata.GetQuery("System.GPS.Satellites"); //"05"
            //object satellites2 = bmpMetadata.GetQuery("/app1/ifd/gps/{ushort=8}"); //"05"

            //double longitude = ConvertCoordinate(longitudeArray);

            return gps;
        }