views:

31

answers:

1

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:

  • current longitude
  • current latitude
  • current speed (which can be easily converted to a distance, given a time 'T')
  • current course

EXPECTED OUTPUTS:

  • estimated longitude/latitude position after time 'T' has elapsed

REQUIREMENT #2: Calculate the course from position 'A' to position 'B'.

INPUT VALUES:

  • longitude 'A'
  • latitude 'A'
  • longitude 'B'
  • latitude 'B'

EXPECTED OUTPUTS:

  • course that points directly from 'A' to 'B'

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.

A: 

HOW TO CALCULATE COURSE FROM POSITION 'A' TO POSITION 'B'

  • Need to have the lat/lon of positions 'A' and 'B'
  • Get an instance of the GeodeticCalculator class
  • Call setStartingGeographicPoint()
  • Call setDestinationGeographicPoint()
  • Call getAzimuth()
  • Convert from azimuth to decimal degrees

HOW TO CALCULATE DEAD RECKONING POSITION 'X' STARTING FROM POSITION 'A'

  • Need to have the lat/lon of position 'A'
  • Need to have the current course of the vessel in azimuth
  • Need to have the distance to travel in meters (or calculate this as speed * time)
  • Get an instance of the GeodeticCalculator class
  • Call setStartingGeographicPoint()
  • Call setDirection()
  • Call 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;
}
Jim Tough