diff --git a/Makefile b/Makefile index 16d07a1..60277de 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ # expresso = ./node_modules/.bin/mocha -docco = ./node_modules/.bin/docco lint: ./node_modules/.bin/jshint lib/carto/*.js lib/carto/tree/*.js @@ -18,7 +17,4 @@ endif check: test -doc: - $(docco) lib/carto/*.js lib/carto/tree/*.js - .PHONY: test diff --git a/lib/carto/parser.js b/lib/carto/parser.js index 4679813..88a0c2f 100644 --- a/lib/carto/parser.js +++ b/lib/carto/parser.js @@ -662,10 +662,11 @@ carto.Parser = function Parser(env) { save(); var key, op, val; if (! $('[')) return; - if (key = $(/^[a-zA-Z0-9\-_]+/) || $(this.entities.quoted) || $(this.entities.variable)) { + if (key = $(/^[a-zA-Z0-9\-_]+/) || $(this.entities.quoted) || $(this.entities.variable) || $(this.entities.field)) { if ((op = $(this.entities.comparison)) && - (val = $(this.entities.quoted) || $(this.entities.variable) || $(/^[\w\-\.]+/))) { + (val = $(this.entities.quoted) || $(this.entities.variable) || $(this.entities.dimension))) { if (! $(']')) return; + if (!key.is) key = new tree.Field(key); return new tree.Filter(key, op, val, memo, env.filename); } } diff --git a/lib/carto/tree/filter.js b/lib/carto/tree/filter.js index 29d3c1d..9dd33c4 100644 --- a/lib/carto/tree/filter.js +++ b/lib/carto/tree/filter.js @@ -1,28 +1,12 @@ (function(tree) { tree.Filter = function Filter(key, op, val, index, filename) { - if (key.is) { - this.key = key.value; - this._key = key; - } else { - this.key = key; - } - + this.key = key; this.op = op; + this.val = val; this.index = index; this.filename = filename; - if (val.is) { - this.val = val.value; - this._val = val; - } else { - this.val = val; - } - - if (ops[this.op][1] == 'numeric') { - this.val = 1 * this.val; - } - this.id = this.key + this.op + this.val; }; @@ -39,15 +23,14 @@ var ops = { }; tree.Filter.prototype.toXML = function(env) { - var val, key; - if (this.val['eval']) this._val = this.val['eval'](env); - if (this.key['eval']) this._key = this.key['eval'](env); - if (this._key) key = this._key.toString(false); - if (this._val) val = this._val.toString(this._val.is == 'string'); + var key = this.key['eval'](env); + var val = this.val['eval'](env); + key = key.toString(false); + val = val.toString(val.is == 'string'); if ( - (ops[this.op][1] == 'numeric' && isNaN(this.val)) || - (ops[this.op][1] == 'string' && (val || this.val)[0] != "'") + (ops[this.op][1] == 'numeric' && isNaN(val)) || + (ops[this.op][1] == 'string' && (val)[0] != "'") ) { env.error({ message: 'Cannot use operator "' + this.op + '" with value ' + this.val, @@ -56,7 +39,7 @@ tree.Filter.prototype.toXML = function(env) { }); } - return '[' + (key || this.key) + ']' + ops[this.op][0] + '' + (val || this.val) + (ops[this.op][2] || ''); + return key + ops[this.op][0] + '' + val + (ops[this.op][2] || ''); }; tree.Filter.prototype.toString = function() { diff --git a/lib/carto/tree/variable.js b/lib/carto/tree/variable.js index dc2ef4a..96da224 100644 --- a/lib/carto/tree/variable.js +++ b/lib/carto/tree/variable.js @@ -7,6 +7,10 @@ tree.Variable = function Variable(name, index, filename) { }; tree.Variable.prototype = { + is: 'variable', + toString: function() { + return this.name; + }, eval: function(env) { var variable, v, diff --git a/package.json b/package.json index bc78e76..28c2456 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ }, "devDependencies": { "mocha": "1.3.x", - "docco": "0.3.x", "jshint": "0.2.x", "sax": "0.1.x" }, diff --git a/test/rendering/support4504.mml b/test/rendering/support4504.mml new file mode 100644 index 0000000..fd33922 --- /dev/null +++ b/test/rendering/support4504.mml @@ -0,0 +1,15 @@ +{ + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Stylesheet": [ + "support4504.mss" + ], + "Layer": [{ + "class": "new", + "name": "countries", + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=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/support4504.mss b/test/rendering/support4504.mss new file mode 100644 index 0000000..ef0f507 --- /dev/null +++ b/test/rendering/support4504.mss @@ -0,0 +1,7 @@ +@z13: 19; +@num_pixels: 50; +@z13area: @z13 * @z13 * @num_pixels; + +#countries[way_area > @z13area] { + polygon-opacity:0.2; +} diff --git a/test/rendering/support4504.result b/test/rendering/support4504.result new file mode 100644 index 0000000..4cb4947 --- /dev/null +++ b/test/rendering/support4504.result @@ -0,0 +1,21 @@ + + + + + + + + countries + + + + + + +