private static Rational[] toExifLatLong( double value ) { // convert to the format dd/1 mm/1 ssss/100 value = Math.abs( value ); int degrees = (int) value; value = ( value - degrees ) * 60; int minutes = (int) value; value = ( value - minutes ) * 6000; int seconds = (int) value; return new Rational[]{ new Rational( degrees, 1 ), new Rational( minutes, 1 ), new Rational( seconds, 100 ) }; }
private static Rational[] toExifLatLong( double value ) { // convert to the format dd/1 mm/1 ssss/100 value = Math.abs( value ); int degrees = (int) value; value = ( value - degrees ) * 60; int minutes = (int) value; value = ( value - minutes ) * 6000; int seconds = (int) value; return new Rational[]{ new Rational( degrees, 1 ), new Rational( minutes, 1 ), new Rational( seconds, 100 ) }; }
/** * @see #getTagValue */ public Rational getTagRationalValue( int tagId, int ifdId ) { Rational[] l = getTagRationalValues( tagId, ifdId ); if( l == null || l.length == 0 ) { return null; } return new Rational( l[0] ); }
/** * @see #getTagValue */ public Rational getTagRationalValue( int tagId, int ifdId ) { Rational[] l = getTagRationalValues( tagId, ifdId ); if( l == null || l.length == 0 ) { return null; } return new Rational( l[0] ); }
/** * Gets the value as a Rational. If there are more than 1 Rationals in this * value, gets the first one. This method should be used for tags of type * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}. * * @param defaultValue the numerator of the Rational to return if tag's * value does not exist or cannot be converted to a Rational (the * denominator will be 1). * @return the tag's value as a Rational, or the defaultValue. */ public Rational getValueAsRational( long defaultValue ) { Rational defaultVal = new Rational( defaultValue, 1 ); return getValueAsRational( defaultVal ); }
/** * Gets the value as a Rational. If there are more than 1 Rationals in this * value, gets the first one. This method should be used for tags of type * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}. * * @param defaultValue the numerator of the Rational to return if tag's * value does not exist or cannot be converted to a Rational (the * denominator will be 1). * @return the tag's value as a Rational, or the defaultValue. */ public Rational getValueAsRational( long defaultValue ) { Rational defaultVal = new Rational( defaultValue, 1 ); return getValueAsRational( defaultVal ); }
/** * Reads value of type {@link ExifTag#TYPE_UNSIGNED_RATIONAL} from the * InputStream. */ protected Rational readUnsignedRational() throws IOException { long nomi = readUnsignedLong(); long denomi = readUnsignedLong(); return new Rational( nomi, denomi ); }
/** * Reads value of type {@link ExifTag#TYPE_UNSIGNED_RATIONAL} from the * InputStream. */ protected Rational readUnsignedRational() throws IOException { long nomi = readUnsignedLong(); long denomi = readUnsignedLong(); return new Rational( nomi, denomi ); }
/** * Reads value of type {@link ExifTag#TYPE_RATIONAL} from the InputStream. */ protected Rational readRational() throws IOException { int nomi = readLong(); int denomi = readLong(); return new Rational( nomi, denomi ); }
/** * Creates and sets the GPS timestamp tag. * * @param timestamp a GPS timestamp. * @return true if success, false if could not be created or set. */ @SuppressWarnings( "unused" ) public boolean addGpsDateTimeStampTag( long timestamp ) { ExifTag t = buildTag( TAG_GPS_DATE_STAMP, mGPSDateStampFormat.format( timestamp ) ); if( t == null ) { return false; } setTag( t ); mGPSTimeStampCalendar.setTimeInMillis( timestamp ); t = buildTag( TAG_GPS_TIME_STAMP, new Rational[]{ new Rational( mGPSTimeStampCalendar.get( Calendar.HOUR_OF_DAY ), 1 ), new Rational( mGPSTimeStampCalendar.get( Calendar.MINUTE ), 1 ), new Rational( mGPSTimeStampCalendar.get( Calendar.SECOND ), 1 ) } ); if( t == null ) { return false; } setTag( t ); return true; }
/** * Reads value of type {@link ExifTag#TYPE_RATIONAL} from the InputStream. */ protected Rational readRational() throws IOException { int nomi = readLong(); int denomi = readLong(); return new Rational( nomi, denomi ); }
/** * Creates and sets the GPS timestamp tag. * * @param timestamp a GPS timestamp. * @return true if success, false if could not be created or set. */ @SuppressWarnings( "unused" ) public boolean addGpsDateTimeStampTag( long timestamp ) { ExifTag t = buildTag( TAG_GPS_DATE_STAMP, mGPSDateStampFormat.format( timestamp ) ); if( t == null ) { return false; } setTag( t ); mGPSTimeStampCalendar.setTimeInMillis( timestamp ); t = buildTag( TAG_GPS_TIME_STAMP, new Rational[]{ new Rational( mGPSTimeStampCalendar.get( Calendar.HOUR_OF_DAY ), 1 ), new Rational( mGPSTimeStampCalendar.get( Calendar.MINUTE ), 1 ), new Rational( mGPSTimeStampCalendar.get( Calendar.SECOND ), 1 ) } ); if( t == null ) { return false; } setTag( t ); return true; }