Can the sensitivity of Polyutil.encode be adjusted ?
zahidcataltas opened this issue · 4 comments
Hello, thank you for making things easy.
Can the sensitivity of Polyutil.encode be adjusted? I guess the decimal part keeps 5 digits, is it possible to make it 6 or 7 digits ?
Can the sensitivity of Polyutil.encode be adjusted? I guess the decimal part keeps 5 digits, is it possible to make it 6 or 7 digits ?
As the library is currently written the number of decimal places is fixed at 5.
The polyline encoding algorithm is well-known and defined here:
https://developers.google.com/maps/documentation/utilities/polylinealgorithm
The 2nd step, as you say, multiplies by 1e5 and rounds the result.
That being said, from briefly scanning the algorithm I don't think there is anything that would prevent you from altering the algorithm to encode more significant digits. You'd just need to obviously change the encoding and decoding steps to match, based on a known precision at which the value was encoded.
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!
@zahidcataltas , the following PR will increase the sensitivity to 7 digits: