org.opensha.commons.geo
Class GeoTools

java.lang.Object
  extended by org.opensha.commons.geo.GeoTools

public class GeoTools
extends Object

This class provides static references to constants and conversions useful for geographic calculations, as well as a variety of utility methods.

Version:
$Id: GeoTools.java 10690 2014-05-09 16:50:49Z pmpowers $
Author:
Peter Powers

Field Summary
static double DEPTH_MAX
          Maximum earthquake depth value (700 km) used for range checking.
static double DEPTH_MIN
          Minimum earthquake depth value (-5 km) used for range checking.
static double EARTH_RADIUS_EQUATORIAL
          The equatorial radius of the earth [6378.1370 km] (see Wikipedia) as derived from the WGS-84 ellipsoid.
static double EARTH_RADIUS_MEAN
          The Authalic mean radius (Ar) of the earth [6371.0072 km] (see Wikipedia).
static double EARTH_RADIUS_POLAR
          The polar radius of the earth [6356.7523 km] (see Wikipedia) as derived from the WGS-84 ellipsoid.
static double LAT_MAX
          Maximum latitude value (90°) used for range checking.
static double LAT_MIN
          Minimum latitude value (-90°) used for range checking.
static double LON_MAX
          Maximum longitude value (180°) used for range checking.
static double LON_MIN
          Minimum longitude value (-180°) used for range checking.
static double MINUTES_PER_DEGREE
          Convenience constant for arcminutes per degree (60).
static double PI_BY_2
          Convenience constant for PI / 2
static double SECONDS_PER_DEGREE
          Convenience constant for arcseconds per degree (3600).
static double TO_DEG
          Conversion multiplier for radians to degrees
static double TO_RAD
          Conversion multiplier for degrees to radians
static double TWOPI
          Convenience constant for 2 * PI
 
Constructor Summary
GeoTools()
           
 
Method Summary
static double degreesLatPerKm(Location p)
          Returns the number of degrees of latitude per km at a given Location.
static double degreesLonPerKm(Location p)
          Returns the number of degrees of longitude per km at a given Location.
static double minutesToDeg(double minutes)
          Converts arcminutes to decimal degrees.
static double radiusAtLocation(Location p)
          Returns the radius of the earth at the latitude of the supplied Location (see Wikipedia for source).
static double secondsToDeg(double seconds)
          Converts arcseconds to decimal degrees.
static double toDecimalDegrees(double degrees, double minutes)
          Converts 'degree : decimal minutes' to decimal degrees.
static void validateDepth(double depth)
          Verifies that a depth value falls within range of DEPTH_MIN and DEPTH_MAX (inclusive).
static void validateDepths(double[] depths)
          Verifies that a set of depth values fall within range of DEPTH_MIN and DEPTH_MAX (inclusive).
static void validateLat(double lat)
          Verifies that a latitude value falls within range of LAT_MIN and LAT_MAX (inclusive).
static void validateLats(double[] lats)
          Verifies that an array of latitude values fall within range of LAT_MIN and LAT_MAX (inclusive).
static void validateLon(double lon)
          Verifies that a longitude value falls within range of LON_MIN and LON_MAX (inclusive).
static void validateLons(double[] lons)
          Verifies that a set of longitude values fall within range of LON_MIN and LON_MAX (inclusive).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EARTH_RADIUS_MEAN

public static final double EARTH_RADIUS_MEAN
The Authalic mean radius (Ar) of the earth [6371.0072 km] (see Wikipedia).

See Also:
Constant Field Values

EARTH_RADIUS_EQUATORIAL

public static final double EARTH_RADIUS_EQUATORIAL
The equatorial radius of the earth [6378.1370 km] (see Wikipedia) as derived from the WGS-84 ellipsoid.

See Also:
Constant Field Values

EARTH_RADIUS_POLAR

public static final double EARTH_RADIUS_POLAR
The polar radius of the earth [6356.7523 km] (see Wikipedia) as derived from the WGS-84 ellipsoid.

See Also:
Constant Field Values

LAT_MIN

public static final double LAT_MIN
Minimum latitude value (-90°) used for range checking.

See Also:
Constant Field Values

LAT_MAX

public static final double LAT_MAX
Maximum latitude value (90°) used for range checking.

See Also:
Constant Field Values

LON_MIN

public static final double LON_MIN
Minimum longitude value (-180°) used for range checking.

See Also:
Constant Field Values

LON_MAX

public static final double LON_MAX
Maximum longitude value (180°) used for range checking.

See Also:
Constant Field Values

DEPTH_MIN

public static final double DEPTH_MIN
Minimum earthquake depth value (-5 km) used for range checking. This follows the positive-down depth convention of seismology.

