mln_engine/camera/
tile_projector.rs1use geometry::Point;
2
3use crate::camera::projection::{ProjectedTilePoint, ProjectionData};
4use crate::camera::view::View;
5use crate::tile::UnwrappedTileID;
6
7#[derive(Clone, Copy)]
10pub struct TileProjector<'a> {
11 view: &'a View,
12 tile_id: UnwrappedTileID,
13 data: ProjectionData,
14}
15
16impl<'a> TileProjector<'a> {
17 #[must_use]
18 pub fn new(view: &'a View, tile_id: &UnwrappedTileID) -> Self {
19 Self::with_data(view, tile_id, view.projection_data(tile_id))
20 }
21
22 #[must_use]
23 pub fn with_data(view: &'a View, tile_id: &UnwrappedTileID, data: ProjectionData) -> Self {
24 TileProjector { view, tile_id: *tile_id, data }
25 }
26
27 #[must_use]
29 pub fn project(&self, point: &Point<f64>, elevation: f64) -> ProjectedTilePoint {
30 self.view.projection().project_tile_point(&self.data, &self.tile_id, point, elevation)
31 }
32
33 #[must_use]
35 pub fn project_as_drawn(&self, point: &Point<f64>, elevation: f64) -> ProjectedTilePoint {
36 self.view.projection().drawn_tile_point(&self.data, &self.tile_id, point, elevation)
37 }
38
39 #[must_use]
40 pub fn circle_radius_correction(&self) -> f64 {
41 self.view.projection().circle_radius_correction(self.view)
42 }
43
44 #[must_use]
45 pub fn pitched_text_correction(&self, tile_anchor: &Point<f64>) -> f64 {
46 self.view.projection().pitched_text_correction(self.view, tile_anchor, &self.tile_id)
47 }
48
49 #[must_use]
50 pub fn view(&self) -> &View {
51 self.view
52 }
53
54 #[must_use]
55 pub fn tile_id(&self) -> &UnwrappedTileID {
56 &self.tile_id
57 }
58}