Fixes integer overflow due to fixed / floating mismatch in coordinate interpolation

This commit is contained in:
Daniel J. Hofmann 2016-03-22 11:01:37 +01:00 committed by Patrick Niklaus
parent a86f09a1f7
commit 776c0d0ae2

View File

@ -261,10 +261,10 @@ Coordinate interpolateLinear(double factor, const Coordinate from, const Coordin
{ {
BOOST_ASSERT(0 <= factor && factor <= 1.0); BOOST_ASSERT(0 <= factor && factor <= 1.0);
FloatLongitude interpolated_lon{((1. - factor) * static_cast<std::int32_t>(from.lon)) + FixedLongitude interpolated_lon(((1. - factor) * static_cast<std::int32_t>(from.lon)) +
(factor * static_cast<std::int32_t>(to.lon))}; (factor * static_cast<std::int32_t>(to.lon)));
FloatLatitude interpolated_lat{((1. - factor) * static_cast<std::int32_t>(from.lat)) + FixedLatitude interpolated_lat(((1. - factor) * static_cast<std::int32_t>(from.lat)) +
(factor * static_cast<std::int32_t>(to.lat))}; (factor * static_cast<std::int32_t>(to.lat)));
return {std::move(interpolated_lon), std::move(interpolated_lat)}; return {std::move(interpolated_lon), std::move(interpolated_lat)};
} }