-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing test in master (json serialization) #3863
Comments
fix in #3864 by reducing the number of significant digits.
The WKT representation allows both a number (integer or floating-point) or a string: | ::= | | |
… id.version field (fixes OSGeo#3863, reworks previous commit)
Thanks for the fix, @rouault |
JSON export: avoid non-significant decimal digits in version field (fixes #3863)
… id.version field (fixes #3863, reworks previous commit)
[Backport 9.3] JSON export: avoid non-significant decimal digits in version field (fixes #3863)
Example of problem and description
As you can see in https://github.com/OSGeo/PROJ/actions/runs/5992619233/job/16252194635#step:6:2595
there is a failing test in master:
json_import.id_code_string_version_double
. The same happens for some windows compilations.Unfortunately I have only an Ubuntu 22.04 to try to find anything.
If I understand correctly, the serialization is done in this piece of code in
metadata.cpp
More exactly in the line
writer->Add(dblVersion);
There it calls
with the default value of
nPrecision
for double: 18There it calls
CPLSPrintf(szFormatting, dfVal)
with
szFormatting = "%.18g"
anddfVal = 9.8d
(my debugger shows9.8000000000000007
)That finally calls
sqlite3_vsnprintf
instatic std::string CPLSPrintf(const char *fmt, ...)
.SQLite documentation https://www.sqlite.org/c3ref/mprintf.html says that it is similar to "snprintf()" from the standard C library.
This example of sqlite3 produces the expected result,
9.8
. https://godbolt.org/z/4545f4vaqBut using the standard C library, it does not: https://godbolt.org/z/hd585fPzj
Reached to this point I do not know how to follow the investigation. I guess something changed in sqlite3, or any other library. (or in the method
c_locale_stod
, but I don't think so)BTW, why are we serializing and "id" as a double, and not as the original string?
Expected Output
No failing tests.
Environment Information
proj
): masterInstallation method
The text was updated successfully, but these errors were encountered: