JpegGeoTagReader { public GeoTag readMetadata(File file) throws Exception { InputStream inputStream = new FileInputStream(file); return readMetadata(inputStream); } JpegGeoTagReader(); GeoTag readMetadata(File file); GeoTag readMetadata(InputStream inputStream); static final byte[] BYTES_PER_FORMAT; static final int GPS_INFO_OFFSET; static final int TIFF_HEADER_OFFSET; static final byte SEGMENTS_END; static final byte GPS_LATITUDE_REF; static final byte GPS_LATITUDE; static final byte GPS_LONGITUDE_REF; static final byte GPS_LONGITUDE; static final byte GPS_ALTITUDE; static final byte GPS_TIME; static final byte GPS_DATE; }
@Test public void testWithGeoTag() throws Exception { InputStream rawIn = getClass().getResourceAsStream("SampleWithGeoTag.jpg"); try { JpegGeoTagReader reader = new JpegGeoTagReader(); GeoTag geoTag = reader.readMetadata(rawIn); assertTrue(geoTag.hasData()); assertEquals(45.50888888888889, geoTag.getLatitude(), 0.00001); assertEquals(-122.67361111111111, geoTag.getLongitude(), 0.00001); assertEquals(26.0, geoTag.getAltitude(), 0.1); } finally { rawIn.close(); } }
@Test public void testWithoutGeoTag() throws Exception { InputStream rawIn = getClass().getResourceAsStream("SampleWithoutGeoTag.jpg"); try { JpegGeoTagReader reader = new JpegGeoTagReader(); GeoTag geoTag = reader.readMetadata(rawIn); assertFalse(geoTag.hasData()); } finally { rawIn.close(); } }