Version 0.7.0: adds style level opacity support. Fixes #146.

layer-status v0.7.0
Tom MacWright 12 years ago
parent 0f86eb910e
commit 4c3aa03012

@ -1,5 +1,9 @@
## Changelog
### 0.7.0
* Support an `opacity` property on any style that is a style-level property
### 0.6.0
* Bump `mapnik-reference` dependency to 1.0.0 to allow for using `buffer-size` in the

@ -9,7 +9,7 @@ tree.Style = function Style(name, attachment, definitions) {
tree.Style.prototype.toXML = function(env) {
var existing = {};
// TODO :add filters and comp op
var image_filters = _.flatten(this.definitions.map(function(definition) {
return definition.rules.filter(function(rule) {
return (rule.name === 'image-filters');
@ -22,24 +22,33 @@ tree.Style.prototype.toXML = function(env) {
});
}));
var opacity = _.flatten(this.definitions.map(function(definition) {
return definition.rules.filter(function(rule) {
return (rule.name === 'opacity');
});
}));
var rules = this.definitions.map(function(definition) {
return definition.toXML(env, existing);
});
var image_filters_xml = '',
comp_op_xml = '';
var attrs_xml = '';
if (image_filters.length) {
image_filters_xml = 'image-filters="' + image_filters.map(function(f) {
attrs_xml += ' image-filters="' + image_filters.map(function(f) {
return f.toXML(env, true);
}).join(',') + '"';
}).join(',') + '" ';
}
if (comp_op.length) {
comp_op_xml = 'comp-op="' + comp_op[0].value.eval(env).toString() + '"';
attrs_xml += ' comp-op="' + comp_op[0].value.eval(env).toString() + '" ';
}
if (opacity.length) {
attrs_xml += ' opacity="' + opacity[0].value.eval(env).toString() + '" ';
}
return '<Style name="' + this.name + '" filter-mode="first" ' + image_filters_xml + ' ' + comp_op_xml + '>\n' + rules.join('') + '</Style>';
return '<Style name="' + this.name + '" filter-mode="first" ' + attrs_xml + '>\n' + rules.join('') + '</Style>';
};
})(require('../tree'));

@ -1,6 +1,6 @@
{
"name": "carto",
"version": "0.6.0",
"version": "0.7.0",
"description": "Mapnik Stylesheet Compiler",
"url": "https://github.com/mapbox/carto",
"repositories": [{
@ -36,7 +36,7 @@
},
"dependencies": {
"underscore": "~1.3.3",
"mapnik-reference": "~2.0.0",
"mapnik-reference": "~2.1.0",
"xml2js": "~0.1.13"
},
"devDependencies": {

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

@ -0,0 +1,6 @@
#world {
opacity:0.2;
text-name: "[NAME]";
text-size: 11;
text-face-name: "Georgia Regular", "Arial Italic";
}

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map 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" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
<FontSet name="fontset-0">
<Font face-name="Georgia Regular"/>
<Font face-name="Arial Italic"/>
</FontSet>
<Style name="world" filter-mode="first" opacity="0.2" >
<Rule>
<TextSymbolizer size="11" fontset-name="fontset-0" ><![CDATA[[NAME]]]></TextSymbolizer>
</Rule>
</Style>
<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">
<StyleName>world</StyleName>
<Datasource>
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
<Parameter name="type"><![CDATA[shape]]></Parameter>
</Datasource>
</Layer>
</Map>
Loading…
Cancel
Save