heliwatch: update for newer tokio-xmpp, geo
This commit is contained in:
parent
e419039481
commit
d5e2527927
|
@ -75,7 +75,7 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
let pos = entry.position()?;
|
let pos = entry.position()?;
|
||||||
let coord = geo::Coordinate { x: pos.longitude, y: pos.latitude };
|
let coord = geo::Coord { x: pos.longitude, y: pos.latitude };
|
||||||
if let Some(old_pos) = self.position.replace(pos.clone()) {
|
if let Some(old_pos) = self.position.replace(pos.clone()) {
|
||||||
if old_pos.longitude != pos.longitude || old_pos.latitude != pos.latitude {
|
if old_pos.longitude != pos.longitude || old_pos.latitude != pos.latitude {
|
||||||
let location = locations.find(&coord);
|
let location = locations.find(&coord);
|
||||||
|
|
|
@ -28,11 +28,11 @@ pub async fn run(jid: String, password: String, muc_jid: String) -> Handle {
|
||||||
};
|
};
|
||||||
let (tx, mut rx) = mpsc::channel(1);
|
let (tx, mut rx) = mpsc::channel(1);
|
||||||
let handle = Handle {
|
let handle = Handle {
|
||||||
room_jid: muc_jid.clone().into(),
|
room_jid: muc_jid.to_bare(),
|
||||||
tx: tx.clone(),
|
tx: tx.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut client = AsyncClient::new(&jid, &password).unwrap();
|
let mut client = AsyncClient::new(Jid::new(&jid).unwrap(), &password);
|
||||||
loop {
|
loop {
|
||||||
match client.next().await {
|
match client.next().await {
|
||||||
Some(Event::Online { .. }) => {
|
Some(Event::Online { .. }) => {
|
||||||
|
|
|
@ -24,7 +24,7 @@ impl Location {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn contains(&self, coord: &geo::Coordinate<f64>) -> bool {
|
pub fn contains(&self, coord: &geo::Coord<f64>) -> bool {
|
||||||
self.poly.contains(coord)
|
self.poly.contains(coord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ impl Locations {
|
||||||
.as_f64().expect("lon f64");
|
.as_f64().expect("lon f64");
|
||||||
let lat = el.get("lat").expect("lat")
|
let lat = el.get("lat").expect("lat")
|
||||||
.as_f64().expect("lat f64");
|
.as_f64().expect("lat f64");
|
||||||
let coord = geo::Coordinate { x: lon, y: lat };
|
let coord = geo::Coord { x: lon, y: lat };
|
||||||
nodes.insert(id, coord);
|
nodes.insert(id, coord);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -168,7 +168,7 @@ impl Locations {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find(&self, coord: &geo::Coordinate<f64>) -> Option<Arc<String>> {
|
pub fn find(&self, coord: &geo::Coord<f64>) -> Option<Arc<String>> {
|
||||||
for l in &self.locations {
|
for l in &self.locations {
|
||||||
if l.contains(coord) {
|
if l.contains(coord) {
|
||||||
return Some(l.name.clone());
|
return Some(l.name.clone());
|
||||||
|
|
Loading…
Reference in New Issue