ucar.unidata.geoloc
Class Bearing

java.lang.Object
  extended by ucar.unidata.geoloc.Bearing

public class Bearing
extends Object

Computes the distance, azimuth, and back azimuth between two lat-lon positions on the Earth's surface. Reference ellipsoid is the WGS-84. You may use a default Earth (equator radius = 6378137.0 meters, flattening = 1.0 / 298.257223563) or you may define your own using a ucar.unidata.geoloc.Earth object.

Author:
Unidata Development Team

Constructor Summary
Bearing()
           
 
Method Summary
static Bearing calculateBearing(double lat1, double lon1, double lat2, double lon2, Bearing result)
          Computes distance (in km), azimuth (degrees clockwise positive from North, 0 to 360), and back azimuth (degrees clockwise positive from North, 0 to 360), from latitude-longituide point pt1 to latitude-longituide pt2.
static Bearing calculateBearing(Earth e, double lat1, double lon1, double lat2, double lon2, Bearing result)
          Computes distance (in km), azimuth (degrees clockwise positive from North, 0 to 360), and back azimuth (degrees clockwise positive from North, 0 to 360), from latitude-longituide point pt1 to latitude-longituide pt2.
static Bearing calculateBearing(Earth e, LatLonPoint pt1, LatLonPoint pt2, Bearing result)
          Calculate the bearing between the 2 points.
static Bearing calculateBearing(LatLonPoint pt1, LatLonPoint pt2, Bearing result)
          Calculate the bearing between the 2 points.
static LatLonPointImpl findPoint(double lat1, double lon1, double az, double dist, LatLonPointImpl result)
          Calculate a position given an azimuth and distance from another point.
static LatLonPointImpl findPoint(Earth e, double lat1, double lon1, double az, double dist, LatLonPointImpl result)
          Calculate a position given an azimuth and distance from another point.
static LatLonPointImpl findPoint(Earth e, LatLonPoint pt1, double az, double dist, LatLonPointImpl result)
          Calculate a position given an azimuth and distance from another point.
static LatLonPointImpl findPoint(LatLonPoint pt1, double az, double dist, LatLonPointImpl result)
          Calculate a position given an azimuth and distance from another point.
 double getAngle()
          Get the azimuth in degrees, 0 = north, clockwise positive
 double getBackAzimuth()
          Get the back azimuth in degrees, 0 = north, clockwise positive
 double getDistance()
          Get the distance in kilometers
static void main(String[] args)
          Test the calculations - forward and back
 String toString()
          Nice format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bearing

public Bearing()
Method Detail

calculateBearing

public static Bearing calculateBearing(Earth e,
                                       LatLonPoint pt1,
                                       LatLonPoint pt2,
                                       Bearing result)
Calculate the bearing between the 2 points. See calculateBearing below.

Parameters:
e - Earth object (defines radius & flattening)
pt1 - Point 1
pt2 - Point 2
result - Object to use if non-null
Returns:
The bearing

calculateBearing

public static Bearing calculateBearing(LatLonPoint pt1,
                                       LatLonPoint pt2,
                                       Bearing result)
Calculate the bearing between the 2 points. See calculateBearing below. Uses default Earth object.

Parameters:
pt1 - Point 1
pt2 - Point 2
result - Object to use if non-null
Returns:
The bearing

calculateBearing

public static Bearing calculateBearing(double lat1,
                                       double lon1,
                                       double lat2,
                                       double lon2,
                                       Bearing result)
Computes distance (in km), azimuth (degrees clockwise positive from North, 0 to 360), and back azimuth (degrees clockwise positive from North, 0 to 360), from latitude-longituide point pt1 to latitude-longituide pt2. Uses default Earth object.

Parameters:
lat1 - Lat of point 1
lon1 - Lon of point 1
lat2 - Lat of point 2
lon2 - Lon of point 2
result - put result here, or null to allocate
Returns:
a Bearing object with distance (in km), azimuth from pt1 to pt2 (degrees, 0 = north, clockwise positive)

calculateBearing

public static Bearing calculateBearing(Earth e,
                                       double lat1,
                                       double lon1,
                                       double lat2,
                                       double lon2,
                                       Bearing result)
Computes distance (in km), azimuth (degrees clockwise positive from North, 0 to 360), and back azimuth (degrees clockwise positive from North, 0 to 360), from latitude-longituide point pt1 to latitude-longituide pt2.

