Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Google compressed string polylines #23998

Closed
jquirke opened this issue Nov 11, 2024 · 1 comment
Closed

Support Google compressed string polylines #23998

jquirke opened this issue Nov 11, 2024 · 1 comment

Comments

@jquirke
Copy link
Contributor

jquirke commented Nov 11, 2024

Expected Behavior or Use Case

Add geospatial functions to work with (i.e. transform) the popular Google polyline string encoding as used in Google Maps and other products to and from the existing Presto geometry constructs like ST_Polyline, ST_Point.

These are efficiently encoded as per:
https://developers.google.com/maps/documentation/utilities/polylinealgorithm

Presto Component, Service, or Connector

Geospatial functions

Possible Implementation

A possible implementation for decoding might look like as suggested in PR: #23999 , where a google maps string is decoded to an array of ST_Points. Alternatively, we could transform it into an ESRI polyline.

presto> SELECT google_polyline_decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@')
                                _col0
----------------------------------------------------------------------
 [POINT (38.5 -120.2), POINT (40.7 -120.95), POINT (43.252 -126.453)]
(1 row)

A possible implementation for encoding might look like as suggested in PR: #23999 , where an array of ST_Points is encoded to a google polyline string.

presto> SELECT google_polyline_encode(ARRAY[ST_Point (38.5, -120.2), ST_Point (40.7, -120.95), ST_Point (43.252, -126.453)])

            _col0
-----------------------------
 _p~iF~ps|U_ulLnnqC_mqNvxq`@
(1 row)

Context

This is an increasingly popular format [1], [2] for storing complex maps routes efficiently.

For example routes of Uber trips are efficiently stored using this format.

[1] https://github.com/frederickjansen/polyline/stargazers
[2] https://github.com/urschrei/pypolyline/stargazers
[3] https://stackoverflow.com/search?q=google+polyline

@jquirke jquirke changed the title Support Google maps compressed string polylines Support Google compressed string polylines Nov 14, 2024
jquirke added a commit to jquirke/presto that referenced this issue Nov 21, 2024
* Support the popular and efficient Google polyline format by adding
GeoFunctions
 - "google_decode_polyline" that decodes a Google polyline string into
an array of ST_Points, specifying an optional precision
 - "google_encode_polyline" that encodes an array of ST_Points into
a Google polyline string, specifying an optional precision

Implements prestodb#23998
tdcmeehan pushed a commit that referenced this issue Nov 21, 2024
* Support the popular and efficient Google polyline format by adding
GeoFunctions
 - "google_decode_polyline" that decodes a Google polyline string into
an array of ST_Points, specifying an optional precision
 - "google_encode_polyline" that encodes an array of ST_Points into
a Google polyline string, specifying an optional precision

Implements #23998
@jquirke jquirke closed this as completed Nov 21, 2024
@jquirke
Copy link
Contributor Author

jquirke commented Nov 21, 2024

Implemented in #23999

yuandagits pushed a commit to yuandagits/presto that referenced this issue Nov 28, 2024
* Support the popular and efficient Google polyline format by adding
GeoFunctions
 - "google_decode_polyline" that decodes a Google polyline string into
an array of ST_Points, specifying an optional precision
 - "google_encode_polyline" that encodes an array of ST_Points into
a Google polyline string, specifying an optional precision

Implements prestodb#23998
sumi-mathew pushed a commit to sumi-mathew/presto that referenced this issue Dec 4, 2024
* Support the popular and efficient Google polyline format by adding
GeoFunctions
 - "google_decode_polyline" that decodes a Google polyline string into
an array of ST_Points, specifying an optional precision
 - "google_encode_polyline" that encodes an array of ST_Points into
a Google polyline string, specifying an optional precision

Implements prestodb#23998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant