routing-service/encoding/polylines/encoding.go

18 lines
330 B
Go
Raw Normal View History

2023-03-27 18:57:28 +00:00
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))
}