I'm currently using the GeoTools toolkit to do calculations on marine vessel data, such as calculating the Great Circle distance between two lon/lat points. I have two other requirements that I need to satisfy, but I'm not sure where to look in GeoTools to find classes to do these kind of calculations.
REQUIREMENT #1: Calculate a Dead Reckoning position for a moving vessel.
INPUT VALUES:
EXPECTED OUTPUTS:
REQUIREMENT #2: Calculate the course from position 'A' to position 'B'.
INPUT VALUES:
EXPECTED OUTPUTS:
QUESTION
Can anyone direct me to classes in GeoTools that are capable of performing these calculations? I'm overwhelmed by the sheer number of classes in GeoTools and I can't seem to find what I need to do this.
HOW TO CALCULATE COURSE FROM POSITION 'A' TO POSITION 'B'
GeodeticCalculator classsetStartingGeographicPoint()setDestinationGeographicPoint()getAzimuth()HOW TO CALCULATE DEAD RECKONING POSITION 'X' STARTING FROM POSITION 'A'
GeodeticCalculator classsetStartingGeographicPoint()setDirection()getDestinationGeographicPoint()Here are some simple units conversion methods that I needed to implement myself. The azimuth was a little confusing. The azimuth ranges from -180 to +180 with the values increasing as the direction "angle" increases in a clockwise direction. So -180 is south, -90 is west, 0 is true north, +90 is east and +180 is also south.
public static final double KNOTS_PER_MPS = 1.9438444924406;
public static final double MPS_PER_KNOT = 0.514444444444444;
public static double metersPerSecondToKnots(double speedInMetersPerSecond) {
return speedInMetersPerSecond * KNOTS_PER_MPS;
}
public static double knotsToMetersPerSecond(double speedInKnots) {
return speedInKnots * MPS_PER_KNOT;
}
public static double courseInDegreesToAzimuth(double courseInDegrees) {
Validate.isTrue(courseInDegrees >= 0.0 && courseInDegrees <= 360.0);
double azimuth;
if (courseInDegrees > 180.0) {
azimuth = -180.0 + (courseInDegrees - 180.0);
} else {
azimuth = courseInDegrees;
}
return azimuth;
}
public static double azimuthToCourseInDegrees(double azimuth) {
Validate.isTrue(azimuth >= -180.0 && azimuth <= 180.0);
double courseInDegrees;
if (azimuth < 0.0) {
courseInDegrees = 360.0 + azimuth;
} else {
courseInDegrees = azimuth;
}
return courseInDegrees;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With