Focus Station Algorithm V1
— Calculate distance d from Location to closest station S
— Calculate direction vector c from Location to S
Case Result
d < 200m "Now: S"
d < 500m && c > 0 "Soon: S"
c > 0 "Next: S"
else "Next: S+1"
Slide 83
Slide 83 text
No content
Slide 84
Slide 84 text
No content
Slide 85
Slide 85 text
No content
Slide 86
Slide 86 text
No content
Slide 87
Slide 87 text
However...
Slide 88
Slide 88 text
GPS data is unreliable
Slide 89
Slide 89 text
Let's create a history for each station
Slide 90
Slide 90 text
struct StationDirectionalLocationHistory {
let stationID: Station.ID
let railDirection: RailDirection
var visitingLocations: [Location] = []
var approachingLocations: [Location] = []
var firstDepartureLocation: Location?
}
Slide 91
Slide 91 text
No content
Slide 92
Slide 92 text
Focus Station Algorithm V2
— Step 1: assign locations to stations
— Step 2: update station phase history
— Step 3: select the focus station phase
Slide 93
Slide 93 text
Step 1: assign locations to
stations
— Assign visitingLocations
or approachingLocations
Slide 94
Slide 94 text
Step 1: assign locations to
stations
— Assign
firstDepartureLocation
Slide 95
Slide 95 text
Step 2: update station phase history
visiting approach departure -> Phase
isEmpty isEmpty !nil departure
isEmpty !isEmpty nil approaching
!isEmpty any nil visiting
!isEmpty any !nil visited
Slide 96
Slide 96 text
approaching
Slide 97
Slide 97 text
visiting
Slide 98
Slide 98 text
visited
Slide 99
Slide 99 text
Step 3: determine focus phase
— Find last station S in travel direction where
phase != nil
Latest Station Phase Focus Phase
departure Next: S+1
approaching Soon: S
visiting Now: S
visited Next: S+1
Slide 100
Slide 100 text
No content
Slide 101
Slide 101 text
No content
Slide 102
Slide 102 text
No content
Slide 103
Slide 103 text
Demo
Slide 104
Slide 104 text
No content
Slide 105
Slide 105 text
github.com/twocentstudios/train-tracker-talk
Slide 106
Slide 106 text
Try Eki Live!
Slide 107
Slide 107 text
✨
Hire Me
✨
— Available for full-time or contract
work
— iOS generalist (not just train
apps)
— twocentstudios.com/blog
— @twocentstudios