Skip to content

Commit

Permalink
Merge pull request CartoDB#12 from stamen/labels-only
Browse files Browse the repository at this point in the history
Labels only
  • Loading branch information
mojodna committed Jul 30, 2015
2 parents 7234932 + 23a51c6 commit 809795f
Show file tree
Hide file tree
Showing 16 changed files with 554 additions and 96 deletions.
27 changes: 27 additions & 0 deletions data/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,30 @@ cartodb_generalizations:
$(error VIEW_SCHEMA is undefined)
endif
node generalizations_sql.js $(VIEW_SCHEMA) $(DATABASE_URL)


basemap_light_only_labels:
node make_named_map.js mapconfig_light_only_labels light_only_labels > /tmp/basemap.json
curl -X DELETE -H 'content-type: application/json' -d @/tmp/basemap.json https://basemaps.cartodb.com/api/v1/map/named/light_only_labels\?api_key=$(CARTODB_API_KEY)
curl -H 'content-type: application/json' -d @/tmp/basemap.json https://basemaps.cartodb.com/api/v1/map/named\?api_key=$(CARTODB_API_KEY)
rm -rf /tmp/basempap.json

basemap_dark_only_labels:
node make_named_map.js mapconfig_dark_only_labels dark_only_labels > /tmp/basemap.json
curl -X DELETE -H 'content-type: application/json' -d @/tmp/basemap.json https://basemaps.cartodb.com/api/v1/map/named/dark_only_labels\?api_key=$(CARTODB_API_KEY)
curl -H 'content-type: application/json' -d @/tmp/basemap.json https://basemaps.cartodb.com/api/v1/map/named\?api_key=$(CARTODB_API_KEY)
rm -rf /tmp/basempap.json

basemap_light_all:
node make_named_map.js mapconfig_light staging_light > /tmp/basemap.json
curl -X DELETE -H 'content-type: application/json' -d @/tmp/basemap.json https://basemaps.cartodb.com/api/v1/map/named/staging_light\?api_key=$(CARTODB_API_KEY)
curl -H 'content-type: application/json' -d @/tmp/basemap.json https://basemaps.cartodb.com/api/v1/map/named\?api_key=$(CARTODB_API_KEY)
rm -rf /tmp/basempap.json
open "tools/test_basemap.html"

basemap_dark_all:
node make_named_map.js mapconfig_dark staging_dark > /tmp/basemap.json
curl -X DELETE -H 'content-type: application/json' -d @/tmp/basemap.json https://basemaps.cartodb.com/api/v1/map/named/staging_dark\?api_key=$(CARTODB_API_KEY)
curl -H 'content-type: application/json' -d @/tmp/basemap.json https://basemaps.cartodb.com/api/v1/map/named\?api_key=$(CARTODB_API_KEY)
rm -rf /tmp/basempap.json
open "tools/test_basemap.html"
7 changes: 4 additions & 3 deletions data/make_named_map.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
var util = require('./util.js');

