use double precision calculations instead of mixing double and float
This commit is contained in:
@@ -41,41 +41,41 @@ namespace coordinate_calculation
|
||||
double haversine_distance(const FixedPointCoordinate &first_coordinate,
|
||||
const FixedPointCoordinate &second_coordinate);
|
||||
|
||||
float great_circle_distance(const FixedPointCoordinate &first_coordinate,
|
||||
double great_circle_distance(const FixedPointCoordinate &first_coordinate,
|
||||
const FixedPointCoordinate &second_coordinate);
|
||||
|
||||
float great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2);
|
||||
double great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2);
|
||||
|
||||
void lat_or_lon_to_string(const int value, std::string &output);
|
||||
|
||||
float perpendicular_distance(const FixedPointCoordinate &segment_source,
|
||||
double perpendicular_distance(const FixedPointCoordinate &segment_source,
|
||||
const FixedPointCoordinate &segment_target,
|
||||
const FixedPointCoordinate &query_location);
|
||||
|
||||
float perpendicular_distance(const FixedPointCoordinate &segment_source,
|
||||
double perpendicular_distance(const FixedPointCoordinate &segment_source,
|
||||
const FixedPointCoordinate &segment_target,
|
||||
const FixedPointCoordinate &query_location,
|
||||
FixedPointCoordinate &nearest_location,
|
||||
float &ratio);
|
||||
double &ratio);
|
||||
|
||||
float perpendicular_distance_from_projected_coordinate(
|
||||
double perpendicular_distance_from_projected_coordinate(
|
||||
const FixedPointCoordinate &segment_source,
|
||||
const FixedPointCoordinate &segment_target,
|
||||
const FixedPointCoordinate &query_location,
|
||||
const std::pair<double, double> &projected_coordinate);
|
||||
|
||||
float perpendicular_distance_from_projected_coordinate(
|
||||
double perpendicular_distance_from_projected_coordinate(
|
||||
const FixedPointCoordinate &segment_source,
|
||||
const FixedPointCoordinate &segment_target,
|
||||
const FixedPointCoordinate &query_location,
|
||||
const std::pair<double, double> &projected_coordinate,
|
||||
FixedPointCoordinate &nearest_location,
|
||||
float &ratio);
|
||||
double &ratio);
|
||||
|
||||
float deg_to_rad(const float degree);
|
||||
float rad_to_deg(const float radian);
|
||||
double deg_to_rad(const double degree);
|
||||
double rad_to_deg(const double radian);
|
||||
|
||||
float bearing(const FixedPointCoordinate &first_coordinate,
|
||||
double bearing(const FixedPointCoordinate &first_coordinate,
|
||||
const FixedPointCoordinate &second_coordinate);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ struct RectangleInt2D
|
||||
Contains(lower_left));
|
||||
}
|
||||
|
||||
float GetMinDist(const FixedPointCoordinate &location) const
|
||||
double GetMinDist(const FixedPointCoordinate &location) const
|
||||
{
|
||||
const bool is_contained = Contains(location);
|
||||
if (is_contained)
|
||||
@@ -117,7 +117,7 @@ struct RectangleInt2D
|
||||
|
||||
BOOST_ASSERT(d != INVALID);
|
||||
|
||||
float min_dist = std::numeric_limits<float>::max();
|
||||
double min_dist = std::numeric_limits<double>::max();
|
||||
switch (d)
|
||||
{
|
||||
case NORTH:
|
||||
@@ -156,14 +156,14 @@ struct RectangleInt2D
|
||||
break;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(min_dist < std::numeric_limits<float>::max());
|
||||
BOOST_ASSERT(min_dist < std::numeric_limits<double>::max());
|
||||
|
||||
return min_dist;
|
||||
}
|
||||
|
||||
float GetMinMaxDist(const FixedPointCoordinate &location) const
|
||||
double GetMinMaxDist(const FixedPointCoordinate &location) const
|
||||
{
|
||||
float min_max_dist = std::numeric_limits<float>::max();
|
||||
double min_max_dist = std::numeric_limits<double>::max();
|
||||
// Get minmax distance to each of the four sides
|
||||
const FixedPointCoordinate upper_left(max_lat, min_lon);
|
||||
const FixedPointCoordinate upper_right(max_lat, max_lon);
|
||||
|
||||
Reference in New Issue
Block a user