diff --git a/lib/carto/tree/filter.js b/lib/carto/tree/filter.js index 3477b76..87c84f0 100644 --- a/lib/carto/tree/filter.js +++ b/lib/carto/tree/filter.js @@ -19,6 +19,10 @@ tree.Filter = function Filter(key, op, val, index, filename) { this.val = val; } + if (this.op !== '=' && this.op !== '!=') { + this.val = 1 * this.val; + } + this.id = this.key + this.op + this.val; }; @@ -34,15 +38,12 @@ var opXML = { }; tree.Filter.prototype.toXML = function(env) { - if (this.op !== '=' && this.op !== '!=') { - this.val = 1 * this.val; - if (isNaN(this.val)) { - env.error({ - message: 'Cannot use operator "' + this.op + '" with value ' + this.val, - index: this.index, - filename: this.filename - }); - } + if (this.op !== '=' && this.op !== '!=' && isNaN(this.val)) { + env.error({ + message: 'Cannot use operator "' + this.op + '" with value ' + this.val, + index: this.index, + filename: this.filename + }); } if (this.val.eval) this._val = this.val.eval(env); if (this.key.eval) this._key = this.key.eval(env); diff --git a/test/errorhandling.test.js b/test/errorhandling.test.js index e315038..cf2c118 100644 --- a/test/errorhandling.test.js +++ b/test/errorhandling.test.js @@ -23,7 +23,7 @@ helper.files('errorhandling', 'mml', function(file) { // @TODO for some reason, fs.readFile includes an additional \n // at the end of read files. Determine why. fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { - assert.deepEqual(output, data.substr(0, data.length - 1)); + if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); }); }); diff --git a/test/errorhandling/multi_stylesheets.mml b/test/errorhandling/multi_stylesheets.mml new file mode 100644 index 0000000..27de05c --- /dev/null +++ b/test/errorhandling/multi_stylesheets.mml @@ -0,0 +1,16 @@ +{ + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Stylesheet": [ + "multi_stylesheets_b.mss", + "multi_stylesheets_a.mss" + ], + "Layer": [{ + "id": "world", + "name": "world", + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Datasource": { + "file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip", + "type": "shape" + } + }] +} diff --git a/test/errorhandling/multi_stylesheets_a.mss b/test/errorhandling/multi_stylesheets_a.mss new file mode 100644 index 0000000..2db5417 --- /dev/null +++ b/test/errorhandling/multi_stylesheets_a.mss @@ -0,0 +1,6 @@ +#world { + polygon-opacity: 0.5; + line-width:4; + line-color:#fff; + line-opacity:0.3; +} diff --git a/test/errorhandling/multi_stylesheets_b.mss b/test/errorhandling/multi_stylesheets_b.mss new file mode 100644 index 0000000..0c58439 --- /dev/null +++ b/test/errorhandling/multi_stylesheets_b.mss @@ -0,0 +1,3 @@ +#world { + polygonopacity: 0.5; +} diff --git a/test/rendering/nominzoom.mml b/test/rendering/nominzoom.mml new file mode 100644 index 0000000..3edb411 --- /dev/null +++ b/test/rendering/nominzoom.mml @@ -0,0 +1,14 @@ +{ + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Stylesheet": [ + "nominzoom.mss" + ], + "Layer": [{ + "name": "world", + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Datasource": { + "file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip", + "type": "shape" + } + }] +} diff --git a/test/rendering/nominzoom.mss b/test/rendering/nominzoom.mss new file mode 100644 index 0000000..af9c4b4 --- /dev/null +++ b/test/rendering/nominzoom.mss @@ -0,0 +1,3 @@ +#world[zoom < 5] { + polygon-fill: #000; +} diff --git a/test/rendering/nominzoom.result b/test/rendering/nominzoom.result new file mode 100644 index 0000000..c2d3bd2 --- /dev/null +++ b/test/rendering/nominzoom.result @@ -0,0 +1,21 @@ + + + + + + + + world + + + + + + +