navigator

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinOffline   = 0
	MaxOffline   = 3600
	MinElevation = 0.0
	MaxElevation = 50000.0
)
View Source
const (
	MinNameValue = 3
	MaxNameValue = 256
)

Variables

View Source
var ErrInvalidRoutePath = errors.New("gpsgen/navigator: route is too short")

ErrInvalidRoutePath indicates that a route has an invalid or too short path.

View Source
var ErrNoRoutes = errors.New("gpsgen/navigator: no routes")

ErrNoRoutes indicates that no routes are available.

View Source
var ErrRouteNotFound = errors.New("gpsgen/navigator: route not found")

ErrRouteNotFound indicates that a specified route was not found.

View Source
var ErrTrackNotFound = errors.New("gpsgen/navigator: track not found")

ErrTrackNotFound indicates that a specified track was not found.

Functions

func TrackFromSnapshot

func TrackFromSnapshot(track *Track, snap *TrackSnapshot)

TrackFromSnapshot restores a track from a snapshot.

Types

type Name

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

Name represents a name used in the navigator.

func ParseName

func ParseName(name string) (Name, error)

ParseName parses the given string and returns a Name instance. An error is returned if the name is invalid.

func (Name) IsEmpty

func (t Name) IsEmpty() bool

IsEmpty checks if the Name instance is empty.

func (Name) String

func (t Name) String() string

IsEmpty checks if the Name instance is empty.

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

Navigator manages navigation operations and state.

func New

func New(opts ...Option) (*Navigator, error)

New creates a new instance of Navigator with the provided options.

func (n *Navigator) AddRoute(routes ...*Route) error

AddRoute adds one or more routes to the navigator.

func (n *Navigator) CurrentBearing() float64

CurrentBearing returns the current bearing of the navigator.

func (n *Navigator) CurrentDistance() float64

CurrentDistance returns the current accumulated distance.

func (n *Navigator) CurrentRoute() *Route

CurrentRoute returns the current route.

func (n *Navigator) CurrentRouteDistance() float64

CurrentRouteDistance returns the current accumulated distance of the current route.

func (n *Navigator) CurrentSegment() Segment

CurrentSegment returns the current segment.

func (n *Navigator) CurrentSegmentDistance() float64

CurrentSegmentDistance returns the current accumulated distance of the current segment.

func (n *Navigator) CurrentTrack() *Track

CurrentTrack returns the current track.

func (n *Navigator) CurrentTrackDistance() float64

CurrentTrackDistance returns the current accumulated distance of the current track.

func (n *Navigator) DestinationTo(meters float64) bool

DestinationTo moves the navigator to a destination specified by distance.

func (n *Navigator) Distance() float64

Distance returns the total distance of the navigator's routes.

func (n *Navigator) EachRoute(fn func(int, *Route) bool)

EachRoute iterates through each route and invokes the provided function.

func (n *Navigator) Elevation() float64

Elevation returns the current elevation.

func (n *Navigator) FromSnapshot(snap *proto.Snapshot_Navigator)

FromSnapshot restores the navigator's state from a snapshot.

func (n *Navigator) IsFinish() bool

IsFinish checks if the navigator has finished its navigation path.

func (n *Navigator) IsOffline() bool

IsOffline checks if the navigator is in offline mode.

func (n *Navigator) Location() geo.LatLonPoint

Location returns the current geographic location of the navigator.

func (n *Navigator) MoveToRoute(routeIndex int) bool

MoveToRoute moves to a route specified by its index.

func (n *Navigator) MoveToRouteByID(routeID string) bool

MoveToRouteByID moves to a route specified by its ID.

func (n *Navigator) MoveToSegment(routeIndex int, trackIndex int, segmentIndex int) bool

MoveToSegment moves to a segment within a track within a route specified by indices.

func (n *Navigator) MoveToTrack(routeIndex int, trackIndex int) bool

MoveToTrack moves to a track within a route specified by indices.

func (n *Navigator) MoveToTrackByID(routeID string, trackID string) bool

MoveToRouteByID moves to a route specified by its ID.

