diff --git a/lib/mess/parser.js b/lib/mess/parser.js index f0d588c..17d882b 100644 --- a/lib/mess/parser.js +++ b/lib/mess/parser.js @@ -775,7 +775,7 @@ mess.Parser = function Parser(env) { elements.push(e); } else if (z) { if (zoom) { - zoom.intersect(z); + zoom.intersection(z); } else { zoom = z; } diff --git a/lib/mess/renderer.js b/lib/mess/renderer.js index 5a5dce5..6d584d2 100644 --- a/lib/mess/renderer.js +++ b/lib/mess/renderer.js @@ -41,7 +41,7 @@ mess.Renderer = function Renderer(env) { var group = this.group(); var autodetect = _.filter(m.Layer, function(l) { return !l.srs; }); _.each(autodetect, function(l) { - var finish = group(); + var next = group(); Step( function() { fs.readdir(path.dirname(l.Datasource.file), this); @@ -61,11 +61,9 @@ mess.Renderer = function Renderer(env) { if (!err) { try { l.srs = require('srs').parse(srs).proj4; - } catch (err) { - finish(err); - } + } catch (err) {} } - finish(err); + next(err); } ); }); @@ -183,6 +181,7 @@ mess.Renderer = function Renderer(env) { var options = {}, group = this.group(); for (var i = 0, l = results.length; i < l; i++) { + var next = group(); new mess.Parser(_.extend(_.extend({ filename: results[i][0] }, that.env), this.env)).parse(results[i][1], @@ -192,7 +191,7 @@ mess.Renderer = function Renderer(env) { throw err; } else { try { - group()(err, [ + next(err, [ results[i][0], tree]); return; diff --git a/lib/mess/tree/ruleset.js b/lib/mess/tree/ruleset.js index 2f434ef..be006ee 100644 --- a/lib/mess/tree/ruleset.js +++ b/lib/mess/tree/ruleset.js @@ -125,17 +125,7 @@ tree.Ruleset.prototype = { // Create a new object for each so that we can have different // elements and filters in the selector. - var instance = new tree.Selector(); - instance.elements = parent.elements.concat(selector.elements); - instance.filters = parent.filters.concat(selector.filters); - if (parent.zoom && selector.zoom) { - instance.zoom = parent.zoom.clone().intersection(selector.zoom); - } else if (parent.zoom || selector.zoom) { - instance.zoom = (parent.zoom || selector.zoom).clone() - } - instance.attachment = selector.attachment; - instance.index = selector.index; - + var instance = parent.clone().merge(selector); selectors.push(instance); } } diff --git a/lib/mess/tree/selector.js b/lib/mess/tree/selector.js index f7bc9ff..6f03344 100644 --- a/lib/mess/tree/selector.js +++ b/lib/mess/tree/selector.js @@ -18,7 +18,18 @@ tree.Selector.prototype.clone = function() { obj.zoom = this.zoom.clone(); } return obj; -} +}; + +tree.Selector.prototype.merge = function(obj) { + Array.prototype.push.apply(this.elements, obj.elements); + Array.prototype.push.apply(this.filters, obj.filters); + if (obj.attachment) this.attachment = obj.attachment; + this.index = obj.index; + + if (this.zoom && obj.zoom) this.zoom.intersection(obj.zoom); + else if (obj.zoom) this.zoom = obj.zoom.clone(); + return this; +}; /** * Determine the specificity of this selector