routing-service/encoding/polylines/encoding.go

18 lines
330 B
Go

package polylines
import (
"github.com/paulmach/orb"
"github.com/twpayne/go-polyline"
)
func Encode(line orb.LineString) string {
preparedLine := [][]float64{}
for _, point := range line {
preparedLine = append(preparedLine, []float64{point.Lon(), point.Lat()})
}
return string(polyline.EncodeCoords(preparedLine))
}