项目作者: twpayne

项目描述 :
Package polyline implements a Google Maps Encoding Polyline encoder and decoder.
高级语言: Go
项目地址: git://github.com/twpayne/go-polyline.git
创建时间: 2014-04-27T18:32:05Z
项目社区:https://github.com/twpayne/go-polyline

开源协议:BSD 2-Clause "Simplified" License

下载


go-polyline

Build Status
PkgGoDev
Coverage Status

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

Encoding example

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

Decoding example

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

License

BSD-2-Clause