t-rex-tileserver / t-rex

t-rex is a vector tile server specialized on publishing MVT tiles from your own data
https://t-rex.tileserver.ch/
MIT License
545 stars 68 forks source link

Custom tile grid resolutions beginner's question #317

Open phillashworth opened 2 months ago

phillashworth commented 2 months ago

I'm using T-Rex to serve OSM openmaptiles in a local projection based on your openmaptiles.toml and usergrid.toml examples and consuming the tiles in OpenLayers.

I'm reprojecting to British National Grid EPSG:27700 which works brilliantly thanks :)

My question regards the user grid resolutions array, I've seen many articles on how to calculate this for web mercator but not for other projections. By trial and error I've managed to find values that perform well and display an appropriate level of details at the various map zoom levels but I'd like to understand how to calculate the resolutions for the custom projection in a more scientific manner. Any pointers would be greatly appreciated.

[grid.user]
    width = 256
    height = 256
    extent = { minx = -238375.0, miny = 0.0, maxx = 900000.0, maxy = 1376256.0}
    srid = 27700
    units = "m"
    resolutions = [???]
    origin = "TopLeft"
pka commented 1 month ago

The OGC spec has a detailed explanation: https://docs.ogc.org/is/17-083r4/17-083r4.html

This BBOX guide shows the usage of morecantile to calculate a grid. You can extract the resolutions from the JSON output.