See Also:
Constant Field Values

DEPTH_MAX

public static final double DEPTH_MAX
Maximum earthquake depth value (700 km) used for range checking. This follows the positive-down depth convention of seismology.

See Also:
Constant Field Values

TO_RAD

public static final double TO_RAD
Conversion multiplier for degrees to radians


TO_DEG

public static final double TO_DEG
Conversion multiplier for radians to degrees


TWOPI

public static final double TWOPI
Convenience constant for 2 * PI

See Also:
Constant Field Values

PI_BY_2

public static final double PI_BY_2
Convenience constant for PI / 2

See Also:
Constant Field Values

SECONDS_PER_DEGREE

public static final double SECONDS_PER_DEGREE
Convenience constant for arcseconds per degree (3600).

See Also:
Constant Field Values

MINUTES_PER_DEGREE

public static final double MINUTES_PER_DEGREE
Convenience constant for arcminutes per degree (60).

See Also:
Constant Field Values
Constructor Detail

GeoTools

public GeoTools()
Method Detail

validateLats

public static final void validateLats(double[] lats)
Verifies that an array of latitude values fall within range of LAT_MIN and LAT_MAX (inclusive).

Parameters:
lats - latitudes to validate
Throws:
NullPointerException - if lats is null
IllegalArgumentException - if any lats value is out of range
See Also:
DataUtils.validate(double, double, double...)

validateLat

public static final void validateLat(double lat)
Verifies that a latitude value falls within range of LAT_MIN and LAT_MAX (inclusive).

Parameters:
lat - latitude to validate
Throws:
IllegalArgumentException - if lat value is out of range
See Also:
DataUtils.validate(double, double, double)

validateLons

public static void validateLons(double[] lons)
Verifies that a set of longitude values fall within range of LON_MIN and LON_MAX (inclusive).

Parameters:
lons - longitudes to validate
Throws:
IllegalArgumentException - if any lons value is out of range
See Also:
DataUtils.validate(double, double, double...)

validateLon

public static void validateLon(double lon)
Verifies that a longitude value falls within range of LON_MIN and LON_MAX (inclusive).

Parameters:
lon - longitude to validate
Throws:
IllegalArgumentException - if lon value is out of range
See Also:
DataUtils.validate(double, double, double)

validateDepths

public static void validateDepths(double[] depths)
Verifies that a set of depth values fall within range of DEPTH_MIN and DEPTH_MAX (inclusive).

Parameters:
depths - depths to validate
Throws:
IllegalArgumentException - if any depths value is out of range
See Also:
DataUtils.validate(double, double, double...)

validateDepth

public static void validateDepth(double depth)
Verifies that a depth value falls within range of DEPTH_MIN and DEPTH_MAX (inclusive).

Parameters:
depth - depth to validate
Throws:
IllegalArgumentException - if a depth value is out of range
See Also:
DataUtils.validate(double, double, double)

radiusAtLocation

public static double radiusAtLocation(Location p)
Returns the radius of the earth at the latitude of the supplied Location (see Wikipedia for source).

Parameters:
p - the Location at which to compute the earth's radius
Returns:
the earth's radius at the supplied Location

degreesLatPerKm

public static double degreesLatPerKm(Location p)
Returns the number of degrees of latitude per km at a given Location. This can be used to convert between km-based and degree-based grid spacing. The calculation takes into account the shape of the earth (oblate spheroid) and scales the conversion accordingly.

Parameters:
p - the Location at which to conversion value
Returns:
the number of decimal degrees latitude per km at a given Location
See Also:
radiusAtLocation(Location)

degreesLonPerKm

public static double degreesLonPerKm(Location p)
Returns the number of degrees of longitude per km at a given Location. This can be used to convert between km-based and degree-based grid spacing. The calculation scales the degrees longitude per km at the equator by the cosine of the supplied latitude. (Note: The values returned are not based on the radius of curvature of the earth at the supplied location.)

Parameters:
p - the Location at which to conversion value
Returns:
the number of decimal degrees longitude per km at a given Location

secondsToDeg

public static double secondsToDeg(double seconds)
Converts arcseconds to decimal degrees.

Parameters:
seconds - value to convert
Returns:
the equivalent number of decimal degrees

minutesToDeg

public static double minutesToDeg(double minutes)
Converts arcminutes to decimal degrees.

Parameters:
minutes - value to convert
Returns:
the equivalent number of decimal degrees

toDecimalDegrees

public static double toDecimalDegrees(double degrees,
                                      double minutes)
Converts 'degree : decimal minutes' to decimal degrees.

Parameters:
degrees - part to convert
minutes - part to convert (decimal minutes)
Returns:
converted value