Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Point Failure #1

rockwood opened this Issue · 5 comments

4 participants



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

       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 joshuaclayton closed this issue from a commit
@joshuaclayton Handle very close points
When step 2's result is 0 (due to points being very close), later steps
(six and up) depend on at least one value being present in the array.
Default to 0 if nothing is present after breaking into 5-bit chunks.

Closes #1

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!


You rock! Thanks.


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


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


Sure thing! Just pushed 0.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.