de.fhg.igd.gps
Class AngularDistance

java.lang.Object
  extended byde.fhg.igd.gps.AngularDistance
Direct Known Subclasses:
Latitude, Longitude

public abstract class AngularDistance
extends Object

This class wraps a double to represent an angular distance in degrees used for global positioning. Additionally, AngularDistance provides functions to convert values into various measures commonly used for angular distances such as degrees, minutes or seconds.

Author:
Dennis Bartussek

Field Summary
protected  double deg_
          Geo-position in decimal degrees.
static int FORMAT_DEG
          Format flag indicating that the degree value of this AngularDistance should be formated as decimal degrees.
static int FORMAT_DEG_MIN
          Format flag indicating that the degree value of this AngularDistance should be formated as degrees and minutes.
static int FORMAT_DEG_MIN_SEC
          Format flag indicating that the degree value of this AngularDistance should be formated as degrees, minutes and seconds.
static int FORMAT_SIGNED
          Format flag indicating that an algebraic sign precedes the degree value.
protected  int MAX_VALUE
          The largest positive value.
protected  char NEG_CHAR
          Suffix for negative values.
protected  char POS_CHAR
          Suffix for positive values.
 
Constructor Summary
AngularDistance(int max, char pos, char neg)
          Constructs a new AngularDistance with the maximum absolute value max and the suffix pos and neg.
 
Method Summary
 double getDegrees()
          Returns the degree value of this AngularDistance.
static double minuteToDegree(double minute)
          Converts a minute value into its degree representation.
 void normalize()
           
 void parse(String str)
          Parses the AngularDistance specified by str according to the internal presentation, which is compatible to the output of toString().
 void parseGpsField(String str)
          Parses the AngularDistance specified by str according to the internal NMEA0183-Format and sets the internal degree value to the parsed data.
 void setDegrees(double value)
          Sets the degree value of this AngularDistance to value.
 String toString()
          Returns the string representation of this AngularDistance.
 String toString(int format)
          Returns a string representation of this AngularDistance, according to the specified format argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FORMAT_SIGNED

public static final int FORMAT_SIGNED
Format flag indicating that an algebraic sign precedes the degree value. If not specified POS_CHAR or NEG_CHAR is appended to the degree value instead.

See Also:
Constant Field Values

FORMAT_DEG

public static final int FORMAT_DEG
Format flag indicating that the degree value of this AngularDistance should be formated as decimal degrees.

See Also:
Constant Field Values

FORMAT_DEG_MIN

public static final int FORMAT_DEG_MIN
Format flag indicating that the degree value of this AngularDistance should be formated as degrees and minutes.

See Also:
Constant Field Values

FORMAT_DEG_MIN_SEC

public static final int FORMAT_DEG_MIN_SEC
Format flag indicating that the degree value of this AngularDistance should be formated as degrees, minutes and seconds.

See Also:
Constant Field Values

POS_CHAR

protected char POS_CHAR
Suffix for positive values.


NEG_CHAR

protected char NEG_CHAR
Suffix for negative values.


MAX_VALUE

protected int MAX_VALUE
The largest positive value.


deg_

protected double deg_
Geo-position in decimal degrees.

Constructor Detail

AngularDistance

public AngularDistance(int max,
                       char pos,
                       char neg)
Constructs a new AngularDistance with the maximum absolute value max and the suffix pos and neg.

Parameters:
max - the absolute value of the largest positive value as well as the smallest negative value
pos - the suffix for positive values
neg - the suffix for negative values
Method Detail

parse

public void parse(String str)
           throws AngularDistanceFormatException
Parses the AngularDistance specified by str according to the internal presentation, which is compatible to the output of toString().
The accepted format is "[+|-]‹double›[°][‹character›]"

Parameters:
str - the String to parse
Returns:
the AngularDistance according to the given String
Throws:
AngularDistanceFormatException - if str does not have the appropriate format

parseGpsField

public void parseGpsField(String str)
                   throws AngularDistanceFormatException
Parses the AngularDistance specified by str according to the internal NMEA0183-Format and sets the internal degree value to the parsed data.
The accepted format is "DMM.m d", with:

Parameters:
str - the String to parse
Throws:
AngularDistanceFormatException - if str does not have the appropriate format

normalize

public void normalize()

setDegrees

public void setDegrees(double value)
Sets the degree value of this AngularDistance to value. The value argument is expected to be equal to or less than MAX_VALUE and equal to or more than -MAX_VALUE and will be normalized if not within the expected range.

Parameters:
value - the new degree value
See Also:
normalize()

getDegrees

public double getDegrees()
Returns the degree value of this AngularDistance.

Returns:
the degree value of this AngularDistance

minuteToDegree

public static double minuteToDegree(double minute)
Converts a minute value into its degree representation.

Parameters:
minute - the minute value to convert
Returns:
the convertet minute value in degrees

toString

public String toString(int format)
Returns a string representation of this AngularDistance, according to the specified format argument.

Returns:
a string representation of this AngularDistance
See Also:
FORMAT_DEG, FORMAT_DEG_MIN, FORMAT_DEG_MIN_SEC, FORMAT_SIGNED

toString

public String toString()
Returns the string representation of this AngularDistance.

Returns:
the string representation of this AngularDistance


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.