From 15ca6d5ca94b5ce27609ff5bd431ddb6c0450a3a Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 17 Jun 2014 15:57:03 +0200 Subject: [PATCH] use explicit casts where feasible --- Algorithms/DouglasPeucker.cpp | 12 ++++++------ Algorithms/PolylineCompressor.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Algorithms/DouglasPeucker.cpp b/Algorithms/DouglasPeucker.cpp index 91a557341..2e647fc38 100644 --- a/Algorithms/DouglasPeucker.cpp +++ b/Algorithms/DouglasPeucker.cpp @@ -44,7 +44,7 @@ struct CoordinatePairCalculator const FixedPointCoordinate &coordinate_b) { // initialize distance calculator with two fixed coordinates a, b - const float RAD = 0.017453292519943295769236907684886; + const float RAD = 0.017453292519943295769236907684886f; first_lat = (coordinate_a.lat / COORDINATE_PRECISION) * RAD; first_lon = (coordinate_a.lon / COORDINATE_PRECISION) * RAD; second_lat = (coordinate_b.lat / COORDINATE_PRECISION) * RAD; @@ -54,23 +54,23 @@ struct CoordinatePairCalculator int operator()(FixedPointCoordinate &other) const { // set third coordinate c - const float RAD = 0.017453292519943295769236907684886; - const float earth_radius = 6372797.560856; + const float RAD = 0.017453292519943295769236907684886f; + const float earth_radius = 6372797.560856f; const float float_lat1 = (other.lat / COORDINATE_PRECISION) * RAD; const float float_lon1 = (other.lon / COORDINATE_PRECISION) * RAD; // compute distance (a,c) - const float x_value_1 = (first_lon - float_lon1) * cos((float_lat1 + first_lat) / 2.); + const float x_value_1 = (first_lon - float_lon1) * cos((float_lat1 + first_lat) / 2.f); const float y_value_1 = first_lat - float_lat1; const float dist1 = sqrt(std::pow(x_value_1, 2) + std::pow(y_value_1, 2)) * earth_radius; // compute distance (b,c) - const float x_value_2 = (second_lon - float_lon1) * cos((float_lat1 + second_lat) / 2.); + const float x_value_2 = (second_lon - float_lon1) * cos((float_lat1 + second_lat) / 2.f); const float y_value_2 = second_lat - float_lat1; const float dist2 = sqrt(std::pow(x_value_2, 2) + std::pow(y_value_2, 2)) * earth_radius; // return the minimum - return std::min(dist1, dist2); + return static_cast(std::min(dist1, dist2)); } float first_lat; diff --git a/Algorithms/PolylineCompressor.cpp b/Algorithms/PolylineCompressor.cpp index cdaf2fbf6..fdada7192 100644 --- a/Algorithms/PolylineCompressor.cpp +++ b/Algorithms/PolylineCompressor.cpp @@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void PolylineCompressor::encodeVectorSignedNumber(std::vector &numbers, std::string &output) const { - const unsigned end = numbers.size(); + const unsigned end = static_cast(numbers.size()); for (unsigned i = 0; i < end; ++i) { numbers[i] <<= 1;