Codota Logo
Rational.toDouble
Code IndexAdd Codota to your IDE (free)

How to use
toDouble
method
in
it.sephiroth.android.library.exif2.Rational

Best Java code snippets using it.sephiroth.android.library.exif2.Rational.toDouble (Showing top 13 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: sephiroth74/Android-Exif-Extended

/**
 * Gets the double representation of the GPS latitude or longitude
 * coordinate.
 *
 * @param coordinate an array of 3 Rationals representing the degrees,
 *                   minutes, and seconds of the GPS location as defined in the
 *                   exif specification.
 * @param reference  a GPS reference reperesented by a String containing "N",
 *                   "S", "E", or "W".
 * @return the GPS coordinate represented as degrees + minutes/60 +
 * seconds/3600
 */
public static double convertLatOrLongToDouble( Rational[] coordinate, String reference ) {
  try {
    double degrees = coordinate[0].toDouble();
    double minutes = coordinate[1].toDouble();
    double seconds = coordinate[2].toDouble();
    double result = degrees + minutes / 60.0 + seconds / 3600.0;
    if( ( reference.startsWith( "S" ) || reference.startsWith( "W" ) ) ) {
      return - result;
    }
    return result;
  } catch( ArrayIndexOutOfBoundsException e ) {
    throw new IllegalArgumentException();
  }
}
origin: sephiroth74/Android-Exif-Extended

/**
 * Return the aperture size, if present, 0 if missing
 */
public double getApertureSize() {
  Rational rational = getTagRationalValue( TAG_F_NUMBER );
  if( null != rational && rational.toDouble() > 0 ) {
    return rational.toDouble();
  }
  rational = getTagRationalValue( TAG_APERTURE_VALUE );
  if( null != rational && rational.toDouble() > 0 ) {
    return Math.exp( rational.toDouble() * Math.log( 2 ) * 0.5 );
  }
  return 0;
}
origin: tateisu/SubwayTooter

/**
 * Return the aperture size, if present, 0 if missing
 */
public double getApertureSize() {
  Rational rational = getTagRationalValue( TAG_F_NUMBER );
  if( null != rational && rational.toDouble() > 0 ) {
    return rational.toDouble();
  }
  rational = getTagRationalValue( TAG_APERTURE_VALUE );
  if( null != rational && rational.toDouble() > 0 ) {
    return Math.exp( rational.toDouble() * Math.log( 2 ) * 0.5 );
  }
  return 0;
}
origin: sephiroth74/Android-Exif-Extended

private static String convertRationalLatLonToString( Rational[] coord, String ref ) {
  try {
    double degrees = coord[0].toDouble();
    double minutes = coord[1].toDouble();
    double seconds = coord[2].toDouble();
    ref = ref.substring( 0, 1 );
    return String.format( "%1$.0f° %2$.0f' %3$.0f\" %4$s", degrees, minutes, seconds, ref.toUpperCase( Locale.getDefault() ) );
  } catch( NumberFormatException e ) {
    e.printStackTrace();
  } catch( ArrayIndexOutOfBoundsException e ) {
    e.printStackTrace();
  }
  return null;
}
origin: tateisu/SubwayTooter

private static String convertRationalLatLonToString( Rational[] coord, String ref ) {
  try {
    double degrees = coord[0].toDouble();
    double minutes = coord[1].toDouble();
    double seconds = coord[2].toDouble();
    ref = ref.substring( 0, 1 );
    return String.format( "%1$.0f° %2$.0f' %3$.0f\" %4$s", degrees, minutes, seconds, ref.toUpperCase( Locale.getDefault() ) );
  } catch( NumberFormatException e ) {
    e.printStackTrace();
  } catch( ArrayIndexOutOfBoundsException e ) {
    e.printStackTrace();
  }
  return null;
}
origin: sephiroth74/Android-Exif-Extended

public static String processLensSpecifications( Rational[] values ) {
  Rational min_focal = values[0];
  Rational max_focal = values[1];
  Rational min_f = values[2];
  Rational max_f = values[3];
  formatter.setMaximumFractionDigits(1);
  StringBuilder sb = new StringBuilder();
  sb.append( formatter.format( min_focal.toDouble() ) );
  sb.append( "-" );
  sb.append( formatter.format( max_focal.toDouble() ) );
  sb.append( "mm f/" );
  sb.append( formatter.format( min_f.toDouble() ) );
  sb.append( "-" );
  sb.append( formatter.format( max_f.toDouble() ) );
  return sb.toString();
}
origin: tateisu/SubwayTooter

/**
 * Gets the double representation of the GPS latitude or longitude
 * coordinate.
 *
 * @param coordinate an array of 3 Rationals representing the degrees,
 *                   minutes, and seconds of the GPS location as defined in the
 *                   exif specification.
 * @param reference  a GPS reference reperesented by a String containing "N",
 *                   "S", "E", or "W".
 * @return the GPS coordinate represented as degrees + minutes/60 +
 * seconds/3600
 */
public static double convertLatOrLongToDouble( Rational[] coordinate, String reference ) {
  try {
    double degrees = coordinate[0].toDouble();
    double minutes = coordinate[1].toDouble();
    double seconds = coordinate[2].toDouble();
    double result = degrees + minutes / 60.0 + seconds / 3600.0;
    if( ( reference.startsWith( "S" ) || reference.startsWith( "W" ) ) ) {
      return - result;
    }
    return result;
  } catch( ArrayIndexOutOfBoundsException e ) {
    throw new IllegalArgumentException();
  }
}
origin: tateisu/SubwayTooter

public static String processLensSpecifications( Rational[] values ) {
  Rational min_focal = values[0];
  Rational max_focal = values[1];
  Rational min_f = values[2];
  Rational max_f = values[3];
  formatter.setMaximumFractionDigits(1);
  StringBuilder sb = new StringBuilder();
  sb.append( formatter.format( min_focal.toDouble() ) );
  sb.append( "-" );
  sb.append( formatter.format( max_focal.toDouble() ) );
  sb.append( "mm f/" );
  sb.append( formatter.format( min_f.toDouble() ) );
  sb.append( "-" );
  sb.append( formatter.format( max_f.toDouble() ) );
  return sb.toString();
}
origin: tateisu/SubwayTooter

/**
 * Return the altitude in meters. If the exif tag does not exist, return
 * <var>defaultValue</var>.
 *
 * @param defaultValue the value to return if the tag is not available.
 */
@SuppressWarnings( "unused" )
public double getAltitude( double defaultValue ) {
  Byte ref = getTagByteValue( TAG_GPS_ALTITUDE_REF );
  Rational gpsAltitude = getTagRationalValue( TAG_GPS_ALTITUDE );
  int seaLevel = 1;
  if( null != ref ) {
    seaLevel = ref.intValue() == 1 ? - 1 : 1;
  }
  if( gpsAltitude != null ) {
    return gpsAltitude.toDouble() * seaLevel;
  }
  return defaultValue;
}
origin: sephiroth74/Android-Exif-Extended

/**
 * Return the altitude in meters. If the exif tag does not exist, return
 * <var>defaultValue</var>.
 *
 * @param defaultValue the value to return if the tag is not available.
 */
@SuppressWarnings( "unused" )
public double getAltitude( double defaultValue ) {
  Byte ref = getTagByteValue( TAG_GPS_ALTITUDE_REF );
  Rational gpsAltitude = getTagRationalValue( TAG_GPS_ALTITUDE );
  int seaLevel = 1;
  if( null != ref ) {
    seaLevel = ref.intValue() == 1 ? - 1 : 1;
  }
  if( gpsAltitude != null ) {
    return gpsAltitude.toDouble() * seaLevel;
  }
  return defaultValue;
}
origin: sephiroth74/Android-Exif-Extended

/**
 * Gets a long representation of the value.
 *
 * @param defaultValue value to return if there is no value or value is a
 *                     rational with a denominator of 0.
 * @return the tag's value as a long, or defaultValue if no representation
 * exists.
 */
public long forceGetValueAsLong( long defaultValue ) {
  long[] l = getValueAsLongs();
  if( l != null && l.length >= 1 ) {
    return l[0];
  }
  byte[] b = getValueAsBytes();
  if( b != null && b.length >= 1 ) {
    return b[0];
  }
  Rational[] r = getValueAsRationals();
  if( r != null && r.length >= 1 && r[0].getDenominator() != 0 ) {
    return (long) r[0].toDouble();
  }
  return defaultValue;
}
origin: tateisu/SubwayTooter

/**
 * Gets a long representation of the value.
 *
 * @param defaultValue value to return if there is no value or value is a
 *                     rational with a denominator of 0.
 * @return the tag's value as a long, or defaultValue if no representation
 * exists.
 */
public long forceGetValueAsLong( long defaultValue ) {
  long[] l = getValueAsLongs();
  if( l != null && l.length >= 1 ) {
    return l[0];
  }
  byte[] b = getValueAsBytes();
  if( b != null && b.length >= 1 ) {
    return b[0];
  }
  Rational[] r = getValueAsRationals();
  if( r != null && r.length >= 1 && r[0].getDenominator() != 0 ) {
    return (long) r[0].toDouble();
  }
  return defaultValue;
}
origin: sephiroth74/Android-Exif-Extended

double speed = shutterSpeed.getValueAsRational( 0 ).toDouble();
Log.d( LOG_TAG, "speed: " + speed );
it.sephiroth.android.library.exif2RationaltoDouble

Javadoc

Gets the rational value as type double. Will cause a divide-by-zero error if the denominator is 0.

Popular methods of Rational

  • <init>
    Create a copy of a Rational.
  • getDenominator
    Gets the denominator of the rational
  • getNumerator
    Gets the numerator of the rational.

Popular in Java

  • Start an intent from android
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • JLabel (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now