I'm using the popular JTS Vividsolutions API for Java. I'm struggling to find if I can perform calculation of the First (direct) geodetic problem with the API. Is there a way to calculate this with this API? It seems that simple one method not exist, but maybe using some combinations of existing methods of that API.

Note - I'm not looking for solutions of implementing the First (direct) geodetic problem algorithm using Java+JTS suite.

  • 1
    Feels like a stupid workaround but at least JTS can rotate. Create a vertical line with correct length and rotate it and find where the end point of the line travels.
    – user30184
    Nov 20, 2015 at 21:21
  • @user30184 actually very elegant solution
    – michael
    Nov 20, 2015 at 21:33
  • @user30184 Thanks, found the solution and put it here for others
    – michael
    Nov 21, 2015 at 8:39

2 Answers 2


I would much rather suggest doing it manually since the math is simple. This will be much faster than using so many potentially complex methods.

public static Point createPointInDistanceAtAngle(Point anchor, 
                                      double distance, double angle) {

    double dx = distance * Math.cos(Math.toRadians(angle));
    double dy = distance * Math.sin(Math.toRadians(angle));

    double x = anchor.getX() + dx;
    double y = anchor.getY() + dy;

    GeometryFactory geometryFactory = new GeometryFactory(); // maybe pass one
    Point point = geometryFactory.createPoint(new Coordinate(x, y));

    return point;

Ok, so I found by myself the solution thanks to @user30184 comment.

The key principal is using JTS rotation via Math Transformation.

//my base point
Coordinate ancorPoint = placeCoordinate;
//create orthogonal point in distance of 0.001 arc degrees
Coordinate endingCoordinate = new Coordinate(placeCoordinate.x+0.001, placeCoordinate.y);
//rotate by 90 degrees = pi/2 = 1.57 (radians)
AffineTransform affineTransform = AffineTransform.getRotateInstance(1.57, ancorPoint.x, ancorPoint.y);
MathTransform mathTransform = new AffineTransform2D(affineTransform);
try {
    //save the result "in place" - modify endingCoordinate to save memory
    JTS.transform(endingCoordinate, endingCoordinate, mathTransform);
} catch (Exception e) {}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.