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 map_aligned_scale(&self) -> f64 {
42 self.view.projection().map_aligned_scale(self.view)
43 }
44
45 #[must_use]
54 pub fn map_aligned_scale_at(&self, tile_anchor: &Point<f64>) -> f64 {
55 self.view.projection().map_aligned_scale_at(self.view, tile_anchor, &self.tile_id)
56 }
57
58 #[must_use]
59 pub fn view(&self) -> &View {
60 self.view
61 }
62
63 #[must_use]
64 pub fn tile_id(&self) -> &UnwrappedTileID {
65 &self.tile_id
66 }
67}