Example #1
0
        public void GeoParser_ExifRead_ParseGpsTest()
        {
            var latitude = GeoParser.ConvertDegreeMinutesSecondsToDouble("52° 18' 29.54\"", "N");

            Assert.AreEqual(52.308205555500003, latitude, 0.000001);

            var longitude = GeoParser.ConvertDegreeMinutesSecondsToDouble("6° 11' 36.8\"", "E");

            Assert.AreEqual(6.1935555554999997, longitude, 0.000001);
        }
Example #2
0
        private double GetGeoLocationLongitude(List <Directory> allExifItems)
        {
            var longitudeString = string.Empty;
            var longitudeRef    = string.Empty;

            foreach (var exifItem in allExifItems)
            {
                var longitudeRefLocal = exifItem.Tags.FirstOrDefault(
                    p => p.DirectoryName == "GPS" &&
                    p.Name == "GPS Longitude Ref")?.Description;

                if (longitudeRefLocal != null)
                {
                    longitudeRef = longitudeRefLocal;
                }

                var longitudeLocal = exifItem.Tags.FirstOrDefault(
                    p => p.DirectoryName == "GPS" &&
                    p.Name == "GPS Longitude")?.Description;

                if (longitudeLocal != null)
                {
                    longitudeString = longitudeLocal;
                    continue;
                }

                var locationQuickTime = exifItem.Tags.FirstOrDefault(
                    p => p.DirectoryName == "QuickTime Metadata Header" &&
                    p.Name == "GPS Location")?.Description;
                if (locationQuickTime != null)
                {
                    return(GeoParser.ParseIsoString(locationQuickTime).Longitude);
                }
            }

            if (!string.IsNullOrWhiteSpace(longitudeString))
            {
                var longitude = GeoParser.ConvertDegreeMinutesSecondsToDouble(longitudeString, longitudeRef);
                longitude = Math.Floor(longitude * 10000000000) / 10000000000;
                return(longitude);
            }

            return(GetXmpGeoData(allExifItems, "exif:GPSLongitude"));
        }