public class IlvGeodeticComputation extends Object
IlvGeodeticComputation
class is useful for calculating distances,
azimuths, and point coordinates. Calculations of this kind are needed to
compute the shortest distance between two objects positioned on the globe, to
draw the shortest trajectory of a plane, to obtain the current distance of a
plane to its destination, etc. Computations of class IlvGeodeticComputation
are very useful when JViews Map objects have to be placed or moved with
precision over a given geographic map to simulate real-world scenarios.
// Create an instance of class IlvGeodeticComputation.
IlvGeodeticComputation c = new IlvGeodeticComputation();
// Specify the ellipsoid by which the spherical model of the earth should be corrected.
c.setEllipsoid(IlvEllipsoid.WGS84);
// Specify the two points of interest.
c.setPoint1(Math.toRadians(2.44638), Math.toRadians(48.88755));//Paris
c.setPoint2(Math.toRadians(-74.10708), Math.toRadians(40.75471));//New York
// Start the computation.
c.computeGeodeticInverse();
// Obtain the results.
System.out.println("Paris to New York: " + c.getDistance()/1000.0 + " Km using WGS 84");
System.out.println("Forward Azimuth: " + Math.toDegrees(c.getForwardAzimuth()));
System.out.println("Backward Azimuth: " + Math.toDegrees(c.getBackwardAzimuth()));
Paris to New York: 5862.1871801901925 Km using WGS 84
Forward Azimuth: -68.04306044159112
Backward Azimuth: 53.65332529862143
Constructor and Description |
---|
IlvGeodeticComputation()
The constructor of a
IlvGeodeticComputation instance. |
IlvGeodeticComputation(IlvEllipsoid el)
The constructor of an
IlvGeodeticComputation instance with the ellipsoid el . |
Modifier and Type | Method and Description |
---|---|
void |
computeGeodeticForward()
Computes the longitude and latitude of a point relative to a given point
according to the forward azimuth and the distance between these two points.
|
void |
computeGeodeticInverse()
Computes the geodetic azimuth and distance between two points.
|
double |
getBackwardAzimuth()
Gets the backward azimuth between the first and second reference points.
|
double |
getDistance()
Gets the distance (in meters) between the first and second reference points.
|
double |
getForwardAzimuth()
Gets the forward azimuth between the first and second reference points.
|
double |
getLatitude1()
Gets the latitude of the first reference point.
|
double |
getLatitude2()
Gets the latitude of the second reference point.
|
double |
getLongitude1()
Gets the longitude of the first reference point.
|
double |
getLongitude2()
Gets the longitude of the second reference point.
|
void |
setDistance(double distance)
Sets the distance (in meters) between the first and second reference points.
|
void |
setEllipsoid(double semiMajorAxisLength,
double invFlat)
Specifies the ellipsoid.
|
void |
setEllipsoid(IlvEllipsoid el)
Sets the ellipsoid.
|
void |
setForwardAzimuth(double fAzimuth)
Sets the forward azimuth.
|
void |
setLatitude1(double lat)
Sets the latitude of the first reference point.
|
void |
setLatitude2(double lat)
Sets the latitude of the second reference point.
|
void |
setLongitude1(double lon)
Sets the longitude of the first reference point.
|
void |
setLongitude2(double lon)
Sets the longitude of the second reference point.
|
void |
setPoint1(double lon,
double lat)
Sets the first reference point.
|
void |
setPoint2(double lon,
double lat)
Sets the second reference point.
|
public IlvGeodeticComputation()
IlvGeodeticComputation
instance. The default ellipsoid
is spherical with a radius of 6,366,707m.public IlvGeodeticComputation(IlvEllipsoid el)
IlvGeodeticComputation
instance with the ellipsoid el
.el
- The ellipsoid used for the computations.public void setEllipsoid(double semiMajorAxisLength, double invFlat)
semiMajorAxisLength
- The length of the semi-major axis in meters.invFlat
- The inverse flattening of the ellipsoid.public void setEllipsoid(IlvEllipsoid el)
el
- The ellipsoid used for the computations.public void setPoint1(double lon, double lat)
lon
- The longitude of the reference point in radians.lat
- The latitude of the reference point in radians.public void setPoint2(double lon, double lat)
lon
- The longitude of the reference point in radians.lat
- The latitude of the reference point in radians.public void setLongitude1(double lon)
lon
- The longitude of the reference point in radians.public void setLongitude2(double lon)
lon
- The longitude of the reference point in radians.public void setLatitude1(double lat)
lat
- The latitude of the reference point in radians.public void setLatitude2(double lat)
lat
- The latitude of the reference point in radians.public double getLongitude1()
public double getLongitude2()
public double getLatitude1()
public double getLatitude2()
public double getDistance()
public void setDistance(double distance)
distance
- The desired distance in meters.public double getForwardAzimuth()
public void setForwardAzimuth(double fAzimuth)
fAzimuth
- The desired forward azimuth.public double getBackwardAzimuth()
public void computeGeodeticInverse()
setPoint1
and setPoint2
methods.public void computeGeodeticForward()
setForwardAzimuth
, setDistance
, and
setPoint1
must have been called before.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.