Name

ST_LineFromEncodedPolyline — Creates a LineString from an Encoded Polyline.

Synopsis

geometry ST_LineFromEncodedPolyline(text polyline, integer precision=5);

Description

Creates a LineString from an Encoded Polyline string.

Optional precision specifies how many decimal places will be preserved in Encoded Polyline. Value should be the same on encoding and decoding, or coordinates will be incorrect.

See http://developers.google.com/maps/documentation/utilities/polylinealgorithm

Availability: 2.2.0

Examples

This example creates a LineString from a polyline.

SELECT ST_AsEWKT(ST_LineFromEncodedPolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@'));
SRID=4326;LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252)

This example selects a different precision than the one used for polyline encoding.

SELECT ST_AsEWKT(ST_LineFromEncodedPolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@',6));
SRID=4326;LINESTRING(-12.02 3.85,-12.095 4.07,-12.6453 4.3252)