Exemple #1
0
        private void GetPhotoLocation(MediaFile file)
        {
            using (Stream photo = file.GetStream())
            {
                var                 picture     = ExifReader.ReadJpeg(photo);
                ExifOrientation     orientation = picture.Orientation;
                ExifGpsLatitudeRef  latRef      = picture.GpsLatitudeRef;
                ExifGpsLongitudeRef longRef     = picture.GpsLongitudeRef;

                latitude.Text  = GetLatitude(latRef, picture.GpsLatitude).ToString();
                longitude.Text = GetLongitude(picture.GpsLongitude).ToString();
            }
        }
Exemple #2
0
        public static double GetLatitude(ExifGpsLatitudeRef latRef, double[] data)
        {
            SplitGpsArray(data);

            var result = ConvertDegreeToAngle();

            if (latRef == ExifGpsLatitudeRef.South)
            {
                result *= -1;
            }

            return(result);
        }
Exemple #3
0
        private double GetLatitude(ExifGpsLatitudeRef latRef, double [] data)
        {
            double degrees = data[0];
            double minutes = data[1];
            double seconds = data.Length > 2 ? data[2] : 0.0;

            double result = ConvertDegreeToAngle(degrees, minutes, seconds);

            if (latRef == ExifGpsLatitudeRef.South)
            {
                result *= -1;
            }

            return(result);
        }
Exemple #4
0
        private void PreviewPhoto(MediaFile mediaFile)
        {
            using (Stream photo = mediaFile.GetStream())
            {
                var picture = ExifReader.ReadJpeg(photo);

                FilePath = mediaFile.Path;

                ExifOrientation     orientation = picture.Orientation;
                ExifGpsLatitudeRef  latRef      = picture.GpsLatitudeRef;
                ExifGpsLongitudeRef longRef     = picture.GpsLongitudeRef;

                Latitude  = GpsHelper.GetLatitude(latRef, picture.GpsLatitude);
                Longitude = GpsHelper.GetLongitude(picture.GpsLongitude);
            }
        }
Exemple #5
0
        /// <summary>
        /// Picks up the default bundled photo, extracts location and plots this on map.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void OnClicked(object sender, EventArgs e)
        {
            var    assembly = typeof(ImagePage).GetTypeInfo().Assembly;
            Stream stream   = assembly.GetManifestResourceStream("XamarinFormsMapsDemo.sample.jpg");
            var    JpegInfo = ExifReader.ReadJpeg(stream);

            lat  = JpegInfo.GpsLatitude[0] + JpegInfo.GpsLatitude[1] / 60 + JpegInfo.GpsLatitude[2] / 3600;           //JpegInfo.GpsLatitude[0];
            lang = JpegInfo.GpsLongitude[0] + JpegInfo.GpsLongitude[1] / 60 + JpegInfo.GpsLongitude[2] / 3600;        //JpegInfo.GpsLongitude[0];
            ExifGpsLatitudeRef  latRef  = JpegInfo.GpsLatitudeRef;
            ExifGpsLongitudeRef longRef = JpegInfo.GpsLongitudeRef;

            if (latRef == ExifGpsLatitudeRef.South)
            {
                lat = lat * -1;
            }

            if (longRef == ExifGpsLongitudeRef.West)
            {
                lang = lang * -1;
            }

            Navigation.PushModalAsync(new MapPage(lat, lang));
        }
Exemple #6
0
        /// <summary>
        /// This will launch photo gallery. Extracts location from photo and plots those on the map.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private async void OnPhotoPickup(object sender, EventArgs e)
        {
            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                //this.ShowUnsupportedMediaAlert ();
                return;
            }

            var ImageFromLibrary = await CrossMedia.Current.PickPhotoAsync();

            if (ImageFromLibrary != null)
            {
                IFile ImageFile = await FileSystem.Current.GetFileFromPathAsync(ImageFromLibrary.Path);

                Stream stream = await ImageFile.OpenAsync(FileAccess.Read);

                var JpegInfo = ExifReader.ReadJpeg(stream);


                lat  = JpegInfo.GpsLatitude[0] + JpegInfo.GpsLatitude[1] / 60 + JpegInfo.GpsLatitude[2] / 3600;               //JpegInfo.GpsLatitude[0];
                lang = JpegInfo.GpsLongitude[0] + JpegInfo.GpsLongitude[1] / 60 + JpegInfo.GpsLongitude[2] / 3600;            //JpegInfo.GpsLongitude[0];
                ExifGpsLatitudeRef  latRef  = JpegInfo.GpsLatitudeRef;
                ExifGpsLongitudeRef longRef = JpegInfo.GpsLongitudeRef;
                if (latRef == ExifGpsLatitudeRef.South)
                {
                    lat = lat * -1;
                }

                if (longRef == ExifGpsLongitudeRef.West)
                {
                    lang = lang * -1;
                }

                await Navigation.PushModalAsync(new MapPage (lat, lang));
            }
        }
        public static double ConvertDegreeAngleToDouble(double degrees, double minutes, double seconds, ExifGpsLatitudeRef latRef)
        {
            double result = ConvertDegreeAngleToDouble(degrees, minutes, seconds);

            if (latRef == ExifGpsLatitudeRef.South)
            {
                result *= -1;
            }
            return(result);
        }