diff --git a/server/src/trees.rs b/server/src/trees.rs index 58d1bae..d2e34fe 100644 --- a/server/src/trees.rs +++ b/server/src/trees.rs @@ -9,7 +9,7 @@ use geo::Point; use serde::Serialize; use mime::{APPLICATION_JSON, IMAGE_PNG}; use http::StatusCode; -use chrono::NaiveDate; +use chrono::{Local, NaiveDate}; use cairo::{ImageSurface, Context}; use crate::{AppState, AreaExtractor, IdExtractor}; @@ -121,19 +121,13 @@ pub fn get_heatmap(state: State) -> (State, Response
) { let app_state = AppState::borrow_from(&state); let result = { let mut db = app_state.db.lock().unwrap(); - db.query("SELECT coord, score FROM trees WHERE coord <@ $1::box AND SCORE IS NOT NULL", &[ + db.query("SELECT coord, score, planted FROM trees WHERE coord <@ $1::box AND SCORE IS NOT NULL", &[ &pe.grow(0.2).to_rect() ]).unwrap() }; const TILE_SIZE: i32 = 256; - // let (w, h) = if pe.w() / 2. > pe.h() { - // (TILE_MAX / 2, (TILE_MAX as f64 * pe.h() / pe.w()) as i32) - // } else { - // (((TILE_MAX as f64 / 2. * pe.w() / pe.h()) as i32), TILE_MAX) - // }; let (w, h) = (TILE_SIZE, TILE_SIZE); - // println!("{}x{} ({}x{})", w, h, pe.w(), pe.h()); let s = ImageSurface::create(cairo::Format::ARgb32, w, h).unwrap(); let ctx = Context::new(&s).unwrap(); ctx.set_antialias(cairo::Antialias::Fast); @@ -141,11 +135,12 @@ pub fn get_heatmap(state: State) -> (State, Response) { for row in result { let point: Point