function make(name) {
function make(name, named_map_name) {
named_map_name = named_map_name || name;
var json = util.node()[name];
return JSON.stringify({
"name": name ,
"name": named_map_name,
"auth":"open",
"version": "0.0.1",
'layergroup': json
})
}

console.log(make(process.argv[2]));
console.log(make(process.argv[2], process.argv[3]));
31 changes: 27 additions & 4 deletions data/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
var node = function() {
var fs = require("fs");
var md5 = require('MD5');
var _ = require('underscore');

var PROJECT = JSON.parse(fs.readFileSync("project.json"));
var IMAGES_HOST = 'http://libs.cartocdn.com.s3.amazonaws.com/stamen-base/';
Expand All @@ -20,6 +21,7 @@ var node = function() {
var mapconfig_light_nolabels = {'layers':[]};
var mapconfig_dark_nolabels = {'layers':[]};
var mapconfig_light_only_labels = {'layers':[]};
var mapconfig_dark_only_labels = {'layers':[]};

// change the host for the images
function replaceImages(cartocss) {
Expand All @@ -45,7 +47,10 @@ var node = function() {
new_layer.name = l.name;
new_layer.options.sql = l.options.sql;
new_layer.options.cartocss = fs.readFileSync(l.options.cartocss_file).toString();
mapconfig_light.layers.push(new_layer);
if (l.name != "global_variables_labels") {
//console.log(l.name);
mapconfig_light.layers.push(new_layer);
}
});

PROJECT.layers.forEach(function(l) {
Expand All @@ -58,7 +63,9 @@ var node = function() {
} else {
new_layer.options.cartocss = replaceImages(fs.readFileSync(l.options.cartocss_file).toString())
}
mapconfig_dark.layers.push(new_layer);
if (l.name != "global_variables_labels") {
mapconfig_dark.layers.push(new_layer);
}
});

PROJECT.layers.forEach(function(l) {
Expand All @@ -85,25 +92,41 @@ var node = function() {
mapconfig_dark_nolabels.layers.push(new_layer);
});


PROJECT.layers.forEach(function(l) {
new_layer = {'type':'cartodb','options':{'cartocss_version':'2.1.1'}};
new_layer.name = l.name;
new_layer.options.sql = l.options.sql;
if (l.name == "global_variables") {
new_layer.options.cartocss = replaceImages(fs.readFileSync("styles/global_variables_only_labels.mss").toString());
mapconfig_light_only_labels.layers.push(new_layer);
} else if (!l.toggle[2]) {
} else if (l.toggle[3]) {
new_layer.options.cartocss = replaceImages(fs.readFileSync(l.options.cartocss_file).toString());
mapconfig_light_only_labels.layers.push(new_layer);
}
});

PROJECT.layers.forEach(function(l) {
new_layer = {'type':'cartodb','options':{'cartocss_version':'2.1.1'}};
new_layer.name = l.name;
new_layer.options.sql = l.options.sql;
if (l.name == "global_variables_labels") {
new_layer.options.cartocss = replaceImages(fs.readFileSync("styles/global_variables_dark_only_labels.mss").toString());
mapconfig_dark_only_labels.layers.push(new_layer);
} else if (l.toggle[3]) {
new_layer.options.cartocss = replaceImages(fs.readFileSync(l.options.cartocss_file).toString());
mapconfig_dark_only_labels.layers.push(new_layer);
}
});


return {
'mapconfig_light': mapconfig_light,
'mapconfig_dark': mapconfig_dark,
'mapconfig_light_nolabels': mapconfig_light_nolabels,
'mapconfig_dark_nolabels': mapconfig_dark_nolabels,
'mapconfig_light_only_labels': mapconfig_light_only_labels
'mapconfig_light_only_labels': mapconfig_light_only_labels,
'mapconfig_dark_only_labels': mapconfig_dark_only_labels
};
}

Expand Down
26 changes: 15 additions & 11 deletions styles/admin1_labels.mss
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
// zooms 3-7

#admin1_labels {
[zoom=5][scalerank<3],
[zoom=6][scalerank<4],
[zoom=7][scalerank<99]
{
#admin1_labels[zoom>=5][zoom<=7]{
text-name: "[name]";
text-halo-fill: @admin1_labels_halo;
text-face-name: "Azo Sans Regular","DejaVu Sans Bold","unifont Medium";
text-transform: uppercase;

text-size: 12;
text-name: "[name]";
text-halo-radius: 1.4px;
[zoom=5][scalerank<3],
[zoom=6][scalerank<4]{
text-size: @admin1_labels_size;
text-halo-radius: @admin1_labels_halo_radius;
text-fill: @admin1_labels;
text-halo-fill: @admin1_labels_halo;
text-face-name: "Azo Sans Regular","DejaVu Sans Bold","unifont Medium";
text-transform: uppercase;
}

[zoom=7][scalerank<99]{
text-size: @admin1_lowzoom_labels_size;
text-halo-radius: @admin1_lowzoom_labels_halo_radius;
text-fill: @admin1_lowzoom_labels;
}
}
4 changes: 2 additions & 2 deletions styles/continent_labels.mss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#continent_labels {
text-size: 12;
text-name: "[name]";
text-name: "[name]";
text-halo-radius: 1.6px;
text-halo-fill: @label_foreground_halo_fill;
text-fill: @label_foreground_fill;
text-fill: @continent_labels;
text-face-name: "Azo Sans Regular";
text-transform: uppercase;

Expand Down
39 changes: 19 additions & 20 deletions styles/country_city_labels.mss
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[zoom=5][scalerank<=5],
[zoom=6][scalerank<=6],
[zoom=7][scalerank<=7] {
shield-name: "[name]";
shield-name: "[name]";
shield-fill: @label_foreground_fill;
shield-halo-fill: @labels_lowzoom_shield_halo_fill;
shield-face-name: "Azo Sans Regular","DejaVu Sans Bold","unifont Medium";
shield-halo-radius: 1.4px;
shield-halo-radius: @labels_lowzoom_shield_halo_radius;
shield-text-transform: uppercase;
shield-min-distance: 5;
[zoom=5] {
Expand All @@ -30,7 +30,7 @@
[cartodb_id =~ '.*(1|3|5|7|9)$'] {
shield-placements: "W,12";
}
shield-text-dx: 5;
shield-text-dx: 6;
shield-text-dy: 0;
shield-unlock-image: true;
shield-wrap-width: 100;
Expand Down Expand Up @@ -83,7 +83,7 @@
text-wrap-width: 100;
text-wrap-before: true;
text-character-spacing: 1.2;
text-halo-radius: 1.4px;
text-halo-radius: @labels_highzoom_halo_radius;
text-halo-fill: @labels_highzoom_halo_fill;
text-fill: @labels_highzoom_text_fill;

Expand All @@ -93,7 +93,7 @@
[zoom=8][scalerank<=6],
[zoom=9][scalerank<=7],
[zoom=10][scalerank<=7] {
text-size: 12;
text-size: @labels_highzoom_class1_text_size;
text-fill: @labels_highzoom_class1_text_fill;
text-line-spacing: -2;
}
Expand All @@ -108,7 +108,7 @@
[zoom=9][scalerank<=5],
[zoom=10][scalerank<=5] {
text-size: 16;
text-fill: @labels_highzoom_class2_text_fill;
text-fill: @labels_highzoom_class2_text_fill;
}
[zoom=11][scalerank<=5],
[zoom=12][scalerank<=5]
Expand All @@ -118,7 +118,7 @@
}

// class 0 (default)
text-size: 10;
text-size: @labels_highzoom_class1_text_size_default;

// At this zoom cities disappear, and it's only neighborhoods
[zoom>=13] {
Expand All @@ -128,51 +128,50 @@
}
}

#country_city_labels[country_city="country"]
{
#country_city_labels[country_city="country"]{
[zoom=3][scalerank<2][pop_est >= 2000000],
[zoom=4][scalerank<3][pop_est >= 2000000],
[zoom=5][scalerank<4] {
text-size: 15;
text-line-spacing: -3;

text-wrap-width: 100;

text-wrap-before: true;
text-ratio: 0.5;
text-name: "[name]";
text-name: "[name]";
[name="Falkland Islands"] {
text-name: [name] + "\n(Malvinas)";
}
text-halo-radius: 1.4;

text-halo-radius: @label_foreground_halo_radius;
text-halo-fill: @label_foreground_halo_fill;
text-face-name: "Azo Sans Regular","DejaVu Sans Bold","unifont Medium";
text-min-distance: 10;
text-transform: uppercase;

[zoom=3] {
text-size: 10;
text-fill: lighten(@label_foreground_fill,10%);
text-halo-radius: 1.8;
text-size: @countries_class2_label_size;
text-fill: @countries_class2_text_fill;
text-halo-radius: @countries_class2_text_halo_radius;

[pop_est>20000000] {
text-fill: lighten(@label_foreground_fill,5%);
text-size: 14;
text-fill: @countries_class1_text_fill;
text-halo-radius: @label_foreground_halo_radius;
text-halo-fill: @label_foreground_halo_fill;
}
}
[zoom=4],[zoom=5] {
text-size: 12;
text-line-spacing: -3;

text-fill: @label_background_fill;
text-fill: @countries_highzoom_class1_text_fill;
text-halo-fill: @label_background_halo_fill;
text-halo-radius: 2;
text-halo-radius: @label_foreground_halo_radius;
text-face-name: "Azo Sans Regular","DejaVu Sans Bold","unifont Medium";

[pop_est>20000000] {
text-size: 16;
text-line-spacing: -4;
text-fill: darken(@label_background_fill, 5%);
text-wrap-width: 200;
}
}
Expand Down
47 changes: 37 additions & 10 deletions styles/global_variables.mss
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ Map {
@admin1_lowzoom: lighten(#6d6e71, 40%);
@admin1_highzoom: lighten(#c79297, 15%);

@admin1_labels: #ccc;
@admin1_labels_halo: white;

//osm roads
@rail_line: #dddddd;
@rail_dashline: #fafafa;
Expand Down Expand Up @@ -87,32 +84,62 @@ Map {
// labels
@label_foreground_fill: #8494a1;
@label_foreground_halo_fill: rgba(236,236,234,0.7);
@label_foreground_halo_radius: 1.4px;

@label_background_fill: #b6b6b6;
@label_background_halo_fill: rgba(255,255,255,0.7);
@labels_lowzoom_shield_fill: lighten(@label_foreground_fill, 7%);

@labels_lowzoom_shield_fill: lighten(@label_foreground_fill, 7%);
@labels_lowzoom_shield_halo_fill: lighten(@label_foreground_halo_fill,10%);
@labels_lowzoom_shield_halo_radius: 1.3px

@labels_highzoom_text_fill: lighten(@label_foreground_fill,15%);
@labels_highzoom_halo_fill: lighten(@label_foreground_halo_fill,10%);
@labels_highzoom_halo_radius: 1.4px;

@labels_highzoom_class1_text_fill: lighten(@label_foreground_fill,5%);
@labels_highzoom_class2_text_fill: darken(@label_foreground_fill,5%);
@labels_highzoom_class1_text_size: 12;
@labels_highzoom_class1_text_size_default: 10;

@labels_marine_fill: white;
@labels_marine_halo_fill: lighten(@label_foreground_fill,10%);
@labels_marine_halo_radius: 1.4px;

@osm_roads_labels_fill: #bbb;
@osm_roads_labels_halo: white;
@osm_roads_labels_radius: 1.8px;

@countries_class1_text_fill: lighten(@label_foreground_fill,5%);
@countries_highzoom_class1_text_fill: darken(@label_background_fill,5%);

@countries_class2_label_size: 10px;
@countries_class2_text_fill: lighten(@label_foreground_fill,10%);
@countries_class2_text_halo_radius: 1.8;

@admin1_labels_size: 10;
@admin1_labels: rgba(255,255,255,1);
@admin1_labels_halo: rgba(47,48,53,0.8);
@admin1_labels_halo_radius: 1.4px;

@admin1_lowzoom_labels_size: @admin1_labels_size;
@admin1_lowzoom_labels: @admin1_labels;
@admin1_lowzoom_labels_halo_radius: @admin1_labels_halo_radius;

@label_park_fill: darken(#d4ded6, 30%);
@label_park_halo_fill: lighten(#e3e3dc, 8%);
@label_park_halo_radius: 1.4px;

@label_water_fill: lighten(#6b8a95, 5%);
@label_water_halo_fill: lighten(#e3e3dc, 8%);
@label_water_halo_radius: 1.4px;

@continent_labels: @label_foreground_fill;

// assets
@city_shield_file: url("http://s3.amazonaws.com/libs.cartocdn.com/stamen-base/city_shield_light.svg");
@city_shield_file_lowzoom: url("http://s3.amazonaws.com/libs.cartocdn.com/stamen-base/city_shield_light.svg");
@capital_shield_file: url("http://s3.amazonaws.com/libs.cartocdn.com/stamen-base/capital_shield_light.png");
@capital_shield_file_lowzoom: url("http://s3.amazonaws.com/libs.cartocdn.com/stamen-base/capital_shield_light.png");

@label_park_halo_fill: lighten(#e3e3dc, 8%);
@label_park_fill: darken(#d4ded6, 30%);

@label_water_halo_fill: lighten(#e3e3dc, 8%);
@label_water_fill: lighten(#6b8a95, 5%);

@park_texture_opacity: 0.0;
Loading

0 comments on commit 809795f

Please sign in to comment.