@Test public void getDegreesMinutesSeconds_NegativeIsSouth(){ double lat = -16.44299d; String expected = "16° 26' 34.764\" S"; String actual = Strings.getDegreesMinutesSeconds(lat, true); assertThat("Negative degree decimals converted to southerly degree minute second", actual, is(expected)); }
public static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude) { String cardinality = (decimaldegrees<0) ? "S":"N"; if(!isLatitude){ cardinality = (decimaldegrees<0) ? "W":"E"; } decimaldegrees = Math.abs(decimaldegrees); int deg = (int) Math.floor(decimaldegrees); double minfloat = (decimaldegrees-deg)*60; int min = (int) Math.floor(minfloat); double secfloat = (minfloat-min)*60; double sec = Math.round(secfloat * 10000.0)/10000.0; if (sec==60) { min++; sec=0; } if (min==60) { deg++; min=0; } return ("" + deg + "° " + min + "' " + sec + "\" " + cardinality); }
Strings { public static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude) { String cardinality = (decimaldegrees<0) ? "S":"N"; if(!isLatitude){ cardinality = (decimaldegrees<0) ? "W":"E"; } decimaldegrees = Math.abs(decimaldegrees); int deg = (int) Math.floor(decimaldegrees); double minfloat = (decimaldegrees-deg)*60; int min = (int) Math.floor(minfloat); double secfloat = (minfloat-min)*60; double sec = Math.round(secfloat * 10000.0)/10000.0; if (sec==60) { min++; sec=0; } if (min==60) { deg++; min=0; } return ("" + deg + "° " + min + "' " + sec + "\" " + cardinality); } }
Strings { public static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude) { String cardinality = (decimaldegrees<0) ? "S":"N"; if(!isLatitude){ cardinality = (decimaldegrees<0) ? "W":"E"; } decimaldegrees = Math.abs(decimaldegrees); int deg = (int) Math.floor(decimaldegrees); double minfloat = (decimaldegrees-deg)*60; int min = (int) Math.floor(minfloat); double secfloat = (minfloat-min)*60; double sec = Math.round(secfloat * 10000.0)/10000.0; if (sec==60) { min++; sec=0; } if (min==60) { deg++; min=0; } return ("" + deg + "° " + min + "' " + sec + "\" " + cardinality); }  }
Strings { public static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude) { String cardinality = (decimaldegrees<0) ? "S":"N"; if(!isLatitude){ cardinality = (decimaldegrees<0) ? "W":"E"; } decimaldegrees = Math.abs(decimaldegrees); int deg = (int) Math.floor(decimaldegrees); double minfloat = (decimaldegrees-deg)*60; int min = (int) Math.floor(minfloat); double secfloat = (minfloat-min)*60; double sec = Math.round(secfloat * 10000.0)/10000.0; if (sec==60) { min++; sec=0; } if (min==60) { deg++; min=0; } return ("" + deg + "° " + min + "' " + sec + "\" " + cardinality); }  static String getDescriptiveDurationString(int numberOfSeconds,
                                                      Context context); static String getBearingDescription(float bearingDegrees,
                                               Context context); static String cleanDescriptionForXml(String desc); static String cleanDescriptionForJson(String desc); static String getIsoDateTime(Date dateToFormat); static String getIsoDateTimeFormat(); static String getIsoCalendarDate(Date dateToFormat); static String getIsoCalendarDateFormat(); static String getReadableDateTime(Date dateToFormat); static boolean isNullOrEmpty(String text); static String htmlDecode(String text); static String getBuildSerial(); static String getFormattedFileName(); static String getFormattedFileName(Session session, PreferenceHelper ph); static String getFormattedCustomFileName(String baseName, Calendar calendar, PreferenceHelper ph); static int toInt(String number, int defaultVal); static String getSpeedDisplay(Context context, double metersPerSecond, boolean imperial); static String getDistanceDisplay(Context context, double meters, boolean imperial, boolean autoscale); static String getTimeDisplay(Context context, long milliseconds); static Map<String, String> getAvailableLocales(Context context); static String getSanitizedMarkdownForFaqView(String md); static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude); static String getDegreesDecimalMinutes(double decimaldegrees, boolean isLatitude); static String getDecimalDegrees(double decimaldegrees); static String getFormattedLatitude(double decimaldegrees); static String getFormattedLongitude(double decimaldegrees); static String getDetectedActivityName(DetectedActivity detectedActivity); }
Strings { public static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude) { String cardinality = (decimaldegrees<0) ? "S":"N"; if(!isLatitude){ cardinality = (decimaldegrees<0) ? "W":"E"; } decimaldegrees = Math.abs(decimaldegrees); int deg = (int) Math.floor(decimaldegrees); double minfloat = (decimaldegrees-deg)*60; int min = (int) Math.floor(minfloat); double secfloat = (minfloat-min)*60; double sec = Math.round(secfloat * 10000.0)/10000.0; if (sec==60) { min++; sec=0; } if (min==60) { deg++; min=0; } return ("" + deg + "° " + min + "' " + sec + "\" " + cardinality); }  static String getDescriptiveDurationString(int numberOfSeconds,
                                                      Context context); static String getBearingDescription(float bearingDegrees,
                                               Context context); static String cleanDescriptionForXml(String desc); static String cleanDescriptionForJson(String desc); static String getIsoDateTime(Date dateToFormat); static String getIsoDateTimeFormat(); static String getIsoCalendarDate(Date dateToFormat); static String getIsoCalendarDateFormat(); static String getReadableDateTime(Date dateToFormat); static boolean isNullOrEmpty(String text); static String htmlDecode(String text); static String getBuildSerial(); static String getFormattedFileName(); static String getFormattedFileName(Session session, PreferenceHelper ph); static String getFormattedCustomFileName(String baseName, Calendar calendar, PreferenceHelper ph); static int toInt(String number, int defaultVal); static String getSpeedDisplay(Context context, double metersPerSecond, boolean imperial); static String getDistanceDisplay(Context context, double meters, boolean imperial, boolean autoscale); static String getTimeDisplay(Context context, long milliseconds); static Map<String, String> getAvailableLocales(Context context); static String getSanitizedMarkdownForFaqView(String md); static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude); static String getDegreesDecimalMinutes(double decimaldegrees, boolean isLatitude); static String getDecimalDegrees(double decimaldegrees); static String getFormattedLatitude(double decimaldegrees); static String getFormattedLongitude(double decimaldegrees); static String getDetectedActivityName(DetectedActivity detectedActivity);  }