Skip to content

Commit

Permalink
feat: add ids for device navigator state
Browse files Browse the repository at this point in the history
  • Loading branch information
mmadfox committed Aug 28, 2023
1 parent 1aa4003 commit cbf921b
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 81 deletions.
6 changes: 6 additions & 0 deletions navigator/navigator.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ func (n *Navigator) Update(state *proto.Device) {
state.Navigator.CurrentRouteIndex = int64(n.routeIndex)
state.Navigator.CurrentTrackIndex = int64(n.trackIndex)
state.Navigator.CurrentSegmentIndex = int64(n.segmentIndex)
if route := n.CurrentRoute(); route != nil {
state.Navigator.CurrentRouteId = route.ID()
}
if track := n.CurrentTrack(); track != nil {
state.Navigator.CurrentTrackId = track.ID()
}

state.Location.Bearing = n.CurrentBearing()
state.Location.Elevation = n.elevation.ValueY()
Expand Down
2 changes: 2 additions & 0 deletions navigator/navigator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ func TestNavigator_Update(t *testing.T) {
require.Equal(t, int64(n.RouteIndex()), state.Navigator.CurrentRouteIndex)
require.Equal(t, int64(n.TrackIndex()), state.Navigator.CurrentTrackIndex)
require.Equal(t, int64(n.SegmentIndex()), state.Navigator.CurrentSegmentIndex)
require.NotEmpty(t, state.Navigator.CurrentRouteId)
require.NotEmpty(t, state.Navigator.CurrentTrackId)

require.Equal(t, n.CurrentBearing(), state.Location.Bearing)
require.Equal(t, n.Elevation(), state.Location.Elevation)
Expand Down
177 changes: 99 additions & 78 deletions proto/gpsgen.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions proto/gpsgen.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ message Device {
int64 current_route_index = 1; // Current route index.
int64 current_track_index = 2; // Current track index.
int64 current_segment_index = 3; // Current segment index.
string current_route_id = 4; // Current route id.
string current_track_id = 5; // Current track id.
}

// Represents distance information.
Expand Down
Loading

0 comments on commit cbf921b

Please sign in to comment.