Documentation ¶
Index ¶
- Constants
- Variables
- func TrackFromSnapshot(track *Track, snap *TrackSnapshot)
- type Name
- type Navigator
- func (n *Navigator) AddRoute(routes ...*Route) error
- func (n *Navigator) CurrentBearing() float64
- func (n *Navigator) CurrentDistance() float64
- func (n *Navigator) CurrentRoute() *Route
- func (n *Navigator) CurrentRouteDistance() float64
- func (n *Navigator) CurrentSegment() Segment
- func (n *Navigator) CurrentSegmentDistance() float64
- func (n *Navigator) CurrentTrack() *Track
- func (n *Navigator) CurrentTrackDistance() float64
- func (n *Navigator) DestinationTo(meters float64) bool
- func (n *Navigator) Distance() float64
- func (n *Navigator) EachRoute(fn func(int, *Route) bool)
- func (n *Navigator) Elevation() float64
- func (n *Navigator) FromSnapshot(snap *proto.Snapshot_Navigator)
- func (n *Navigator) IsFinish() bool
- func (n *Navigator) IsOffline() bool
- func (n *Navigator) Location() geo.LatLonPoint
- func (n *Navigator) MoveToRoute(routeIndex int) bool
- func (n *Navigator) MoveToRouteByID(routeID string) bool
- func (n *Navigator) MoveToSegment(routeIndex int, trackIndex int, segmentIndex int) bool
- func (n *Navigator) MoveToTrack(routeIndex int, trackIndex int) bool
- func (n *Navigator) MoveToTrackByID(routeID string, trackID string) bool
- func (n *Navigator) NextElevation(tick float64)
- func (n *Navigator) NextLocation(tick float64, speed float64) (ok bool)
- func (n *Navigator) NextRoute() bool
- func (n *Navigator) NumRoutes() int
- func (n *Navigator) OfflineDuration() int
- func (n *Navigator) PrevRoute() bool
- func (n *Navigator) RemoveRoute(routeID string) (ok bool)
- func (n *Navigator) RemoveTrack(routeID string, trackID string) bool
- func (n *Navigator) Reset()
- func (n *Navigator) ResetRoutes() bool
- func (n *Navigator) RouteAt(index int) *Route
- func (n *Navigator) RouteByID(routeID string) (*Route, error)
- func (n *Navigator) RouteDistance() float64
- func (n *Navigator) RouteIndex() int
- func (n *Navigator) SegmentDistance() float64
- func (n *Navigator) SegmentIndex() int
- func (n *Navigator) Snapshot() *proto.Snapshot_Navigator
- func (n *Navigator) Sum() [3]int
- func (n *Navigator) ToOffline()
- func (n *Navigator) TrackDistance() float64
- func (n *Navigator) TrackIndex() int
- func (n *Navigator) Update(state *proto.Device)
- type Option
- type Route
- func (r *Route) AddTrack(track *Track) *Route
- func (r *Route) ChangeColor(color colorful.Color) error
- func (r *Route) ChangeName(name string) error
- func (r *Route) Color() string
- func (r *Route) Distance() float64
- func (r *Route) EachTrack(fn func(int, *Track) bool)
- func (r *Route) ID() string
- func (r *Route) Name() Name
- func (r *Route) NumTracks() int
- func (r *Route) Props() properties.Properties
- func (r *Route) RemoveTrack(trackID string) (ok bool)
- func (r *Route) RouteFromSnapshot(snap *RouteSnapshot) error
- func (r *Route) Snapshot() *RouteSnapshot
- func (r *Route) TrackAt(i int) *Track
- func (r *Route) TrackByID(trackID string) (*Track, error)
- type RouteSnapshot
- type Segment
- func (s Segment) Bearing() float64
- func (s Segment) DestinationTo(meters float64) geo.LatLonPoint
- func (s Segment) Distance() float64
- func (s Segment) Index() int
- func (s Segment) IsEmpty() bool
- func (s Segment) PointA() geo.LatLonPoint
- func (s Segment) PointB() geo.LatLonPoint
- func (s Segment) Snapshot() *SegmentSnapshot
- type SegmentSnapshot
- type Track
- func (t *Track) ChangeColor(color string) error
- func (t *Track) ChangeName(name string) error
- func (t *Track) Color() string
- func (t *Track) Distance() float64
- func (t *Track) ID() string
- func (t *Track) IsClosed() bool
- func (t *Track) Name() Name
- func (t *Track) NumSegments() int
- func (t *Track) Props() properties.Properties
- func (t *Track) SegmentAt(i int) Segment
- func (t *Track) Snapshot() *TrackSnapshot
- type TrackSnapshot
Constants ¶
const ( MinOffline = 0 MaxOffline = 3600 MinElevation = 0.0 MaxElevation = 50000.0 )
const ( MinNameValue = 3 MaxNameValue = 256 )
Variables ¶
var ErrInvalidRoutePath = errors.New("gpsgen/navigator: route is too short")
ErrInvalidRoutePath indicates that a route has an invalid or too short path.
var ErrNoRoutes = errors.New("gpsgen/navigator: no routes")
ErrNoRoutes indicates that no routes are available.
var ErrRouteNotFound = errors.New("gpsgen/navigator: route not found")
ErrRouteNotFound indicates that a specified route was not found.
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.
type Navigator ¶
type Navigator struct {
// contains filtered or unexported fields
}
Navigator manages navigation operations and state.
func (*Navigator) CurrentBearing ¶
CurrentBearing returns the current bearing of the navigator.
func (*Navigator) CurrentDistance ¶
CurrentDistance returns the current accumulated distance.
func (*Navigator) CurrentRoute ¶
CurrentRoute returns the current route.
func (*Navigator) CurrentRouteDistance ¶
CurrentRouteDistance returns the current accumulated distance of the current route.
func (*Navigator) CurrentSegment ¶
CurrentSegment returns the current segment.
func (*Navigator) CurrentSegmentDistance ¶
CurrentSegmentDistance returns the current accumulated distance of the current segment.
func (*Navigator) CurrentTrack ¶
CurrentTrack returns the current track.
func (*Navigator) CurrentTrackDistance ¶
CurrentTrackDistance returns the current accumulated distance of the current track.
func (*Navigator) DestinationTo ¶
DestinationTo moves the navigator to a destination specified by distance.
func (*Navigator) EachRoute ¶
EachRoute iterates through each route and invokes the provided function.
func (*Navigator) FromSnapshot ¶
func (n *Navigator) FromSnapshot(snap *proto.Snapshot_Navigator)
FromSnapshot restores the navigator's state from a snapshot.
func (*Navigator) Location ¶
func (n *Navigator) Location() geo.LatLonPoint
Location returns the current geographic location of the navigator.
func (*Navigator) MoveToRoute ¶
MoveToRoute moves to a route specified by its index.
func (*Navigator) MoveToRouteByID ¶
MoveToRouteByID moves to a route specified by its ID.
func (*Navigator) MoveToSegment ¶
MoveToSegment moves to a segment within a track within a route specified by indices.
func (*Navigator) MoveToTrack ¶
MoveToTrack moves to a track within a route specified by indices.
func (*Navigator) MoveToTrackByID ¶
MoveToRouteByID moves to a route specified by its ID.
func (*Navigator) NextElevation ¶
NextElevation updates the next elevation.
func (*Navigator) NextLocation ¶
NextLocation updates the navigator's location based on the provided tick and speed.
func (*Navigator) OfflineDuration ¶
OfflineDuration returns the remaining offline duration.
func (*Navigator) RemoveRoute ¶
RemoveRoute removes a route by its ID.
func (*Navigator) RemoveTrack ¶
RemoveTrack removes a track from a route.
func (*Navigator) ResetRoutes ¶
ResetRoutes resets all routes in the navigator.
func (*Navigator) RouteDistance ¶
RouteDistance returns the distance of the current route.
func (*Navigator) RouteIndex ¶
RouteIndex returns the index of the current route.
func (*Navigator) SegmentDistance ¶
SegmentDistance returns the distance of the current segment.
func (*Navigator) SegmentIndex ¶
SegmentIndex returns the index of the current segment.
func (*Navigator) Snapshot ¶
func (n *Navigator) Snapshot() *proto.Snapshot_Navigator
Snapshot creates a snapshot of the navigator's state.
func (*Navigator) Sum ¶
Sum calculates and returns a summary of versions for the navigator, routes, and tracks.
func (*Navigator) ToOffline ¶
func (n *Navigator) ToOffline()
ToOffline puts the navigator into offline mode.
func (*Navigator) TrackDistance ¶
TrackDistance returns the distance of the current track.
func (*Navigator) TrackIndex ¶
TrackIndex returns the index of the current track.
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 ¶
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 RestoreRoute ¶
func RestoreRoute( routeID string, color string, props properties.Properties, ) *Route
RestoreRoute restores a Route instance with the given parameters.
func RouteFromTracks ¶
RouteFromTracks creates a new Route instance from a list of tracks.
func (*Route) ChangeColor ¶
ChangeColor changes the color of the route.
func (*Route) ChangeName ¶
ChangeName changes the name of the route.
func (*Route) EachTrack ¶
EachTrack iterates through each track in the route and applies a function.
func (*Route) Props ¶
func (r *Route) Props() properties.Properties
Props returns the properties associated with the route.
func (*Route) RemoveTrack ¶
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.
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) 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) 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 ¶
type SegmentSnapshot = proto.Snapshot_Navigator_Route_Track_Segment
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 ¶
ChangeColor changes the color of the track.
func (*Track) ChangeName ¶
ChangeName changes the name of the track.
func (*Track) NumSegments ¶
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) 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.