Fix zoom from scale condition for NULL result

And rewrite in cleaner form.
This commit is contained in:
Javier Goizueta 2016-05-27 15:10:20 +02:00
parent 0b3ad5e569
commit 2a30eb2fd3

View File

@ -19,9 +19,18 @@ IMMUTABLE
AS $$
SELECT
CASE
-- Don't bother if the scale is larger than ~zoom level 0
WHEN scaleDenominator > 600000000 OR scaleDenominator = 0 THEN NULL
WHEN scaleDenominator = 0 THEN _CDB_MaxSupportedZoom()
ELSE CAST (LEAST(ROUND(LOG(2, 559082264.028/scaleDenominator)), _CDB_MaxSupportedZoom()) AS INTEGER)
WHEN scaleDenominator > 600000000 THEN
-- Scale is smaller than zoom level 0
NULL
WHEN scaleDenominator = 0 THEN
-- Actual zoom level would be infinite
_CDB_MaxSupportedZoom()
ELSE
CAST (
LEAST(
ROUND(LOG(2, 559082264.028/scaleDenominator)),
_CDB_MaxSupportedZoom()
)
AS INTEGER)
END;
$$;