Struct Tile

Source
pub struct Tile {
    pub x: u32,
    pub y: u32,
    pub z: u8,
}
Expand description

Tile X-Y-Z struct

Fields§

§x: u32

x value (column)

§y: u32

y value (row – flipped in mbtiles)

§z: u8

z value (zoom level)

Implementations§

Source§

impl Tile

Source

pub fn new(x: u32, y: u32, z: u8) -> Self

Create a new Tile

Source

pub fn flip(&self) -> Self

flip the y value (row) and return flipped tile

Source

pub fn bounds(&self) -> (f64, f64, f64, f64)

Return bounds tuple (west, south, east, north) for the tile

Source

pub fn from_row_major_id(id: u64) -> Self

Return tile from row-major tile-id

Source

pub fn from_rmid(id: u64) -> Self

Return tile from row-major tile-id (alias for from_row_major_id)

Source

pub fn fmt_zxy(&self, sep: Option<&str>) -> String

Return zxy string with optional separator (default is ‘/’)

Source

pub fn fmt_zxy_ext(&self, ext: &str, sep: Option<&str>) -> String

Return zxy string with extension and optional separator (default is ‘/’)

§Examples
use utiles_core::Tile;
let tile = Tile::new(1, 2, 3);
assert_eq!(tile.fmt_zxy_ext("png", Some("-")), "3-1-2.png");
assert_eq!(tile.fmt_zxy_ext("png", None), "3/1/2.png");
Source

pub fn from_quadkey(quadkey: &str) -> UtilesCoreResult<Self>

Convert quadkey string to Tile

§Errors

Returns error on invalid quadkey (e.g. “1234” – oh no ‘4’ is invalid)

Source

pub fn from_qk(qk: &str) -> UtilesCoreResult<Self>

Convert quadkey string to Tile (alias for from_quadkey)

§Errors

Returns error on invalid quadkey (e.g. “1234” – oh no ‘4’ is invalid)

Source

pub fn from_json_obj(json: &str) -> UtilesCoreResult<Self>

Return tile from json-object string (e.g. {"x": 1, "y": 2, "z": 3})

§Errors

Returns error if serde parsing fails

§Examples
use utiles_core::Tile;
let tile = Tile::from_json_obj(r#"{"x": 1, "y": 2, "z": 3}"#).unwrap();
assert_eq!(tile, Tile::new(1, 2, 3));
Source

pub fn from_json_arr(json: &str) -> UtilesCoreResult<Self>

Return tile from json-array string (e.g. [1, 2, 3])

§Errors

Returns error if serde parsing fails

§Examples
use utiles_core::Tile;
let tile = Tile::from_json_arr("[1, 2, 3]").unwrap();
assert_eq!(tile, Tile::new(1, 2, 3));
Source

pub fn from_json(json: &str) -> Result<Self, UtilesCoreError>

Return tile from json string either object or array

§Errors

Returns error if serde parsing fails

§Examples
use utiles_core::Tile;
let tile_from_obj = Tile::from_json(r#"{"x": 1, "y": 2, "z": 3}"#).unwrap();
assert_eq!(tile_from_obj, Tile::new(1, 2, 3));
let tile_from_arr = Tile::from_json(r#"[1, 2, 3]"#).unwrap();
assert_eq!(tile_from_arr, Tile::new(1, 2, 3));
Source

pub fn from_json_loose(json: &str) -> UtilesCoreResult<Self>

Return tile from json string either object or array

§Errors

Returns error if unable to parse json string

Source

pub fn quadkey(&self) -> String

Return the quadkey for the tile

Source

pub fn qk(&self) -> String

Return the quadkey for the tile (alias for quadkey)

Source

pub fn from_lnglat_zoom( lng: f64, lat: f64, zoom: u8, truncate: Option<bool>, ) -> UtilesCoreResult<Self>

Return new Tile from given (lng, lat, zoom)

§Errors

Returns an error if the conversion fails resulting in invalid tile

Source

pub fn up(&self) -> Self

Return the bounding box of the tile

Source

pub fn down(&self) -> Self

Return the tile to the bottom

Source

pub fn left(&self) -> Self

Return the tile to the left

Source

pub fn right(&self) -> Self

Return the tile to the right

Source

pub fn up_left(&self) -> Self

Return the tile to the top left

Source

pub fn up_right(&self) -> Self

Return the tile to the top right

Source

pub fn down_left(&self) -> Self

Return the tile to the bottom left

Source

pub fn down_right(&self) -> Self

Return the tile to the bottom right

Source

pub fn neighbors(&self) -> Vec<Self>

Return a vector with the 3-8 neighbors of the tile

Source

pub fn children1(&self) -> [Tile; 4]

Return direct children

Source

pub fn children(&self, zoom: Option<u8>) -> Vec<Tile>

Return the children tiles of the tile

Source

pub fn children_zorder(&self, zoom: Option<u8>) -> Vec<Tile>

Return the children tiles of the tile

Source

pub fn parent(&self, zoom: Option<u8>) -> Option<Self>

Return the parent tile

Source

pub fn siblings(&self) -> Vec<Self>

Return sibling tiles that share the same parent tile (not neighbors)

Source

pub fn feature(&self, opts: &FeatureOptions) -> UtilesCoreResult<TileFeature>

Return a TileFeature for the tile

§Errors

Returns an error if the feature creation fails (which may be impossible [2024-08-14])

Source§

impl Tile

Source

pub fn pmtileid(&self) -> u64

Return pmtile-id for the tile

Source

pub fn from_pmtileid(id: u64) -> Self

Return tile from pmtile-id

Source

pub fn from_pmid(id: u64) -> Self

Return tile from pmtile-id (alias for from_pmtileid)

Source

pub fn parent_pmtileid(&self) -> Option<u64>

Return the parent tile’s pmtile-id

Trait Implementations§

Source§

impl Clone for Tile

Source§

fn clone(&self) -> Tile

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Tile

Source§

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

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

impl<'de> Deserialize<'de> for Tile

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Tile

Source§

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

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

impl From<(u32, u32, u8)> for Tile

Source§

fn from(tuple: (u32, u32, u8)) -> Self

Converts to this type from the input type.
Source§

impl From<Tile> for (u32, u32, u8)

Source§

fn from(tile: Tile) -> Self

Converts to this type from the input type.
Source§

impl From<Tile> for SiblingRelationship

Source§

fn from(value: Tile) -> Self

Converts to this type from the input type.
Source§

impl From<Tile> for WebBBox

Source§

fn from(tile: Tile) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Tile

Source§

type Err = Box<dyn Error>

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 IsOk for Tile

Source§

fn ok(&self) -> UtilesCoreResult<Self>

Returns Ok if the value is Ok or an error Read more
Source§

impl Ord for Tile

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. 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 · 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 PartialOrd for Tile

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, other: &Self) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Tile

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TileChildren1 for Tile

Source§

fn children1(&self) -> [Self; 4]

Returns direct children in Z order: 1) top-left 2) top-right 3) bottom-left 4) bottom-right
Source§

