emcconville / google-map-polyline-encoding-tool

A simple class to handle polyline-encoding for Google Maps
Other
154 stars 40 forks source link

Decode to nested array? #3

Closed RSully closed 10 years ago

RSully commented 10 years ago

I haven't started using this yet, but based on the read me I am wondering what the logic was behind this:

array(8) {
  [0] =>
  double(41.90374)
  [1] =>
  double(-87.66729)
...

Why return an array not structured the same as the input (e.g. [[x,y],[x,y]])?

RSully commented 10 years ago

Upon closer inspection I have a number of problems with this library. The logic is all there though, and for that I am torn between forking it and submitting pull-requests, and making my own project giving credit to you for the logic. Going with the former would mean breaking backwards compatibility, going with the latter would mean one less polyline project for people to choose between :wink:

emcconville commented 10 years ago

The points are kept as a flat list of doubles.

X0,Y0,X1,Y1...Xn,Yn

This is pretty common for low-level interfaces (think how RGBA data is stored in raster images). Users would be expected to translate this list into there localized business requirement. Luckily Polyline::Pair was already created to address your issue.

As for the argument of forking -v- creating. This class was created in 2008, and has been posted here for reference. The original logic was published by Google & Wikipedia, and is nothing more than bit-shifting & bit-tagging. This library will probably migrate over to traits as singleton & overloading are no longer glamorous. I would highly encourage you to make you own library.