thinwrap_location_polyline (thinwrap_location v1.3.0)

View Source

The four locked polyline utilities, byte-for-byte compatible with the TypeScript, PHP, Go and Python siblings (tested against the shared parity vectors).

  • encode/1 — coordinates to a Google precision-5 polyline.
  • decode/1 — a Google precision-5 polyline to coordinates.
  • decode_flex/1 — a HERE flexible polyline to coordinates (altitude skipped).
  • encode_esri_paths/1 — coordinate paths to an Esri JSON paths geometry.

Every normalized routing result carries its geometry as a precision-5 polyline, whatever the provider returned.

Summary

Functions

Decode a Google-format precision-5 polyline. A truncated or invalid string is data, not misuse, so it returns {error, Error} with code unknown.

Decode a HERE flexible polyline; altitude, if present, is decoded and skipped.

Encode coordinates into a Google-format precision-5 polyline.

Convert coordinate paths into an Esri JSON paths geometry: each point an [lng, lat] pair, CRS fixed at WGS-84.

Functions

decode/1

-spec decode(binary()) ->
                {ok, [thinwrap_location:lat_lng()]} | {error, thinwrap_location:connector_error()}.

Decode a Google-format precision-5 polyline. A truncated or invalid string is data, not misuse, so it returns {error, Error} with code unknown.

decode_flex/1

-spec decode_flex(binary()) ->
                     {ok, [thinwrap_location:lat_lng()]} | {error, thinwrap_location:connector_error()}.

Decode a HERE flexible polyline; altitude, if present, is decoded and skipped.

encode/1

-spec encode([thinwrap_location:lat_lng()]) -> binary().

Encode coordinates into a Google-format precision-5 polyline.

encode_esri_paths(Paths)

-spec encode_esri_paths([[thinwrap_location:lat_lng()]]) -> map().

Convert coordinate paths into an Esri JSON paths geometry: each point an [lng, lat] pair, CRS fixed at WGS-84.