Skip to main content

Tile

Struct Tile 

Source
pub struct Tile { /* private fields */ }
Expand description

A single tile.

Implementations§

Source§

impl Tile

Source

pub fn new(zoom: u8, x: u32, y: u32) -> Option<Tile>

Constucts a Tile with the following zoom, x and y values.

Returns None if the x/y are invalid for that zoom level, or if the zoom is >= 100.

§Examples
assert!(Tile::new(0, 3, 3).is_none());
Source

pub fn zoom(&self) -> u8

zoom of this tile

Source

pub fn x(&self) -> u32

X value of this tile

Source

pub fn y(&self) -> u32

Y value of tile

Source

pub fn from_tms(tms: &str) -> Option<Tile>

Constucts a Tile with the following zoom, x and y values based on a TMS URL. Returns None if the TMS url is invalid, or those

§Examples
let t = Tile::from_tms("/10/547/380.png");
assert_eq!(t, Tile::new(10, 547, 380));
assert_eq!(Tile::from_tms("foobar"), None);
Source

pub fn parent(&self) -> Option<Tile>

Returns the parent tile for this tile, i.e. the tile at the zoom-1 that this tile is inside.

assert_eq!(Tile::new(1, 0, 0).unwrap().parent(), Tile::new(0, 0, 0));

None if there is no parent, which is at zoom 0.

assert_eq!(Tile::new(0, 0, 0).unwrap().parent(), None);
Source

pub fn subtiles(&self) -> Option<[Tile; 4]>

Returns the subtiles (child) tiles for this tile. The 4 tiles at zoom+1 which cover this tile. Returns None if this is at the maximum permissable zoom level, and hence there are no subtiles.

let t = Tile::new(0, 0, 0).unwrap();
let subtiles: [Tile; 4] = t.subtiles().unwrap();
assert_eq!(subtiles[0], Tile::new(1, 0, 0).unwrap());
assert_eq!(subtiles[1], Tile::new(1, 1, 0).unwrap());
assert_eq!(subtiles[2], Tile::new(1, 0, 1).unwrap());
assert_eq!(subtiles[3], Tile::new(1, 1, 1).unwrap());
Source

pub fn all_subtiles_iter(&self) -> AllSubTilesIterator

Iterate on all child tiles of this tile

Source

pub fn centre_point(&self) -> LatLon

Returns the LatLon for the centre of this tile.

Source

pub fn center_point(&self) -> LatLon

Returns the LatLon for the centre of this tile.

Source

pub fn nw_corner(&self) -> LatLon

Returns the LatLon of the top left, i.e. north west corner, of this tile.

Source

pub fn ne_corner(&self) -> LatLon

Returns the LatLon of the top right, i.e. north east corner, of this tile.

Source

pub fn sw_corner(&self) -> LatLon

Returns the LatLon of the bottom left, i.e. south west corner, of this tile.

Source

pub fn se_corner(&self) -> LatLon

Returns the LatLon of the bottom right, i.e. south east corner, of this tile.

Source

pub fn top(&self) -> f32

Source

pub fn bottom(&self) -> f32

Source

pub fn left(&self) -> f32

Source

pub fn right(&self) -> f32

Source

pub fn tc_path<T: Display>(&self, ext: T) -> String

Returns the TC (TileCache) path for storing this tile.

Source

pub fn mp_path<T: Display>(&self, ext: T) -> String

Returns the MP (MapProxy) path for storing this tile.

Source

pub fn ts_path<T: Display>(&self, ext: T) -> String

Returns the TS (TileStash safe) path for storing this tile.

Source

pub fn zxy(&self) -> String

Returns the Z/X/Y representation of this tile

Source

pub fn zxy_path<T: Display>(&self, ext: T) -> String

Returns the ZXY path for storing this tile.

Source

pub fn mt_path<T: Display>(&self, ext: T) -> String

Returns the ModTileMetatile path for storing this tile

Source

pub fn all() -> AllTilesIterator

Returns an iterator that yields all the tiles possible, starting from 0/0/0. Tiles are generated in a breath first manner, with all zoom 1 tiles before zoom 2 etc.

let mut all_tiles_iter = Tile::all();
Source

pub fn all_to_zoom(max_zoom: u8) -> AllTilesToZoomIterator

Returns an iterator that yields all the tiles from zoom 0 down to, and including, all the tiles at max_zoom zoom level. Tiles are generated in a breath first manner, with all zoom 1 tiles before zoom 2 etc.

Source

pub fn bbox(&self) -> BBox

The BBox for this tile.

Source

pub fn metatile(&self, scale: u8) -> Option<Metatile>

Source

pub fn modtile_metatile(&self) -> Option<ModTileMetatile>

Trait Implementations§

Source§

impl Clone for Tile

Source§

fn clone(&self) -> Tile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Tile

Source§

impl Debug for Tile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Tile

Source§

impl FromStr for Tile

Source§

type Err = &'static str

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Tile

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Tile

Source§

fn eq(&self, other: &Tile) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Tile

Auto Trait Implementations§

§

impl Freeze for Tile

§

impl RefUnwindSafe for Tile

§

impl Send for Tile

§

impl Sync for Tile

§

impl Unpin for Tile

§

impl UnsafeUnpin for Tile

§

impl UnwindSafe for Tile

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.