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 #[cfg(test)]
41 pub(crate) fn circle_radius_correction(&self) -> f64 {
42 self.view.projection().circle_radius_correction(self.view)
43 }
44
45 #[must_use]
46 pub fn pitched_text_correction(&self, tile_anchor: &Point<f64>) -> f64 {
47 self.view.projection().pitched_text_correction(self.view, tile_anchor, &self.tile_id)
48 }
49
50 #[must_use]
51 pub fn view(&self) -> &View {
52 self.view
53 }
54
55 #[must_use]
56 pub fn tile_id(&self) -> &UnwrappedTileID {
57 &self.tile_id
58 }
59}