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

@ -17,11 +17,20 @@ RETURNS int
LANGUAGE SQL LANGUAGE SQL
IMMUTABLE IMMUTABLE
AS $$ AS $$
SELECT SELECT
CASE CASE
-- Don't bother if the scale is larger than ~zoom level 0 WHEN scaleDenominator > 600000000 THEN
WHEN scaleDenominator > 600000000 OR scaleDenominator = 0 THEN NULL -- Scale is smaller than zoom level 0
WHEN scaleDenominator = 0 THEN _CDB_MaxSupportedZoom() NULL
ELSE CAST (LEAST(ROUND(LOG(2, 559082264.028/scaleDenominator)), _CDB_MaxSupportedZoom()) AS INTEGER) 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; END;
$$; $$;