Function slippy_map_tilenames::zoom_in [] [src]

pub fn zoom_in(
    x: u32,
    y: u32
) -> ((u32, u32), (u32, u32), (u32, u32), (u32, u32))

Zooms in starting from the given tile

The zoom in function, given a tile t:(x, y) corresponding to the zoomlevel z, returns the 4 tiles onto which the tile t is split out zooming to the next zoomlevel z + 1.

The actual zoomlevel is of no consequence to the function, since the tile t will be split out into 4 tiles when zooming in, as per the definitions of a web slippy map.

For more info, cf the relevant article in wiki.openstreetmap.org

Arguments

  • x - X current tile coordinate
  • y - Y current tile coordinate

Notice how the zoomlevel is unimportant, and therefore not needed as argument, since many tile's X and Y coordinates are shared among many different zoomlevels.

Output

This functions gets in output 4 tiles referenced as follows:

((x1, y1), (x2, y1), (x1, y2), (x2, y2))

Grafically:

+--------+--------+
| x1, y1 | x2, y1 |
+--------+--------+
| x1, y2 | x2, y2 |
+--------+--------+

Examples

extern crate slippy_map_tilenames as smt;

fn main() {
    let (x, y) = smt::zoom_out(5,7); // (2,3)
    println!("t: (5,7), z: 3; zooming out to z: 2 => ({}, {})", x, y);
}

Unexpected Behavior

This function does not behave unexpectedly. However care should be taken in providing the tile's coordinates in input, since many tile's X and Y coordinates are shared among many different zoomlevels.