make short variable names more legible

This commit is contained in:
Dennis Luxen 2014-05-26 12:41:25 +02:00
parent b51ad16756
commit 58b35f6e2d

View File

@ -49,13 +49,13 @@ FixedPointCoordinate::FixedPointCoordinate(int lat, int lon) : lat(lat), lon(lon
#ifndef NDEBUG #ifndef NDEBUG
if (0 != (std::abs(lat) >> 30)) if (0 != (std::abs(lat) >> 30))
{ {
std::bitset<32> y(lat); std::bitset<32> y_coordinate_vector(lat);
SimpleLogger().Write(logDEBUG) << "broken lat: " << lat << ", bits: " << y; SimpleLogger().Write(logDEBUG) << "broken lat: " << lat << ", bits: " << y_coordinate_vector;
} }
if (0 != (std::abs(lon) >> 30)) if (0 != (std::abs(lon) >> 30))
{ {
std::bitset<32> x(lon); std::bitset<32> x_coordinate_vector(lon);
SimpleLogger().Write(logDEBUG) << "broken lon: " << lon << ", bits: " << x; SimpleLogger().Write(logDEBUG) << "broken lon: " << lon << ", bits: " << x_coordinate_vector;
} }
#endif #endif
} }
@ -114,16 +114,16 @@ double FixedPointCoordinate::ApproximateDistance(const int lat1,
return earth * cHarv; return earth * cHarv;
} }
double FixedPointCoordinate::ApproximateDistance(const FixedPointCoordinate &c1, double FixedPointCoordinate::ApproximateDistance(const FixedPointCoordinate &coordinate_1,
const FixedPointCoordinate &c2) const FixedPointCoordinate &coordinate_2)
{ {
return ApproximateDistance(c1.lat, c1.lon, c2.lat, c2.lon); return ApproximateDistance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, coordinate_2.lon);
} }
float FixedPointCoordinate::ApproximateEuclideanDistance(const FixedPointCoordinate &c1, float FixedPointCoordinate::ApproximateEuclideanDistance(const FixedPointCoordinate &coordinate_1,
const FixedPointCoordinate &c2) const FixedPointCoordinate &coordinate_2)
{ {
return ApproximateEuclideanDistance(c1.lat, c1.lon, c2.lat, c2.lon); return ApproximateEuclideanDistance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, coordinate_2.lon);
} }
float FixedPointCoordinate::ApproximateEuclideanDistance(const int lat1, float FixedPointCoordinate::ApproximateEuclideanDistance(const int lat1,
@ -142,10 +142,10 @@ float FixedPointCoordinate::ApproximateEuclideanDistance(const int lat1,
const float float_lat2 = (lat2 / COORDINATE_PRECISION) * RAD; const float float_lat2 = (lat2 / COORDINATE_PRECISION) * RAD;
const float float_lon2 = (lon2 / COORDINATE_PRECISION) * RAD; const float float_lon2 = (lon2 / COORDINATE_PRECISION) * RAD;
const float x = (float_lon2 - float_lon1) * cos((float_lat1 + float_lat2) / 2.); const float x_value = (float_lon2 - float_lon1) * cos((float_lat1 + float_lat2) / 2.);
const float y = float_lat2 - float_lat1; const float y_value = float_lat2 - float_lat1;
const float earth_radius = 6372797.560856; const float earth_radius = 6372797.560856;
return sqrt(x * x + y * y) * earth_radius; return sqrt(x_value * x_value + y_value * y_value) * earth_radius;
} }
float FixedPointCoordinate::ComputePerpendicularDistance(const FixedPointCoordinate &point, float FixedPointCoordinate::ComputePerpendicularDistance(const FixedPointCoordinate &point,
@ -220,7 +220,7 @@ float FixedPointCoordinate::ComputePerpendicularDistance(const FixedPointCoordin
const FixedPointCoordinate &coord_b, const FixedPointCoordinate &coord_b,
const FixedPointCoordinate &query_location, const FixedPointCoordinate &query_location,
FixedPointCoordinate &nearest_location, FixedPointCoordinate &nearest_location,
float &r) float &ratio)
{ {
BOOST_ASSERT(query_location.isValid()); BOOST_ASSERT(query_location.isValid());
@ -251,27 +251,27 @@ float FixedPointCoordinate::ComputePerpendicularDistance(const FixedPointCoordin
nY = 0.; nY = 0.;
} }
r = (p - nY * a) / c; // These values are actually n/m+n and m/m+n , we need ratio = (p - nY * a) / c; // These values are actually n/m+n and m/m+n , we need
// not calculate the explicit values of m an n as we // not calculate the explicit values of m an n as we
// are just interested in the ratio // are just interested in the ratio
if (std::isnan(r)) if (std::isnan(r))
{ {
r = ((coord_b.lat == query_location.lat) && (coord_b.lon == query_location.lon)) ? 1. : 0.; ratio = ((coord_b.lat == query_location.lat) && (coord_b.lon == query_location.lon)) ? 1. : 0.;
} }
else if (std::abs(r) <= std::numeric_limits<float>::epsilon()) else if (std::abs(r) <= std::numeric_limits<float>::epsilon())
{ {
r = 0.; ratio = 0.;
} }
else if (std::abs(r - 1.) <= std::numeric_limits<float>::epsilon()) else if (std::abs(ratio - 1.) <= std::numeric_limits<float>::epsilon())
{ {
r = 1.; ratio = 1.;
} }
BOOST_ASSERT(!std::isnan(r)); BOOST_ASSERT(!std::isnan(ratio));
if (r <= 0.) if (ratio <= 0.)
{ {
nearest_location = coord_a; nearest_location = coord_a;
} }
else if (r >= 1.) else if (ratio >= 1.)
{ {
nearest_location = coord_b; nearest_location = coord_b;
} }
@ -353,9 +353,9 @@ float FixedPointCoordinate::GetBearing(const FixedPointCoordinate &other) const
const float delta_long = DegreeToRadian(lon / COORDINATE_PRECISION - other.lon / COORDINATE_PRECISION); const float delta_long = DegreeToRadian(lon / COORDINATE_PRECISION - other.lon / COORDINATE_PRECISION);
const float lat1 = DegreeToRadian(other.lat / COORDINATE_PRECISION); const float lat1 = DegreeToRadian(other.lat / COORDINATE_PRECISION);
const float lat2 = DegreeToRadian(lat / COORDINATE_PRECISION); const float lat2 = DegreeToRadian(lat / COORDINATE_PRECISION);
const float y = std::sin(delta_long) * std::cos(lat2); const float y_value = std::sin(delta_long) * std::cos(lat2);
const float x = std::cos(lat1) * std::sin(lat2) - std::sin(lat1) * std::cos(lat2) * std::cos(delta_long); const float x_value = std::cos(lat1) * std::sin(lat2) - std::sin(lat1) * std::cos(lat2) * std::cos(delta_long);
float result = RadianToDegree(std::atan2(y, x)); float result = RadianToDegree(std::atan2(y_value, x_value));
while (result < 0.f) while (result < 0.f)
{ {