Add support for variable transforms - refs #163, and improve test coverage

This commit is contained in:
Tom MacWright 2014-09-03 15:12:31 -04:00
parent 57ddf46813
commit c570c2cd0e
13 changed files with 70 additions and 1 deletions

View File

@ -78,6 +78,7 @@ tree.Call.prototype = {
}; };
} }
if (fn !== args.length && if (fn !== args.length &&
!(Array.isArray(fn) && _.include(fn, args.length)) &&
// support variable-arg functions like `colorize-alpha` // support variable-arg functions like `colorize-alpha`
fn !== -1) { fn !== -1) {
env.error({ env.error({

View File

@ -12,6 +12,14 @@ ref.setData = function(data) {
ref.data = data; ref.data = data;
ref.selector_cache = generateSelectorCache(data); ref.selector_cache = generateSelectorCache(data);
ref.mapnikFunctions = generateMapnikFunctions(data); ref.mapnikFunctions = generateMapnikFunctions(data);
ref.mapnikFunctions.matrix = [6];
ref.mapnikFunctions.translate = [1, 2];
ref.mapnikFunctions.scale = [1, 2];
ref.mapnikFunctions.rotate = [1, 3];
ref.mapnikFunctions.skewX = [1];
ref.mapnikFunctions.skewY = [1];
ref.required_cache = generateRequiredProperties(data); ref.required_cache = generateRequiredProperties(data);
}; };

View File

@ -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": [
"bad_op.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.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"
}
}]
}

View File

@ -0,0 +1,3 @@
#world {
line-width: 20% + 2px;
}

View File

@ -0,0 +1 @@
bad_op.mss:2:4 If two operands differ, the first must not be %

View File

@ -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": [
"bad_op_2.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.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"
}
}]
}

View File

@ -0,0 +1,3 @@
#world {
line-width: 20px * 2%;
}

View File

@ -0,0 +1 @@
bad_op_2.mss:2:4 Percent values can only be added or subtracted from other values

View File

@ -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": [
"invaliddimension.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.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"
}
}]
}

View File

@ -0,0 +1,3 @@
#world {
line-width: 10wifflewaffles;
}

View File

@ -0,0 +1 @@
invaliddimension.mss:2:4 Invalid unit: 'wifflewaffles'

View File

@ -2,4 +2,6 @@
#world { #world {
point-file: url(foo.png); point-file: url(foo.png);
point-transform: translate( @trans * 2, @trans); point-transform: translate( @trans * 2, @trans);
marker-width: 2;
marker-transform: scale(2);
} }

View File

@ -6,6 +6,7 @@
<Style name="world" filter-mode="first"> <Style name="world" filter-mode="first">
<Rule> <Rule>
<PointSymbolizer file="[absolute path]" transform="translate(4,2)" /> <PointSymbolizer file="[absolute path]" transform="translate(4,2)" />
<MarkersSymbolizer width="2" transform="scale(2)" />
</Rule> </Rule>
</Style> </Style>
<Layer name="world" <Layer name="world"