Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Point Failure #1

Closed
rockwood opened this Issue · 5 comments

4 participants

@rockwood

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 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
ee318e1
@joshuaclayton

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

You rock! Thanks.

@cdmwebs

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

@danielcooper

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

@joshuaclayton

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.