twpayne/go-polyline

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

Go

122

124 commits

updated Apr 11, 2026

See the code

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

decoding
encoding
geospatial
gis
go
golang
google-maps
polyline

Significant stargazers

Ernie Hershey

117 followers · starred Dec 2023

Mike Guida

103 followers · starred Jul 2024

twpayne/go-polyline

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

Go

122

124 commits

updated Apr 11, 2026

See the code

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

decoding
encoding
geospatial
gis
go
golang
google-maps
polyline

Significant stargazers

Ernie Hershey

117 followers · starred Dec 2023

Mike Guida

103 followers · starred Jul 2024

Languages

Go

100.0%