This commit is contained in:
Stuart Lynn 2015-09-08 12:00:05 -04:00
parent 2a47541cc5
commit a03f9ca4e2
4 changed files with 72 additions and 30 deletions

10
dist/torque.full.js vendored

File diff suppressed because one or more lines are too long

View File

@ -4399,9 +4399,9 @@ var Profiler = require('../profiler');
},{"../":10,"../profiler":17}],22:[function(require,module,exports){ },{"../":10,"../profiler":17}],22:[function(require,module,exports){
var TAU = Math.PI*2; var TAU = Math.PI*2;
// min value to render a line. // min value to render a line.
// it does not make sense to render a line of a width is not even visible // it does not make sense to render a line of a width is not even visible
var LINEWIDTH_MIN_VALUE = 0.05; var LINEWIDTH_MIN_VALUE = 0.05;
var MAX_SPRITE_RADIUS = 255; var MAX_SPRITE_RADIUS = 255;
function renderPoint(ctx, st) { function renderPoint(ctx, st) {
@ -4473,6 +4473,20 @@ var Profiler = require('../profiler');
} }
} }
function renderText(ctx,st){
var width = st['marker-width']
var text = st['text-name']
var font = st['text-face-name'] ? st['text-face-name'] : 'Droid Sans Regular'
var textSize = st['text-size'] ? st['text-size'] : '10px'
var color = st['text-fill'] ? st['text-fill'] : 'white'
// ctx.font = textSize+"px "+font
ctx.fillStyle = color
ctx.font= textSize + " " + font
ctx.fillText(text, -width/2.0, width/2.0 )
}
function renderSprite(ctx, img, st) { function renderSprite(ctx, img, st) {
if(img.complete){ if(img.complete){
@ -4487,6 +4501,7 @@ module.exports = {
renderPoint: renderPoint, renderPoint: renderPoint,
renderSprite: renderSprite, renderSprite: renderSprite,
renderRectangle: renderRectangle, renderRectangle: renderRectangle,
renderText: renderText,
MAX_SPRITE_RADIUS: MAX_SPRITE_RADIUS MAX_SPRITE_RADIUS: MAX_SPRITE_RADIUS
}; };
@ -4557,7 +4572,7 @@ var Filters = require('./torque_filters');
this.TILE_SIZE = 256; this.TILE_SIZE = 256;
this._style = null; this._style = null;
this._gradients = {}; this._gradients = {};
this._forcePoints = false; this._forcePoints = false;
} }
@ -4659,13 +4674,19 @@ var Filters = require('./torque_filters');
cartocss.renderPoint(ctx, st); cartocss.renderPoint(ctx, st);
} }
} }
if(st['text-name']){
st['text-name'] = st['text-name'].replace("{{value}}",value)
cartocss.renderText(ctx,st)
}
prof.end(true); prof.end(true);
if (torque.flags.sprites_to_images) { if (torque.flags.sprites_to_images) {
var i = this._createImage(); var i = this._createImage();
i.src = canvas.toDataURL(); i.src = canvas.toDataURL();
return i; return i;
} }
return canvas; return canvas;
}, },
@ -4693,7 +4714,7 @@ var Filters = require('./torque_filters');
} }
} }
} }
prof.end(true); prof.end(true);
return callback && callback(null); return callback && callback(null);
@ -4737,7 +4758,7 @@ var Filters = require('./torque_filters');
}, },
// //
// renders a tile in the canvas for key defined in // renders a tile in the canvas for key defined in
// the torque tile // the torque tile
// //
_renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) { _renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) {
@ -4774,7 +4795,7 @@ var Filters = require('./torque_filters');
} }
} }
} }
prof.end(true); prof.end(true);
}, },
@ -4925,7 +4946,7 @@ var Filters = require('./torque_filters');
} }
gradient = {}; gradient = {};
var colorize = this._style['image-filters'].args; var colorize = this._style['image-filters'].args;
var increment = 1/colorize.length; var increment = 1/colorize.length;
for (var i = 0; i < colorize.length; i++){ for (var i = 0; i < colorize.length; i++){
var key = increment * i + increment; var key = increment * i + increment;
@ -4966,7 +4987,7 @@ var carto = global.carto || require('carto');
// //
// this renderer just render points depending of the value // this renderer just render points depending of the value
// //
function RectanbleRenderer(canvas, options) { function RectanbleRenderer(canvas, options) {
this.options = options; this.options = options;
carto.tree.Reference.set(torque['torque-reference']); carto.tree.Reference.set(torque['torque-reference']);
@ -5043,7 +5064,7 @@ var carto = global.carto || require('carto');
// by-pass the style generation for improving performance // by-pass the style generation for improving performance
color = this._shader['polygon-fill']({ value: value }, { zoom: 0 }); color = this._shader['polygon-fill']({ value: value }, { zoom: 0 });
ctx.fillStyle = color; ctx.fillStyle = color;
//TODO: each function should have a default value for each //TODO: each function should have a default value for each
//property defined in the cartocss //property defined in the cartocss
alpha = polygon_alpha({ value: value }, { zoom: 0 }); alpha = polygon_alpha({ value: value }, { zoom: 0 });
if(alpha === null) { if(alpha === null) {
@ -5057,7 +5078,7 @@ var carto = global.carto || require('carto');
}, },
// //
// renders a tile in the canvas for key defined in // renders a tile in the canvas for key defined in
// the torque tile // the torque tile
// //
renderTile: function(tile, key, callback) { renderTile: function(tile, key, callback) {
@ -13932,7 +13953,7 @@ module.exports={
"url": "https://github.com/cartodb/carto", "url": "https://github.com/cartodb/carto",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "http://github.com/cartodb/carto.git" "url": "git+ssh://git@github.com/cartodb/carto.git"
}, },
"author": { "author": {
"name": "CartoDB", "name": "CartoDB",
@ -14003,7 +14024,7 @@ module.exports={
"bugs": { "bugs": {
"url": "https://github.com/cartodb/carto/issues" "url": "https://github.com/cartodb/carto/issues"
}, },
"homepage": "https://github.com/cartodb/carto", "homepage": "https://github.com/cartodb/carto#readme",
"_id": "carto@0.15.1-cdb1", "_id": "carto@0.15.1-cdb1",
"_shasum": "62534c2975cbee073f10c6c14a0c7e889c9469e7", "_shasum": "62534c2975cbee073f10c6c14a0c7e889c9469e7",
"_resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz", "_resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz",

2
dist/torque.js vendored

File diff suppressed because one or more lines are too long

View File

@ -4406,9 +4406,9 @@ var Profiler = require('../profiler');
},{"../":10,"../profiler":17}],22:[function(require,module,exports){ },{"../":10,"../profiler":17}],22:[function(require,module,exports){
var TAU = Math.PI*2; var TAU = Math.PI*2;
// min value to render a line. // min value to render a line.
// it does not make sense to render a line of a width is not even visible // it does not make sense to render a line of a width is not even visible
var LINEWIDTH_MIN_VALUE = 0.05; var LINEWIDTH_MIN_VALUE = 0.05;
var MAX_SPRITE_RADIUS = 255; var MAX_SPRITE_RADIUS = 255;
function renderPoint(ctx, st) { function renderPoint(ctx, st) {
@ -4480,6 +4480,20 @@ var Profiler = require('../profiler');
} }
} }
function renderText(ctx,st){
var width = st['marker-width']
var text = st['text-name']
var font = st['text-face-name'] ? st['text-face-name'] : 'Droid Sans Regular'
var textSize = st['text-size'] ? st['text-size'] : '10px'
var color = st['text-fill'] ? st['text-fill'] : 'white'
// ctx.font = textSize+"px "+font
ctx.fillStyle = color
ctx.font= textSize + " " + font
ctx.fillText(text, -width/2.0, width/2.0 )
}
function renderSprite(ctx, img, st) { function renderSprite(ctx, img, st) {
if(img.complete){ if(img.complete){
@ -4494,6 +4508,7 @@ module.exports = {
renderPoint: renderPoint, renderPoint: renderPoint,
renderSprite: renderSprite, renderSprite: renderSprite,
renderRectangle: renderRectangle, renderRectangle: renderRectangle,
renderText: renderText,
MAX_SPRITE_RADIUS: MAX_SPRITE_RADIUS MAX_SPRITE_RADIUS: MAX_SPRITE_RADIUS
}; };
@ -4564,7 +4579,7 @@ var Filters = require('./torque_filters');
this.TILE_SIZE = 256; this.TILE_SIZE = 256;
this._style = null; this._style = null;
this._gradients = {}; this._gradients = {};
this._forcePoints = false; this._forcePoints = false;
} }
@ -4666,13 +4681,19 @@ var Filters = require('./torque_filters');
cartocss.renderPoint(ctx, st); cartocss.renderPoint(ctx, st);
} }
} }
if(st['text-name']){
st['text-name'] = st['text-name'].replace("{{value}}",value)
cartocss.renderText(ctx,st)
}
prof.end(true); prof.end(true);
if (torque.flags.sprites_to_images) { if (torque.flags.sprites_to_images) {
var i = this._createImage(); var i = this._createImage();
i.src = canvas.toDataURL(); i.src = canvas.toDataURL();
return i; return i;
} }
return canvas; return canvas;
}, },
@ -4700,7 +4721,7 @@ var Filters = require('./torque_filters');
} }
} }
} }
prof.end(true); prof.end(true);
return callback && callback(null); return callback && callback(null);
@ -4744,7 +4765,7 @@ var Filters = require('./torque_filters');
}, },
// //
// renders a tile in the canvas for key defined in // renders a tile in the canvas for key defined in
// the torque tile // the torque tile
// //
_renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) { _renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) {
@ -4781,7 +4802,7 @@ var Filters = require('./torque_filters');
} }
} }
} }
prof.end(true); prof.end(true);
}, },
@ -4932,7 +4953,7 @@ var Filters = require('./torque_filters');
} }
gradient = {}; gradient = {};
var colorize = this._style['image-filters'].args; var colorize = this._style['image-filters'].args;
var increment = 1/colorize.length; var increment = 1/colorize.length;
for (var i = 0; i < colorize.length; i++){ for (var i = 0; i < colorize.length; i++){
var key = increment * i + increment; var key = increment * i + increment;
@ -4973,7 +4994,7 @@ var carto = global.carto || require('carto');
// //
// this renderer just render points depending of the value // this renderer just render points depending of the value
// //
function RectanbleRenderer(canvas, options) { function RectanbleRenderer(canvas, options) {
this.options = options; this.options = options;
carto.tree.Reference.set(torque['torque-reference']); carto.tree.Reference.set(torque['torque-reference']);
@ -5050,7 +5071,7 @@ var carto = global.carto || require('carto');
// by-pass the style generation for improving performance // by-pass the style generation for improving performance
color = this._shader['polygon-fill']({ value: value }, { zoom: 0 }); color = this._shader['polygon-fill']({ value: value }, { zoom: 0 });
ctx.fillStyle = color; ctx.fillStyle = color;
//TODO: each function should have a default value for each //TODO: each function should have a default value for each
//property defined in the cartocss //property defined in the cartocss
alpha = polygon_alpha({ value: value }, { zoom: 0 }); alpha = polygon_alpha({ value: value }, { zoom: 0 });
if(alpha === null) { if(alpha === null) {
@ -5064,7 +5085,7 @@ var carto = global.carto || require('carto');
}, },
// //
// renders a tile in the canvas for key defined in // renders a tile in the canvas for key defined in
// the torque tile // the torque tile
// //
renderTile: function(tile, key, callback) { renderTile: function(tile, key, callback) {