Fix rounding issue due to non-associative floating arithmetic
Failing test features/car/traffic_turn_penalties.feature:33 Tables were not identical: from | to | route | speed | time | a | h | ad,dhk,dhk | 63 km/h | 11.5s +-1 | | i | g | fim,fg,fg | 59 km/h | 12s +-1 | | (-) a | (-) e | (-) ad,de,de | (-) 57 km/h | (-) 12.5s +-1 | | (+) a | (+) e | (+) ad,de,de | (+) 58 km/h | (+) 12.5s +-1 | | c | g | cd,de,ef,fg,fg | 63 km/h | 23s +-1 | | p | g | mp,fim,fg,fg | 61 km/h | 23.5s +-1 | | a | l | ad,dhk,kl,kl | 60 km/h | 24s +-1 | | l | e | kl,dhk,de,de | 59 km/h | 24.5s +-1 | | g | n | fg,fim,mn,mn | 57 km/h | 25s +-1 |
This commit is contained in:
parent
911d1e81b6
commit
3881ead8e5
@ -276,10 +276,13 @@ Coordinate interpolateLinear(double factor, const Coordinate from, const Coordin
|
||||
{
|
||||
BOOST_ASSERT(0 <= factor && factor <= 1.0);
|
||||
|
||||
FixedLongitude interpolated_lon(((1. - factor) * static_cast<std::int32_t>(from.lon)) +
|
||||
(factor * static_cast<std::int32_t>(to.lon)));
|
||||
FixedLatitude interpolated_lat(((1. - factor) * static_cast<std::int32_t>(from.lat)) +
|
||||
(factor * static_cast<std::int32_t>(to.lat)));
|
||||
const auto from_lon = static_cast<std::int32_t>(from.lon);
|
||||
const auto from_lat = static_cast<std::int32_t>(from.lat);
|
||||
const auto to_lon = static_cast<std::int32_t>(to.lon);
|
||||
const auto to_lat = static_cast<std::int32_t>(to.lat);
|
||||
|
||||
FixedLongitude interpolated_lon(from_lon + factor * (to_lon - from_lon));
|
||||
FixedLatitude interpolated_lat(from_lat + factor * (to_lat - from_lat));
|
||||
|
||||
return {std::move(interpolated_lon), std::move(interpolated_lat)};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user