Categorygithub.com/twpayne/go-polyline
modulepackage
1.1.1
Repository: https://github.com/twpayne/go-polyline.git
Documentation: pkg.go.dev

# README

go-polyline

Build Status PkgGoDev Coverage Status

Package polyline implements a Google Maps Encoding Polyline encoder and decoder.

Encoding example

func ExampleEncodeCoords() {
	coords := [][]float64{
		{38.5, -120.2},
		{40.7, -120.95},
		{43.252, -126.453},
	}
	fmt.Println(string(polyline.EncodeCoords(coords)))
	// Output: _p~iF~ps|U_ulLnnqC_mqNvxq`@
}

Decoding example

func ExampleDecodeCoords() {
	buf := []byte("_p~iF~ps|U_ulLnnqC_mqNvxq`@")
	coords, _, _ := polyline.DecodeCoords(buf)
	fmt.Println(coords)
	// Output: [[38.5 -120.2] [40.7 -120.95] [43.252 -126.453]]
}

License

BSD-2-Clause

# Functions

DecodeCoord decodes a single coordinate from buf using the default codec.
DecodeCoords decodes an array of coordinates from buf using the default codec.
DecodeInt decodes a single signed integer from buf.
DecodeUint decodes a single unsigned integer from buf.
EncodeCoord returns the encoding of an array of coordinates using the default codec.
EncodeCoords returns the encoding of an array of coordinates using the default codec.
EncodeInt appends the encoding of a single signed integer i to buf and returns the new buf.
EncodeUint appends the encoding of a single unsigned integer u to buf and returns the new buf.

# Variables

# Structs

A Codec represents an encoder.