From f91ac22bfc924fa6469e3a14dfe3c01f194a4261 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Thu, 8 Jan 2015 16:21:24 +0100 Subject: [PATCH 1/4] adds method to gather image asset file names --- lib/carto/renderer_js.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index 716ed29..8064f2b 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -5,6 +5,7 @@ var _ = global._ || require('underscore'); function CartoCSS(style, options) { this.options = options || {}; + this.imageURLs = []; if(style) { this.setStyle(style); } @@ -164,6 +165,9 @@ CartoCSS.prototype = { } } }, + getIconURLs: function(){ + return this.imageURLs; + }, parse: function(cartocss) { var parse_env = { @@ -198,6 +202,13 @@ CartoCSS.prototype = { var layer = layers[key] = (layers[key] || { symbolizers: [] }); + this.imageURLs = _getImageURLs(def); + for(var u = 0; u Date: Thu, 8 Jan 2015 16:40:02 +0100 Subject: [PATCH 2/4] removes old reference, renames method --- lib/carto/renderer_js.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index 8064f2b..18d49d5 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -165,7 +165,7 @@ CartoCSS.prototype = { } } }, - getIconURLs: function(){ + getImageURLs: function(){ return this.imageURLs; }, @@ -202,7 +202,6 @@ CartoCSS.prototype = { var layer = layers[key] = (layers[key] || { symbolizers: [] }); - this.imageURLs = _getImageURLs(def); for(var u = 0; u Date: Thu, 8 Jan 2015 17:10:43 +0100 Subject: [PATCH 3/4] uses proper equality checks --- lib/carto/renderer_js.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index 18d49d5..dd88cee 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -203,7 +203,7 @@ CartoCSS.prototype = { symbolizers: [] }); for(var u = 0; u Date: Thu, 8 Jan 2015 17:30:49 +0100 Subject: [PATCH 4/4] adds basic test for marker-files --- test/rendering_js.test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index 61d5800..a6ae419 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -74,6 +74,35 @@ describe('RenderingJS', function() { assert(layer0.getSymbolizers()[1] === 'line'); }); + it ("should return list of marker-files", function(){ + var css = [ + 'Map {', + '-torque-time-attribute: "date";', + '-torque-aggregation-function: "count(cartodb_id)";', + '-torque-frame-count: 760;', + '-torque-animation-duration: 15;', + '-torque-resolution: 2', + '}', + '#layer {', + ' marker-width: 3;', + ' marker-fill-opacity: 0.8;', + ' marker-fill: #FEE391; ', + ' marker-file: url(http://localhost:8081/gal.svg); ', + ' comp-op: "lighten";', + ' [value > 2] { marker-file: url(http://upload.wikimedia.org/wikipedia/commons/4/43/Flag_of_the_Galactic_Empire.svg); }', + ' [value > 3] { marker-file: url(http://upload.wikimedia.org/wikipedia/commons/c/c9/Flag_of_Syldavia.svg); }', + ' [frame-offset = 1] { marker-width: 10; marker-fill-opacity: 0.05;}', + ' [frame-offset = 2] { marker-width: 15; marker-fill-opacity: 0.02;}', + '}' + ].join('\n'); + var shader = (new carto.RendererJS({ debug: true })).render(css); + var markerURLs = shader.getImageURLs(); + var against = ["http://localhost:8081/gal.svg", "http://upload.wikimedia.org/wikipedia/commons/4/43/Flag_of_the_Galactic_Empire.svg", "http://upload.wikimedia.org/wikipedia/commons/c/c9/Flag_of_Syldavia.svg"]; + for(var i = 0; i