Elijah Robison | GIS Blog

A scrapbook of GIS tricks, with emphasis on FOSS4G.

MySQL Implementation of Google’s Encoded Polyline Algorithm

with one comment

I just noticed someone created a MySQL implementation of Google’s Encoded Polyline Algorithm incorporating some elements of my PostgreSQL/PostGIS approach, specifically, support for multi-part, multi-ring polygon geometries.

And this is exciting, at the bottom of his post, Fabien says he’s working on a solution for consuming the Google encoded geometries in Leaflet. Nice! I love open source software!

I thought I’d mention the MySQL approach here to help expose Fabien’s solution to English searches and drive a little more traffic to his site. If you can’t read French, Google Translate is your friend!

FWIW–if anyone is interested and so inclined–there is a potential improvement that could be made to the Google Encoded Polyline implementation allowing users to specify a desired number of significant digits before rounding the Latitude and Longitude coordinate values prior to encoding. If memory serves, the documentation for Google’s algorithm allows/expects only 5 significant digits. But on some datasets with curved line features (often just heavily sampled line-segments), this limitation of 5 significant digits degrades the data, and you end up with jagged line features. So an improved solution would provide an optional parameter to specify significant digits.

All else equal–nice work, Fabien!

Written by elrobis

September 22nd, 2014 at 4:26 pm

One Response to 'MySQL Implementation of Google’s Encoded Polyline Algorithm'

Subscribe to comments with RSS

  1. Hello,
    Thank you for your article! 🙂
    My english isn’t very good, but I will try…

    I published a new short article (still in French…) about encoded (complex) geometries and Leaflet.
    You can find the article here: http://dogeo.fr/afficher-des-polygones-a-la-geometrie-encodee-sur-leaflet/
    You can also see an example here: http://dogeo.fr/_apps/MySQL-Multipolygons-encoded-to-Leaflet/

    I hope that the language barrier will not be a problem.
    And yes, Leaflet is awsome!


    5 Feb 15 at 6:26 am

Leave a Reply