diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java index 7ab5d5fee..a3b4c4609 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java @@ -148,13 +148,21 @@ public final class GpsTagConstants { public static final int GPS_TAG_GPS_DIFFERENTIAL_VALUE_DIFFERENTIAL_CORRECTED = 1; + /** + * Horizontal positioning errors in meters. + * + * @since 1.0.0-alpha6 + */ + public static final TagInfoRational GPS_TAG_GPS_HOR_POSITIONING_ERROR = new TagInfoRational("GPSHPositioningError", 0x001f, + TiffDirectoryType.EXIF_DIRECTORY_GPS); + public static final List ALL_GPS_TAGS = Collections.unmodifiableList(Arrays.asList(GPS_TAG_GPS_VERSION_ID, GPS_TAG_GPS_LATITUDE_REF, GPS_TAG_GPS_LATITUDE, GPS_TAG_GPS_LONGITUDE_REF, GPS_TAG_GPS_LONGITUDE, GPS_TAG_GPS_ALTITUDE_REF, GPS_TAG_GPS_ALTITUDE, GPS_TAG_GPS_TIME_STAMP, GPS_TAG_GPS_SATELLITES, GPS_TAG_GPS_STATUS, GPS_TAG_GPS_MEASURE_MODE, GPS_TAG_GPS_DOP, GPS_TAG_GPS_SPEED_REF, GPS_TAG_GPS_SPEED, GPS_TAG_GPS_TRACK_REF, GPS_TAG_GPS_TRACK, GPS_TAG_GPS_IMG_DIRECTION_REF, GPS_TAG_GPS_IMG_DIRECTION, GPS_TAG_GPS_MAP_DATUM, GPS_TAG_GPS_DEST_LATITUDE_REF, GPS_TAG_GPS_DEST_LATITUDE, GPS_TAG_GPS_DEST_LONGITUDE_REF, GPS_TAG_GPS_DEST_LONGITUDE, GPS_TAG_GPS_DEST_BEARING_REF, GPS_TAG_GPS_DEST_BEARING, GPS_TAG_GPS_DEST_DISTANCE_REF, GPS_TAG_GPS_DEST_DISTANCE, GPS_TAG_GPS_PROCESSING_METHOD, GPS_TAG_GPS_AREA_INFORMATION, - GPS_TAG_GPS_DATE_STAMP, GPS_TAG_GPS_DIFFERENTIAL)); + GPS_TAG_GPS_DATE_STAMP, GPS_TAG_GPS_DIFFERENTIAL, GPS_TAG_GPS_HOR_POSITIONING_ERROR)); public static byte[] gpsVersion() { return GPS_VERSION.clone(); diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java index ea724befe..e0fae16e2 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java @@ -17,13 +17,19 @@ package org.apache.commons.imaging.formats.jpeg.exif; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.File; import java.util.stream.Stream; import org.apache.commons.imaging.Imaging; +import org.apache.commons.imaging.common.RationalNumber; import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata; +import org.apache.commons.imaging.formats.tiff.TiffField; import org.apache.commons.imaging.formats.tiff.TiffImageMetadata; +import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants; import org.apache.commons.imaging.internal.Debug; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -63,4 +69,16 @@ public void test(final File imageFile) throws Exception { Debug.debug(); } + + /** + * @throws Exception if it cannot open the images. + */ + @Test + public void testReadMetadata() throws Exception { + final File imageFile = new File(GpsTest.class.getResource("/images/jpeg/exif/2024-04-30_G012.JPG").getFile()); + final JpegImageMetadata jpegMetadata = (JpegImageMetadata) Imaging.getMetadata(imageFile); + final TiffField gpsHPosErrorField = jpegMetadata.findExifValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_HOR_POSITIONING_ERROR); + final RationalNumber gpsHPosError = (RationalNumber) gpsHPosErrorField.getValue(); + assertEquals(0.014, gpsHPosError.doubleValue()); + } } diff --git a/src/test/resources/images/jpeg/exif/2024-04-30_G012.JPG b/src/test/resources/images/jpeg/exif/2024-04-30_G012.JPG new file mode 100644 index 000000000..e4b871845 Binary files /dev/null and b/src/test/resources/images/jpeg/exif/2024-04-30_G012.JPG differ