]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/drew/jpeg/JpegData.java
Version 9, February 2010
[GpsPrune.git] / tim / prune / drew / jpeg / JpegData.java
index 51995c96922b90f30ad117f6394f2e1b0424c758..623fc3480709c3658c28ee74551a98af56483961 100644 (file)
@@ -5,7 +5,6 @@ import java.util.List;
 
 /**
  * Class to hold the GPS data extracted from a Jpeg including position and time
- * All contents are in Rational format
  */
 public class JpegData
 {
@@ -16,9 +15,12 @@ public class JpegData
        private Rational[] _latitude = null;
        private Rational[] _longitude = null;
        private Rational   _altitude = null;
-       private Rational[] _timestamp = null;
-       private Rational[] _datestamp = null;
-       private ArrayList _errors = null;
+       private Rational[] _gpsTimestamp = null;
+       private Rational[] _gpsDatestamp = null;
+       private String _originalTimestamp = null;
+       private int _orientationCode = -1;
+       private byte[] _thumbnail = null;
+       private ArrayList<String> _errors = null;
 
 
        /**
@@ -113,21 +115,41 @@ public class JpegData
        }
 
        /**
-        * Set the timestamp
+        * Set the Gps timestamp
         * @param inValues array of Rationals holding timestamp
         */
-       public void setTimestamp(Rational[] inValues)
+       public void setGpsTimestamp(Rational[] inValues)
        {
-               _timestamp = inValues;
+               _gpsTimestamp = inValues;
        }
 
        /**
-        * Set the datestamp
+        * Set the Gps datestamp
         * @param inValues array of Rationals holding datestamp
         */
-       public void setDatestamp(Rational[] inValues)
+       public void setGpsDatestamp(Rational[] inValues)
        {
-               _datestamp = inValues;
+               _gpsDatestamp = inValues;
+       }
+
+       /**
+        * Set the original timestamp
+        * @param inStamp original timestamp of photo
+        */
+       public void setOriginalTimestamp(String inStamp)
+       {
+               _originalTimestamp = inStamp;
+       }
+
+       /**
+        * Set the orientation code
+        * @param inCode code from exif (1 to 8)
+        */
+       public void setOrientationCode(int inCode)
+       {
+               if (inCode >= 1 && inCode <= 8) {
+                       _orientationCode = inCode;
+               }
        }
 
        /** @return latitude ref as char */
@@ -142,10 +164,37 @@ public class JpegData
        public byte getAltitudeRef() { return _altitudeRef; }
        /** @return altitude as Rational */
        public Rational getAltitude() { return _altitude; }
-       /** @return timestamp as array of 3 Rationals */
-       public Rational[] getTimestamp() { return _timestamp; }
-       /** @return timestamp as array of 3 Rationals */
-       public Rational[] getDatestamp() { return _datestamp; }
+       /** @return Gps timestamp as array of 3 Rationals */
+       public Rational[] getGpsTimestamp() { return _gpsTimestamp; }
+       /** @return Gps datestamp as array of 3 Rationals */
+       public Rational[] getGpsDatestamp() { return _gpsDatestamp; }
+       /** @return orientation code (1 to 8) */
+       public int getOrientationCode() { return _orientationCode; }
+       /** @return original timestamp as string */
+       public String getOriginalTimestamp() { return _originalTimestamp; }
+
+       /**
+        * Set the thumbnail
+        * @param inBytes byte array containing thumbnail
+        */
+       public void setThumbnailImage(byte[] inBytes) {
+               _thumbnail = inBytes;
+       }
+       /** @return thumbnail as byte array */
+       public byte[] getThumbnailImage() {
+               return _thumbnail;
+       }
+
+       /**
+        * @return rotation required to display photo properly (0 to 3)
+        */
+       public int getRequiredRotation()
+       {
+               if (_orientationCode <= 2) { return 0; } // no rotation required
+               if (_orientationCode <= 4) { return 2; } // 180 degrees
+               if (_orientationCode <= 6) { return 1; } // 270 degrees, so need to rotate by 90
+               return 3; // 90 degrees, so need to rotate by 270
+       }
 
        /**
         * @return true if data looks valid, ie has at least lat and long
@@ -165,7 +214,7 @@ public class JpegData
         */
        public void addError(String inError)
        {
-               if (_errors == null) _errors = new ArrayList();
+               if (_errors == null) _errors = new ArrayList<String>();
                _errors.add(inError);
        }
 
@@ -189,7 +238,7 @@ public class JpegData
        /**
         * @return all errors as a list
         */
-       public List getErrors()
+       public List<String> getErrors()
        {
                return _errors;
        }