Reputation: 36656
I read some code and saw this method:
private double calculateDistance(Coordinate coordinate1, Coordinate coordinate2) {
return coordinate1.distance(coordinate2) * (Math.PI * 6371.0)/ 180;
}
Do someone has an idea why is the last part needed for the calculation?
* (Math.PI * 6371.0)/ 180;
?
Upvotes: 0
Views: 56
Reputation: 178253
6371.0
looks like the Earth's radius in km. Multiplying by Math.PI / 180
converts degrees to radians.
This is turning a distance in radians to kilometers.
Upvotes: 1