Improve precision of GPS lat/lon printed values

main
Miloš Komarčević 4 years ago committed by Luis Díaz Más
parent 3f3bbc28ad
commit 94adf1b038

@ -2625,14 +2625,33 @@ namespace Exiv2 {
{
std::ios::fmtflags f( os.flags() );
if (value.count() == 3) {
static const char* unit[] = { " deg", "'", "\"" };
for (int i = 0; i < value.count() ; ++i) {
const int v = (int) (value.toFloat(i)+0.5f); // nearest integer
os << (i != 0? " " : "") << v << unit[i];
Rational deg = value.toRational(0);
Rational min = value.toRational(1);
Rational sec = value.toRational(2);
if ((deg.second != 1) || (min.second == 0) || (sec.second == 0)) {
return os << "(" << value << ")";
}
const int32_t dd = deg.first;
const int32_t mm = min.first / min.second;
const int32_t rem = min.first % min.second;
if ((min.second > 1) && (rem > 0)) {
if ((sec.first == 0) && (sec.second == 1)) {
sec.first = 60 * rem;
sec.second = min.second;
} else {
return os << "(" << value << ")";
}
}
const float ss = (float)sec.first / sec.second;
os << dd << " deg ";
os << mm << "' ";
std::ostringstream oss;
oss.copyfmt(os);
os << std::fixed << std::setprecision(sec.second > 1 ? 2 : 0) << ss << "\"";
os.copyfmt(oss);
}
else {
os << value;
os << "(" << value << ")";
}
os.flags(f);
return os;

@ -10,9 +10,9 @@ class CheckRegularExpressionSupport(metaclass=system_tests.CaseMeta):
commands = [ "$exiv2 -pa --grep gpsl/i $filename" ]
stdout = [ """Exif.GPSInfo.GPSLatitudeRef Ascii 2 North
Exif.GPSInfo.GPSLatitude Rational 3 52 deg 4' 0"
Exif.GPSInfo.GPSLatitude Rational 3 52 deg 3' 49.02"
Exif.GPSInfo.GPSLongitudeRef Ascii 2 East
Exif.GPSInfo.GPSLongitude Rational 3 1 deg 14' 0"
Exif.GPSInfo.GPSLongitude Rational 3 1 deg 13' 49.16"
"""
]
stderr = [""]

@ -36,8 +36,8 @@ set Exif.GPSInfo.GPSLongitude 1/1 495984/10000 0/1
output_grep_GPSL,
"",
"""Exif.GPSInfo.GPSLatitudeRef Ascii 2 North
Exif.GPSInfo.GPSLatitude Rational 3 51 deg 11' 0"
Exif.GPSInfo.GPSLatitude Rational 3 51 deg 10' 41.81"
Exif.GPSInfo.GPSLongitudeRef Ascii 2 West
Exif.GPSInfo.GPSLongitude Rational 3 1 deg 50' 0"
Exif.GPSInfo.GPSLongitude Rational 3 1 deg 49' 35.90"
"""
]

@ -69,9 +69,9 @@ Exif.Photo.Saturation Short 1 Normal
Exif.Image.GPSTag Long 1 870
Exif.GPSInfo.GPSVersionID Byte 4 2.0.0.0
Exif.GPSInfo.GPSLatitudeRef Ascii 2 North
Exif.GPSInfo.GPSLatitude Rational 3 47 deg 36' 58"
Exif.GPSInfo.GPSLatitude Rational 3 47 deg 36' 58.02"
Exif.GPSInfo.GPSLongitudeRef Ascii 2 East
Exif.GPSInfo.GPSLongitude Rational 3 1 deg 31' 1"
Exif.GPSInfo.GPSLongitude Rational 3 1 deg 31' 0.94"
Exif.GPSInfo.GPSAltitudeRef Byte 1 Above sea level
Exif.GPSInfo.GPSAltitude Rational 1 86 m
Exif.Thumbnail.Compression Short 1 JPEG (old-style)

Loading…
Cancel
Save