go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.25k stars 192 forks source link

Set Tile Resolution / Extent #955

Closed wroge closed 8 months ago

wroge commented 8 months ago

Unfortunately, my generated Vector Tiles are incorrect... Previously I created my Vector Tiles with T-Rex, specifying a resolution of 16384. However, with Tegola, I am unable to configure the tile extent of the ST_AsMVT PostGIS function. (Default: 4096)

Bildschirmfoto 2023-10-11 um 13 25 30

https://github.com/go-spatial/tegola/blob/master/provider/postgis/postgis.go#L1029

sqls = append(sqls, fmt.Sprintf(
    `(SELECT ST_AsMVT(q,'%s',%d,'%s',%s) AS data FROM (%s) AS q)`,
    layers[i].MVTName,
    tegola.DefaultExtent,
    l.GeomFieldName(),
    featureIDName,
    sql,
))

My config:

[[providers]]
# ...
type = "mvt_postgis"
uri = "${PG_CONNECTION}"
srid = 3857

[[providers.layers]]
# ...
geometry_type = "POLYGON"
id_fieldname = "objectid"
geometry_fieldname = "wkb_geometry"
sql = "SELECT ST_AsMVTGeom(ST_Transform(geom, 3857), ST_Transform(!BBOX!, 3857)) AS wkb_geometry, objectid FROM my_table WHERE ST_Transform(geom, 3857) && ST_Transform(!BBOX!, 3857)"

[[maps]]
# ...
bounds = [6.3, 51.25, 11.6, 54.17]
center = [10.023321918554046, 52.44665611695578, 15.0]
tile_buffer = 150

[[maps.layers]]
# ...
min_zoom = 12
max_zoom = 15 
dont_simplify = true

If desired, I can try to provide a pull request.

wroge commented 8 months ago
Bildschirmfoto 2023-10-13 um 09 49 42

The issue was on my side.

ARolek commented 8 months ago

@wroge just wondering, why are you bumping up the resolution?

wroge commented 8 months ago

I thought it might help... other vector tiling tools offer this option. It doesn't make too much sense.. realize that now too.

ARolek commented 8 months ago

Ok got it. Generally speaking you should be able to pack plenty of data into the vector tile at zoom 16 and then let the UI over zoom on that tile.