Add euclideanDistance to coordinate_calculation
This commit is contained in:
		
							parent
							
								
									c9a19c954e
								
							
						
					
					
						commit
						75912b3662
					
				| @ -19,6 +19,10 @@ const constexpr long double EARTH_RADIUS = 6372797.560856; | |||||||
| namespace coordinate_calculation | namespace coordinate_calculation | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|  | //! Projects both coordinates and takes the euclidean distance of the projected points
 | ||||||
|  | // Does not return meters!
 | ||||||
|  | double euclideanDistance(const Coordinate first_coordinate, const Coordinate second_coordinate); | ||||||
|  | 
 | ||||||
| double haversineDistance(const Coordinate first_coordinate, const Coordinate second_coordinate); | double haversineDistance(const Coordinate first_coordinate, const Coordinate second_coordinate); | ||||||
| 
 | 
 | ||||||
| double greatCircleDistance(const Coordinate first_coordinate, const Coordinate second_coordinate); | double greatCircleDistance(const Coordinate first_coordinate, const Coordinate second_coordinate); | ||||||
|  | |||||||
| @ -17,6 +17,18 @@ namespace util | |||||||
| namespace coordinate_calculation | namespace coordinate_calculation | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|  | double euclideanDistance(const Coordinate coordinate_1, const Coordinate coordinate_2) | ||||||
|  | { | ||||||
|  |     const double x1 = static_cast<double>(toFloating(coordinate_1.lon)); | ||||||
|  |     const double y1 = mercator::latToY(toFloating(coordinate_1.lat)); | ||||||
|  |     const double x2 = static_cast<double>(toFloating(coordinate_2.lon)); | ||||||
|  |     const double y2 = mercator::latToY(toFloating(coordinate_2.lat)); | ||||||
|  |     const double dx = x1 - x2; | ||||||
|  |     const double dy = y1 - y2; | ||||||
|  | 
 | ||||||
|  |     return std::sqrt(dx * dx + dy * dy); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| double haversineDistance(const Coordinate coordinate_1, const Coordinate coordinate_2) | double haversineDistance(const Coordinate coordinate_1, const Coordinate coordinate_2) | ||||||
| { | { | ||||||
|     auto lon1 = static_cast<int>(coordinate_1.lon); |     auto lon1 = static_cast<int>(coordinate_1.lon); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user