|
function getCartoCss(id, rules) { |
|
return '#' + id + ' {\n\t' + |
|
rules.join('\n\t') |
|
+ '\n}' |
|
} |
|
|
|
var DEFAULT_STYLE = [ |
|
"#points['mapnik::geometry_type'=1] {", |
|
" marker-fill-opacity: 0.7;", |
|
" marker-line-color: #FFF;", |
|
" marker-line-width: 0.5;", |
|
" marker-line-opacity: 1;", |
|
" marker-placement: point;", |
|
" marker-type: ellipse;", |
|
" marker-width: 4;", |
|
" marker-fill: red;", |
|
" marker-allow-overlap: true;", |
|
"}", |
|
"#lines['mapnik::geometry_type'=2] {", |
|
" line-color: red;", |
|
" line-width: 2;", |
|
" line-opacity: 1.0;", |
|
"}", |
|
"#polygons['mapnik::geometry_type'=3] {", |
|
" polygon-fill: red;", |
|
" polygon-opacity: 0.7;", |
|
" line-color: #FFF;", |
|
" line-width: 0.5;", |
|
" line-opacity: 1;", |
|
"}" |
|
].join('\n'); |
|
|
|
// All of these could be standardized to use 7 colors |
|
|
|
// EGBERT / 117181 |
|
var colors_1 = [ |
|
'#9bbbd5', |
|
'#8cacc6', |
|
'#7d9cb6', |
|
'#6e8da7', |
|
'#5e7e98', |
|
'#4f6f88', |
|
'#406079', |
|
'#315069', |
|
'#22415a' |
|
]; |
|
|
|
// OLIVE / 117185 |
|
var colors_2 = [ |
|
'#b5c88d', |
|
'#9cb075', |
|
'#84975d', |
|
'#6b7f44', |
|
'#53662c', |
|
'#3a4e14' |
|
]; |
|
|
|
|
|
// RAPUNZEL / 117186 |
|
var colors_3 = [ |
|
'#f4bb84', |
|
'#e3aa74', |
|
'#d19865', |
|
'#c08755', |
|
'#ae7646', |
|
'#9d6536', |
|
'#8b5327', |
|
'#7a4217' |
|
]; |
|
|
|
// HELEN / 130828 |
|
var colors_4 = [ |
|
'#94c7b6', |
|
'#77a997', |
|
'#5b8a79', |
|
'#3e6b5a', |
|
'#214d3b' |
|
]; |
|
|
|
// SCOOTER / 130830 |
|
var colors_5 = [ |
|
'#e38f8f', |
|
'#c57372', |
|
'#a75655', |
|
'#893a38', |
|
'#6b1d1b' |
|
]; |
|
|
|
// WALTER / 130832 |
|
var colors_6 = [ |
|
'#e49bc1', |
|
'#c67ea3', |
|
'#a86184', |
|
'#894466', |
|
'#6b2747' |
|
]; |
|
|
|
// UNNAMED / 139413 |
|
var colors_7 = [ |
|
'#c2a8cc', |
|
'#482e51' |
|
]; |
|
|
|
var examples = { |
|
|
|
'ospreys-manual': { |
|
sql: [ |
|
"SELECT id, year, season,", |
|
"(year::text || '-' || season) as cartodb_id,", |
|
"CASE WHEN season = 'spring' THEN year*10 + 1 ELSE year+10 + 2 END AS year_and_season,", |
|
" ST_MakeLine(", |
|
" ST_Transform(", |
|
" ST_SetSRID(", |
|
" ST_MakePoint(lon, lat),", |
|
" 4326),", |
|
" 3857)", |
|
" ORDER BY timestamp DESC", |
|
" ) as the_geom_webmercator", |
|
"FROM", |
|
"(", |
|
" SELECT *, ", |
|
" ST_Distance(", |
|
" the_geom_webmercator, ", |
|
" lag(the_geom_webmercator) ", |
|
" OVER (", |
|
" ORDER BY id, timestamp", |
|
" )", |
|
" ) AS dist ", |
|
" FROM", |
|
" movebank_api_output", |
|
") as _", |
|
"WHERE season != 'other'", |
|
"AND dist < 100000", |
|
"GROUP BY id, year, season", |
|
"order by cartodb_id", |
|
].join('\n'), |
|
cartocss: [ |
|
"#layer{", |
|
" line-width: 3;", |
|
" line-opacity: 0.8;", |
|
" line-join: round;", |
|
" [id=117181]{ line-color: ramp([year_and_season],(" + colors_1.join() + ")); } /* Egbert */", |
|
" [id=117185]{ line-color: ramp([year_and_season],(" + colors_2.join() + ")); } /* Olive */", |
|
" [id=117186]{ line-color: ramp([year_and_season],(" + colors_3.join() + ")); } /* Rapunzel */", |
|
" [id=130828]{ line-color: ramp([year_and_season],(" + colors_4.join() + ")); } /* Helen */", |
|
" [id=130830]{ line-color: ramp([year_and_season],(" + colors_5.join() + ")); } /* Scooter */", |
|
" [id=130832]{ line-color: ramp([year_and_season],(" + colors_6.join() + ")); } /* Walter */", |
|
" [id=139413]{ line-color: ramp([year_and_season],(" + colors_7.join() + ")); } /* Unnamed */", |
|
"}" |
|
].join('\n'), |
|
center: [45, -110], |
|
zoom: 5 |
|
}, |
|
|
|
'ospreys-colorbrewer': { |
|
sql: [ |
|
"SELECT id, year, season,", |
|
"(year::text || '-' || season) as cartodb_id,", |
|
"CASE WHEN season = 'spring' THEN year*10 + 1 ELSE year+10 + 2 END AS year_and_season,", |
|
" ST_MakeLine(", |
|
" ST_Transform(", |
|
" ST_SetSRID(", |
|
" ST_MakePoint(lon, lat),", |
|
" 4326),", |
|
" 3857)", |
|
" ORDER BY timestamp DESC", |
|
" ) as the_geom_webmercator", |
|
"FROM", |
|
"(", |
|
" SELECT *, ", |
|
" ST_Distance(", |
|
" the_geom_webmercator, ", |
|
" lag(the_geom_webmercator) ", |
|
" OVER (", |
|
" ORDER BY id, timestamp", |
|
" )", |
|
" ) AS dist ", |
|
" FROM", |
|
" movebank_api_output", |
|
") as _", |
|
"WHERE season != 'other'", |
|
"AND dist < 100000", |
|
"GROUP BY id, year, season", |
|
"order by cartodb_id", |
|
].join('\n'), |
|
cartocss: [ |
|
"#layer{", |
|
" line-width: 3;", |
|
" line-opacity: 0.8;", |
|
" line-join: round;", |
|
" [id=117181]{ line-color: ramp([year_and_season],colorbrewer(Blues)); } /* Egbert */", |
|
" [id=117185]{ line-color: ramp([year_and_season],colorbrewer(Greens)); } /* Olive */", |
|
" [id=117186]{ line-color: ramp([year_and_season],colorbrewer(YlOrBr)); } /* Rapunzel */", |
|
" [id=130828]{ line-color: ramp([year_and_season],colorbrewer(BuGr)); } /* Helen */", |
|
" [id=130830]{ line-color: ramp([year_and_season],colorbrewer(Oranges)); } /* Scooter */", |
|
" [id=130832]{ line-color: ramp([year_and_season],colorbrewer(PuRd)); } /* Walter */", |
|
" [id=139413]{ line-color: ramp([year_and_season],colorbrewer(Purples)); } /* Unnamed */", |
|
"}" |
|
].join('\n'), |
|
center: [45, -110], |
|
zoom: 5 |
|
} |
|
|
|
}; |