impl TileLike for Tile

Source§

fn x(&self) -> u32

x coordinate (column)
Source§

fn y(&self) -> u32

y coordinate (row – flipped for TMS)
Source§

fn z(&self) -> u8

z coordinate (zoom level)
Source§

fn zoom(&self) -> u8

zoom level
Source§

fn yflip(&self) -> u32

x coordinate
Source§

fn flipy(&self) -> u32

both bc I keep forgetting which is which
Source§

fn yup(&self) -> u32

Source§

fn xyz_str_fslash(&self) -> String

Source§

fn zxy_str_fslash(&self) -> String

Source§

fn xyz_str_sep(&self, sep: &str) -> String

Source§

fn zxy_str_sep(&self, sep: &str) -> String

Source§

fn tile(&self) -> Tile

Return Tile struct
Source§

fn valid(&self) -> bool

Return if the tile is valid (x, y is in bounds for zoom level z)
Source§

fn ul(&self) -> LngLat

Return the ul (upper left) corner of the tile
Source§

fn ur(&self) -> LngLat

Return the ur (upper right) corner of the tile
Source§

fn lr(&self) -> LngLat

Return the lr (lower right) corner of the tile
Source§

fn ll(&self) -> LngLat

Return the ll (lower left) corner of the tile
Source§

fn quadkey(&self) -> String

Return the quadkey for the tile
Source§

fn qk(&self) -> String

Return the quadkey for the tile (alias for quadkey)
Source§

fn pmtileid(&self) -> u64

Return the pmtile-id for the tile
Source§

fn pmid(&self) -> u64

Return the pmtile id
Source§

fn row_major_id(&self) -> u64

Return the row major id for the tile
Source§

fn rmid(&self) -> u64

Return the row major id for the tile (alias for row_major_id)
Source§

fn bbox(&self) -> (f64, f64, f64, f64)

Return the geo-bbox tuple for the tile (west, south, east, north)
Source§

fn geobbox(&self) -> BBox

Source§

fn webbbox(&self) -> WebBBox

Source§

fn bbox_string(&self) -> String

Source§

fn center(&self) -> LngLat

Return the center of the tile as a LngLat
Source§

fn json_arr(&self) -> String

Return json array string for tile with spaces after commas
Source§

fn json_arr_min(&self) -> String

Return json array string for tile with no spaces after commas
Source§

fn json_obj(&self) -> String

Return json object string for tile
Source§

fn json(&self) -> String

Return json object string for tile
Source§

fn tuple_string(&self) -> String

Return tuple string for tile (x, y, z)
Source§

fn mbtiles_sql_where(&self) -> String

Return sql WHERE clause for querying mbtiles (y is up)
Source§

fn zbox(&self) -> TileZBox

return zbox for tile-like
Source§

fn children_zbox(&self, depth: Option<u8>) -> TileZBox

Return children-zbox for tile-like at optional depth (default 1)
Source§

impl TileParent for Tile

Source§

fn parent(&self, zoom: Option<u8>) -> Option<Tile>

Source§

fn root() -> Tile

Source§

fn iter_parents(&self) -> Parents<Self>

Source§

impl TryFrom<&Map<String, Value>> for Tile

Source§

type Error = UtilesCoreError

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

fn try_from(map: &Map<String, Value>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for Tile

Source§

type Error = UtilesCoreError

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

fn try_from(val: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Vec<Value>> for Tile

Source§

type Error = UtilesCoreError

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

fn try_from(arr: &Vec<Value>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&str> for Tile

Source§

type Error = UtilesCoreError

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

fn try_from(s: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<(u64, u64, u64)> for Tile

Source§

type Error = UtilesCoreError

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

fn try_from(tuple: (u64, u64, u64)) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Tile

Source§

type Error = UtilesCoreError

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

fn try_from(val: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Tile

Source§

impl Eq for Tile

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 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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,