Algorithm from U.S. National Geodetic Survey, FORTRAN program "inverse," subroutine "INVER1," by L. PFEIFER and JOHN G. GERGEN. See http://www.ngs.noaa.gov/TOOLS/Inv_Fwd/Inv_Fwd.html

Original documentation:
SOLUTION OF THE GEODETIC INVERSE PROBLEM AFTER T.VINCENTY
MODIFIED RAINSFORD'S METHOD WITH HELMERT'S ELLIPTICAL TERMS
EFFECTIVE IN ANY AZIMUTH AND AT ANY DISTANCE SHORT OF ANTIPODAL
STANDPOINT/FOREPOINT MUST NOT BE THE GEOGRAPHIC POLE

Reference ellipsoid is the WGS-84 ellipsoid.
See http://www.colorado.edu/geography/gcraft/notes/datum/elist.html

Requires close to 1.4 E-5 seconds wall clock time per call on a 550 MHz Pentium with Linux 7.2.

Parameters:
e - Earth object (defines radius and flattening)
lat1 - Lat of point 1
lon1 - Lon of point 1
lat2 - Lat of point 2
lon2 - Lon of point 2
result - put result here, or null to allocate
Returns:
a Bearing object with distance (in km), azimuth from pt1 to pt2 (degrees, 0 = north, clockwise positive)

getAngle

public double getAngle()
Get the azimuth in degrees, 0 = north, clockwise positive

Returns:
azimuth in degrees

getBackAzimuth

public double getBackAzimuth()
Get the back azimuth in degrees, 0 = north, clockwise positive

Returns:
back azimuth in degrees

getDistance

public double getDistance()
Get the distance in kilometers

Returns:
distance in km

toString

public String toString()
Nice format.

Overrides:
toString in class Object
Returns:
return a nice format of this Bearing

main

public static void main(String[] args)
Test the calculations - forward and back

Parameters:
args - non used

findPoint

public static LatLonPointImpl findPoint(Earth e,
                                        LatLonPoint pt1,
                                        double az,
                                        double dist,
                                        LatLonPointImpl result)
Calculate a position given an azimuth and distance from another point.

Parameters:
e - Earth object (defines radius and flattening)
pt1 - Point 1
az - azimuth (degrees)
dist - distance from the point (km)
result - Object to use if non-null
Returns:
The LatLonPoint
See Also:
findPoint(double,double,double,double,LatLonPointImpl)

findPoint

public static LatLonPointImpl findPoint(LatLonPoint pt1,
                                        double az,
                                        double dist,
                                        LatLonPointImpl result)
Calculate a position given an azimuth and distance from another point. Uses default Earth.

Parameters:
pt1 - Point 1
az - azimuth (degrees)
dist - distance from the point (km)
result - Object to use if non-null
Returns:
The LatLonPoint
See Also:
findPoint(double,double,double,double,LatLonPointImpl)

findPoint

public static LatLonPointImpl findPoint(double lat1,
                                        double lon1,
                                        double az,
                                        double dist,
                                        LatLonPointImpl result)
Calculate a position given an azimuth and distance from another point. See details, below. Uses default Earth.

Parameters:
lat1 - latitude of starting point
lon1 - longitude of starting point
az - forward azimuth (degrees)
dist - distance from the point (km)
result - Object to use if non-null
Returns:
the position as a LatLonPointImpl

findPoint

public static LatLonPointImpl findPoint(Earth e,
                                        double lat1,
                                        double lon1,
                                        double az,
                                        double dist,
                                        LatLonPointImpl result)
Calculate a position given an azimuth and distance from another point.

Algorithm from National Geodetic Survey, FORTRAN program "forward," subroutine "DIRCT1," by stephen j. frakes. http://www.ngs.noaa.gov/TOOLS/Inv_Fwd/Inv_Fwd.html

Original documentation:

    SOLUTION OF THE GEODETIC DIRECT PROBLEM AFTER T.VINCENTY
    MODIFIED RAINSFORD'S METHOD WITH HELMERT'S ELLIPTICAL TERMS
    EFFECTIVE IN ANY AZIMUTH AND AT ANY DISTANCE SHORT OF ANTIPODAL
  

Parameters:
e - Earth object (defines radius and flattening)
lat1 - latitude of starting point
lon1 - longitude of starting point
az - forward azimuth (degrees)
dist - distance from the point (km)
result - Object to use if non-null
Returns:
the position as a LatLonPointImpl


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.