Refactor WKTWriter::writeTrimmedNumber for big and small values #973
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR modifies how big and small values are formatted by WKTWriter by switching from positional to scientific notation where necessary, to avoid rounding to zero or overflowing a char buffer crash.
This somewhat expands the "trim" mode definition to mean "print pretty numbers" since it doesn't always honour (e.g.) "3" to show fixed millimetre precision, since it will use scientific notation to show smaller non-zero numbers if necessary. The non-trim mode still uses fixed notation, and will show (e.g.) "-0" in some cases.
Also the char buffer used for these numbers is reduced from 128 to 28.
Some new unit tests are added for
GEOS_printDouble
from the CAPI. Other unit tests check outputs with trim set on/off.Closes #970
Some [unpractical] geometries mapped in SI meters:
./bin/geosop -a "point(0 0)" buffer 2.8179403227e-15
./bin/geosop -a "point(0 0)" buffer 4.40e26
./bin/geosop -a "point(5e-324 1.7e308)"