We have two coordinates (latitude, longitude) and let's assume we want to travel along a straight line between them. After traveling a certain distance along this line, we would like to calculate a new coordinate for this location. How can this be done?
Point startCoord = new Point(52.515343254180486, 13.384435940499088); Point endCoord = new Point(52.51544771840784, 13.386055994744083); double totalDistance = 110.23868303918874; // in meters double intervalDistance = 50; // in meters
Note: Distances between points will always be fairly small.
Based on this post we can find the
intervalDistance as hypotenuse, we can find x and y distances away from the
startCoord using simple trig:
double dx = intervalDistance * Math.sin(angle); double dy = intervalDistance * Math.cos(angle);
And based on this post, we can calculate the new coordinate based on the x and y distance away (in meters) from the