Crates.io | tile-grid |
lib.rs | tile-grid |
version | 0.6.2 |
source | src |
created_at | 2019-07-27 18:15:40.543083 |
updated_at | 2024-10-29 15:24:06.439245 |
description | Library for map tile grid calculations. |
homepage | https://github.com/pka/tile-grid |
repository | https://github.com/pka/tile-grid |
max_upload_size | |
id | 152119 |
size | 329,346 |
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.
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)
);
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));
Morecantile by Vincent Sarago et al.
ogcapi by Balthasar Teuscher
tile-grid is released under the MIT License.