heliwatch: ignore big planes by emitter_category, lift MAX_ALTITUDE to 10_000 ft

This commit is contained in:
Astro 2021-11-09 15:59:40 +01:00
parent 3fbb5febfb
commit 71b534fe6e
1 changed files with 14 additions and 3 deletions

View File

@ -6,10 +6,21 @@ use tokio::sync::mpsc::{channel, Receiver};
use super::location::Locations;
/// ft
const MAX_ALTITUDE: u16 = 5000;
const MAX_ALTITUDE: u16 = 10_000;
/// s
const STATE_TIMEOUT: u64 = 180;
const IGNORED_CATEGORIES: &[u8] = &[
// Small (15,500..75,000) lbs
2,
// Large (75,000..300,000 lbs)
3,
// High Vortex Large
4,
// Heavy (> 300,000 lbs)
5,
];
#[derive(Debug, Clone)]
pub struct Event {
pub action: Action,
@ -122,8 +133,8 @@ pub fn run(host: &'static str, port: u16, locations: Locations) -> Receiver<Even
let hex = format!("{}", icao_address);
let entry = entry.read().unwrap();
if entry.altitude.map(|altitude| altitude > MAX_ALTITUDE)
.unwrap_or(false)
if entry.altitude.map(|altitude| altitude > MAX_ALTITUDE).unwrap_or(false) ||
entry.emitter_category.as_ref().map(|category| IGNORED_CATEGORIES.contains(category)).unwrap_or(false)
{
if !ignored.contains(&hex) {
ignored.insert(hex.clone());