Author: britter
Date: Sun Jan 11 11:47:19 2015
New Revision: 1650892
URL: http://svn.apache.org/r1650892
Log:
Add test for IMAGING-144
Added:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/write/
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSetTest.java
(with props)
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java?rev=1650892&r1=1650891&r2=1650892&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java
Sun Jan 11 11:47:19 2015
@@ -32,6 +32,8 @@ public interface GpsTagConstants {
"GPSVersionID", 0x0000, 4,
TiffDirectoryType.EXIF_DIRECTORY_GPS);
+ byte[] GPS_VERSION = new byte[] { (byte)2, (byte)3, (byte)0, (byte)0 };
+
// ************************************************************
TagInfoAscii GPS_TAG_GPS_LATITUDE_REF = new TagInfoAscii(
"GPSLatitudeRef", 0x0001, 2,
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java?rev=1650892&r1=1650891&r2=1650892&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java
Sun Jan 11 11:47:19 2015
@@ -138,7 +138,7 @@ public final class TiffOutputSet {
final TiffOutputDirectory gpsDirectory = getOrCreateGPSDirectory();
gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_VERSION_ID);
- gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_VERSION_ID, (byte)2,
(byte)3, (byte)0, (byte)0);
+ gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_VERSION_ID,
GpsTagConstants.GPS_VERSION);
final String longitudeRef = longitude < 0 ? "W" : "E";
longitude = Math.abs(longitude);
Added:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSetTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSetTest.java?rev=1650892&view=auto
==============================================================================
---
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSetTest.java
(added)
+++
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSetTest.java
Sun Jan 11 11:47:19 2015
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.imaging.formats.tiff.write;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TiffOutputSetTest {
+
+ private TiffOutputSet tiffOutputSet;
+
+ @Before
+ public void setUp() throws Exception {
+ tiffOutputSet = new TiffOutputSet();
+ }
+
+ /*
+ * TiffOutputSet.setGPSInDegrees should make sure, GPSVersionID is set
+ *
+ * https://issues.apache.org/jira/browse/IMAGING-144
+ */
+ @Test
+ public void testImaging144() throws Exception {
+ tiffOutputSet.setGPSInDegrees(1.0, 1.0);
+
+ TiffOutputDirectory gpsDirectory = tiffOutputSet.getGPSDirectory();
+ TiffOutputField gpsVersionId = getGpsVersionId(gpsDirectory);
+
+ assertNotNull(gpsVersionId);
+ assertTrue(gpsVersionId.bytesEqual(GpsTagConstants.GPS_VERSION));
+ }
+
+ private static TiffOutputField getGpsVersionId(TiffOutputDirectory
gpsDirectory) {
+ List<TiffOutputField> fields = gpsDirectory.getFields();
+ for (TiffOutputField field : fields) {
+ if (field.tagInfo.equals(GpsTagConstants.GPS_TAG_GPS_VERSION_ID)) {
+ return field;
+ }
+ }
+ return null;
+ }
+}
Propchange:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSetTest.java
------------------------------------------------------------------------------
svn:eol-style = native