raphaelmor / Polyline

Polyline encoder / decoder in swift
MIT License
299 stars 50 forks source link

Issue with Highway drive #3

Closed raphaelmor closed 10 years ago

raphaelmor commented 10 years ago

from @Erulezz

I am simulating an Highway drive with the Simulator and saving all the coordinates. What it normally >should do is follow the complete highway in the San Francisco Bay area, but i'm getting polylines >back like this:

{zbFtdzgVnCbsALfALfALfANhANhANfANfANhANhANdANfANhANfALbALfANhANfALhALfABjAFhABjA@jA?jACjAEjAIjAKjAMhAQhASfAWfAYfAYfAYfAYfAYfAWdAWfAYdAWfAUhAQhAOfAMhAKhAIjAEhACjAAjA@jABjADhAFjAHhAJhALhAJhALfALjALhALjALhAJhAJhAHdAFfABfA@dA?dACfAEfAGdAIdAMdAOdAQdAUdAWbAYbA[A]~@?@|@c@z@e@x@g@x@i@t@k@v@k@v@k@v@i@t@i@t@g@t@g@v@g@v@e@x@c@z@a@z@c@z@c@|@c@z@a@|@a@|@c@~@a@|@a@|@?@z@c@|@a@|@a@z@a@|@?@|@a@~@]z@]~@]~@?@A[~@]|@?@~@?@|@a@|@c@x@e@v@g@t@g@n@i@p@i@n@i@p@g@l@i@p@i@n@g@l@i@n@e@p@e@r@c@t@a@t@?@x@?@x@[|@[~@Y|@[A[A[bA[bA[bA]bA[A]bA[bA[dA[bA[A[A]A]|@?@|@c@z@e@x@g@v@i@r@m@p@o@n@m@j@q@h@q@f@q@d@q@d@s@d@q@f@s@f@s@f@q@f@o@h@o@l@m@l@k@p@i@p@g@t@c@r@a@v@c@x@?@z@]z@]|@[~@W~@UAUAQbASdAQbAObAQdAQdAQbAOdASdAUbAWAY~@]~@]|@?@|@?@z@a@|@g@x@g@t@g@t@i@r@k@r@k@n@o@l@q@h@q@h@s@d@u@b@y@b@w@b@w@@w@@y@^y@b@w@@y@@w@b@w@f@s@f@q@j@q@n@o@p@k@t@i@v@g@z@c@z@c@|@?@|@]~@YAWAUbASdAQfAMhAKhAIjAEjACjAAjA?jA?lA?hAAjAAjAAjAEhAIhAKhAOfAQfAS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AOdAMfAKdAIdAIfAKfAIhAIhAKjAKjAKhAKlAOjAMjAQjAUfAWhA[dA[dA]`Ac@bAe@~@e@z@g@x@g@z@g@x@g@x@g@v@g@x@g@x@g@x@g@x@i@z@i@x@g@x@g@x@i@z@i@z@g@z@g@x@i@z@i@z@i@z@i@z@k@z@m@x@m@x@

As you can see the line is getting off the highway. The first 2-3 km or so is correct. If i check the >coordinates saved in the array they are always on the highway, even the last coordinate in the array. >Strange thing is, it doesn't always happen. It is properly some value in the coordinate that is going >wrong or something.

EricDRX commented 10 years ago

I have taken some images with an example: This is the simulator:

schermafbeelding 2014-10-20 om 10 33 51

This is the polyline:

schermafbeelding 2014-10-20 om 10 34 24

Doing some more tests with also a City Run this afternoon :)

raphaelmor commented 10 years ago

I managed to reproduce the issue, and found a fix (https://github.com/raphaelmor/Polyline/pull/4). When two coordinates are separated by 0.00016, the encoder behaved badly. I also fixed some rounding, so now the results are identical to Google Map iOS SDK. (but not exactly to the online tool, see README for more details).

Please let me know if it fixes your issue.

EricDRX commented 10 years ago

Thanks for your explanation :) It is working perfect now:

schermafbeelding 2014-10-21 om 09 45 48

schermafbeelding 2014-10-21 om 09 46 52

Thanks a lot!

raphaelmor commented 10 years ago

No problem ! I'm happy you find it useful !