com.javadocmd.simplelatlng.util
Class LatLngConfig

java.lang.Object
  extended by com.javadocmd.simplelatlng.util.LatLngConfig

public class LatLngConfig
extends Object

Configuration parameters for latitude and longitude calculations.

Author:
Tyler Coles

Field Summary
static double DEGREE_TOLERANCE
          The tolerance (in degrees) by which two angles can differ and still be considered the same.
static double EARTH_MEAN_RADIUS_KILOMETERS
          The Earth's mean radius in kilometers.
 
Method Summary
static long doubleToLong(double value)
          Function used to convert an angle in degrees to its internal, fixed-precision long representation.
static NumberFormat getDegreeFormat()
          Retrieve a NumberFormatter to use for formatting coordinates to String.
static double getEarthRadius(LengthUnit unit)
          Retrieve the Earth's spherical approximation radius in the desired unit.
static double longToDouble(long value)
          Function used to convert an angle in degrees to its external double representation.
static void setDegreeFormat(ThreadLocal<NumberFormat> formatThreadLocal)
          Sets the NumberFormatter to use for the purposes of all future coordinate formatting in this library.
static void setEarthRadius(double radius, LengthUnit unit)
          Sets the Earth's radius for the purposes of all future calculations in this library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEGREE_TOLERANCE

public static final double DEGREE_TOLERANCE
The tolerance (in degrees) by which two angles can differ and still be considered the same. A tolerance of 1e-6 yields a precision of nearly 1 centimeter, which is far more accurate than any of the distance calculations can claim to be.

See Also:
Constant Field Values

EARTH_MEAN_RADIUS_KILOMETERS

public static final double EARTH_MEAN_RADIUS_KILOMETERS
The Earth's mean radius in kilometers. Used as the default radius for calculations.

See Also:
Constant Field Values
Method Detail

getDegreeFormat

public static NumberFormat getDegreeFormat()
Retrieve a NumberFormatter to use for formatting coordinates to String.

Returns:
the formatter.

setDegreeFormat

public static void setDegreeFormat(ThreadLocal<NumberFormat> formatThreadLocal)
Sets the NumberFormatter to use for the purposes of all future coordinate formatting in this library. You must provide an instance of ThreadLocal for this.

Parameters:
formatThreadLocal - a ThreadLocal instance which instantiates the NumberFormatter to use.

getEarthRadius

public static double getEarthRadius(LengthUnit unit)
Retrieve the Earth's spherical approximation radius in the desired unit.

Parameters:
unit - the desired unit for the result.
Returns:
the Earth's radius in the desired unit.

setEarthRadius

public static void setEarthRadius(double radius,
                                  LengthUnit unit)
Sets the Earth's radius for the purposes of all future calculations in this library. If there is a radius that is more accurate for the locations you most care about, you can configure that here.

Parameters:
radius - the Earth's spherical approximation radius.
unit - the unit the radius is given in.

doubleToLong

public static long doubleToLong(double value)
Function used to convert an angle in degrees to its internal, fixed-precision long representation. Intended for library use only.

Parameters:
value - the value to convert.
Returns:
the long value.

longToDouble

public static double longToDouble(long value)
Function used to convert an angle in degrees to its external double representation. Intended for library use only.

Parameters:
value - the value to convert.
Returns:
the double value.


Copyright © 2010-2013. All Rights Reserved.