# How to get Lat/Long between start and end coordinates and spaced at equal distance?

Suppose I have two GPS points (start and end points) each with lat/lon. I want to get equally spaced GPS points between start and end nodes. That is, I want to find GPS points for example every 10 meter from start node to end node.

Similar question is asked here. From the answers given I have referred the one by Vikram Gupta. This solution works fine but if you replace

``````int dist = (int) d / interval
``````

by

``````int dist = (int) d
``````

in getLocations(...) method some calculated coordinates lay beyond the end coordinate. How can the code be modified to prevent this?

• Welcome to GIS SE. As a new user, please take the Tour. All questions should be standalone. You can reference another question, but the question itself should be a coherent whole. Please Edit this question so that it clear enough that someone else could answer it. – Vince Jan 20 '18 at 14:22

``````   public static boolean nodeInBetween(Node start, Node end, Node
newNode) {
if (start.getLatitude() < end.getLatitude()) {
if (newNode.getLatitude()>end.getLatitude()) {
return false;
}
} else if (start.getLatitude() > end.getLatitude()) {
if (newNode.getLatitude() < end.getLatitude()) {
>return false;
}
>} else if (start.getLongitude() < end.getLongitude()) {
if (newNode.getLongitude() > end.getLongitude()) {
return false;
}
} else if (start.getLongitude() > end.getLongitude()) {
if (newNode.getLongitude() < end.getLongitude()) {
return false;
}
}
return true;
}
``````

and modify part of for loop of the getLocations(...) method as follows

``````        if (nodeInBetween(start, end, newNode)) {