-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dart: Flutter web gives completely wrong results when decoding polyline #26
Comments
i have same issue, is the problem have fix? |
I have not found a fix using this package. I have switched to a completely different method, specifically, calling a server of mine which is responsible for getting directions/polyline, using google maps, and communicating that result via http. Not my favourite work around, but it works well for my use case |
Sounds a bit like #52 |
The Dart Lib uses int in Dart for the equivalent of long in Java in https://github.com/heremaps/flexible-polyline/blob/master/dart/lib/converter.dart#L84 The issue is caused by Dart itself - as when code is compiled to JavaScript it loses Precision. You need to use precision 5 or need to use the JavaScript lib (Gist with BigInt lib) for decoding instead as recommended here: #52 (comment) |
Theoretically a base-10 big-int would be relatively easy to implement, since the only operations needed are:
At precision 15 we need log2(360 * 10^15) + 1 = 60 bits. That means that if you were to use Dart's 53 bit type only 2 variables are enough. You could e.g. work with 10^9 per variable (31 bits if signed). Addition would only need to take care of the carry (there's enough space to avoid overflow), and division by a power of ten shifts down the remainder (the equivalent of a bit-shift in base-2). This approach could work for JS as well, and might be noticeably faster than base-2 BigInteger generic size BigInt library. What do you think @moo24 / @haifeng2013 ? |
Decoding polylines on flutter web is completely wrong.
Using the provided example from https://pub.dev/packages/flexible_polyline, running on android works just fine and prints out the expected results
results in the following on android/ios
But running the exact same code with flutter web gives the following:
The first address is correct, but subsequent addresses 2-4 are very large
If there are any additional params/options available that fix the decoding scheme based on web vs mobile, that would be an acceptable workaround until a better solution can be found
The text was updated successfully, but these errors were encountered: