Fix floating point precision issues with new algorithm for Encode() and Decode() #9
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.
The original algorithm used floating point arithmetic which caused precision issues as discussed in Issue google/open-location-code#307.
The new algorithm implemented in this PR uses 64-bit integer arithmetic to avoid the precision errors and was ported from the Java implementation google/open-location-code#347.
The CodeArea class was improved without any breaking changes to add the CodeLength property and to extend a new publicly accessible GeoArea class which contains the generic area properties and methods. The CodeArea constructor is still not publicly accessible to ensure that all CodeArea instances represent a valid OLC area.
The unit tests were improved to read and parse the test_data CSV files from the original open-location-code project. The
encoding.csv
anddecoding.csv
TestData files also include new test cases for these changes. No unit tests or test cases were removed (only added).