go-spatial / tegola

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

fix: filter by zoom level for min/max zoom 0 #871

Closed iwpnd closed 2 years ago

iwpnd commented 2 years ago

Prior to this, setting min_zoom=0 and max_zoom=0 would result in the layer being present across the entire zoom range.

Should fix #870

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build dcc9261d9-PR-871


Totals Coverage Status
Change from base Build c3aeca0fa: 0.0%
Covered Lines: 5599
Relevant Lines: 12367

💛 - Coveralls
iwpnd commented 2 years ago

Now that i think of it, it might not be necessary. It might suffice if you prompt the user that 0 is not a supported min zoom level and/or default to 1. Either way, your input would be much appreciated here @ARolek

ARolek commented 2 years ago

@iwpnd the change you submitted is really simple, so no issues there. I'm trying to figure out why I put the logic check in for zoom == 0. Looking back at the blame history it was something I put in 5 years ago when I originally authored this file and I can't for the life of me remember why.

It might suffice if you prompt the user that 0 is not a supported min zoom level and/or default to 1

I like this idea. Just add a log in saying min_zoom of 0 is not supported. adjusting to '1'.

Thanks for the PR and investigation.

iwpnd commented 2 years ago

@ARolek I'm afraid that won't work for max_zoom 0 as tegola sets the constant max zoom of 22 if the MaxZoom is left blank in the toml. Modifying ParseInt would potentially negatively impact other variables in the config, so that is not an option either.

edit: nevermind my dumb ass, i can just check whether value is 0 after I make sure that l.MaxZoom is not a nil pointer.

iwpnd commented 2 years ago

874 will change max_zoom to 1 if set to 0 by the user. I leave the choice of which route to take to you. Either merge #871 or #874. :)