Repository navigation
Fix rounding carry in DMM and DMS coordinates - #412
Merged
Merged
Conversation
Round the last displayed component before carrying into minutes or degrees. Add exact output checks to the degree conversion test.
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.
Viking can display 10.1 degrees north as N10°5'60.0000" in DMS mode instead of the expected N10°6'0.0000". The floating point value falls just below a minute boundary. The minutes have already been split off when the seconds round to 60. DMM can also display 60.000000 minutes for a value just below a whole degree.
The formatter now rounds minutes or seconds to the displayed precision before applying the carry. In DMS mode the seconds can carry into minutes and then into degrees. In DMM mode the minutes carry into degrees.
The degree conversion test checks the DMM and DMS strings for latitude and longitude at 10.1 and 51.3 degrees. It also covers a negative coordinate and a value just below a whole degree. An ordinary coordinate checks that the formatting still works when no carry is needed.
I built degrees_converters.c with the degrees_converter test program and ran check_degrees_conversions.sh. The new checks fail on the current code and pass with this change. The existing checks still pass. I also compared the old and new DMM and DMS strings for 3.6 million latitudes between -180 and 180. The output changed for only 404 of them. Every changed value used to show 60 seconds. No new output contains 60 minutes or seconds.