Skip to content

Commit

Permalink
Center heartbeat latlng to center of containing res12 hex (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbalser authored Mar 13, 2024
1 parent 60b5450 commit 4678560
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mobile_verifier/src/heartbeats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ impl Heartbeat {
}
}

pub fn asserted_distance(&self, asserted_location: u64) -> anyhow::Result<i64> {
let asserted_latlng: LatLng = CellIndex::try_from(asserted_location)?.into();
let hb_latlng = LatLng::new(self.lat, self.lon)?;
Ok(asserted_latlng.distance_m(hb_latlng).round() as i64)
fn centered_latlng(&self) -> anyhow::Result<LatLng> {
Ok(LatLng::new(self.lat, self.lon)?
.to_cell(h3o::Resolution::Twelve)
.into())
}
}

Expand Down Expand Up @@ -470,7 +470,7 @@ impl ValidatedHeartbeat {
));
}

let Ok(hb_latlng) = LatLng::new(heartbeat.lat, heartbeat.lon) else {
let Ok(hb_latlng) = heartbeat.centered_latlng() else {
return Ok(Self::new(
heartbeat,
cell_type,
Expand Down

0 comments on commit 4678560

Please sign in to comment.