use explicit casts where feasible
This commit is contained in:
		
							parent
							
								
									58f23cda4a
								
							
						
					
					
						commit
						15ca6d5ca9
					
				| @ -44,7 +44,7 @@ struct CoordinatePairCalculator | |||||||
|                              const FixedPointCoordinate &coordinate_b) |                              const FixedPointCoordinate &coordinate_b) | ||||||
|     { |     { | ||||||
|         // initialize distance calculator with two fixed coordinates a, 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_lat = (coordinate_a.lat / COORDINATE_PRECISION) * RAD; | ||||||
|         first_lon = (coordinate_a.lon / COORDINATE_PRECISION) * RAD; |         first_lon = (coordinate_a.lon / COORDINATE_PRECISION) * RAD; | ||||||
|         second_lat = (coordinate_b.lat / COORDINATE_PRECISION) * RAD; |         second_lat = (coordinate_b.lat / COORDINATE_PRECISION) * RAD; | ||||||
| @ -54,23 +54,23 @@ struct CoordinatePairCalculator | |||||||
|     int operator()(FixedPointCoordinate &other) const |     int operator()(FixedPointCoordinate &other) const | ||||||
|     { |     { | ||||||
|         // set third coordinate c
 |         // set third coordinate c
 | ||||||
|         const float RAD = 0.017453292519943295769236907684886; |         const float RAD = 0.017453292519943295769236907684886f; | ||||||
|         const float earth_radius = 6372797.560856; |         const float earth_radius = 6372797.560856f; | ||||||
|         const float float_lat1 = (other.lat / COORDINATE_PRECISION) * RAD; |         const float float_lat1 = (other.lat / COORDINATE_PRECISION) * RAD; | ||||||
|         const float float_lon1 = (other.lon / COORDINATE_PRECISION) * RAD; |         const float float_lon1 = (other.lon / COORDINATE_PRECISION) * RAD; | ||||||
| 
 | 
 | ||||||
|         // compute distance (a,c)
 |         // 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 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; |         const float dist1 = sqrt(std::pow(x_value_1, 2) + std::pow(y_value_1, 2)) * earth_radius; | ||||||
| 
 | 
 | ||||||
|         // compute distance (b,c)
 |         // 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 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; |         const float dist2 = sqrt(std::pow(x_value_2, 2) + std::pow(y_value_2, 2)) * earth_radius; | ||||||
| 
 | 
 | ||||||
|         // return the minimum
 |         // return the minimum
 | ||||||
|         return std::min(dist1, dist2); |         return static_cast<int>(std::min(dist1, dist2)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     float first_lat; |     float first_lat; | ||||||
|  | |||||||
| @ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| void PolylineCompressor::encodeVectorSignedNumber(std::vector<int> &numbers, std::string &output) | void PolylineCompressor::encodeVectorSignedNumber(std::vector<int> &numbers, std::string &output) | ||||||
|     const |     const | ||||||
| { | { | ||||||
|     const unsigned end = numbers.size(); |     const unsigned end = static_cast<unsigned>(numbers.size()); | ||||||
|     for (unsigned i = 0; i < end; ++i) |     for (unsigned i = 0; i < end; ++i) | ||||||
|     { |     { | ||||||
|         numbers[i] <<= 1; |         numbers[i] <<= 1; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user