org.cts.util
Class AngleFormat

java.lang.Object
  extended by org.cts.util.AngleFormat

public final class AngleFormat
extends Object

Formatter to print angles as a degrees/minutes/seconds (DMS) and to parse DMS strings

The format method uses pattern such as #D� MM' SS\" H(N|S) to define the string representation of an angle.

Author:
Michaël Michaud


Field Summary
static AngleFormat LATITUDE_FORMATTER
           
static AngleFormat LONGITUDE_FORMATTER
           
 
Constructor Summary
AngleFormat()
           
AngleFormat(String pattern)
          Create a new angle formatter able to write an angle as a DMS string following a specific pattern.
 
Method Summary
static double dd2dms(double ddAngle)
           
static double deg2gra(double angle)
           
static double deg2min(double angle)
           
static double deg2rad(double angle)
           
static double deg2sec(double angle)
           
static double dms2dd(double dmsAngle)
           
 String format(double angle)
          Format an angle following the special pattern defined by this object.
static double gra2deg(double angle)
           
static double gra2rad(double angle)
           
static double parseAndConvert2Radians(String angle)
          This method parse a string which represent an angle in radians, in grades or in degrees.
static double parseAngle(String angle)
          Parse a string representing an angle written in DMSH (degrees / minutes / seconds / hemisphere).
static double rad2deg(double angle)
           
static double rad2gra(double angle)
           
static double rad2min(double angle)
           
static double rad2sec(double angle)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LONGITUDE_FORMATTER

public static final AngleFormat LONGITUDE_FORMATTER

LATITUDE_FORMATTER

public static final AngleFormat LATITUDE_FORMATTER
Constructor Detail

AngleFormat

public AngleFormat()

AngleFormat

public AngleFormat(String pattern)
            throws IllegalArgumentException
Create a new angle formatter able to write an angle as a DMS string following a specific pattern.

Parameters:
pattern - the Pattern to format angles
  • #D means degrees
  • DD means degrees (two digits mandatory)
  • #D.DD means degrees (two fractional digits)
  • idem for minutes (M) and seconds (S)
  • H(N|S) means use suffix 'N' for positive angles and 'S' for negative angles instead of +/- sign
  • no H(XXX|YYY) means that +/- sign will be used
  • a prefix may be used before the first # or D
  • any character different from DMSH may be used to separate D, M and H

Exemples :

  • latitude = #D° MM' SS.SSS\" H(N|S) --> latitude = 45° 09' 56.897" S
  • #D deg #M min --> -4 deg 6 min
Throws:
IllegalArgumentException
Method Detail

rad2deg

public static double rad2deg(double angle)

rad2gra

public static double rad2gra(double angle)

rad2min

public static double rad2min(double angle)

rad2sec

public static double rad2sec(double angle)

deg2rad

public static double deg2rad(double angle)

deg2gra

public static double deg2gra(double angle)

deg2min

public static double deg2min(double angle)

deg2sec

public static double deg2sec(double angle)

gra2rad

public static double gra2rad(double angle)

gra2deg

public static double gra2deg(double angle)

dms2dd

public static double dms2dd(double dmsAngle)

dd2dms

public static double dd2dms(double ddAngle)

format

public String format(double angle)
Format an angle following the special pattern defined by this object.

Parameters:
angle - angle to format (the angle must be in degrees).

parseAngle

public static double parseAngle(String angle)
                         throws IllegalArgumentException
Parse a string representing an angle written in DMSH (degrees / minutes / seconds / hemisphere). The parser is very flexible and can analyze strings as

Parameters:
angle - the string to parse
Returns:
the angle in degrees
Throws:
IllegalArgumentException

parseAndConvert2Radians

public static double parseAndConvert2Radians(String angle)
                                      throws IllegalArgumentException

This method parse a string which represent an angle in radians, in grades or in degrees.

The parser try to recognize a symbol to determine the units used in the string and convert the angle into radians.

Throws:
IllegalArgumentException


Copyright © 2014 IRSTV CNRS-FR-2488. All Rights Reserved.