From be78202e0bcf462861c8c7150d8e68e089719f6d Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Thu, 21 Feb 2013 15:29:33 -0500 Subject: [PATCH] Allow layers to be rendered without datasources. --- lib/carto/tree/layer.js | 4 +++- test/rendering/layer_nodatasource.mml | 10 ++++++++++ test/rendering/layer_nodatasource.mss | 4 ++++ test/rendering/layer_nodatasource.result | 17 +++++++++++++++++ test/support/helper.js | 1 + 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/rendering/layer_nodatasource.mml create mode 100644 test/rendering/layer_nodatasource.mss create mode 100644 test/rendering/layer_nodatasource.result diff --git a/lib/carto/tree/layer.js b/lib/carto/tree/layer.js index 5e33ef6..713c77a 100644 --- a/lib/carto/tree/layer.js +++ b/lib/carto/tree/layer.js @@ -20,9 +20,11 @@ tree.LayerXML = function(obj, styles) { styles.reverse().map(function(s) { return '' + s + ''; }).join('\n ') + + (dsoptions.length ? '\n \n ' + dsoptions.join('\n ') + - '\n \n' + + '\n \n' + : '') + ' \n'; }; diff --git a/test/rendering/layer_nodatasource.mml b/test/rendering/layer_nodatasource.mml new file mode 100644 index 0000000..01eadc0 --- /dev/null +++ b/test/rendering/layer_nodatasource.mml @@ -0,0 +1,10 @@ +{ + "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": [ + "layer_nodatasource.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.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" + }] +} diff --git a/test/rendering/layer_nodatasource.mss b/test/rendering/layer_nodatasource.mss new file mode 100644 index 0000000..249df79 --- /dev/null +++ b/test/rendering/layer_nodatasource.mss @@ -0,0 +1,4 @@ +#world { + polygon-fill: green; + line-color: hsl(30, 40%, 90%); +} diff --git a/test/rendering/layer_nodatasource.result b/test/rendering/layer_nodatasource.result new file mode 100644 index 0000000..3e78bad --- /dev/null +++ b/test/rendering/layer_nodatasource.result @@ -0,0 +1,17 @@ + + + + + + + + world + + + diff --git a/test/support/helper.js b/test/support/helper.js index 58a6873..4519978 100644 --- a/test/support/helper.js +++ b/test/support/helper.js @@ -195,6 +195,7 @@ helper.removeAbsoluteImages = function(xml) { helper.removeAbsoluteDatasources = function(xml) { xml.Map.forEach(function(map) { if (map.Layer) map.Layer.forEach(function(layer) { + if (!layer.Datasource) return; layer.Datasource.forEach(function(datasource) { datasource.Parameter.forEach(function(param) { if (param.name === 'file') {