From 4678560d243b3ea9c2c676f33512f19856a22c38 Mon Sep 17 00:00:00 2001 From: Brian Balser Date: Wed, 13 Mar 2024 12:20:06 -0400 Subject: [PATCH] Center heartbeat latlng to center of containing res12 hex (#762) --- mobile_verifier/src/heartbeats/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mobile_verifier/src/heartbeats/mod.rs b/mobile_verifier/src/heartbeats/mod.rs index 8c2640f04..22b9fe15b 100644 --- a/mobile_verifier/src/heartbeats/mod.rs +++ b/mobile_verifier/src/heartbeats/mod.rs @@ -225,10 +225,10 @@ impl Heartbeat { } } - pub fn asserted_distance(&self, asserted_location: u64) -> anyhow::Result { - 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 { + Ok(LatLng::new(self.lat, self.lon)? + .to_cell(h3o::Resolution::Twelve) + .into()) } } @@ -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,