Changeset View
Changeset View
Standalone View
Standalone View
src/extractors/exiv2extractor.cpp
Show First 20 Lines • Show All 286 Lines • ▼ Show 20 Line(s) | 246 | { | |||
---|---|---|---|---|---|
287 | 287 | | |||
288 | return std::numeric_limits<double>::quiet_NaN(); | 288 | return std::numeric_limits<double>::quiet_NaN(); | ||
289 | } | 289 | } | ||
290 | 290 | | |||
291 | double Exiv2Extractor::fetchGpsAltitude(const Exiv2::ExifData& data) | 291 | double Exiv2Extractor::fetchGpsAltitude(const Exiv2::ExifData& data) | ||
292 | { | 292 | { | ||
293 | double alt = std::numeric_limits<double>::quiet_NaN(); | 293 | double alt = std::numeric_limits<double>::quiet_NaN(); | ||
294 | Exiv2::ExifData::const_iterator it = data.findKey(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitude")); | 294 | Exiv2::ExifData::const_iterator it = data.findKey(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitude")); | ||
295 | if (it != data.end()) { | 295 | if (it != data.end() && (it->value().typeId() == Exiv2::unsignedRational || it->value().typeId() == Exiv2::signedRational)) { | ||
296 | auto ratio = it->value().toRational(); | 296 | auto ratio = it->value().toRational(); | ||
297 | it = data.findKey(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitudeRef")); | 297 | it = data.findKey(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitudeRef")); | ||
298 | if ((ratio.second != 0) && (it != data.end())) { | 298 | if ((ratio.second != 0) && (it != data.end()) && (it->value().typeId() == Exiv2::unsignedByte || it->value().typeId() == Exiv2::signedByte)) { | ||
299 | auto altRef = it->value().toLong(); | 299 | auto altRef = it->value().toLong(); | ||
300 | if (altRef) { | 300 | if (altRef) { | ||
301 | alt = -1.0 * ratio.first / ratio.second; | 301 | alt = -1.0 * ratio.first / ratio.second; | ||
302 | } else { | 302 | } else { | ||
303 | alt = 1.0 * ratio.first / ratio.second; | 303 | alt = 1.0 * ratio.first / ratio.second; | ||
304 | } | 304 | } | ||
305 | } | 305 | } | ||
306 | } | 306 | } | ||
Show All 13 Lines |