List of usage examples for org.apache.commons.imaging.formats.tiff.constants GpsTagConstants GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH
String GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH
To view the source code for org.apache.commons.imaging.formats.tiff.constants GpsTagConstants GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH.
Click Source Link
From source file:org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils.java
/** * Calculates the decimal degree-value from a degree value given in * degrees-minutes-seconds-format/* w w w .ja v a2 s . c o m*/ * * @param degMinSec an array of length 3, the values in there are (in this order) * degrees, minutes and seconds * @param ref the latitude or longitude reference determining if the given value * is: * <ul> * <li>north ( * {@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH}) or * south ( * {@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH}) of * the equator</li> * <li>east ( * {@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST}) or * west ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST} * ) of the equator</li> * </ul> * @return the decimal degree-value for the given input, negative when west of * 0-meridian or south of equator, positive otherwise * @throws IllegalArgumentException if {@code degMinSec} doesn't have length 3 or if {@code ref} is * not one of the values mentioned above */ public static double degMinSecToDouble(RationalNumber[] degMinSec, String ref) { if (degMinSec == null || degMinSec.length != 3) { throw new IllegalArgumentException("Array's length must be 3."); } for (int i = 0; i < 3; i++) { if (degMinSec[i] == null) throw new IllegalArgumentException("Null value in array."); } switch (ref) { case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH: case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH: case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST: case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST: break; default: throw new IllegalArgumentException("Invalid ref."); } double result = degMinSec[0].doubleValue(); // degrees result += degMinSec[1].doubleValue() / 60; // minutes result += degMinSec[2].doubleValue() / 3600; // seconds if (GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH.equals(ref) || GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST.equals(ref)) { result *= -1; } result = 360 * ((result + 180) / 360 - Math.floor((result + 180) / 360)) - 180; return result; }
From source file:org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtilsTest.java
/** * Test {@link MapillaryUtils#degMinSecToDouble(RationalNumber[], String)} * method./*from w w w .j a v a 2s . c o m*/ */ @Test public void degMinSecToDoubleTest() { RationalNumber[] num = new RationalNumber[3]; num[0] = new RationalNumber(1, 1); num[1] = new RationalNumber(0, 1); num[2] = new RationalNumber(0, 1); String ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH; assertEquals(1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01); ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH; assertEquals(-1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01); num[0] = new RationalNumber(180, 1); assertEquals(-180, MapillaryUtils.degMinSecToDouble(num, ref), 0.01); num[0] = new RationalNumber(190, 1); assertEquals(170, MapillaryUtils.degMinSecToDouble(num, ref), 0.01); }