Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS height information reading #617

Open
yw19841107 opened this issue Jun 21, 2023 · 1 comment
Open

GPS height information reading #617

yw19841107 opened this issue Jun 21, 2023 · 1 comment

Comments

@yw19841107
Copy link

yw19841107 commented Jun 21, 2023

I am using JAVA version 2.18.0,When writing a code to read the GPS height, the height result obtained is not the same as the original value stored in the photo. At present, it is rounded to retain the last two Decimal separator of the GPS height value. Please improve it

@StefanOltmann
Copy link
Contributor

StefanOltmann commented Feb 4, 2024

The GPS data is of the TIFF rational type, which means it’s a floating number that can’t have an exact representation. See the docs.

Google Photos rounds two 3 digits after the dot.
Rounding to the last 6 decimal places is the most common thing I see.

GeoLocation.toString() gives you the double numbers without any rounding:

public String toString()
{
return _latitude + ", " + _longitude;
}

So I assume you want to see a different format for the DMS here:

DecimalFormat format = new DecimalFormat("0.##");
return String.format("%s\u00B0 %s' %s\"", format.format(dms[0]), format.format(dms[1]), format.format(dms[2]));

Two decimal places for DMS seems to be a very common representation.

How many do you want?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants