tegola
tegola copied to clipboard
!ZOOM! substitution error
With a query containing the SQL way_area > pixel_size(!ZOOM!)*4
I get ERROR: syntax error at or near "ANY" (SQLSTATE 42601)
Because this is similar to previous problems with st_asbinary, I checked the code
https://github.com/terranodo/tegola/blob/9c523ad35e1e6ce3a06ca09e580518e78ac65622/provider/postgis/postgis.go#L277-L279
Substituting an expression to where an integer is expected isn't safe. Functions that accept zoom as a parameter are reasonably common, e.g. ZRes, or functions which take something that depends on z, like LabelGrid from postgis-vt-util. Many SQL functions are called with something depending on zoom, e.g. ST_SnapToGrid.
Unlike the st_asbinary case, I'm not aware of any workarounds.
@pnorman you have done a great job identifying various ways the current implementation is brittle. @ear7h is going to take on developing a more robust way to handle SQL substitution during the v0.7.0 milestone. We will be packaging these various issues into test cases so if you hit any additional situations please submit them.
@pnorman you have done a great job identifying various ways the current implementation is brittle. @ear7h is going to take on developing a more robust way to handle SQL substitution during the v0.7.0 milestone.
Let me know if I can help in some way
We will be packaging these various issues into test cases so if you hit any additional situations please submit them.
Will do.
!ZOOM! < n
and n > !ZOOM!
currently act differently, with the former causing a syntax error and the latter working.
Given that this issue makes !ZOOM! almost impossible to use for anything non-trivial at the moment, and the fact that pretty much everyone uses it to just remove objects at lower zoom levels, could we take the simple approach of replacing that ANY()
operator with 24
for the moment?
@pnorman I think you can set the geometry_type
on the provider layer to avoid tegola trying to infer the geometry type on startup. Additional details: https://tegola.io/documentation/configuration/#provider-layers