spat: Use likely time, if available
This commit is contained in:
parent
712550160f
commit
c771afe744
4 changed files with 33 additions and 18 deletions
|
|
@ -66,7 +66,7 @@ pub struct State {
|
|||
pub struct SignalGroupData {
|
||||
pub phase: SignalPhase,
|
||||
pub maneuver: map::Maneuvers,
|
||||
pub min_end_sec: Option<i16>,
|
||||
pub end_sec: Option<i16>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "spat")]
|
||||
|
|
@ -290,19 +290,23 @@ impl State {
|
|||
.map(core::convert::Into::into)
|
||||
.unwrap_or_default();
|
||||
|
||||
let min_end_sec = sig.min_end_time().map(|time| {
|
||||
let dur = time.sub(self.time.and_utc()).as_seconds_f32();
|
||||
let end_sec =
|
||||
sig.likely_time()
|
||||
.or_else(|| sig.min_end_time())
|
||||
.map(|time| {
|
||||
let dur =
|
||||
time.sub(self.time.and_utc()).as_seconds_f32();
|
||||
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
let min_end_sec = dur.round() as i16;
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
let end_sec = dur.round() as i16;
|
||||
|
||||
min_end_sec
|
||||
});
|
||||
end_sec
|
||||
});
|
||||
|
||||
Some(SignalGroupData {
|
||||
phase,
|
||||
maneuver: manv,
|
||||
min_end_sec,
|
||||
end_sec,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue