I am trying to combine a new coded polyline with an existing polyline without decoding and transcoding the entire polyline. The new encoded polyline will be uploaded to the server (linux), where I would like to add it to the existing polyline.
The problem is that you cannot just crush them together. The following are some sample data. I hope to find / create a solution in either PHP or the shell script, but the problem is that I do not have enough technical understanding to interpret the encoded polyline algorithm.
41.386692,-73.475912 41.424822,-73.375027 41.428292,-73.311173 41.426183,-73.254577 41.470168,-73.218532 41.498865,-73.155278 (Yes, 6 points are easy, but it going to be more like 7,000 coordinate pairs)
- The first 3 coordinated pairs are encoded:
yir{Fnwm_MimFquRuTanK - Last 3:
s`z{Fbpb~L{qGg`FkrDkjK - All 6:
yir{Fnwm_MimFquRuTanKdLw`J{qGg`FkrDkjK
Interactive Polyline Encoder Utility
The format of the encoded polyline (you can get this through an interactive encoder)
Polyline encoder
Edit:
I also have source data that encoded polylines at both ends. Therefore, I can also save the first and last coordinate pair separately.
Useful readings:
In the end, I wrote a blog post that has a lot more information about how encoded polylines work. You can read it here: What is an encoded polyline?
google-maps google-maps-api-3 google-polyline
Dan mandle
source share