Compare commits
2 Commits
master
...
rastercolo
Author | SHA1 | Date | |
---|---|---|---|
|
1dcafcc3a0 | ||
|
96a41b8615 |
@ -12,6 +12,25 @@ tree.functions = {
|
||||
hsl: function (h, s, l) {
|
||||
return this.hsla(h, s, l, 1.0);
|
||||
},
|
||||
// Only require val
|
||||
stop: function (val) {
|
||||
if (arguments.length > 1) var color = arguments[1];
|
||||
if (arguments.length > 2) var mode = arguments[2];
|
||||
|
||||
return {
|
||||
is: 'tag',
|
||||
val: val,
|
||||
color: color,
|
||||
mode: mode,
|
||||
toString: function(env) {
|
||||
return '\n\t<stop value="' + val.eval(env) + '"' +
|
||||
(color ? ' color="' + color.eval(env) + '" ' : '') +
|
||||
(mode ? ' mode="' + mode.eval(env) + '" ' : '') +
|
||||
'/>';
|
||||
|
||||
}
|
||||
};
|
||||
},
|
||||
hsla: function (h, s, l, a) {
|
||||
h = (number(h) % 360) / 360;
|
||||
s = number(s); l = number(l); a = number(a);
|
||||
|
@ -6,6 +6,7 @@
|
||||
tree.Call = function Call(name, args, index) {
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
this.is = 'call';
|
||||
this.index = index;
|
||||
};
|
||||
tree.Call.prototype = {
|
||||
@ -34,7 +35,7 @@ tree.Call.prototype = {
|
||||
}
|
||||
|
||||
if (this.name in tree.functions) { // 1.
|
||||
if (tree.functions[this.name].length === args.length) {
|
||||
if (tree.functions[this.name].length < args.length) {
|
||||
return tree.functions[this.name].apply(tree.functions, args);
|
||||
} else {
|
||||
env.error({
|
||||
|
@ -111,6 +111,9 @@ tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) {
|
||||
if (x && x.serialization && x.serialization === 'content') {
|
||||
selfclosing = false;
|
||||
tagcontent = attributes[key].eval(env).toXML(env, true);
|
||||
} else if (x && x.serialization && x.serialization === 'tag') {
|
||||
selfclosing = false;
|
||||
tagcontent = attributes[key].eval(env).toXML(env, true);
|
||||
} else {
|
||||
xml += attributes[key].eval(env).toXML(env) + ' ';
|
||||
}
|
||||
|
@ -113,6 +113,12 @@ tree.Reference.validValue = function(env, selector, value) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (tree.Reference.selector(selector).type == 'tags') {
|
||||
if (!value.value) return false;
|
||||
for (i = 0; i < value.value[0].value.length; i++) {
|
||||
if (value.value[0].value[i].is !== 'tag') return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (tree.Reference.selector(selector).validate) {
|
||||
var valid = false;
|
||||
|
@ -575,6 +575,28 @@
|
||||
"gaussian",
|
||||
"lanczos"
|
||||
]
|
||||
},
|
||||
"colorizer-default-mode": {
|
||||
"css": "raster-colorizer-default-mode",
|
||||
"type": [
|
||||
"discrete",
|
||||
"linear",
|
||||
"exact"
|
||||
]
|
||||
},
|
||||
"colorizer-default-color": {
|
||||
"css": "raster-colorizer-default-color",
|
||||
"type": "color"
|
||||
},
|
||||
"colorizer-epsilon": {
|
||||
"css": "raster-colorizer-epsilon",
|
||||
"type": "float"
|
||||
},
|
||||
"stop": {
|
||||
"css": "raster-colorizer-stops",
|
||||
"type": "tags",
|
||||
"serialization": "tag",
|
||||
"tagname": "tagname"
|
||||
}
|
||||
},
|
||||
"point": {
|
||||
|
14
test/rendering/rastercolorizer.mml
Normal file
14
test/rendering/rastercolorizer.mml
Normal file
@ -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.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
|
||||
"Stylesheet": [
|
||||
"rastercolorizer.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",
|
||||
"Datasource": {
|
||||
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
|
||||
"type": "shape"
|
||||
}
|
||||
}]
|
||||
}
|
10
test/rendering/rastercolorizer.mss
Normal file
10
test/rendering/rastercolorizer.mss
Normal file
@ -0,0 +1,10 @@
|
||||
#world {
|
||||
raster-opacity:0;
|
||||
raster-colorizer-default-mode:discrete;
|
||||
raster-colorizer-default-color:#f00;
|
||||
raster-colorizer-epsilon:0.05;
|
||||
raster-colorizer-stops:
|
||||
stop(5, #f00)
|
||||
stop(10, #f40, linear)
|
||||
stop(10, #f80);
|
||||
}
|
Loading…
Reference in New Issue
Block a user