Rename mess to carto.

This commit is contained in:
Tom MacWright 2011-02-07 11:22:14 -05:00
parent 5ab5d38a26
commit 3147a89a48
44 changed files with 92 additions and 92 deletions

View File

@ -11,6 +11,6 @@ test:
endif
doc:
docco lib/mess/*.js lib/mess/tree/*.js
docco lib/carto/*.js lib/carto/tree/*.js
.PHONY: test

View File

@ -1,4 +1,4 @@
# mess.js
# carto
Is a stylesheet renderer for Mapnik. It's an evolution of the [Cascadenik](https://github.com/mapnik/Cascadenik) idea and language, with an emphasis on speed and flexibility.
@ -6,7 +6,7 @@ Is a stylesheet renderer for Mapnik. It's an evolution of the [Cascadenik](https
Follow the directions to install [node-zipfile](https://github.com/springmeyer/node-zipfile) and then:
npm install mess
npm install carto
_note: possibly broken on ubuntu_
@ -16,7 +16,7 @@ _incompatibility_
* MML files are assumed to be JSON, not XML. The files are near-identical to the XML files accepted by Cascadenik, just translated into JSON.
* Like Cascadenik, you can also include remote stylesheets, by including their URLs as simple strings in the Stylesheet array.
mess.js MML:
carto.js MML:
{
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs",
@ -58,9 +58,9 @@ Cascadenik MML
## Attachments
_new_
In CSS, a certain object can only have one instance of a property. A `<div>` has a specific border width and color, rules that match better than others (#id instead of .class) override previous definitions. `mess.js` acts the same way normally for the sake of familiarity and organization, but Mapnik itself is more powerful.
In CSS, a certain object can only have one instance of a property. A `<div>` has a specific border width and color, rules that match better than others (#id instead of .class) override previous definitions. `carto.js` acts the same way normally for the sake of familiarity and organization, but Mapnik itself is more powerful.
Layers in Mapnik can have multiple [borders](http://trac.mapnik.org/wiki/LineSymbolizer) and multiple copies of other attributes. This ability is useful in drawing line outlines, like in the case of road borders or 'glow' effects around coasts. `mess.js` makes this accessible by allowing attachments to styles:
Layers in Mapnik can have multiple [borders](http://trac.mapnik.org/wiki/LineSymbolizer) and multiple copies of other attributes. This ability is useful in drawing line outlines, like in the case of road borders or 'glow' effects around coasts. `carto.js` makes this accessible by allowing attachments to styles:
#world {
line-color: #fff;
@ -72,7 +72,7 @@ Layers in Mapnik can have multiple [borders](http://trac.mapnik.org/wiki/LineSym
line-width: 6;
}
Attachments are optional: if you don't define them, mess.js does overriding of styles just like Cascadenik.
Attachments are optional: if you don't define them, carto.js does overriding of styles just like Cascadenik.
This brings us to another _incompatibility_: `line-inline` and `line-outline` have been removed from the language, because attachments are capable of the same trick.
@ -84,7 +84,7 @@ Instead of the name attribute of the [TextSymbolizer](http://trac.mapnik.org/wik
<table>
<tr>
<th>cascadenik</th>
<th>mess.js</th>
<th>carto.js</th>
</tr>
<tr>
<td valign='top'>
@ -106,19 +106,19 @@ Instead of the name attribute of the [TextSymbolizer](http://trac.mapnik.org/wik
## Mapnik2
_new_
`mess.js` is only compatible with [Mapnik2](http://trac.mapnik.org/wiki/Mapnik2). Compatibility with Mapnik 0.7.x is not planned.
`carto.js` is only compatible with [Mapnik2](http://trac.mapnik.org/wiki/Mapnik2). Compatibility with Mapnik 0.7.x is not planned.
## Rasters and Buildings
_new_
Rasters are supported in mess.js - it knows how to download `.vrt`, `.tiff`, and soon other raster formats, and the properties of the [RasterSymbolizer](http://trac.mapnik.org/wiki/RasterSymbolizer) are exposed in the language.
Rasters are supported in carto.js - it knows how to download `.vrt`, `.tiff`, and soon other raster formats, and the properties of the [RasterSymbolizer](http://trac.mapnik.org/wiki/RasterSymbolizer) are exposed in the language.
The [BuildingSymbolizer](http://trac.mapnik.org/wiki/BuildingSymbolizer) is also supported in `mess.js`. The code stores symbolizer types and properties in a JSON file (in `tree/reference.js`), so new Mapnik features can be quickly implemented here.
The [BuildingSymbolizer](http://trac.mapnik.org/wiki/BuildingSymbolizer) is also supported in `carto.js`. The code stores symbolizer types and properties in a JSON file (in `tree/reference.js`), so new Mapnik features can be quickly implemented here.
## Variables & Expressions
_new_
`mess.js` inherits from its basis in [less.js](http://lesscss.org/) some new features in CSS. One can define variables in stylesheets, and use expressions to modify them.
`carto.js` inherits from its basis in [less.js](http://lesscss.org/) some new features in CSS. One can define variables in stylesheets, and use expressions to modify them.
@mybackground: #2B4D2D;
@ -134,7 +134,7 @@ _new_
## Nested Styles
_new_
`mess.js` also inherits nesting of rules from less.js.
`carto.js` also inherits nesting of rules from less.js.
/* Applies to all layers with .land class */
.land {
@ -163,11 +163,11 @@ This can be a convenient way to group style changes by zoom level:
## FontSets
_new_
By defining multiple fonts in a `text-face-name` definition, you create [FontSets](http://trac.mapnik.org/wiki/FontSet) in `mess.js`. These are useful for supporting multiple character sets and fallback fonts for distributed styles.
By defining multiple fonts in a `text-face-name` definition, you create [FontSets](http://trac.mapnik.org/wiki/FontSet) in `carto.js`. These are useful for supporting multiple character sets and fallback fonts for distributed styles.
<table>
<tr>
<th>mess</th><th>XML</th>
<th>carto</th><th>XML</th>
</tr>
<tr>
<td valign='top'>
@ -200,26 +200,26 @@ By defining multiple fonts in a `text-face-name` definition, you create [FontSet
#### Using the binary
messc map_file.json
cartoc map_file.json
#### Using the code
Currently `mess.js` is designed to be invoked from [node.js](http://nodejs.org/).
Currently `carto.js` is designed to be invoked from [node.js](http://nodejs.org/).
The `Renderer` interface is the main API for developers, and it takes an MML file as a string as input.
// defined variables:
// - input (the name or identifier of the file being parsed)
// - data (a string containing the MML or an object of MML)
var mess = require('mess');
var carto = require('carto');
new mess.Renderer({
new carto.Renderer({
filename: input,
local_data_dir: path.dirname(input),
}).render(data, function(err, output) {
if (err) {
if (Array.isArray(err)) {
err.forEach(function(e) {
mess.writeError(e, options);
carto.writeError(e, options);
});
} else { throw err; }
} else {
@ -229,7 +229,7 @@ The `Renderer` interface is the main API for developers, and it takes an MML fil
## Credits
`mess.js` is based on [less.js](https://github.com/cloudhead/less.js), a CSS compiler written by Alexis Sellier.
`carto.js` is based on [less.js](https://github.com/cloudhead/less.js), a CSS compiler written by Alexis Sellier.
It depends on:

View File

@ -6,7 +6,7 @@ var path = require('path'),
require.paths.unshift(path.join(__dirname, '../lib'), path.join(__dirname, '../lib/node'));
var mess = require('mess');
var mess = require('carto');
var args = process.argv.slice(1);
var options = {
silent: false,

View File

@ -8,7 +8,7 @@ var xml2js = require('xml2js'),
require.paths.unshift(path.join(__dirname, '../lib'), path.join(__dirname, '../lib/node'));
var mess = require('mess'),
var mess = require('carto'),
args = process.argv.slice(1);
var options = {

View File

@ -154,4 +154,4 @@ function clamp(val) {
return Math.min(1, Math.max(0, val));
}
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -4,13 +4,13 @@ var path = require('path'),
require.paths.unshift(path.join(__dirname, '..'));
var mess = {
var carto = {
version: [1, 0, 40],
Parser: require('mess/parser').Parser,
Renderer: require('mess/renderer').Renderer,
External: require('mess/external'),
importer: require('mess/parser').importer,
tree: require('mess/tree'),
Parser: require('carto/parser').Parser,
Renderer: require('carto/renderer').Renderer,
External: require('carto/external'),
importer: require('carto/parser').importer,
tree: require('carto/tree'),
writeError: function(ctx, options) {
var message = '';
var extract = ctx.extract;
@ -61,10 +61,10 @@ var mess = {
'reference', 'rule', 'ruleset', 'selector', 'style', 'url', 'value',
'variable', 'zoom', 'invalid', 'fontset'
].forEach(function(n) {
require(path.join('mess', 'tree', n));
require(path.join('carto', 'tree', n));
});
mess.Parser.importer = function(file, paths, callback) {
carto.Parser.importer = function(file, paths, callback) {
var pathname;
paths.unshift('.');
@ -83,11 +83,11 @@ mess.Parser.importer = function(file, paths, callback) {
fs.readFile(pathname, 'utf-8', function(e, data) {
if (e) sys.error(e);
new mess.Parser({
new carto.Parser({
paths: [path.dirname(pathname)],
filename: pathname
}).parse(data, function(e, root) {
if (e) mess.writeError(e);
if (e) carto.writeError(e);
callback(root);
});
});
@ -97,9 +97,9 @@ mess.Parser.importer = function(file, paths, callback) {
}
};
require('mess/functions');
require('carto/functions');
for (var k in mess) { exports[k] = mess[k] }
for (var k in carto) { exports[k] = carto[k] }
// Stylize a string
function stylize(str, style) {

View File

@ -1,15 +1,15 @@
var mess, tree;
var carto, tree;
if (typeof(window) === 'undefined') {
mess = exports,
tree = require('mess/tree');
carto = exports,
tree = require('carto/tree');
} else {
if (typeof(window.mess) === 'undefined') { window.mess = {} }
mess = window.mess,
tree = window.mess.tree = {};
if (typeof(window.carto) === 'undefined') { window.carto = {} }
carto = window.carto,
tree = window.carto.tree = {};
}
//
// mess.js - parser
// carto.js - parser
//
// A relatively straight-forward predictive parser.
// There is no tokenization/lexing stage, the input is parsed
@ -41,7 +41,7 @@ if (typeof(window) === 'undefined') {
// It also takes care of moving all the indices forwards.
//
//
mess.Parser = function Parser(env) {
carto.Parser = function Parser(env) {
var input, // LeSS input string
i, // current index in `input`
j, // current chunk
@ -62,7 +62,7 @@ mess.Parser = function Parser(env) {
paths: env && env.paths || [], // Search paths, when importing
queue: [], // Files which haven't been imported yet
files: {}, // Holds the imported parse trees
mime: env && env.mime, // MIME type of .mess files
mime: env && env.mime, // MIME type of .carto files
push: function(path, callback) {
var that = this;
this.queue.push(path);
@ -70,7 +70,7 @@ mess.Parser = function Parser(env) {
//
// Import a file asynchronously
//
mess.Parser.importer(path, this.paths, function(root) {
carto.Parser.importer(path, this.paths, function(root) {
that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue
that.files[path] = root; // Store the root
@ -982,7 +982,7 @@ if (typeof(window) !== 'undefined') {
//
// Used by `@import` directives
//
mess.Parser.importer = function(path, paths, callback, env) {
carto.Parser.importer = function(path, paths, callback, env) {
if (path.charAt(0) !== '/' && paths.length > 0) {
path = paths[0] + path;
}

View File

@ -4,14 +4,14 @@ var path = require('path'),
Step = require('step'),
_ = require('underscore')._,
sys = require('sys'),
mess = require('mess'),
tree = require('mess/tree');
carto = require('carto'),
tree = require('carto/tree');
require.paths.unshift(path.join(__dirname, '..', 'lib'));
// Rendering circuitry for JSON map manifests.
// This is node-only for the time being.
mess.Renderer = function Renderer(env) {
carto.Renderer = function Renderer(env) {
env = _.extend({}, env);
if (!env.debug) env.debug = false;
if (!env.data_dir) env.data_dir = '/tmp/';
@ -151,7 +151,7 @@ mess.Renderer = function Renderer(env) {
);
},
// Compile (already downloaded) styles with mess.js,
// Compile (already downloaded) styles with carto,
// calling callback with an array of [map object, [stylesheet objects]]
//
// Called with the results of localizeStyle or localizeExternals:
@ -194,7 +194,7 @@ mess.Renderer = function Renderer(env) {
that.env,
this.env
), { filename: result[0] });
new mess.Parser(parse_env).parse(result[1],
new carto.Parser(parse_env).parse(result[1],
function(err, tree) {
if (env.debug) console.warn('Parsing time: '
+ ((new Date - parsingTime))
@ -385,7 +385,7 @@ mess.Renderer = function Renderer(env) {
}
}
var nl = new mess.tree.Layer(l);
var nl = new carto.tree.Layer(l);
output.push(nl.toXML());
});
output.unshift(env.effects.map(function(e) {
@ -476,4 +476,4 @@ mess.Renderer = function Renderer(env) {
};
};
module.exports = mess;
module.exports = carto;

View File

@ -1,7 +1,7 @@
/**
* TODO: document this. What does this do?
*/
require('mess/tree').find = function (obj, fun) {
require('carto/tree').find = function (obj, fun) {
for (var i = 0, r; i < obj.length; i++) {
if (r = fun.call(obj, obj[i])) { return r }
}

View File

@ -11,4 +11,4 @@ tree.Alpha.prototype = {
eval: function() { return this }
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -10,4 +10,4 @@ tree.Anonymous.prototype = {
eval: function() { return this }
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -36,4 +36,4 @@ tree.Call.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -91,4 +91,4 @@ tree.Color.prototype = {
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -11,4 +11,4 @@ tree.Comment.prototype = {
eval: function() { return this }
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -154,4 +154,4 @@ tree.Definition.prototype.toXML = function(env, existing) {
return xml;
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -41,4 +41,4 @@ tree.Dimension.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -30,4 +30,4 @@ tree.Directive.prototype = {
rulesets: function() { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) }
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -29,4 +29,4 @@ tree.Element.prototype.matches = function(id, classes) {
(this.value.replace(/^#/, '') == id);
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -18,4 +18,4 @@ tree.Expression.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -51,4 +51,4 @@ tree.Filter.prototype.toString = function() {
return '[' + this.id + ']';
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -1,4 +1,4 @@
var tree = require('mess/tree');
var tree = require('carto/tree');
tree.Filterset = function Filterset() {};

View File

@ -35,4 +35,4 @@ tree.FontSet.prototype.toXML = function(env) {
+ '\n</FontSet>'
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -74,4 +74,4 @@ tree.Import.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -5,4 +5,4 @@ tree.Invalid = function Invalid(chunk, index, message) {
this.type = 'syntax';
this.message = message || "Invalid code: " + this.chunk;
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -34,5 +34,5 @@ tree.JavaScript.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -14,4 +14,4 @@ tree.Keyword.prototype = {
toString: function() { return this.value }
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -27,4 +27,4 @@ tree.Layer.prototype.toXML = function() {
' </Layer>\n';
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -96,4 +96,4 @@ tree.mixin.Definition.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -34,4 +34,4 @@ tree.operate = function(op, a, b) {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -14,4 +14,4 @@ tree.Quoted.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -153,4 +153,4 @@ tree.Reference.validValue = function(env, selector, value) {
}
}
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -89,4 +89,4 @@ tree.Shorthand.prototype = {
eval: function() { return this }
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -188,4 +188,4 @@ tree.Ruleset.prototype = {
return result;
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -27,4 +27,4 @@ tree.Selector.prototype.specificity = function() {
}, [0, 0, this.conditions, this.index]);
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -16,4 +16,4 @@ tree.Style.prototype.toXML = function(env) {
return '<Style name="' + this.name + '" filter-mode="first">\n' + rules.join('') + '</Style>';
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -33,4 +33,4 @@ tree.URL.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -28,4 +28,4 @@ tree.Value.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -34,4 +34,4 @@ tree.Variable.prototype = {
}
};
})(require('mess/tree'));
})(require('carto/tree'));

View File

@ -1,4 +1,4 @@
var tree = require('mess/tree');
var tree = require('carto/tree');
// Storage for zoom ranges. Only supports continuous ranges,
// and stores them as bit-sequences so that they can be combined,

View File

@ -1,4 +1,4 @@
var External = require('mess/external');
var External = require('carto/external');
var path = require('path'),
assert = require('assert'),
fs = require('fs'),

View File

@ -3,8 +3,8 @@ var path = require('path'),
assert = require('assert'),
fs = require('fs');
var mess = require('mess');
var tree = require('mess/tree');
var carto = require('carto');
var tree = require('carto/tree');
var helper = require('./support/helper');
helper.files('rendering', 'mml', function(file) {
@ -13,7 +13,7 @@ helper.files('rendering', 'mml', function(file) {
var renderResult;
helper.file(file, function(mml) {
new mess.Renderer({
new carto.Renderer({
paths: [ path.dirname(file) ],
data_dir: path.join(__dirname, '../data'),
local_data_dir: path.join(__dirname, 'rendering'),

View File

@ -3,8 +3,8 @@ var path = require('path'),
assert = require('assert'),
fs = require('fs');
var mess = require('mess');
var tree = require('mess/tree');
var carto = require('carto');
var tree = require('carto/tree');
var helper = require('./support/helper');
function cleanupItem(key, value) {
@ -26,7 +26,7 @@ function cleanupItem(key, value) {
helper.files('specificity', 'mss', function(file) {
exports['test ' + file] = function(beforeExit) {
helper.file(file, function(content) {
new mess.Parser({
new carto.Parser({
paths: [ path.dirname(file) ],
filename: file
}).parse(content, function (err, tree) {