func (n *Navigator) NextElevation(tick float64)

NextElevation updates the next elevation.

func (n *Navigator) NextLocation(tick float64, speed float64) (ok bool)

NextLocation updates the navigator's location based on the provided tick and speed.

func (n *Navigator) NextRoute() bool

NextRoute moves to the next route.

func (n *Navigator) NumRoutes() int

NumRoutes returns the number of routes in the navigator.

func (n *Navigator) OfflineDuration() int

OfflineDuration returns the remaining offline duration.

func (n *Navigator) PrevRoute() bool

PrevRoute moves to the previous route.

func (n *Navigator) RemoveRoute(routeID string) (ok bool)

RemoveRoute removes a route by its ID.

func (n *Navigator) RemoveTrack(routeID string, trackID string) bool

RemoveTrack removes a track from a route.

func (n *Navigator) Reset()
func (n *Navigator) ResetRoutes() bool

ResetRoutes resets all routes in the navigator.

func (n *Navigator) RouteAt(index int) *Route

RouteAt returns the route at the specified index.

func (n *Navigator) RouteByID(routeID string) (*Route, error)

RouteByID retrieves a route by its ID.

func (n *Navigator) RouteDistance() float64

RouteDistance returns the distance of the current route.

func (n *Navigator) RouteIndex() int

RouteIndex returns the index of the current route.

func (n *Navigator) SegmentDistance() float64

SegmentDistance returns the distance of the current segment.

func (n *Navigator) SegmentIndex() int

SegmentIndex returns the index of the current segment.

func (n *Navigator) Snapshot() *proto.Snapshot_Navigator

Snapshot creates a snapshot of the navigator's state.

func (n *Navigator) Sum() [3]int

Sum calculates and returns a summary of versions for the navigator, routes, and tracks.

func (n *Navigator) ToOffline()

ToOffline puts the navigator into offline mode.

func (n *Navigator) TrackDistance() float64

TrackDistance returns the distance of the current track.

func (n *Navigator) TrackIndex() int

TrackIndex returns the index of the current track.

func (n *Navigator) Update(state *proto.Device)

Update updates the navigator's state in the provided Device proto message.

type Option

type Option func(*navigatorOptions)

Option is a function type that modifies navigatorOptions.

func SkipOfflineMode

func SkipOfflineMode() Option

SkipOfflineMode skips offline mode in the navigator.

func WithElevation

func WithElevation(min, max float64, amplitude int, mode types.SensorMode) Option

WithElevation sets the elevation options for the navigator.

func WithOffline

func WithOffline(min, max int) Option

WithOffline sets the offline time options for the navigator.

type Route

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

Route represents a route containing tracks and associated properties.

func NewRoute

func NewRoute() *Route

NewRoute creates a new Route instance with default values.

func RestoreRoute

func RestoreRoute(
	routeID string,
	color string,
	props properties.Properties,
) *Route

RestoreRoute restores a Route instance with the given parameters.

func RouteFromTracks

func RouteFromTracks(tracks ...*Track) *Route

RouteFromTracks creates a new Route instance from a list of tracks.

func (*Route) AddTrack

func (r *Route) AddTrack(track *Track) *Route

AddTrack adds a track to the route.

func (*Route) ChangeColor

func (r *Route) ChangeColor(color colorful.Color) error

ChangeColor changes the color of the route.

func (*Route) ChangeName

func (r *Route) ChangeName(name string) error

ChangeName changes the name of the route.

func (*Route) Color

func (r *Route) Color() string

Color returns the color of the route.

func (*Route) Distance

func (r *Route) Distance() float64

Distance returns the total distance of the route.

func (*Route) EachTrack

func (r *Route) EachTrack(fn func(int, *Track) bool)

EachTrack iterates through each track in the route and applies a function.

func (*Route) ID

func (r *Route) ID() string

ID returns the ID of the route.

func (*Route) Name

func (r *Route) Name() Name

Name returns the name of the route.

func (*Route) NumTracks

func (r *Route) NumTracks() int

