|
1 | 1 | use egui::{Frame, Ui}; |
| 2 | +use human_bytes::human_bytes; |
| 3 | +use lyon::geom::point; |
| 4 | +use nalgebra_glm::vec4; |
| 5 | +use osm::math::{num2deg, world_to_tile_space}; |
2 | 6 |
|
3 | 7 | use crate::{app_state::AppState, drawing::ui::widgets::key_value_table::widget_key_value_table}; |
4 | 8 |
|
5 | 9 | pub fn view_stats(ui: &mut Ui, app_state: &mut AppState) { |
6 | 10 | Frame::default().outer_margin(5.0).show(ui, |ui| { |
7 | 11 | let tile_stats = app_state.tile_cache.get_stats(); |
| 12 | + let z = app_state.zoom; |
| 13 | + let screen_to_global = app_state.screen.pixel_to_world(z); |
| 14 | + let p = screen_to_global |
| 15 | + * vec4( |
| 16 | + app_state.cursor().x * 2.0, |
| 17 | + app_state.cursor().y * 2.0, |
| 18 | + 0.0, |
| 19 | + 0.0, |
| 20 | + ); |
| 21 | + let latlon = num2deg(world_to_tile_space(&point(p.x, p.y), z.floor() as u32)); |
8 | 22 | let data = [ |
9 | 23 | ("mouse x", app_state.cursor().x.to_string()), |
10 | | - ("mouse y", app_state.cursor().x.to_string()), |
11 | | - ("cached tiles", format!("{}", tile_stats.cached_tiles)), |
12 | | - ("loading tiles", format!("{}", tile_stats.loading_tiles)), |
13 | | - ("objects", format!("{}", tile_stats.tile_stats.objects)), |
14 | | - ("features", format!("{}", tile_stats.tile_stats.features)), |
15 | | - ("vertices", format!("{}", tile_stats.tile_stats.vertices)), |
16 | | - ("indices", format!("{}", tile_stats.tile_stats.indices)), |
17 | | - ( |
18 | | - "size", |
19 | | - human_bytes::human_bytes(tile_stats.tile_stats.size as f64), |
20 | | - ), |
| 24 | + ("mouse y", app_state.cursor().y.to_string()), |
| 25 | + ("mouse lat", latlon.y.to_string()), |
| 26 | + ("mouse lon", latlon.x.to_string()), |
| 27 | + ("cached tiles", tile_stats.cached_tiles.to_string()), |
| 28 | + ("loading tiles", tile_stats.loading_tiles.to_string()), |
| 29 | + ("objects", tile_stats.tile_stats.objects.to_string()), |
| 30 | + ("features", tile_stats.tile_stats.features.to_string()), |
| 31 | + ("vertices", tile_stats.tile_stats.vertices.to_string()), |
| 32 | + ("indices", tile_stats.tile_stats.indices.to_string()), |
| 33 | + ("size", human_bytes(tile_stats.tile_stats.size as f64)), |
21 | 34 | ]; |
22 | 35 | widget_key_value_table(ui, &data); |
23 | 36 | }); |
|
0 commit comments