joshuaclayton / polylines Goto Github PK
View Code? Open in Web Editor NEWEasily handle Google polylines
License: MIT License
Easily handle Google polylines
License: MIT License
Hi there,
Thanks for this wonderful library. I realize that google's algorithm anticipates latitude/longitude pairing. However, most pairings (including geojson data) are usually in the form of [longitude, latitude] or [x,y].
Does it make more sense for this gem's api to accept [longitude, latitude] pairings so that users can almost pump straight geojson data into it? This would make things much more convenient.
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?
Hi,
I'm currently using the ruby gem polylines, and thank you for this.
However, I sometime experienced strange behaviour using the gem. Sometimes, I have problems with the output, it seems like there is an issue with rounding when i decode a polyline. If i compare with the array received from the official "Interactive Polyline Encoder Utility", sometimes, I haven't the same result.
https://developers.google.com/maps/documentation/utilities/polylineutility
For example, the string of the polylines used is :
"eyhiHkx}LcGdBGHAFa@WdCeL?IACKOH_@NF?PFqCfE}RTwB?Y|@@v@K`@Yn@oABcAGmAQ{@IiA@cBhGoXtMom@`TyaA^sBB}@Ga@KYMWk@i@y@iAOq@E{ALoB\\eCZwAJF\\uABM^TjLtI`ErCrBtAhAl@l@RTBNCf@]pF{EvMgMjI{Id@[XGxCa@`VyEpHwAtGkA|SyDzCm@X@NFPRnEzFNVJh@@|@oDdPlBpAe@c@D{@^FPH|EhG"
And I linked you 2 screenshots of the results, one with the Google Encoder Utility (on web page), and the other one with the Ruby Gem Polylines (in console).
The item selected on the list of the first screenshot correspond in the second to :
48.87205,2.3006
(rdb:1) array_poly1[25]
[48.87205000000001, 2.300600000000001]
As you can see the result seems rounded.
What do you think about that ? Have you ever experienced something similar?
Thank you,
Maxime
I've opened a pull request to add support for this here:
#5
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?
Was seeing very odd behavior (encoded lines suddenly becoming null) in production server. Looked over code and it seems there are some class level variables that might be overridden by competing threads. I didn't have time to fork and fix it, but thought I should mention this. We switched to https://github.com/nayutaya/googlemaps-polyline and things are back to normal.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.