routing

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2022 License: Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MONGO_EVENT_CREATED = iota + 1
	MONGO_EVENT_READ
	MONGO_EVENT_UPDATED
	MONGO_EVENT_DELETED
)
View Source
const (
	ORDER_PLANNED = iota + 1
	ORDER_PROCESSING
	ORDER_STARTED
	ORDER_FINISHED
)
View Source
const (
	STOPPED = iota + 1
	RUNNING
	PAUSED
	PREPARING

	STARTED
	FINISHED
	HOMEWARD
	OUTWARD
	RESTING
)
View Source
const DIRECTED_GRAPH = false

directed graph uses oneway, causes problems

Variables

View Source
var FLEET_SERVCICE_URL string
View Source
var MESSAGING_SERVCICE_URL string
View Source
var ROUTING_SERVCICE_URL string
View Source
var SEARCH_SERVCICE_URL string

Functions

func CreateClient

func CreateClient() *http.Client

func GetClient

func GetClient() *http.Client

func SendMongoEvent

func SendMongoEvent(id string, collection string, mongoEventType MongoEventType)

Types

type ActionType

type ActionType int

type Base

type Base struct {
	ID   primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty" db:"id"`
	Name string             `json:"name" bson:"name" db:"name"`
	Geom Geometry           `json:"geometry" bson:"geom"`
}

type Feature

type Feature struct {
	ID         string      `json:"_id,omitempty" bson:"_id,omitempty"`
	Type       string      `json:"type" bson:"type"`
	Geom       Geometry    `json:"geometry" bson:"geom"`
	Properties interface{} `json:"properties" bson:"properties"`
}

type FeatureCollection

type FeatureCollection struct {
	ID       string     `json:"_id,omitempty" bson:"_id,omitempty"`
	Type     string     `json:"type" bson:"type"`
	Features *[]Feature `json:"features" bson:"features"`
	Name     string     `json:"name" bson:"name"`
}

func ReadAllPOIs

func ReadAllPOIs() (*FeatureCollection, error)

type Fleet

type Fleet struct {
	ID     primitive.ObjectID `json:"id" bson:"_id" db:"id"`
	Trucks map[string]*Truck
	Orders map[string]*Order
}

func GetFleetInstance

func GetFleetInstance() *Fleet

func (Fleet) FindFreeTruck

func (fleet Fleet) FindFreeTruck() []*Truck

func (Fleet) StartOrder

func (fleet Fleet) StartOrder(orderName string, truckName string, startNodeId int) error

type Geometry

type Geometry struct {
	Type        string    `json:"type" bson:"type"`
	Coordinates []float64 `json:"coordinates" bson:"coordinates"`
}

{"type":"Point","coordinates":[12.4045328,51.7979734]}

type MongoEvent

type MongoEvent struct {
	ID         string         `json:"id" bson:"_id"`
	Collection string         `json:"collection" bson:"collection"`
	Type       MongoEventType `json:"type" bson:"type"`
	Time       time.Time      `json:"time" bson:"time"`
}

type MongoEventType

type MongoEventType int

type Node

type Node struct {
	ID  int64   `json:"id" bson:"_id" db:"id"`
	Lon float64 `json:"lon" bson:"lon" db:"lon"`
	Lat float64 `json:"lat" bson:"lat" db:"lat"`
}

func FindNearestNodeForPOI

func FindNearestNodeForPOI(id int) (*Node, error)

type Order

type Order struct {
	ID         primitive.ObjectID `json:"id" bson:"_id" db:"id"`
	Name       string             `json:"name" bson:"name" db:"name"`
	OrderState OrderState         `json:"state" bson:"state" db:"-"`
	StartTime  time.Time          `json:"starttime" bson:"starttime" db:"starttime"`
	EndTime    time.Time          `json:"endtime" bson:"endtime" db:"endtime"`
	Tsp        *Tsp               `json:"-" bson:"-" db:"-"`
	TruckID    primitive.ObjectID `json:"truckid" bson:"_truckid" db:"truckid"`
}

func NewOrder

func NewOrder(name string) *Order

func (*Order) AssignTruck

func (order *Order) AssignTruck(truckID primitive.ObjectID)

func (*Order) RequestTSP

func (order *Order) RequestTSP(startNodeId int) error

type OrderState

type OrderState int

type POI

type POI struct {
	ID       int64  `json:"id" bson:"_id" db:"fid"`
	Osm_ID   int64  `json:"osm_id" bson:"osm_id" db:"osm_id"`
	Name     string `json:"name" bson:"name"`
	GeomJSON string `db:"geom" json:"-"`
}

type Place

type Place struct {
	ID          primitive.ObjectID `json:"id" bson:"_id" db:"id"`
	Name        string             `json:"name" bson:"name" db:"name"`
	Geometry    Geometry           `json:"geom" bson:"geom" db:"geom"`
	OsmId       int64              `json:"osm_id" bson:"osm_id" db:"osm_id"`
	Description string             `json:"description" bson:"description" db:"description"`
}

func NewPlace

func NewPlace(name string) *Place

type Position

type Position struct {
	Lon float64 `json:"lon" bson:"lon"`
	Lat float64 `json:"lat" bson:"lat"`
}

type PositionEvent

type PositionEvent struct {
	ID       primitive.ObjectID `json:"id" bson:"_id"`
	Name     string             `json:"name" bson:"name"`
	Position Position           `json:"pos" bson:"pos"`
	Time     time.Time          `json:"time" bson:"time"`
}

type Route

type Route struct {
	ID          int64       `json:"id" bson:"_id"`
	Name        string      `json:"name" bson:"name"`
	Source      int         `json:"source" bson:"source"`
	Target      int         `json:"target" bson:"target"`
	Type        string      `json:"type" bson:"type"`
	Coordinates [][]float64 `json:"coordinates" bson:"coordinates"`
}

type RouteEvent

type RouteEvent struct {
	ID    primitive.ObjectID `json:"id" bson:"_id"`
	Name  string             `json:"name" bson:"name"`
	Route Route              `json:"route" bson:"route"`
}

type Truck

type Truck struct {
	ID         primitive.ObjectID `json:"id" bson:"_id" db:"id"`
	Name       string             `json:"name" bson:"name" db:"name"`
	Position   *Position          `json:"pos" bson:"-" db:"-"`
	Route      *Route             `json:"route" bson:"-" db:"-"`
	Base       *Base              `json:"base" bson:"base" db:"base"`
	ActionType ActionType         `json:"action" bson:"action" db:"-"`
}

func NewTruck

func NewTruck(name string) *Truck

func (*Truck) SetActionType

func (truck *Truck) SetActionType(ActionType ActionType)

func (*Truck) SetRoute

func (truck *Truck) SetRoute(route *Route)

func (*Truck) StartOrder

func (truck *Truck) StartOrder(order *Order)

type TruckActionEvent

type TruckActionEvent struct {
	ID         primitive.ObjectID `json:"id" bson:"_id"`
	Name       string             `json:"name" bson:"name"`
	ActionType ActionType         `json:"action" bson:"action"`
}

type Tsp

type Tsp struct {
	Start  int       `json:"start" bson:"start"`
	Steps  []TspStep `json:"steps" bson:"steps"`
	Places string    `json:"places" bson:"places"`
}

func CalculateTSP

func CalculateTSP(start int, ids string) (*Tsp, error)

ids []int

type TspStep

type TspStep struct {
	Seq     int     `json:"seq" bson:"seq"`
	Node    int64   `json:"node" bson:"node"`
	Cost    float64 `json:"cost" bson:"cost"`
	AggCost float64 `json:"agg_cost" bson:"agg_cost"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL