postgis-vt-util comes with a standard formula for zoom from scaleDenominator, and this is well tested. This also fixes the function throwing an error on NULL input.