polyline encoding

polyline encoding

[8] Encoded Polyline は、一連の経緯度の組のリストを単一の ASCII文字列として符号化する方式です。 Google Maps で用いられています。

符号化

[11] 一連の経緯度符号化してそのままの順序で並べます。

[12]経緯度は、緯度経度の順に符号化して順に並べます。

[13] 各値の最終文字は、 0x3F-0x5E を使って表されます。 それよりも前の文字は、0x5F-0x7E を使って表されます。

[10] 同じような性質を持つ他のデータにも適用できます。 Google 自身が 「level」の符号化に用いる例を示しています >>4。 ただし、この場合経緯度のように値2つの組ではなく、値1つだけのリストとなります。 しかも、経緯度のように前の値とのを取ったり、ビット演算したりせずに、 5ビット符号無し整数としてそのまま符号化しているようです。

[19] 一般化すると、符号化器・復号器は次の引数を取るアルゴリズムとなります。

組の個数
1組のデータとして扱われるべき値の個数。緯度経度の場合は 2
桁移動
個々の値を整数化するため符号化時に掛け、復号時に割るべき数。 緯度経度の場合は 1e5。
差分
1つ前の値とのかどうか。緯度経度の場合は

文脈

[9] Google MapsAPI符号化復号の機能が提供されています。

[15] StravaAPI で採用されています >>14

メモ

[2] mapbox/polyline: polyline encoding and decoding in javascript ( 版) https://github.com/mapbox/polyline

[4] Interactive Polyline Encoder Utility  |  Google Maps APIs  |  Google Developers ( 版) https://developers.google.com/maps/documentation/utilities/polylineutility

[5] Encoded Polyline Algorithm Format  |  Google Maps APIs  |  Google Developers () https://developers.google.com/maps/documentation/utilities/polylinealgorithm

Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string. Point coordinates are encoded using signed values.

[6] Interactive Polyline Encoder Utility  |  Google Maps APIs  |  Google Developers () https://developers.google.com/maps/documentation/utilities/polylineutility

Polylines in Google Maps are formed as a set of latitude/longitude pairs. In addition, for each vertex (location) in an encoded polyline, a level can be specified indicating that the location should appear on that level and any level higher (i.e. any decrease in zoom.).

[7] Geo::Google::PolylineEncoder - search.cpan.org () http://search.cpan.org/dist/Geo-Google-PolylineEncoder/lib/Geo/Google/PolylineEncoder.pm

[14] Strava API Reference ( ()) https://strava.github.io/api/#polylines

Activity and segment API requests may include summary polylines of their respective routes. The values are string encodings of the latitude and longitude points using the Google encoded polyline algorithm format.

[16] wakaba/perl-geo-encodedpolyline () https://github.com/wakaba/perl-geo-encodedpolyline

[17] wakaba/js-geo-encodedpolyline () https://github.com/wakaba/js-geo-encodedpolyline

[18] ST_AsEncodedPolyline () https://postgis.net/docs/ST_AsEncodedPolyline.html