Fix json rendering of large osm ids
This commit is contained in:
parent
3614af7f64
commit
ef96e499f8
@ -78,6 +78,7 @@
|
||||
- FIXED: Ensure required file check in osrm-routed is correctly enforced. [#6655](https://github.com/Project-OSRM/osrm-backend/pull/6655)
|
||||
- FIXED: Correct HTTP docs to reflect summary output dependency on steps parameter. [#6655](https://github.com/Project-OSRM/osrm-backend/pull/6655)
|
||||
- ADDED: Extract prerelease/build information from package semver [#6839](https://github.com/Project-OSRM/osrm-backend/pull/6839)
|
||||
- FIXED: Fix json rendering problem for large osm ids [#7096](https://github.com/Project-OSRM/osrm-backend/pull/7096)
|
||||
- Profiles:
|
||||
- FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615)
|
||||
- ADDED: Add optional support of cargo bike exclusion and width to bicyle profile [#7044](https://github.com/Project-OSRM/osrm-backend/pull/7044)
|
||||
|
@ -54,7 +54,10 @@ template <typename Out> struct Renderer
|
||||
// `fmt::memory_buffer` stores first 500 bytes in the object itself(i.e. on stack in this
|
||||
// case) and then grows using heap if needed
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::format_to(std::back_inserter(buffer), FMT_COMPILE("{:.10g}"), number.value);
|
||||
if (static_cast<std::uint64_t>(number.value) == number.value)
|
||||
fmt::format_to(std::back_inserter(buffer), FMT_COMPILE("{}"), static_cast<std::uint64_t>(number.value));
|
||||
else
|
||||
fmt::format_to(std::back_inserter(buffer), FMT_COMPILE("{:.10g}"), number.value);
|
||||
|
||||
write(buffer.data(), buffer.size());
|
||||
}
|
||||
|
@ -87,8 +87,13 @@ BOOST_AUTO_TEST_CASE(test_json_issue_6531)
|
||||
BOOST_CHECK_EQUAL(output, "0.1234567892");
|
||||
|
||||
output.clear();
|
||||
renderer(123456789123456789.);
|
||||
BOOST_CHECK_EQUAL(output, "1.234567891e+17");
|
||||
renderer(12345678912345678.);
|
||||
BOOST_CHECK_EQUAL(output, "12345678912345678");
|
||||
|
||||
// handle large osm ids
|
||||
output.clear();
|
||||
renderer(1000396615812);
|
||||
BOOST_CHECK_EQUAL(output, "1000396615812");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user