Fix performance-type-promotion-in-math-fn clang-tidy warning (#6908)
This commit is contained in:
parent
163a2cfe3c
commit
1a6f4c44e7
@ -54,7 +54,6 @@ Checks: >
|
|||||||
performance-*,
|
performance-*,
|
||||||
-performance-noexcept-move-constructor,
|
-performance-noexcept-move-constructor,
|
||||||
-performance-no-int-to-ptr,
|
-performance-no-int-to-ptr,
|
||||||
-performance-type-promotion-in-math-fn,
|
|
||||||
readability-*,
|
readability-*,
|
||||||
-readability-avoid-const-params-in-decls,
|
-readability-avoid-const-params-in-decls,
|
||||||
-readability-braces-around-statements,
|
-readability-braces-around-statements,
|
||||||
|
@ -443,8 +443,8 @@ class RouteAPI : public BaseAPI
|
|||||||
if (requested_annotations & RouteParameters::AnnotationsType::Speed)
|
if (requested_annotations & RouteParameters::AnnotationsType::Speed)
|
||||||
{
|
{
|
||||||
double prev_speed = 0;
|
double prev_speed = 0;
|
||||||
speed =
|
speed = GetAnnotations<float>(
|
||||||
GetAnnotations<float>(fb_result,
|
fb_result,
|
||||||
leg_geometry,
|
leg_geometry,
|
||||||
[&prev_speed](const guidance::LegGeometry::Annotation &anno)
|
[&prev_speed](const guidance::LegGeometry::Annotation &anno)
|
||||||
{
|
{
|
||||||
@ -454,8 +454,7 @@ class RouteAPI : public BaseAPI
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto speed =
|
auto speed = std::round(anno.distance / anno.duration * 10.) / 10.;
|
||||||
round(anno.distance / anno.duration * 10.) / 10.;
|
|
||||||
prev_speed = speed;
|
prev_speed = speed;
|
||||||
return util::json::clamp_float(speed);
|
return util::json::clamp_float(speed);
|
||||||
}
|
}
|
||||||
|
@ -497,13 +497,13 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
|||||||
{
|
{
|
||||||
// Calculate the speed for this line
|
// Calculate the speed for this line
|
||||||
std::uint32_t speed_kmh_idx = static_cast<std::uint32_t>(
|
std::uint32_t speed_kmh_idx = static_cast<std::uint32_t>(
|
||||||
round(length / from_alias<double>(forward_duration) * 10 * 3.6));
|
std::round(length / from_alias<double>(forward_duration) * 10 * 3.6));
|
||||||
|
|
||||||
// Rate values are in meters per weight-unit - and similar to speeds, we
|
// Rate values are in meters per weight-unit - and similar to speeds, we
|
||||||
// present 1 decimal place of precision (these values are added as
|
// present 1 decimal place of precision (these values are added as
|
||||||
// double/10) lower down
|
// double/10) lower down
|
||||||
std::uint32_t forward_rate = static_cast<std::uint32_t>(
|
std::uint32_t forward_rate = static_cast<std::uint32_t>(
|
||||||
round(length / from_alias<double>(forward_weight) * 10.));
|
std::round(length / from_alias<double>(forward_weight) * 10.));
|
||||||
|
|
||||||
auto tile_line = coordinatesToTileLine(a, b, tile_bbox);
|
auto tile_line = coordinatesToTileLine(a, b, tile_bbox);
|
||||||
if (!tile_line.empty())
|
if (!tile_line.empty())
|
||||||
@ -531,13 +531,13 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
|||||||
{
|
{
|
||||||
// Calculate the speed for this line
|
// Calculate the speed for this line
|
||||||
std::uint32_t speed_kmh_idx = static_cast<std::uint32_t>(
|
std::uint32_t speed_kmh_idx = static_cast<std::uint32_t>(
|
||||||
round(length / from_alias<double>(reverse_duration) * 10 * 3.6));
|
std::round(length / from_alias<double>(reverse_duration) * 10 * 3.6));
|
||||||
|
|
||||||
// Rate values are in meters per weight-unit - and similar to speeds, we
|
// Rate values are in meters per weight-unit - and similar to speeds, we
|
||||||
// present 1 decimal place of precision (these values are added as
|
// present 1 decimal place of precision (these values are added as
|
||||||
// double/10) lower down
|
// double/10) lower down
|
||||||
std::uint32_t reverse_rate = static_cast<std::uint32_t>(
|
std::uint32_t reverse_rate = static_cast<std::uint32_t>(
|
||||||
round(length / from_alias<double>(reverse_weight) * 10.));
|
std::round(length / from_alias<double>(reverse_weight) * 10.));
|
||||||
|
|
||||||
auto tile_line = coordinatesToTileLine(b, a, tile_bbox);
|
auto tile_line = coordinatesToTileLine(b, a, tile_bbox);
|
||||||
if (!tile_line.empty())
|
if (!tile_line.empty())
|
||||||
|
@ -40,8 +40,8 @@ RasterDatum RasterSource::GetRasterData(const int lon, const int lat) const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::size_t xth = static_cast<std::size_t>(round((lon - xmin) / xstep));
|
const std::size_t xth = static_cast<std::size_t>(std::round((lon - xmin) / xstep));
|
||||||
const std::size_t yth = static_cast<std::size_t>(round((ymax - lat) / ystep));
|
const std::size_t yth = static_cast<std::size_t>(std::round((ymax - lat) / ystep));
|
||||||
|
|
||||||
return {raster_data(xth, yth)};
|
return {raster_data(xth, yth)};
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ void test_route_same_coordinates_fixture(bool use_json_only_api)
|
|||||||
itr.get<json::Object>().values["hint"] = "";
|
itr.get<json::Object>().values["hint"] = "";
|
||||||
|
|
||||||
// Round value to 6 decimal places for double comparison later
|
// Round value to 6 decimal places for double comparison later
|
||||||
itr.get<json::Object>().values["distance"] =
|
itr.get<json::Object>().values["distance"] = std::round(
|
||||||
round(itr.get<json::Object>().values["distance"].get<json::Number>().value * 1000000);
|
itr.get<json::Object>().values["distance"].get<json::Number>().value * 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto location = json::Array{{{7.437070}, {43.749248}}};
|
const auto location = json::Array{{{7.437070}, {43.749248}}};
|
||||||
@ -65,11 +65,11 @@ void test_route_same_coordinates_fixture(bool use_json_only_api)
|
|||||||
{"waypoints",
|
{"waypoints",
|
||||||
json::Array{{json::Object{{{"name", "Boulevard du Larvotto"},
|
json::Array{{json::Object{{{"name", "Boulevard du Larvotto"},
|
||||||
{"location", location},
|
{"location", location},
|
||||||
{"distance", round(0.137249 * 1000000)},
|
{"distance", std::round(0.137249 * 1000000)},
|
||||||
{"hint", ""}}},
|
{"hint", ""}}},
|
||||||
json::Object{{{"name", "Boulevard du Larvotto"},
|
json::Object{{{"name", "Boulevard du Larvotto"},
|
||||||
{"location", location},
|
{"location", location},
|
||||||
{"distance", round(0.137249 * 1000000)},
|
{"distance", std::round(0.137249 * 1000000)},
|
||||||
{"hint", ""}}}}}},
|
{"hint", ""}}}}}},
|
||||||
{"routes",
|
{"routes",
|
||||||
json::Array{{json::Object{
|
json::Array{{json::Object{
|
||||||
|
Loading…
Reference in New Issue
Block a user