Skip to main content

mln_engine/source/
render_image_source.rs

1// An image source draws one image, stretched over the quad of its
2// coordinates, in the tiles that the quad covers: its render tiles, one in
3// each world copy it draws in, which all show its one image tile.
4
5use std::sync::Arc;
6
7use geometry::Point;
8use mln_style::bitmap::PremultipliedImage;
9use mln_style::feature::GeometryCoordinates;
10use mln_style::geo::LatLngBounds;
11use mln_style::range::Range;
12use mln_style::subdivision_granularity::SubdivisionGranularitySetting;
13use mln_style::{Source, constants};
14
15use crate::camera::TileCoordinate;
16use crate::camera::tile_coordinate::TileCoordinatePoint;
17use crate::draw::context::Context;
18use crate::draw::identity::SimpleIdentity;
19use crate::draw::quads::{RasterLayoutVertex, StoredQuads};
20use crate::draw::segment::SegmentBase;
21use crate::layer::layer_drawing::MadeFrom;
22use crate::layer::layer_type::ErasedEvaluatedLayer;
23use crate::log_target;
24use crate::render::tile::{RenderTile, TileContent};
25use crate::source::render_source::{RenderSource, RenderSourceBase, RenderTileParameters, TileOrder};
26use crate::source::{ImageOf, SourceImage};
27use crate::tile::UnwrappedTileID;
28use crate::tile_store::store::TileStore;
29use crate::tile_store::tile_cover::{TileCoverParameters, tile_cover, tile_cover_bounds};
30use crate::tile_store::tile_parameters::TileParameters;
31
32// The mapping from the unit square onto the image's corners: the perspective
33// terms of the projective warp and how far it is blended towards the
34// bilinear one, as the "auto" warp blends them, after Heckbert,
35// "Fundamentals of Texture Mapping and Image Warping" (1989), 2.2.3 and A.2.
36#[derive(Clone, Copy, Debug)]
37struct ImageWarp {
38    perspective_x: f64,
39    perspective_y: f64,
40    blend: f64,
41}
42
43impl Default for ImageWarp {
44    fn default() -> Self {
45        ImageWarp { perspective_x: 0.0, perspective_y: 0.0, blend: 1.0 }
46    }
47}
48
49/// The cells across a side of the grid that draws a warp blended towards
50/// the bilinear one, GL JS's `SUBDIVIDED_QUAD_GRANULARITY`.
51const BLENDED_WARP_CELLS: u32 = 16;
52
53fn is_parallelogram(corners: &GeometryCoordinates) -> bool {
54    let [top_left, top_right, bottom_right, bottom_left] =
55        [corners[0], corners[1], corners[2], corners[3]].map(|p| (i32::from(p.x), i32::from(p.y)));
56    top_left.0 + bottom_right.0 == top_right.0 + bottom_left.0
57        && top_left.1 + bottom_right.1 == top_right.1 + bottom_left.1
58}
59
60/// The corner of a concave quad of `corners` (top left, top right, bottom
61/// right, bottom left) that points into it, by its index; `None` for a
62/// quad that isn't concave.
63fn concave_corner(corners: &GeometryCoordinates) -> Option<usize> {
64    let point = |i: usize| (i64::from(corners[i % 4].x), i64::from(corners[i % 4].y));
65    // Which way the outline turns at each corner: a concave quad turns
66    // against the other three at one.
67    let turns = [0, 1, 2, 3].map(|i| {
68        let ((ax, ay), (bx, by), (cx, cy)) = (point(i + 3), point(i), point(i + 1));
69        ((bx - ax) * (cy - by) - (by - ay) * (cx - bx)).signum()
70    });
71    (0..4).find(|&i| turns[i] != 0 && (0..4).all(|j| j == i || turns[j] == -turns[i]))
72}
73
74fn image_warp(corners: &GeometryCoordinates) -> ImageWarp {
75    const PROJECTIVE_FORESHORTENING: f64 = 4.0;
76    const BILINEAR_FORESHORTENING: f64 = 512.0;
77    // A parallelogram is warped affinely either way.
78    if is_parallelogram(corners) {
79        return ImageWarp::default();
80    }
81    let top_left = corners[0];
82    let top_right = corners[1];
83    let bottom_right = corners[2];
84    let bottom_left = corners[3];
85    let (tl_x, tl_y) = (i32::from(top_left.x), i32::from(top_left.y));
86    let (tr_x, tr_y) = (i32::from(top_right.x), i32::from(top_right.y));
87    let (br_x, br_y) = (i32::from(bottom_right.x), i32::from(bottom_right.y));
88    let (bl_x, bl_y) = (i32::from(bottom_left.x), i32::from(bottom_left.y));
89    let sum_x = f64::from(tl_x - tr_x + br_x - bl_x);
90    let sum_y = f64::from(tl_y - tr_y + br_y - bl_y);
91    let right_x = f64::from(tr_x - br_x);
92    let right_y = f64::from(tr_y - br_y);
93    let down_x = f64::from(bl_x - br_x);
94    let down_y = f64::from(bl_y - br_y);
95    let determinant = right_x * down_y - right_y * down_x;
96    let perspective_x = (sum_x * down_y - down_x * sum_y) / determinant;
97    let perspective_y = (right_x * sum_y - sum_x * right_y) / determinant;
98    // The homogeneous denominator at the four corners, normalized to one at
99    // the top left; its spread is the foreshortening, and it stays finite
100    // and positive only while the quad is a perspective view of the image.
101    let denominators = [1.0, 1.0 + perspective_x, 1.0 + perspective_x + perspective_y, 1.0 + perspective_y];
102    // The first largest and smallest, which comparisons with a NaN keep.
103    let mut largest = denominators[0];
104    let mut smallest = denominators[0];
105    for &denominator in &denominators[1..] {
106        if largest < denominator {
107            largest = denominator;
108        }
109        if denominator < smallest {
110            smallest = denominator;
111        }
112    }
113    let foreshortening = largest / smallest;
114    let blend_term = (1.0 - PROJECTIVE_FORESHORTENING / foreshortening)
115        / (1.0 - PROJECTIVE_FORESHORTENING / BILINEAR_FORESHORTENING);
116    let blend = if 0.0 < blend_term { blend_term } else { 0.0 };
117    if !foreshortening.is_finite() || foreshortening < 1.0 || foreshortening > BILINEAR_FORESHORTENING || blend >= 1.0 {
118        return ImageWarp::default();
119    }
120    ImageWarp { perspective_x, perspective_y, blend }
121}
122
123/// Where the raster shader puts the unit square that a draw's vertices span
124/// (0 to `EXTENT` on both axes), in its tile's units: onto the quad of four
125/// corners, warped by an `ImageWarp`. The shader evaluates the warp per
126/// vertex and interpolates the texture coordinates projectively, so a
127/// projective warp draws exactly on two triangles.
128#[derive(Clone, Copy, Debug, PartialEq)]
129pub struct ImageQuad {
130    /// The top left corner's x and y, and the top right's.
131    pub coords_top: [f32; 4],
132    /// The bottom left corner's x and y, and the bottom right's.
133    pub coords_bottom: [f32; 4],
134    /// The warp's perspective terms and its blend towards the bilinear warp,
135    /// then padding.
136    pub warp: [f32; 4],
137}
138
139impl ImageQuad {
140    /// The quad of a tile itself, which draws the vertices where they are.
141    pub const TILE: ImageQuad = {
142        let extent = constants::EXTENT as f32;
143        ImageQuad {
144            coords_top: [0.0, 0.0, extent, 0.0],
145            coords_bottom: [0.0, extent, extent, extent],
146            warp: [0.0, 0.0, 1.0, 0.0],
147        }
148    };
149
150    fn new(corners: &GeometryCoordinates, warp: &ImageWarp) -> ImageQuad {
151        let [top_left, top_right, bottom_right, bottom_left] =
152            [corners[0], corners[1], corners[2], corners[3]].map(|p| [f32::from(p.x), f32::from(p.y)]);
153        ImageQuad {
154            coords_top: [top_left[0], top_left[1], top_right[0], top_right[1]],
155            coords_bottom: [bottom_left[0], bottom_left[1], bottom_right[0], bottom_right[1]],
156            warp: [warp.perspective_x as f32, warp.perspective_y as f32, warp.blend as f32, 0.0],
157        }
158    }
159}
160
161fn to_vertex_coordinate(value: f64) -> i16 {
162    mln_style::math::clamp_f64(value.round(), f64::from(i16::MIN), f64::from(i16::MAX)) as i16
163}
164
165// The unit square as a grid of `cells` x `cells`, textured edge to edge,
166// which the raster shader puts on the image's quad, each cell split along
167// its diagonal from the top right, or from the top left if `from_top_left`.
168fn build_image_mesh(tile: &mut ImageTile, cells: u32, from_top_left: bool) {
169    let rows = cells + 1;
170    let extent = constants::EXTENT as u32;
171    let mut vertices = Vec::with_capacity((rows * rows) as usize);
172    for j in 0..rows {
173        for i in 0..rows {
174            let (x, y) = ((i * extent / cells) as u16, (j * extent / cells) as u16);
175            vertices.push(RasterLayoutVertex::new(Point::new(x as i16, y as i16), Point::new(x, y)));
176        }
177    }
178    let mut indices: Vec<u16> = Vec::with_capacity((cells * cells * 6) as usize);
179    for j in 0..cells {
180        for i in 0..cells {
181            let top_left = (j * rows + i) as u16;
182            let top_right = top_left.wrapping_add(1);
183            let bottom_left = top_left.wrapping_add(rows as u16);
184            let bottom_right = bottom_left.wrapping_add(1);
185            if from_top_left {
186                indices.extend_from_slice(&[top_left, top_right, bottom_right]);
187                indices.extend_from_slice(&[top_left, bottom_right, bottom_left]);
188            } else {
189                indices.extend_from_slice(&[top_left, top_right, bottom_left]);
190                indices.extend_from_slice(&[top_right, bottom_left, bottom_right]);
191            }
192        }
193    }
194    let segments = vec![SegmentBase::with_lengths(0, 0, vertices.len(), indices.len())];
195    tile.set_mesh(vertices, indices, segments);
196}
197
198/// Where an image tile's mesh is.
199enum Mesh {
200    /// It has none yet.
201    None,
202    /// Its vertices and indices, until their upload moves them.
203    Data { vertices: Vec<RasterLayoutVertex>, indices: Vec<u16>, segments: Vec<SegmentBase> },
204    /// In the context's stores.
205    Stored(StoredQuads),
206}
207
208/// What an image source shows in each of its tiles: its image, and the mesh
209/// of the unit square that the image's quad puts in the tile. The raster
210/// layers that draw the source share them.
211pub struct ImageTile {
212    id: SimpleIdentity,
213    pub(crate) image: Arc<PremultipliedImage>,
214    mesh: Mesh,
215    /// Counts the changes of the mesh, after which the layers build their
216    /// draws of the image again.
217    generation: u64,
218    /// The box of the quad's corners, in the tile units of the source's
219    /// tiles' canonical tile: min x, min y, max x, max y.
220    pub(crate) bounds: [i32; 4],
221    /// Where the mesh's vertices draw, in the same units.
222    pub(crate) quad: ImageQuad,
223}
224
225impl ImageTile {
226    /// The tile of `image`, which it shares, without a mesh.
227    #[must_use]
228    fn new(image: Arc<PremultipliedImage>) -> Self {
229        ImageTile {
230            id: SimpleIdentity::new(),
231            image,
232            mesh: Mesh::None,
233            generation: 0,
234            bounds: [0; 4],
235            quad: ImageQuad::TILE,
236        }
237    }
238
239    /// The tile's identity, by which the layers keep the image's texture.
240    #[must_use]
241    pub(crate) fn id(&self) -> SimpleIdentity {
242        self.id
243    }
244
245    /// What a layer's value of the tile is made from: its identity, with
246    /// the number of times its mesh changed.
247    #[must_use]
248    pub(crate) fn stamp(&self) -> MadeFrom {
249        (self.id, [self.generation, 0])
250    }
251
252    /// Whether the tile has a mesh.
253    #[must_use]
254    fn has_mesh(&self) -> bool {
255        !matches!(self.mesh, Mesh::None)
256    }
257
258    /// Makes the mesh `vertices` and `indices` in `segments`.
259    fn set_mesh(&mut self, vertices: Vec<RasterLayoutVertex>, indices: Vec<u16>, segments: Vec<SegmentBase>) {
260        self.mesh = Mesh::Data { vertices, indices, segments };
261        self.generation += 1;
262    }
263
264    /// The mesh in the context's stores, once its upload moved it.
265    #[must_use]
266    pub fn quads(&self) -> Option<&StoredQuads> {
267        match &self.mesh {
268            Mesh::Stored(quads) => Some(quads),
269            Mesh::Data { vertices, .. } => {
270                debug_assert!(vertices.is_empty(), "an image source's mesh drawn before its upload");
271                None
272            }
273            Mesh::None => None,
274        }
275    }
276
277    /// Moves the mesh into `context`'s stores, unless it is there or there
278    /// is none.
279    fn upload(&mut self, context: &mut Context) {
280        self.mesh = match std::mem::replace(&mut self.mesh, Mesh::None) {
281            Mesh::Data { vertices, indices, segments } if !vertices.is_empty() => {
282                Mesh::Stored(StoredQuads::new(context, vertices, indices, segments))
283            }
284            mesh => mesh,
285        };
286    }
287}
288
289pub(crate) struct RenderImageSource {
290    base: RenderSourceBase,
291    /// Reads the image from each version of the source.
292    image_of: ImageOf,
293    tile: Option<ImageTile>,
294    /// The tile the image draws in, in each world copy it draws in: one
295    /// canonical tile under different wraps.
296    tile_ids: Vec<UnwrappedTileID>,
297    /// The tiles of `tile_ids` that the frame draws, and their order.
298    render_tiles: Vec<RenderTile>,
299    order: Vec<usize>,
300    mesh_corners: GeometryCoordinates,
301    mesh_cells: u32,
302}
303
304impl RenderImageSource {
305    #[must_use]
306    pub(crate) fn new(style_source: Source, image_of: ImageOf) -> Self {
307        RenderImageSource {
308            base: RenderSourceBase::new(style_source),
309            image_of,
310            tile: None,
311            tile_ids: Vec::new(),
312            render_tiles: Vec::new(),
313            order: Vec::new(),
314            mesh_corners: GeometryCoordinates::new(),
315            mesh_cells: 0,
316        }
317    }
318
319    /// Whether the source's image has arrived. A source without an image
320    /// (one made without a url) has nothing to load, so a still render of it
321    /// finishes.
322    fn loaded(&self) -> bool {
323        self.tile.is_some() || self.image().is_none_or(|image| image.image.is_none())
324    }
325
326    fn image(&self) -> Option<SourceImage> {
327        (self.image_of)(&self.base.style_source)
328    }
329}
330
331impl RenderSource for RenderImageSource {
332    fn base(&self) -> &RenderSourceBase {
333        &self.base
334    }
335
336    // A source that draws nowhere holds no frame back: the style tracks
337    // the load of its image.
338    fn is_loaded(&self, _store: &TileStore) -> bool {
339        !self.base.enabled || self.loaded()
340    }
341
342    fn update(
343        &mut self,
344        _store: &mut TileStore,
345        style_source: Source,
346        _layers: &[Arc<dyn ErasedEvaluatedLayer>],
347        needs_rendering: bool,
348        _needs_relayout: bool,
349        parameters: &TileParameters<'_>,
350    ) {
351        self.base.enabled = needs_rendering;
352        if !needs_rendering {
353            return;
354        }
355
356        let view = parameters.view;
357        self.base.style_source = style_source;
358
359        let Some(source_image) = self.image() else {
360            self.base.enabled = false;
361            return;
362        };
363        let coords = source_image.coordinates;
364        let image = source_image.image;
365
366        let Some(image) = image.filter(|image| image.valid()) else {
367            self.base.enabled = false;
368            return;
369        };
370
371        // Compute the z0 tile coordinates for the given LatLngs
372        let mut ne_point: TileCoordinatePoint = Point::new(f64::NEG_INFINITY, f64::NEG_INFINITY);
373        let mut sw_point: TileCoordinatePoint = Point::new(f64::INFINITY, f64::INFINITY);
374        let mut tile_coordinates: Vec<TileCoordinatePoint> = Vec::new();
375        for lat_lng in &coords {
376            let point = TileCoordinate::from_lat_lng(0.0, lat_lng).p;
377            tile_coordinates.push(point);
378            sw_point.x = if point.x < sw_point.x { point.x } else { sw_point.x };
379            ne_point.x = if ne_point.x < point.x { point.x } else { ne_point.x };
380            sw_point.y = if point.y < sw_point.y { point.y } else { sw_point.y };
381            ne_point.y = if ne_point.y < point.y { point.y } else { ne_point.y };
382        }
383
384        // Calculate the optimum zoom level to determine the tile ids to use
385        // for transforms
386        let dx = ne_point.x - sw_point.x;
387        let dy = ne_point.y - sw_point.y;
388        let d_max = if dx < dy { dy } else { dx };
389        let floor = (-d_max.log2()).floor();
390        let zoom = (if 0.0 < floor { floor } else { 0.0 }) as u8;
391
392        // Only enable if the long side of the image is > 2 pixels. Resulting
393        // in a display of at least 2 x 1 px image
394        self.base.enabled = d_max * 2.0f64.powf(view.zoom()) * constants::TILE_SIZE_D > 2.0;
395        if !self.base.enabled {
396            return;
397        }
398
399        let mut image_bounds = LatLngBounds::hull(coords[0], coords[1]);
400        image_bounds.extend(&coords[2]);
401        image_bounds.extend(&coords[3]);
402        let tile_cover_ids = tile_cover_bounds(&image_bounds, zoom);
403        self.tile_ids.clear();
404        // The cover is empty, for example, when the image lies wholly outside
405        // the latitudes a Web Mercator map can show (beyond about ±85.05°).
406        if tile_cover_ids.is_empty() {
407            self.base.enabled = false;
408            return;
409        }
410        self.tile_ids.push(tile_cover_ids[0]);
411
412        let mut has_visible_tile = false;
413        // A wrap does not move a tile on the globe, so the image draws once
414        // there, in the world copy the cover chose.
415        let globe = view.is_globe();
416        // The image draws in each world copy whose quad overlaps the view's
417        // tiles: while terrain draws, the terrain's, raised ground's too, as
418        // every source covers the view then.
419        let ideal_tiles = match parameters.terrain {
420            Some(terrain) => terrain.tiles.iter().map(|tile| tile.id).collect(),
421            None => tile_cover(
422                &TileCoverParameters {
423                    view: view.clone(),
424                    tile_lod_min_radius: parameters.tile_lod_min_radius,
425                    tile_lod_scale: parameters.tile_lod_scale,
426                    tile_lod_pitch_threshold: parameters.tile_lod_pitch_threshold,
427                    tile_lod_mode: parameters.tile_lod_mode,
428                    requested_zoom: None,
429                    round_zoom: false,
430                    max_content_elevation: 0.0,
431                },
432                view.integer_zoom(),
433                Range::new(0u8, zoom),
434                None,
435            ),
436        };
437        for tile in &ideal_tiles {
438            for covering_tile in &tile_cover_ids {
439                if covering_tile.canonical == tile.canonical
440                    || covering_tile.canonical.is_child_of(&tile.canonical)
441                    || tile.canonical.is_child_of(&covering_tile.canonical)
442                {
443                    // The copy that puts this covering tile on the view's
444                    // tile: where the quad crosses the antimeridian, the
445                    // covering tile may lie in the world next to the
446                    // first's, and one view tile may see two copies. A
447                    // copy too many worlds from the first has no tile id.
448                    let wrap = i32::from(tile.wrap) - i32::from(covering_tile.wrap) + i32::from(tile_cover_ids[0].wrap);
449                    let Ok(wrap) = i16::try_from(wrap) else {
450                        continue;
451                    };
452                    has_visible_tile = true;
453                    let wrapped_tile_id = UnwrappedTileID::with_wrap(wrap, tile_cover_ids[0].canonical);
454                    if globe {
455                        self.tile_ids = vec![wrapped_tile_id];
456                        break;
457                    }
458                    if !self.tile_ids.contains(&wrapped_tile_id) {
459                        self.tile_ids.push(wrapped_tile_id);
460                    }
461                }
462            }
463            if globe && has_visible_tile {
464                break;
465            }
466        }
467
468        self.base.enabled = has_visible_tile;
469        if !self.base.enabled {
470            return;
471        }
472
473        // The corners in the units of the cover's first tile, rounded to the
474        // nearest unit as GL JS rounds them, so that an edge falls on the
475        // pixels GL JS draws it on.
476        let tile = tile_cover_ids[0];
477        let scale = 2.0f64.powi(i32::from(tile.canonical.z));
478        let extent = f64::from(constants::EXTENT);
479        let geom_coords: GeometryCoordinates = tile_coordinates
480            .iter()
481            .map(|point| {
482                let x = point.x * scale - f64::from(tile.canonical.x) - f64::from(tile.wrap) * scale;
483                let y = point.y * scale - f64::from(tile.canonical.y);
484                Point::new(to_vertex_coordinate(x * extent), to_vertex_coordinate(y * extent))
485            })
486            .collect();
487
488        // A changed image gets a new tile, whose id tells the layers to make
489        // its texture.
490        let tile = match &mut self.tile {
491            Some(tile) if Arc::ptr_eq(&tile.image, &image) => tile,
492            slot => slot.insert(ImageTile::new(image)),
493        };
494
495        // The globe bends the quad over the sphere with the tile mesh
496        // granularity of its tile. Two triangles draw a parallelogram's
497        // affine warp and a projective warp exactly; one blended towards the
498        // bilinear warp is neither, and would bend along their diagonal, so
499        // it draws on a grid. A concave quad's bilinear warp folds over
500        // itself, out of the quad: it draws on two triangles split along the
501        // diagonal inside it.
502        let warp = image_warp(&geom_coords);
503        let concave = concave_corner(&geom_coords);
504        let cells = if view.is_globe() {
505            SubdivisionGranularitySetting::globe().tile.granularity_for_zoom_level(self.tile_ids[0].canonical.z)
506        } else if warp.blend > 0.0 && !is_parallelogram(&geom_coords) && concave.is_none() {
507            BLENDED_WARP_CELLS
508        } else {
509            1
510        };
511        if !tile.has_mesh() || geom_coords != self.mesh_corners || cells != self.mesh_cells {
512            build_image_mesh(tile, cells, matches!(concave, Some(0 | 2)));
513            tile.quad = ImageQuad::new(&geom_coords, &warp);
514            let mut bounds = [i32::MAX, i32::MAX, i32::MIN, i32::MIN];
515            for corner in &geom_coords {
516                let (x, y) = (i32::from(corner.x), i32::from(corner.y));
517                bounds = [bounds[0].min(x), bounds[1].min(y), bounds[2].max(x), bounds[3].max(y)];
518            }
519            tile.bounds = bounds;
520            self.mesh_corners = geom_coords;
521            self.mesh_cells = cells;
522        }
523    }
524
525    /// Makes a render tile of each tile the image draws in, once it has
526    /// arrived. An image shrunk out of sight or out of view draws in none.
527    fn update_render_tiles(&mut self, _store: &mut TileStore, parameters: &RenderTileParameters<'_>) {
528        self.render_tiles.clear();
529        self.order.clear();
530        if !self.base.enabled || !self.loaded() {
531            return;
532        }
533        for (index, id) in self.tile_ids.iter().enumerate() {
534            let mut tile = RenderTile::of_tile_id(*id, id.overscale_to(id.canonical.z), false);
535            tile.set_projection(parameters.transform);
536            self.render_tiles.push(tile);
537            self.order.push(index);
538        }
539    }
540
541    /// A disabled source's tile ids and corners may be of other
542    /// coordinates: it draws in no tile.
543    fn release_render_data(&mut self) {
544        self.render_tiles.clear();
545        self.order.clear();
546    }
547
548    fn upload(&mut self, _store: &mut TileStore, context: &mut Context) {
549        if let Some(tile) = &mut self.tile {
550            tile.upload(context);
551        }
552    }
553
554    fn render_tiles(&self) -> &[RenderTile] {
555        &self.render_tiles
556    }
557
558    /// The tiles in the order they cover the image, for every order: they
559    /// are copies of one tile.
560    fn tile_order(&self, _order: TileOrder) -> Option<&[usize]> {
561        Some(&self.order)
562    }
563
564    fn tile_contents<'a>(&'a self, _store: &'a TileStore, contents: &mut Vec<Option<TileContent<'a>>>) {
565        let tile = self.tile.as_ref().map(TileContent::Image);
566        contents.extend(self.render_tiles.iter().map(|_| tile));
567    }
568
569    fn dump_debug_logs(&self) {
570        log::info!(
571            target: log_target::GENERAL,
572            "Image source {}: loaded {}",
573            self.base.style_source.id(),
574            self.loaded()
575        );
576    }
577
578    fn max_zoom(&self) -> Option<u8> {
579        None
580    }
581}