10 unstable releases (4 breaking)

0.5.2 Jun 16, 2023
0.5.1 Jun 14, 2023
0.4.0 May 14, 2023
0.3.0 Feb 19, 2021
0.1.1 Jul 27, 2019

#45 in Geospatial

Download history 81/week @ 2023-12-13 4/week @ 2023-12-20 1/week @ 2024-01-03 4/week @ 2024-01-10 3/week @ 2024-01-17 20/week @ 2024-01-24 17/week @ 2024-01-31 17/week @ 2024-02-07 49/week @ 2024-02-14 81/week @ 2024-02-21 113/week @ 2024-02-28 110/week @ 2024-03-06 144/week @ 2024-03-13 83/week @ 2024-03-20 89/week @ 2024-03-27

433 downloads per month
Used in 3 crates (2 directly)

MIT license

120KB
2.5K SLoC

tile-grid

Crates.io Documentation

tile-grid is a library for using OGC TileMatrixSets (TMS).

tile-grid follows the OGC Two Dimensional Tile Matrix Set specification found in https://docs.ogc.org/is/17-083r4/17-083r4.html

Note: Variable matrix width tile set are not supported.

Usage

Load tile set matrix and get bounds of a tile

use tile_grid::{tms, BoundingBox, Xyz};

let tms = tms().lookup("WebMercatorQuad").unwrap();

// Get the bounds for tile Z=4, X=10, Y=10 in the input projection
let bounds = tms.xy_bounds(&Xyz::new(10, 10, 4));
assert_eq!(
    bounds,
    BoundingBox::new(
        5009377.085697308,
        -7514065.628545959,
        7514065.628545959,
        -5009377.085697308
    )
);

// Get the bounds for tile Z=4, X=10, Y=10 in LatLon (WGS84)
let bounds = tms.bounds(&Xyz::new(10, 10, 4)).unwrap();
assert_eq!(
    bounds,
    BoundingBox::new(45.0, -55.77657301866769, 67.5, -40.97989806962013)
);

Find tile for lat/lon

use tile_grid::{tms, Xyz};

let tms = tms().lookup("WebMercatorQuad").unwrap();

let tile = tms.tile(159.31, -42.0, 4).unwrap();
assert_eq!(tile, Xyz::new(15, 10, 4));

// Or using coordinates in input CRS
let tile = tms.xy_tile(17734308.1, -5160979.4, 4);
assert_eq!(tile, Xyz::new(15, 10, 4));

Credits

License

tile-grid is released under the MIT License.

Dependencies

~2.2–5MB
~74K SLoC