Skip to main content

geospatial_types/
raster.rs

1//! Raster tile imagery records (option-1 map source).
2
3use serde::{Deserialize, Serialize};
4
5/// Encoded image formats a raster tile provider may deliver.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
7#[serde(rename_all = "snake_case")]
8pub enum RasterImageFormat {
9    /// PNG imagery.
10    Png,
11    /// JPEG imagery.
12    Jpeg,
13}
14
15/// Pixel resolution a raster tile is rendered at. `Standard` is the plain
16/// tile form; `Retina` is the Tiles API's `@2x` form: twice the texels per
17/// edge for the same logical tile span.
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
19#[serde(rename_all = "snake_case")]
20pub enum RasterTileResolution {
21    /// One texel per logical tile pixel.
22    #[default]
23    Standard,
24    /// Twice the texels per logical tile pixel (the `@2x` request form).
25    Retina,
26}
27
28/// One fetched web-mercator XYZ raster tile.
29#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
30pub struct RasterTileData {
31    /// Tile column coordinate at the given zoom level.
32    pub tile_x: u32,
33    /// Tile row coordinate at the given zoom level.
34    pub tile_y: u32,
35    /// Zoom level this tile belongs to.
36    pub zoom_level: u8,
37    /// Encoding of the byte payload.
38    pub image_format: RasterImageFormat,
39    /// Pixel resolution the payload was rendered at. Serialized payloads
40    /// recorded before the field existed are all standard resolution, so the
41    /// field defaults there on deserialization.
42    #[serde(default)]
43    pub tile_resolution: RasterTileResolution,
44    /// Encoded image bytes.
45    pub image_bytes: Vec<u8>,
46}