routing-service/routing.go

36 lines
596 B
Go
Raw Normal View History

2023-03-27 18:57:28 +00:00
package routing
import (
"fmt"
2023-03-29 10:51:09 +00:00
"time"
2023-03-27 18:57:28 +00:00
"github.com/paulmach/orb"
)
type RoutingService interface {
Route(locations []orb.Point) (route *Route, err error)
}
func NewRoutingService(service_type string, baseUrl string) (RoutingService, error) {
if service_type == "valhalla" {
return NewValhallaRouting(baseUrl)
}
return nil, fmt.Errorf("%s routing service not supported", service_type)
}
type Route struct {
Summary RouteSummary
2023-03-29 10:51:09 +00:00
Legs []RouteLeg
2023-03-27 18:57:28 +00:00
}
type RouteSummary struct {
Polyline string
}
2023-03-29 10:51:09 +00:00
type RouteLeg struct {
Distance float64
Duration time.Duration
Polyline string
}