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
|
## 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
|
### 0.4.10
|
||||||
|
|
||||||
* Updated reference.json
|
* Updated reference.json
|
||||||
|
@ -2,8 +2,10 @@ var _ = require('underscore');
|
|||||||
var carto = require('./index');
|
var carto = require('./index');
|
||||||
var tree = require('./tree');
|
var tree = require('./tree');
|
||||||
|
|
||||||
carto.Renderer = function Renderer(env) {
|
carto.Renderer = function Renderer(env, options) {
|
||||||
this.env = env || {};
|
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
|
// Prepare a MML document (given as an object) into a
|
||||||
@ -20,6 +22,8 @@ carto.Renderer.prototype.render = function render(m, callback) {
|
|||||||
effects: []
|
effects: []
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tree.Reference.setVersion(this.options.mapnik_version);
|
||||||
|
|
||||||
var output = [];
|
var output = [];
|
||||||
|
|
||||||
// Transform stylesheets into rulesets.
|
// Transform stylesheets into rulesets.
|
||||||
@ -33,7 +37,7 @@ carto.Renderer.prototype.render = function render(m, callback) {
|
|||||||
var time = +new Date(),
|
var time = +new Date(),
|
||||||
root = (carto.Parser(env)).parse(s.data);
|
root = (carto.Parser(env)).parse(s.data);
|
||||||
if (env.benchmark)
|
if (env.benchmark)
|
||||||
console.warn('Parsing time: ' + ((new Date() - time)) + 'ms');
|
console.warn('Parsing time: ' + (new Date() - time) + 'ms');
|
||||||
return root.toList(env);
|
return root.toList(env);
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
var mapnik_reference = require('mapnik-reference');
|
var mapnik_reference = require('mapnik-reference');
|
||||||
|
|
||||||
tree.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 = {};
|
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;
|
return tree.Reference.selector(selector).type == value[0].is;
|
||||||
} else {
|
} else {
|
||||||
// TODO: handle in reusable way
|
// 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
|
return tree.Reference
|
||||||
.selector(selector).type
|
.selector(selector).type
|
||||||
.indexOf(value.value[0].value) !== -1;
|
.indexOf(value.value[0].value) !== -1;
|
||||||
|
@ -47,18 +47,28 @@ tree.Rule.prototype.toXML = function(env, content) {
|
|||||||
|
|
||||||
if ((this.value instanceof tree.Value) &&
|
if ((this.value instanceof tree.Value) &&
|
||||||
!tree.Reference.validValue(env, this.name, this.value)) {
|
!tree.Reference.validValue(env, this.name, this.value)) {
|
||||||
return env.error({
|
if (!tree.Reference.selector(this.name)) {
|
||||||
message: 'Invalid value for ' +
|
return env.error({
|
||||||
this.name +
|
message: 'Unrecognized property: ' +
|
||||||
', a valid ' +
|
this.name,
|
||||||
(tree.Reference.selector(this.name).validate ||
|
index: this.index,
|
||||||
tree.Reference.selector(this.name).type) +
|
type: 'syntax',
|
||||||
' is expected. ' + this.value +
|
filename: this.filename
|
||||||
' was given.',
|
});
|
||||||
index: this.index,
|
} else {
|
||||||
type: 'syntax',
|
return env.error({
|
||||||
filename: this.filename
|
message: 'Invalid value for ' +
|
||||||
});
|
this.name +
|
||||||
|
', a valid ' +
|
||||||
|
(tree.Reference.selector(this.name).validate ||
|
||||||
|
tree.Reference.selector(this.name).type) +
|
||||||
|
' is expected. ' + this.value +
|
||||||
|
' was given.',
|
||||||
|
index: this.index,
|
||||||
|
type: 'syntax',
|
||||||
|
filename: this.filename
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.variable) {
|
if (this.variable) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "carto",
|
"name": "carto",
|
||||||
|
"version": "0.5.0",
|
||||||
"description": "Mapnik Stylesheet Compiler",
|
"description": "Mapnik Stylesheet Compiler",
|
||||||
"url": "https://github.com/mapbox/carto",
|
"url": "https://github.com/mapbox/carto",
|
||||||
"repositories": [{
|
"repositories": [{
|
||||||
@ -22,7 +23,6 @@
|
|||||||
"Konstantin Käfer",
|
"Konstantin Käfer",
|
||||||
"Alexis Sellier <self@cloudhead.net>"
|
"Alexis Sellier <self@cloudhead.net>"
|
||||||
],
|
],
|
||||||
"version": "0.4.10",
|
|
||||||
"licenses": [{
|
"licenses": [{
|
||||||
"type": "Apache"
|
"type": "Apache"
|
||||||
}],
|
}],
|
||||||
|
Loading…
Reference in New Issue
Block a user