Closed sridharraman closed 3 years ago
Would also like to confirm this bug when attempting to decode the polyline:
kbdoH{ioqCoF_j@Lwc@lC{BhNoMzCuJbEm]?wKkBaQmD}EqM_GwFiBfCge@zE_K~SaTdT`L|Da\\\\xJsX|EyJtQgPpXuRjKAtJqBfM[pn@g^nF}G??
Happens here: https://github.com/joshuaclayton/polylines/blob/master/lib/polylines/decoder.rb#L13
@donkey-hotei it looks like this works well with FastPolylines
at least! However, to debug such issue, we should also have the array of locations once decoded.
@joshuaclayton I have more information on the issue, transform_to_array_of_lat_lng_and_deltas
is returning an array of 55 elements, which should not be possible. And it seems like there should be 54 of those, hence a quick and dirty fix would be:
diff --git a/lib/polylines/decoder.rb b/lib/polylines/decoder.rb
index f8479a4..eda432c 100644
--- a/lib/polylines/decoder.rb
+++ b/lib/polylines/decoder.rb
@@ -7,7 +7,7 @@ module Polylines
[].tap do |points|
points << [points_with_deltas.shift, points_with_deltas.shift]
- while points_with_deltas.any?
+ while points_with_deltas.size > 1
points << [
points.last[0] + points_with_deltas.shift,
points.last[1] + points_with_deltas.shift
@BuonOmo thanks for pointing out the fix, and @sridharraman @donkey-hotei for highlighting the issue! I was able to capture the failure in a test, apply the change, and I've just published 0.4.0.
I get this error when I run
Polylines::Decoder.decode_polyline(encoded_points)
.But, the same points works fine in Google's interactive decoder.
E.g. encoded_points = "epnyHvtb@
DuAfAl@t@nDzAnAnm@mq@yi@iqBdn@w_Bas@mUi[i[TcCfAq@
B\qBe@r@_@aGbJ"Any idea why this could be happening?