joshuaclayton / polylines

Easily handle Google polylines
MIT License
93 stars 17 forks source link

Point Failure #1

Closed rockwood closed 12 years ago

rockwood commented 12 years ago

Hi,

We're testing this out for our app and stumbled on some issues when encoding certain points.

for instance, doing:

Polylines::Encoder.encode_points([[41.3522171071184, -86.0456299662023],[41.3522171071183, -86.0454368471533]])

Gives the error

NoMethodError:
       undefined method `+' for nil:NilClass
     # ./lib/polylines/base.rb:62:in `block (2 levels) in step_10'
     # ./lib/polylines/base.rb:62:in `map'
     # ./lib/polylines/base.rb:62:in `block in step_10'
     # ./lib/polylines/base.rb:73:in `encode!'
     # ./lib/polylines/base.rb:62:in `step_10'
     # ./lib/polylines/encoder.rb:18:in `block in encode'
     # ./lib/polylines/encoder.rb:10:in `tap'
     # ./lib/polylines/encoder.rb:10:in `encode'
     # ./lib/polylines/encoder.rb:5:in `block in encode_points'
     # ./lib/polylines/encoder.rb:5:in `map'
     # ./lib/polylines/encoder.rb:5:in `encode_points'
     # ./spec/polylines/encoder_spec.rb:14:in `block (2 levels) in <top (required)>'

I'm not quite sure why only some points are failing. Any ideas?

joshuaclayton commented 12 years ago

Looks like there wasn't a case to handle when breaking into 5-bit chunks returned an empty array. I've made sure both encoding and decoding works with this set of points. Thanks!

rockwood commented 12 years ago

You rock! Thanks.

cdmwebs commented 12 years ago

@joshuaclayton you da man. Thanks a ton. I was just getting ready to dive in to this.

danielcooper commented 12 years ago

We've run into this problem too - the fix worked great. Would you be able to push to RubyGems?

joshuaclayton commented 12 years ago

Sure thing! Just pushed 0.1.0