go-spatial / tegola

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

With mvt_postgis data provider tegola returns mvt file with size 0 byte if the tile have no data #788

Open F-15023 opened 3 years ago

F-15023 commented 3 years ago

Hello, I have encountered with a problem. If the tile have no data inside of its BBOX tegola with postgis data provider will returns mvt file wich will contains names of layers at least. But with new mvt_postgis data provider tegola will returns empty file with 0 byte size. And the problem is, the caching server can't use this file (because of its size, I think) and returns 404. Is it possible to make this type of files not totally empty and remain names of layers for example?

pnorman commented 3 years ago

A zero byte file where there's no data is correct.

F-15023 commented 3 years ago

The problem is that nginx returns 404 if file 0 bytes and this files can't be cached also. Can you add parameter that make tegola returns the same file as with postgis data provider for this type of mvt?

ARolek commented 3 years ago

@F-15023

Can you add parameter that make tegola returns the same file as with postgis data provider for this type of mvt

Can you expand on this? Are you saying that PostGIS is returning a non 0-byte tile, but tegola is returning a 0-byte tile?

F-15023 commented 3 years ago

For example, we have tile which have no data. With postgis data provider (I mean type = postgis in tegola config in [[providers]] section) tegola returns mvt file which will contains all layers names from tegola config even if layers have no objects. You can see something like this inside of mvt file for empty tile: layers { name: "rivers" extent: 4096 version: 2 } layers { name: "buildings" extent: 4096 version: 2 } ...etc. And this mvt file will not have 0 byte size. But with new mvt_postgis data provider tegola will return absolutely empty file without layers names and it will be 0 byte size. And this leads to some problems as I say before. Now I had to add a useless layer containing the BBOX borders, just to avoid 0 byte files. Maybe there are better solutions exists?

ARolek commented 3 years ago

@F-15023 Ah yes, I'm thinking that's potentially a bug in tegola as it should probably be returning 0 byte tiles if no data exists. I need to look into this a bit.

Can you share any of your nginx config? I'm surprised that it's returning a 404 even though tegola is not. I could maybe understand a 204 No Content, but I'm surprised that changing the status code to 404 on a 0-byte body would be the default behavior.