Esempio n. 1
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"));
        }
Esempio n. 2
0
        public void GeoParser_ParseIsoString_WrongPlusFormat()
        {
            var result = GeoParser.ParseIsoString("0-05");

            Assert.AreEqual(0, result.Latitude, 0.001);
        }
Esempio n. 3
0
        public void GeoParser_ParseIsoString_LotsOfMinus()
        {
            var result = GeoParser.ParseIsoString("0-05-0-0-0-0-0-0-0-0");

            Assert.AreEqual(0, result.Latitude, 0.001);
        }
Esempio n. 4
0
        public void GeoParser_ParseIsoString_DoesNotEndOnSlash()
        {
            var result = GeoParser.ParseIsoString("-05.2169-080.6303");             // no slash here

            Assert.AreEqual(0, result.Latitude, 0.001);
        }