GeoTools - How to Perform Dead Reckoning and Course Calculations Using GeoTools Classes

I am currently using the GeoTools toolkit to calculate ship data, such as calculating the distance of the Great Circle 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 for this kind of computation.

REQUIREMENT No. 1: Calculate the Dead Reckoning position for a moving vessel.

INPUT VALUES:

  • current longitude
  • current latitude
  • current speed (which can be easily converted to a distance, given the time "T")
  • current rate

EXPECTED OUTPUTS:

  • estimated longitude / latitude after the expiration of time "T"

REQUIREMENT No. 2: Calculate the course from position "A" to position "B".

INPUT VALUES:

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

EXPECTED OUTPUTS:

  • which points straight from 'A' to 'B'

Question

Can someone direct me to classes in GeoTools that are capable of doing this computation? The huge number of classes in GeoTools amazes me, and I cannot find what I need to do.

+3
source share
1 answer

HOW TO CALCULATE THE COURSE FROM POSITION "A" TO POSITION "B"

  • You need to have lat / lon positions "A" and "B"
  • Get class instance GeodeticCalculator
  • Call setStartingGeographicPoint()
  • Call setDestinationGeographicPoint()
  • Call getAzimuth()

"" "A"

  • lat/lon 'A'
  • .
  • ​​ ( * ).
  • GeodeticCalculator
  • setStartingGeographicPoint()
  • setDirection()
  • getDestinationGeographicPoint()

, . . -180 +180, "" . , -180 , -90 , 0 - , +90 +180 .

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;
}
+6

Source: https://habr.com/ru/post/1769201/


All Articles