Changelog for 0.5.0. Adds second parameter to Render for specifying
Mapnik version. Handle unrecognized selectors slightly better for backwards-and-forwards stylesheets.
This commit is contained in:
parent
c38cc9c58b
commit
1645df71a4
@ -1,5 +1,10 @@
|
||||
## Changelog
|
||||
|
||||
### 0.5.0
|
||||
|
||||
* Now uses the [mapnik-reference](https://github.com/mapnik/mapnik-reference) npm module
|
||||
instead of copying `reference.json` when it's updated
|
||||
|
||||
### 0.4.10
|
||||
|
||||
* Updated reference.json
|
||||
|
@ -2,8 +2,10 @@ var _ = require('underscore');
|
||||
var carto = require('./index');
|
||||
var tree = require('./tree');
|
||||
|
||||
carto.Renderer = function Renderer(env) {
|
||||
carto.Renderer = function Renderer(env, options) {
|
||||
this.env = env || {};
|
||||
this.options = options || {};
|
||||
this.options.mapnik_version = this.options.mapnik_version || 'latest';
|
||||
};
|
||||
|
||||
// Prepare a MML document (given as an object) into a
|
||||
@ -20,6 +22,8 @@ carto.Renderer.prototype.render = function render(m, callback) {
|
||||
effects: []
|
||||
});
|
||||
|
||||
tree.Reference.setVersion(this.options.mapnik_version);
|
||||
|
||||
var output = [];
|
||||
|
||||
// Transform stylesheets into rulesets.
|
||||
@ -33,7 +37,7 @@ carto.Renderer.prototype.render = function render(m, callback) {
|
||||
var time = +new Date(),
|
||||
root = (carto.Parser(env)).parse(s.data);
|
||||
if (env.benchmark)
|
||||
console.warn('Parsing time: ' + ((new Date() - time)) + 'ms');
|
||||
console.warn('Parsing time: ' + (new Date() - time) + 'ms');
|
||||
return root.toList(env);
|
||||
})
|
||||
.flatten()
|
||||
|
@ -3,7 +3,11 @@
|
||||
var mapnik_reference = require('mapnik-reference');
|
||||
|
||||
tree.Reference = {
|
||||
data: mapnik_reference.version['2.1.0']
|
||||
data: mapnik_reference.version.latest
|
||||
};
|
||||
|
||||
tree.Reference.setVersion = function(version) {
|
||||
tree.Reference.data = mapnik_reference.version[version];
|
||||
};
|
||||
|
||||
tree.Reference.required_prop_list_cache = {};
|
||||
@ -100,7 +104,9 @@ tree.Reference.validValue = function(env, selector, value) {
|
||||
return tree.Reference.selector(selector).type == value[0].is;
|
||||
} else {
|
||||
// TODO: handle in reusable way
|
||||
if (value.value[0].is == 'keyword') {
|
||||
if (!tree.Reference.selector(selector)) {
|
||||
return false;
|
||||
} else if (value.value[0].is == 'keyword') {
|
||||
return tree.Reference
|
||||
.selector(selector).type
|
||||
.indexOf(value.value[0].value) !== -1;
|
||||
|
@ -47,6 +47,15 @@ tree.Rule.prototype.toXML = function(env, content) {
|
||||
|
||||
if ((this.value instanceof tree.Value) &&
|
||||
!tree.Reference.validValue(env, this.name, this.value)) {
|
||||
if (!tree.Reference.selector(this.name)) {
|
||||
return env.error({
|
||||
message: 'Unrecognized property: ' +
|
||||
this.name,
|
||||
index: this.index,
|
||||
type: 'syntax',
|
||||
filename: this.filename
|
||||
});
|
||||
} else {
|
||||
return env.error({
|
||||
message: 'Invalid value for ' +
|
||||
this.name +
|
||||
@ -60,6 +69,7 @@ tree.Rule.prototype.toXML = function(env, content) {
|
||||
filename: this.filename
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (this.variable) {
|
||||
return '';
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "carto",
|
||||
"version": "0.5.0",
|
||||
"description": "Mapnik Stylesheet Compiler",
|
||||
"url": "https://github.com/mapbox/carto",
|
||||
"repositories": [{
|
||||
@ -22,7 +23,6 @@
|
||||
"Konstantin Käfer",
|
||||
"Alexis Sellier <self@cloudhead.net>"
|
||||
],
|
||||
"version": "0.4.10",
|
||||
"licenses": [{
|
||||
"type": "Apache"
|
||||
}],
|
||||
|
Loading…
Reference in New Issue
Block a user