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

Unable to generate tiles, tile extents appear to be wrong ... #292

Closed Medit8r closed 1 year ago

Medit8r commented 1 year ago

For some reason the tileset extent does not appear to be working. It have tried generating tiles from a geopackage and from postgis with the same issue. I'd like to generate tiles for a small region in south western Australia. Here is the extent in web mercator coordinates:

extent = { minx = 12896455.0, miny = -3757644.4, maxx = 12898290.3, maxy = -3757033.5 }

Here is my config file:

[service.mvt] viewer = true

[[datasource]] name = "database" default = true dbconn = "postgres://postgres:Med1t8r@localhost:5432/WP_Asset"

[grid] predefined = "web_mercator"

[[tileset]] name = "WP_Asset" minzoom = 16 cache_limits = {minzoom = 8, maxzoom = 16, no_cache = false} extent = { minx = 12896455.0, miny = -3757644.4, maxx = 12898290.3, maxy = -3757033.5 } start_zoom = 16

[[tileset.layer]] name = "nodes_hv_minor" table_name = "nodes_hv_minor" geometry_field = "geom" geometry_type = "POINT" srid = 3857 fid_field = "FEATURE_ID" tile_size = 4096 simplify = true tolerance = "!pixel_width!/2" buffer_size = 10 make_valid = true [[tileset.layer.query]] minzoom = 16 maxzoom = 16 sql = """ SELECT FEATURE_ID, geom, PICK_ID, EQUIP_NAME, STYLEKEY FROM nodes_hv_minor WHERE geom && !bbox!"""

[cache.file] base = "/tmp/mvtcache"

baseurl = "http://example.com/tiles"

[webserver] bind = "127.0.0.1" port = 6767

[[webserver.static]]

path = "/static"

dir = "./public/"

Here is the debug listing when I attempt to generate the tiles:

t_rex generate --config WP_Asset_postgis.conf --loglevel debug 2022-09-14 09:47:14.108 INFO Reading configuration from 'WP_Asset_postgis.conf' 2022-09-14 09:47:14.109 DEBUG Connecting to postgres://postgres:Med1t8r@localhost:5432/WP_Asset 2022-09-14 09:47:14.199 DEBUG detect_data_columns for layer nodes_hv_minor with sql Some(" SELECT FEATURE_ID, geom, PICK_ID, EQUIP_NAME, STYLEKEY \n FROM nodes_hv_minor \n WHERE geom && !bbox!") 2022-09-14 09:47:14.215 DEBUG Query for layer 'nodes_hv_minor': SELECT geom,"feature_id","pick_id","equip_name","stylekey" FROM ( SELECT FEATURE_ID, geom, PICK_ID, EQUIP_NAME, STYLEKEY FROM nodes_hv_minor WHERE geom && ST_MakeEnvelope($1-0.625$5::FLOAT8,$2-0.625$5::FLOAT8,$3+0.625$5::FLOAT8,$4+0.625$5::FLOAT8,3857)) AS _q 2022-09-14 09:47:14.216 INFO Tile cache directory: /tmp/mvtcache 2022-09-14 09:47:14.216 DEBUG detect_data_columns for layer nodes_hv_minor with sql Some(" SELECT FEATURE_ID, geom, PICK_ID, EQUIP_NAME, STYLEKEY \n FROM nodes_hv_minor \n WHERE geom && !bbox!") 2022-09-14 09:47:14.217 DEBUG Filecache.write /tmp/mvtcache/WP_Asset.json 2022-09-14 09:47:14.555 DEBUG Filecache.write /tmp/mvtcache/WP_Asset.style.json 2022-09-14 09:47:14.558 DEBUG detect_data_columns for layer nodes_hv_minor with sql Some(" SELECT FEATURE_ID, geom, PICK_ID, EQUIP_NAME, STYLEKEY \n FROM nodes_hv_minor \n WHERE geom && !bbox!") 2022-09-14 09:47:14.561 DEBUG detect_data_columns for layer nodes_hv_minor with sql Some(" SELECT FEATURE_ID, geom, PICK_ID, EQUIP_NAME, STYLEKEY \n FROM nodes_hv_minor \n WHERE geom && !bbox!") 2022-09-14 09:47:14.562 DEBUG Filecache.write /tmp/mvtcache/WP_Asset/metadata.json Generating tileset 'WP_Asset'... 2022-09-14 09:47:14.565 DEBUG input extent: Some(Extent { minx: 12896455.0, miny: -3757644.4, maxx: 12898290.3, maxy: -3757033.5 }) 2022-09-14 09:47:14.566 DEBUG tile limits: Extent { minx: 1435626803638.367, miny: 4245720.660413529, maxx: 1435831108299.82, maxy: -12316623.451079082 } 2022-09-14 09:47:14.568 DEBUG level 16: ExtentInt { minx: 2147483647, miny: 39711, maxx: 65536, maxy: 12627 } Level 16: 1 / 58160672118324 [>-------------------------------------------------------------------------------------] 2022-09-14 09:47:14.571 DEBUG WP_Asset/16/2147483647/39711 retrieving with Extent { minx: 1313158108633.197, miny: 4245618.29907183, maxx: 1313158109244.6934, maxy: 4246229.795298111 } 2022-09-14 09:47:14.577 DEBUG Reading features in layer nodes_hv_minor 2022-09-14 09:47:14.577 DEBUG WP_Asset/16/2147483647/39711 layer nodes_hv_minor: 0 features

Notice how the input extent is correct,but the tile limits extents is way off. I don't know what the $5 parameter is in the ST_MakeEnvelope, but is it creating the issue? Then see that the 'x' value for the tile coordinate is way off (ie. 16/2147483647/39711).

Note as well, that the y values are negative, since they are in the southern hemisphere.

Any help would be greatly appreciated. I used t_rex years ago on another project and didn't have any problems. Now I am scratching my head ...

pka commented 1 year ago

Extents are specified in WGS84 geographic coordinates. The only exception is with an optional SRID in the generate command contributed in #236.