Refactor WKTWriter::writeTrimmedNumber for big and small values#973
Merged
mwtoews merged 1 commit intolibgeos:mainfrom Oct 23, 2023
Merged
Refactor WKTWriter::writeTrimmedNumber for big and small values#973mwtoews merged 1 commit intolibgeos:mainfrom
mwtoews merged 1 commit intolibgeos:mainfrom
Conversation
dc14361 to
8eff14c
Compare
8eff14c to
a41c140
Compare
This was referenced Nov 18, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_printDoublefrom 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)"