Valhalla structs
Build and Push Docker Image / build_and_push (push) Successful in 4m1s
Details
Build and Push Docker Image / build_and_push (push) Successful in 4m1s
Details
This commit is contained in:
parent
0139ebdf72
commit
11405e2a99
284
valhalla.go
284
valhalla.go
|
@ -1,258 +1,52 @@
|
||||||
package valhalla
|
package valhalla
|
||||||
|
|
||||||
// #cgo LDFLAGS: -L/usr/local/lib/ -lvalhalla-go
|
type ValhallaHandler struct {
|
||||||
// #include <stdio.h>
|
Actor *Actor
|
||||||
// #include <stdlib.h>
|
|
||||||
// #include "./bindings/valhalla_go.h"
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Actor struct {
|
|
||||||
ptr unsafe.Pointer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewActorFromFile(configPath string) (*Actor, error) {
|
func NewValhallaHandler() (*ValhallaHandler, error) {
|
||||||
var isError uint8 = 0
|
actor, err := NewActorFromConfig(DefaultConfig())
|
||||||
cs := C.CString(configPath)
|
if err != nil {
|
||||||
resp := C.actor_init_from_file(cs, (*C.char)(unsafe.Pointer(&isError)))
|
return nil, err
|
||||||
C.free(unsafe.Pointer(cs))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return &Actor{ptr: unsafe.Pointer(resp)}, nil
|
|
||||||
case 1:
|
|
||||||
err := C.GoString((*C.char)(resp))
|
|
||||||
C.free(unsafe.Pointer(resp))
|
|
||||||
return nil, errors.New(err)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return nil, errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return &ValhallaHandler{
|
||||||
|
Actor: actor,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewActorFromConfig(config *Config) (*Actor, error) {
|
func (h *ValhallaHandler) Route(input ValhallaRouteInput) (*ValhallaRouteResponse, error) {
|
||||||
var isError uint8 = 0
|
return nil, nil
|
||||||
cs := C.CString(config.String())
|
|
||||||
resp := C.actor_init_from_config(cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
C.free(unsafe.Pointer(cs))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return &Actor{ptr: unsafe.Pointer(resp)}, nil
|
|
||||||
case 1:
|
|
||||||
err := C.GoString((*C.char)(resp))
|
|
||||||
C.free(unsafe.Pointer(resp))
|
|
||||||
return nil, errors.New(err)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return nil, errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (actor *Actor) Centroid(request string) (string, error) {
|
type ValhallaRouteInput struct {
|
||||||
var isError uint8 = 0
|
Locations []ValhallaLocation `json:"locations"`
|
||||||
cs := C.CString(request)
|
Costing *string `json:"costing,omitempty"`
|
||||||
cresp := C.actor_centroid((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
CostingOptions *ValhallaCostingOptions `json:"costing_options,omitempty"`
|
||||||
resp := C.GoString(cresp)
|
Language *string `json:"language,omitempty"`
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (actor *Actor) Expansion(request string) (string, error) {
|
type ValhallaRouteResponse struct{}
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
type ValhallaLocation struct {
|
||||||
cresp := C.actor_expansion((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
Lat float64 `json:"lat"`
|
||||||
resp := C.GoString(cresp)
|
Lon float64 `json:"lon"`
|
||||||
C.free(unsafe.Pointer(cresp))
|
Type *string `json:"type,omitempty"`
|
||||||
switch isError {
|
Heading *string `json:"heading,omitempty"`
|
||||||
case 0:
|
HeadingTolerance *string `json:"heading_tolerance,omitempty"`
|
||||||
return resp, nil
|
Street *string `json:"street,omitempty"`
|
||||||
case 1:
|
Radius *int64 `json:"radius,omitempty"`
|
||||||
return "", errors.New(resp)
|
RankCandidates *bool `json:"rank_candidates,omitempty"`
|
||||||
default:
|
PreferedSide *string `json:"prefered_side"`
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
// DisplayLat
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
// DisplayLon
|
||||||
}
|
// SearchCutoff
|
||||||
|
// NodeSnapTolerance
|
||||||
|
// StreetSideTolerance
|
||||||
|
// StreetSideMaxDistance
|
||||||
|
// StreetSideCutoff
|
||||||
|
// SearchFilters
|
||||||
|
// PreferredLayer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (actor *Actor) Height(request string) (string, error) {
|
type ValhallaCostingOptions struct{}
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_height((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) Isochrone(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_isochrone((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) Locate(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_locate((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) Matrix(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_matrix((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) OptimizedRoute(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_optimized_route((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) Route(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_route((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) Status(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_status((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) TraceAttributes(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_trace_attributes((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) TraceRoute(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_trace_route((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (actor *Actor) TransitAvailable(request string) (string, error) {
|
|
||||||
var isError uint8 = 0
|
|
||||||
cs := C.CString(request)
|
|
||||||
cresp := C.actor_transit_available((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
|
||||||
resp := C.GoString(cresp)
|
|
||||||
C.free(unsafe.Pointer(cresp))
|
|
||||||
switch isError {
|
|
||||||
case 0:
|
|
||||||
return resp, nil
|
|
||||||
case 1:
|
|
||||||
return "", errors.New(resp)
|
|
||||||
default:
|
|
||||||
log.Panic().Msg("Invalid error code from valhalla C binding")
|
|
||||||
return "", errors.New("Invalid error code from valhalla C binding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,258 @@
|
||||||
|
package valhalla
|
||||||
|
|
||||||
|
// #cgo LDFLAGS: -L/usr/local/lib/ -llibvalhalla-go
|
||||||
|
// #include <stdio.h>
|
||||||
|
// #include <stdlib.h>
|
||||||
|
// #include "./bindings/valhalla_go.h"
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Actor struct {
|
||||||
|
ptr unsafe.Pointer
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewActorFromFile(configPath string) (*Actor, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(configPath)
|
||||||
|
resp := C.actor_init_from_file(cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
C.free(unsafe.Pointer(cs))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return &Actor{ptr: unsafe.Pointer(resp)}, nil
|
||||||
|
case 1:
|
||||||
|
err := C.GoString((*C.char)(resp))
|
||||||
|
C.free(unsafe.Pointer(resp))
|
||||||
|
return nil, errors.New(err)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return nil, errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewActorFromConfig(config *Config) (*Actor, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(config.String())
|
||||||
|
resp := C.actor_init_from_config(cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
C.free(unsafe.Pointer(cs))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return &Actor{ptr: unsafe.Pointer(resp)}, nil
|
||||||
|
case 1:
|
||||||
|
err := C.GoString((*C.char)(resp))
|
||||||
|
C.free(unsafe.Pointer(resp))
|
||||||
|
return nil, errors.New(err)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return nil, errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) Centroid(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_centroid((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) Expansion(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_expansion((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) Height(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_height((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) Isochrone(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_isochrone((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) Locate(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_locate((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) Matrix(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_matrix((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) OptimizedRoute(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_optimized_route((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) Route(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_route((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) Status(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_status((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) TraceAttributes(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_trace_attributes((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) TraceRoute(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_trace_route((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (actor *Actor) TransitAvailable(request string) (string, error) {
|
||||||
|
var isError uint8 = 0
|
||||||
|
cs := C.CString(request)
|
||||||
|
cresp := C.actor_transit_available((C.Actor)(actor.ptr), cs, (*C.char)(unsafe.Pointer(&isError)))
|
||||||
|
resp := C.GoString(cresp)
|
||||||
|
C.free(unsafe.Pointer(cresp))
|
||||||
|
switch isError {
|
||||||
|
case 0:
|
||||||
|
return resp, nil
|
||||||
|
case 1:
|
||||||
|
return "", errors.New(resp)
|
||||||
|
default:
|
||||||
|
log.Panic().Msg("Invalid error code from valhalla C binding")
|
||||||
|
return "", errors.New("Invalid error code from valhalla C binding")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue