Implementation of the Google Polyline algorithm
(https://developers.google.com/maps/documentation/utilities/polylinealgorithm)