Fixing cartox bugs: no filters, rgb, float values.

This commit is contained in:
Tom MacWright 2011-02-21 10:43:02 -05:00
parent c4b35bf4f2
commit f3339fb42f
2 changed files with 39 additions and 28 deletions

View File

@ -57,28 +57,33 @@ fs.readFile(input, 'utf-8', function (err, data) {
process.exit(1);
}
new carto.Renderer({
filename: input,
benchmark: options.benchmark,
local_data_dir: path.dirname(input),
}).render(data, function(err, output) {
if (err) {
if (Array.isArray(err)) {
err.forEach(function(e) {
carto.writeError(e, options);
});
} else {
throw err;
}
try {
new carto.Renderer({
filename: input,
benchmark: options.benchmark,
local_data_dir: path.dirname(input),
}).render(data, function(err, output) {
if (err) {
if (Array.isArray(err)) {
err.forEach(function(e) {
carto.writeError(e, options);
});
} else {
console.log(err);
throw err;
}
process.exit(1);
} else {
if (!options.benchmark) {
sys.puts(output);
process.exit(1);
} else {
var duration = (+new Date) - start;
console.log('TOTAL: ' + (duration) + 'ms');
if (!options.benchmark) {
sys.puts(output);
} else {
var duration = (+new Date) - start;
console.log('TOTAL: ' + (duration) + 'ms');
}
}
}
});
});
} catch (e) {
sys.error(e);
}
});

View File

@ -115,6 +115,8 @@ upRule.prototype.upSymbolizers = function(xmlRule) {
}
if (symmap[i][j].type == 'uri') {
css_rules.push(cssmap(i, j) + ': url("' + xmlRule[i][0][j] + '");');
} else if (symmap[i][j].type == 'float' || symmap[i][j].type == 'color') {
css_rules.push(cssmap(i, j) + ': ' + xmlRule[i][0][j] + ';');
} else {
css_rules.push(cssmap(i, j) + ': "' + xmlRule[i][0][j] + '";');
}
@ -126,12 +128,16 @@ upRule.prototype.upSymbolizers = function(xmlRule) {
upRule.prototype.toMSS = function() {
return ' ' + this.filters.map(function(f) {
return '[' + f + ']';
}).join('')
+ ' {\n '
+ this.rules.join('\n ')
+ '\n }';
if (this.filters.length) {
return ' ' + this.filters.map(function(f) {
return '[' + f + ']';
}).join('')
+ ' {\n '
+ this.rules.join('\n ')
+ '\n }\n';
} else {
return this.rules.join('\n ');
}
}
function upDatasource(ds) {
@ -164,7 +170,7 @@ fs.readFile(input, 'utf-8', function (e, data) {
newLayer.Datasource = upDatasource(l.Datasource);
layers.push(newLayer);
});
document.Stylesheet = [{ id: 'gen', data: styles.join('') }];
document.Stylesheet = [{ id: 'gen', data: styles.join('\n') }];
document.Layer = layers;
console.log(JSON.stringify(document));
});