Last active
August 29, 2015 14:14
-
-
Save andy-esch/0766a904158b032f981d to your computer and use it in GitHub Desktop.
make a checkerboard from an appropriately-sized table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- By using a table with 4^zoom rows, the following sql statement produces a checkboard | |
-- The following config works for making a checkerboard with zoom = 3 (4^3 = 64 rows) | |
WITH | |
vars AS (SELECT 3 AS zoom) | |
SELECT | |
(8 * ss.c1 + ss.c2 = ss.cartodb_id) as tf, | |
ss.c1, | |
ss.c2, | |
ss.cartodb_id as cartodb_id, | |
CASE | |
WHEN | |
ss.cartodb_id % 2 = 0 AND ss.c1 % 2 = 0 | |
THEN | |
CDB_XYZ_Extent(c1,c2,vars.zoom) | |
WHEN | |
ss.cartodb_id % 2 = 1 AND ss.c1 % 2 = 1 | |
THEN | |
CDB_XYZ_Extent(c1,c2,vars.zoom) | |
ELSE | |
null | |
END AS the_geom_webmercator | |
FROM ( | |
SELECT | |
floor((cartodb_id-1) / (1 << vars.zoom))::int as c1, | |
(cartodb_id % (1 << vars.zoom))::int as c2, | |
cartodb_id | |
from for_loops, vars) as ss, vars | |
ORDER BY c1, c2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment