position

package
v0.0.0-...-abdf720 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceletNatsSubject = "train.tracelet"
	GpsNatsSubject      = "train.gps"
)

Variables

View Source
var (
	RegisterSiteNatsTopic = "site.register"
)

Functions

This section is empty.

Types

type Coordinates

type Coordinates struct {
	Lat float64 `json:"lat"`
	Lon float64 `json:"lng"`
}

type GpsMessage

type GpsMessage struct {
	ID          string      `json:"id"`
	Coordinates Coordinates `json:"coordinates"`
}

type Position

type Position struct {
	Lat  float64 `json:"lat"`
	Lon  float64 `json:"lon"`
	Hres bool    `json:"hres"`
}

type SiteInfo

type SiteInfo struct {
	SiteId string        `json:"id"`
	Zero   Coordinates   `json:"zero"`
	Area   []Coordinates `json:"area"`
}

type SiteManager

type SiteManager struct {
	// contains filtered or unexported fields
}

func NewSiteManager

func NewSiteManager() (*SiteManager, error)

NewSiteManager will return an new SiteManager object. The state file can be passed by env variable SITES_STATE_FILE. If no state file is passed, a temporary file will be created.

func (*SiteManager) RegisterHandler

func (c *SiteManager) RegisterHandler(msg *nats.Msg)

func (*SiteManager) RegisterSite

func (s *SiteManager) RegisterSite(siteInfo SiteInfo) error

type TraceletMessage

type TraceletMessage struct {
	X       float64 `json:"x"`
	Y       float64 `json:"y"`
	SiteID  string  `json:"site-id"`
	TrainID string  `json:"train-id"`
}

type TrainPosition

type TrainPosition struct {
	ID       string   `json:"id"`
	SiteID   string   `json:"site-id"`
	Position Position `json:"position"`
}

func GpsToTrainPositon

func GpsToTrainPositon(gpsData GpsMessage) TrainPosition

GpsToTrainPositon convert GpsMessage to Position struct

func TraceletToTrainPosition

func TraceletToTrainPosition(traceletData TraceletMessage, siteManager *SiteManager) (TrainPosition, error)

TraceletToTrainPosition convert TraceletMessage to Position struct

Jump to

Keyboard shortcuts

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