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
impl Tile
Sourcepub fn bounds(&self) -> (f64, f64, f64, f64)
pub fn bounds(&self) -> (f64, f64, f64, f64)
Return bounds tuple (west, south, east, north) for the tile
Sourcepub fn from_row_major_id(id: u64) -> Self
pub fn from_row_major_id(id: u64) -> Self
Return tile from row-major tile-id
Sourcepub fn from_rmid(id: u64) -> Self
pub fn from_rmid(id: u64) -> Self
Return tile from row-major tile-id (alias for from_row_major_id
)
Sourcepub fn fmt_zxy(&self, sep: Option<&str>) -> String
pub fn fmt_zxy(&self, sep: Option<&str>) -> String
Return zxy string with optional separator (default is ‘/’)
Sourcepub fn fmt_zxy_ext(&self, ext: &str, sep: Option<&str>) -> String
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");
Sourcepub fn from_quadkey(quadkey: &str) -> UtilesCoreResult<Self>
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)
Sourcepub fn from_qk(qk: &str) -> UtilesCoreResult<Self>
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)
Sourcepub fn from_json_obj(json: &str) -> UtilesCoreResult<Self>
pub fn from_json_obj(json: &str) -> UtilesCoreResult<Self>
Sourcepub fn from_json_arr(json: &str) -> UtilesCoreResult<Self>
pub fn from_json_arr(json: &str) -> UtilesCoreResult<Self>
Sourcepub fn from_json(json: &str) -> Result<Self, UtilesCoreError>
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));
Sourcepub fn from_json_loose(json: &str) -> UtilesCoreResult<Self>
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
Sourcepub fn from_lnglat_zoom(
lng: f64,
lat: f64,
zoom: u8,
truncate: Option<bool>,
) -> UtilesCoreResult<Self>
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
Sourcepub fn down_right(&self) -> Self
pub fn down_right(&self) -> Self
Return the tile to the bottom right
Sourcepub fn children_zorder(&self, zoom: Option<u8>) -> Vec<Tile>
pub fn children_zorder(&self, zoom: Option<u8>) -> Vec<Tile>
Return the children tiles of the tile
Sourcepub fn siblings(&self) -> Vec<Self>
pub fn siblings(&self) -> Vec<Self>
Return sibling tiles that share the same parent tile (not neighbors)
Sourcepub fn feature(&self, opts: &FeatureOptions) -> UtilesCoreResult<TileFeature>
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
impl Tile
Sourcepub fn from_pmtileid(id: u64) -> Self
pub fn from_pmtileid(id: u64) -> Self
Return tile from pmtile-id
Sourcepub fn parent_pmtileid(&self) -> Option<u64>
pub fn parent_pmtileid(&self) -> Option<u64>
Return the parent tile’s pmtile-id
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tile
impl<'de> Deserialize<'de> for Tile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Tile> for SiblingRelationship
impl From<Tile> for SiblingRelationship
Source§impl Ord for Tile
impl Ord for Tile
Source§impl PartialOrd for Tile
impl PartialOrd for Tile
Source§impl TileChildren1 for Tile
impl TileChildren1 for Tile
Source§impl TileLike for Tile
impl TileLike for Tile
fn yup(&self) -> u32
fn xyz_str_fslash(&self) -> String
fn zxy_str_fslash(&self) -> String
fn xyz_str_sep(&self, sep: &str) -> String
fn zxy_str_sep(&self, sep: &str) -> String
Source§fn row_major_id(&self) -> u64
fn row_major_id(&self) -> u64
Source§fn bbox(&self) -> (f64, f64, f64, f64)
fn bbox(&self) -> (f64, f64, f64, f64)
fn geobbox(&self) -> BBox
fn webbbox(&self) -> WebBBox
fn bbox_string(&self) -> String
Source§fn json_arr_min(&self) -> String
fn json_arr_min(&self) -> String
Source§fn tuple_string(&self) -> String
fn tuple_string(&self) -> String
(x, y, z)
Source§fn mbtiles_sql_where(&self) -> String
fn mbtiles_sql_where(&self) -> String
WHERE
clause for querying mbtiles (y is up)Source§impl TileParent for Tile
impl TileParent for Tile
impl Copy for Tile
impl Eq for Tile
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.