decode static method
Implementation
static List<LatLng> decode(final String encodedPath) {
final len = encodedPath.length;
// For speed we preallocate to an upper bound on the final length, then
// truncate the array before returning.
final path = <LatLng>[];
var index = 0;
var lat = 0;
var lng = 0;
final big0 = BigInt.from(0);
final big0x1f = BigInt.from(0x1f);
final big0x20 = BigInt.from(0x20);
while (index < len) {
var shift = 0;
BigInt b, result;
result = big0;
do {
b = BigInt.from(encodedPath.codeUnitAt(index++) - 63);
result |= (b & big0x1f) << shift;
shift += 5;
} while (b >= big0x20);
var rShifted = result >> 1;
int dLat;
if (result.isOdd) {
dLat = (~rShifted).toInt();
} else {
dLat = rShifted.toInt();
}
lat += dLat;
shift = 0;
result = big0;
do {
b = BigInt.from(encodedPath.codeUnitAt(index++) - 63);
result |= (b & big0x1f) << shift;
shift += 5;
} while (b >= big0x20);
rShifted = result >> 1;
int dlng;
if (result.isOdd) {
dlng = (~rShifted).toInt();
} else {
dlng = rShifted.toInt();
}
lng += dlng;
path.add(LatLng((lat / 1E5).toDouble(), (lng / 1E5).toDouble()));
}
return path;
}