NumTracks returns the number of tracks in the route.

func (*Route) Props

func (r *Route) Props() properties.Properties

Props returns the properties associated with the route.

func (*Route) RemoveTrack

func (r *Route) RemoveTrack(trackID string) (ok bool)

RemoveTrack removes a track from the route.

func (*Route) RouteFromSnapshot

func (r *Route) RouteFromSnapshot(snap *RouteSnapshot) error

RouteFromSnapshot restores a route from a snapshot.

func (*Route) Snapshot

func (r *Route) Snapshot() *RouteSnapshot

Snapshot creates a snapshot of the route.

func (*Route) TrackAt

func (r *Route) TrackAt(i int) *Track

TrackAt returns the track at the specified index.

func (*Route) TrackByID

func (r *Route) TrackByID(trackID string) (*Track, error)

TrackByID returns the track with the specified ID.

type RouteSnapshot

type RouteSnapshot = proto.Snapshot_Navigator_Route

RouteSnapshot is a serialized snapshot of a Route.

type Segment

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

Segment represents a segment between two geographical points in a track.

func SegmentFromSnapshot

func SegmentFromSnapshot(snap *SegmentSnapshot) Segment

SegmentFromSnapshot restores a segment from a snapshot.

func (Segment) Bearing

func (s Segment) Bearing() float64

Bearing returns the bearing (direction) of the segment in degrees.

func (Segment) DestinationTo

func (s Segment) DestinationTo(meters float64) geo.LatLonPoint

DestinationTo calculates the destination point from the starting point given a certain distance and bearing.

func (Segment) Distance

func (s Segment) Distance() float64

Distance returns the distance of the segment.

func (Segment) Index

func (s Segment) Index() int

Index returns the index of the segment.

func (Segment) IsEmpty

func (s Segment) IsEmpty() bool

IsEmpty checks if the segment is empty (distance is zero).

func (Segment) PointA

func (s Segment) PointA() geo.LatLonPoint

PointA returns the starting point of the segment.

func (Segment) PointB

func (s Segment) PointB() geo.LatLonPoint

PointB returns the ending point of the segment.

func (Segment) Snapshot

func (s Segment) Snapshot() *SegmentSnapshot

Snapshot returns a serialized snapshot of the segment.

type SegmentSnapshot

SegmentSnapshot is a serialized snapshot of a Segment.

type Track

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

Track represents a track composed of segments.

func NewTrack

func NewTrack(points []geo.LatLonPoint) (*Track, error)

NewTrack creates a new Track instance from a list of geographical points.

func RestoreTrack

func RestoreTrack(trackID, color string, points []geo.LatLonPoint) (*Track, error)

RestoreTrack restores a track from a snapshot.

func (*Track) ChangeColor

func (t *Track) ChangeColor(color string) error

ChangeColor changes the color of the track.

func (*Track) ChangeName

func (t *Track) ChangeName(name string) error

ChangeName changes the name of the track.

func (*Track) Color

func (t *Track) Color() string

Color returns the color of the track.

func (*Track) Distance

func (t *Track) Distance() float64

Distance returns the distance of the track.

func (*Track) ID

func (t *Track) ID() string

ID returns the ID of the track.

func (*Track) IsClosed

func (t *Track) IsClosed() bool

IsClosed checks if the track is closed.

func (*Track) Name

func (t *Track) Name() Name

Name returns the name of the track.

func (*Track) NumSegments

func (t *Track) NumSegments() int

NumSegments returns the number of segments in the track.

func (*Track) Props

func (t *Track) Props() properties.Properties

Props returns the properties of the track.

func (*Track) SegmentAt

func (t *Track) SegmentAt(i int) Segment

SegmentAt returns the segment at the specified index.

func (*Track) Snapshot

func (t *Track) Snapshot() *TrackSnapshot

Snapshot returns a serialized snapshot of the track.

type TrackSnapshot

type TrackSnapshot = proto.Snapshot_Navigator_Route_Track

TrackSnapshot is a serialized snapshot of a Track.

Jump to

Keyboard shortcuts

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