12 releases

0.6.2 Oct 29, 2024
0.6.1 May 19, 2024
0.6.0 Apr 30, 2024
0.5.2 Jun 16, 2023
0.2.1 Jul 29, 2019

#44 in Geospatial

Download history 128/week @ 2024-09-17 109/week @ 2024-09-24 113/week @ 2024-10-01 176/week @ 2024-10-08 159/week @ 2024-10-15 174/week @ 2024-10-22 291/week @ 2024-10-29 263/week @ 2024-11-05 169/week @ 2024-11-12 135/week @ 2024-11-19 142/week @ 2024-11-26 164/week @ 2024-12-03 263/week @ 2024-12-10 43/week @ 2024-12-17 3/week @ 2024-12-24 19/week @ 2024-12-31

400 downloads per month
Used in 4 crates (2 directly)

MIT license

99KB
2K 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

~5–8.5MB
~135K SLoC