updated raster colorizer support
This commit is contained in:
parent
55fbafe0d0
commit
74fa914c8c
@ -10,6 +10,24 @@ tree.functions = {
|
|||||||
if (rgb.some(isNaN) || isNaN(a)) return null;
|
if (rgb.some(isNaN) || isNaN(a)) return null;
|
||||||
return new tree.Color(rgb, a);
|
return new tree.Color(rgb, a);
|
||||||
},
|
},
|
||||||
|
// 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.ev(env) + '"' +
|
||||||
|
(color ? ' color="' + color.ev(env) + '" ' : '') +
|
||||||
|
(mode ? ' mode="' + mode.ev(env) + '" ' : '') +
|
||||||
|
'/>';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
hsl: function (h, s, l) {
|
hsl: function (h, s, l) {
|
||||||
return this.hsla(h, s, l, 1.0);
|
return this.hsla(h, s, l, 1.0);
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,7 @@ tree.Call.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.name in tree.functions) {
|
if (this.name in tree.functions) {
|
||||||
if (tree.functions[this.name].length === args.length) {
|
if (tree.functions[this.name].length <= args.length) {
|
||||||
var val = tree.functions[this.name].apply(tree.functions, args);
|
var val = tree.functions[this.name].apply(tree.functions, args);
|
||||||
if (val === null) {
|
if (val === null) {
|
||||||
env.error({
|
env.error({
|
||||||
|
@ -130,6 +130,9 @@ tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) {
|
|||||||
if (x && x.serialization && x.serialization === 'content') {
|
if (x && x.serialization && x.serialization === 'content') {
|
||||||
selfclosing = false;
|
selfclosing = false;
|
||||||
tagcontent = attributes[j].ev(env).toXML(env, true);
|
tagcontent = attributes[j].ev(env).toXML(env, true);
|
||||||
|
} else if (x && x.serialization && x.serialization === 'tag') {
|
||||||
|
selfclosing = false;
|
||||||
|
tagcontent = attributes[j].ev(env).toXML(env, true);
|
||||||
} else {
|
} else {
|
||||||
xml += attributes[j].ev(env).toXML(env) + ' ';
|
xml += attributes[j].ev(env).toXML(env) + ' ';
|
||||||
}
|
}
|
||||||
@ -137,7 +140,7 @@ tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) {
|
|||||||
if (selfclosing) {
|
if (selfclosing) {
|
||||||
xml += '/>\n';
|
xml += '/>\n';
|
||||||
} else {
|
} else {
|
||||||
if (tagcontent.indexOf('<Format') != -1) {
|
if (tagcontent.indexOf('<') != -1) {
|
||||||
xml += '>' + tagcontent + '</' + name + '>\n';
|
xml += '>' + tagcontent + '</' + name + '>\n';
|
||||||
} else {
|
} else {
|
||||||
xml += '><![CDATA[' + tagcontent + ']]></' + name + '>\n';
|
xml += '><![CDATA[' + tagcontent + ']]></' + name + '>\n';
|
||||||
|
@ -163,6 +163,12 @@ ref.validValue = function(env, selector, value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else if (ref.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 (ref.selector(selector).type == 'functions') {
|
} else if (ref.selector(selector).type == 'functions') {
|
||||||
// For backwards compatibility, you can specify a string for `functions`-compatible
|
// For backwards compatibility, you can specify a string for `functions`-compatible
|
||||||
// values, though they will not be validated.
|
// values, though they will not be validated.
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"underscore": "~1.4.3",
|
"underscore": "~1.4.3",
|
||||||
"mapnik-reference": "~5.0.3",
|
"mapnik-reference": "https://github.com/mapnik/mapnik-reference/archive/raster-colorizer.tar.gz",
|
||||||
"xml2js": "~0.1.13",
|
"xml2js": "~0.1.13",
|
||||||
"optimist": "~0.3.5"
|
"optimist": "~0.3.5"
|
||||||
},
|
},
|
||||||
|
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