wxbox/wxbox-tiler/src/main.rs
2024-10-19 00:06:56 -04:00

50 lines
1.3 KiB
Rust

pub(crate) mod sources;
pub(crate) mod coords;
mod grib2;
mod pixmap;
use std::borrow::Cow;
use std::collections::{BTreeMap, HashMap};
use std::env::args;
use std::fs::File;
use std::io::BufReader;
use tokio::sync::RwLock;
use std::time::SystemTime;
use actix_web::{App, get, HttpServer};
use actix_web::web::Data;
use grib::codetables::{CodeTable1_4, CodeTable4_2, CodeTable4_3, Lookup};
use grib::{GribError, SectionBody};
use ordered_float::OrderedFloat;
use crate::grib2::GriddedLookupTable;
use crate::sources::noaa::mrms_cref;
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
#[repr(usize)]
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Clone)]
pub enum LutKey {
NoaaMrmsCref = 1
}
pub struct AppState {
lut_cache: RwLock<BTreeMap<LutKey, GriddedLookupTable>>,
lut_cache_timestamps: RwLock<BTreeMap<LutKey, SystemTime>>
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let data = Data::new(AppState {
lut_cache: RwLock::new(BTreeMap::new()),
lut_cache_timestamps: RwLock::new(BTreeMap::new())
});
HttpServer::new(move || {
App::new()
.service(mrms_cref)
.app_data(data.clone())
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}