Created
August 4, 2016 12:18
-
-
Save jmwenda/8188fe57bab6256d6a43ddca89b00c42 to your computer and use it in GitHub Desktop.
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
var markersLayerSource = { | |
user_name: 'nation', | |
type: 'cartodb', | |
sublayers: [{ | |
sql: "WITH hgridA AS (SELECT CDB_HexagonGrid(ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 48), greatest(!pixel_width!,!pixel_height!) * 48) as cell), bigs AS (SELECT * FROM (SELECT ST_Centroid(ST_Collect(i.the_geom_webmercator)) as the_geom_webmercator, count(i.cartodb_id) as points_count, 1 as cartodb_id, array_agg(cartodb_id) AS id_list FROM hgridA, (select * from reports WHERE published = true) i where ST_Intersects(i.the_geom_webmercator, hgridA.cell) GROUP BY hgridA.cell) t WHERE points_count > 100 ), hgridB AS (SELECT CDB_HexagonGrid(ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 36), greatest(!pixel_width!,!pixel_height!) * 36) as cell), mids AS (SELECT * FROM (SELECT ST_Centroid(ST_Collect(i.the_geom_webmercator)) as the_geom_webmercator, count(i.cartodb_id) as points_count, 1 as cartodb_id, array_agg(cartodb_id) AS id_list FROM hgridB, (select * from reports WHERE published = true) i where ST_Intersects(i.the_geom_webmercator, hgridB.cell) AND cartodb_id NOT IN (SELECT unnest(id_list) FROM bigs) GROUP BY hgridB.cell) t WHERE points_count > 25 ), hgridC AS (SELECT CDB_HexagonGrid(ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 24), greatest(!pixel_width!,!pixel_height!) * 24) as cell), smalls AS (SELECT * FROM (SELECT ST_Centroid(ST_Collect(i.the_geom_webmercator)) as the_geom_webmercator, count(i.cartodb_id) as points_count, 1 as cartodb_id, array_agg(cartodb_id) AS id_list FROM hgridC, (select * from reports WHERE published = true) i where ST_Intersects(i.the_geom_webmercator, hgridC.cell) AND cartodb_id NOT IN (SELECT unnest(id_list) FROM bigs) AND cartodb_id NOT IN (SELECT unnest(id_list) FROM mids) GROUP BY hgridC.cell) t WHERE points_count > 5 ) SELECT the_geom_webmercator, 1 points_count, cartodb_id, ARRAY[cartodb_id] as id_list, 'origin' as src, cartodb_id::text cdb_list FROM reports WHERE published = true AND cartodb_id NOT IN (select unnest(id_list) FROM bigs) AND cartodb_id NOT IN (select unnest(id_list) FROM mids) AND cartodb_id NOT IN (select unnest(id_list) FROM smalls) UNION ALL SELECT *, 'bigs' as src, array_to_string(id_list, ',') FROM bigs UNION ALL SELECT *, 'mids' as src, array_to_string(id_list, ',') FROM mids UNION ALL SELECT *, 'smalls' as src, array_to_string(id_list, ',') FROM smalls", | |
https: 'force https', | |
cartocss: "#reports {marker-width: 12;marker-fill: #109DCD;marker-opacity: 0.6;marker-line-width: 0;marker-allow-overlap: true;marker-comp-op: dst-atop;[src = 'smalls'] {marker-width: 20; }[src = 'mids'] {marker-width: 44;}[src = 'bigs'] { marker-width: 64; }[zoom>11]{marker-width: 52;}}#reports::lables {text-size: 0;text-fill: black;text-opacity: 0.8;text-name: [points_count];text-face-name: 'DejaVu Sans Book';text-halo-fill: #fff;text-halo-radius: 0;[src = 'smalls'] {text-size: 18; text-halo-radius: 1; }[src = 'mids'] {text-size: 26; text-halo-radius: 1; }[src = 'bigs'] { text-size: 32; text-halo-radius: 1; }text-allow-overlap: true;[zoom>11]{text-size: 36;}}", | |
interactivity: 'cartodb_id' | |
}] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment