fixed encoding, rotation, other stuff
This commit is contained in:
parent
971cf01abe
commit
93ef93dacd
1 changed files with 9 additions and 7 deletions
16
index.js
16
index.js
|
@ -11,11 +11,11 @@ module.exports = function(input, output, feedFile, opts) {
|
||||||
var section = -1;
|
var section = -1;
|
||||||
var sections = [[], [], [], []];
|
var sections = [[], [], [], []];
|
||||||
|
|
||||||
fs.createReadStream(feedFile)
|
fs.createReadStream(feedFile, { encoding: "latin1" })
|
||||||
.on("data", function(data) {
|
.on("data", function(data) {
|
||||||
buf += data.toString();
|
buf += data.toString();
|
||||||
|
|
||||||
var lines = buf.split("\n");
|
var lines = buf.split("\r\n");
|
||||||
buf = lines.pop();
|
buf = lines.pop();
|
||||||
|
|
||||||
for(var i = 0; i < lines.length; i++) {
|
for(var i = 0; i < lines.length; i++) {
|
||||||
|
@ -72,7 +72,9 @@ module.exports = function(input, output, feedFile, opts) {
|
||||||
var p = match[1];
|
var p = match[1];
|
||||||
var x = match[3];
|
var x = match[3];
|
||||||
var y = match[4];
|
var y = match[4];
|
||||||
var r = match[5];
|
var r = Math.round(match[5] - 90);
|
||||||
|
|
||||||
|
if(r < 0) r += 360;
|
||||||
|
|
||||||
if(!feeds[p]) {
|
if(!feeds[p]) {
|
||||||
if(!opts.quite)
|
if(!opts.quite)
|
||||||
|
@ -83,7 +85,7 @@ module.exports = function(input, output, feedFile, opts) {
|
||||||
|
|
||||||
var feed = feeds[p];
|
var feed = feeds[p];
|
||||||
|
|
||||||
this.push([ 0, seq++, feed.slot, x, y, r, 0.50, 0, 100, null, null, null ].join(",") + "\n");
|
this.push([ ++seq, 1, feed.slot, Math.abs(x), Math.abs(y), r, 0.50, 0, 100, null, null, null ].join(",") + "\r\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
@ -91,13 +93,13 @@ module.exports = function(input, output, feedFile, opts) {
|
||||||
|
|
||||||
next(null, tr, sections);
|
next(null, tr, sections);
|
||||||
}], function(err, tr, sections) {
|
}], function(err, tr, sections) {
|
||||||
var rs = fs.createReadStream(input);
|
var rs = fs.createReadStream(input, { encoding: "latin1" });
|
||||||
var ws = fs.createWriteStream(output);
|
var ws = fs.createWriteStream(output, { encoding: "latin1" });
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
async.forEachSeries(sections, function(section, next) {
|
async.forEachSeries(sections, function(section, next) {
|
||||||
ws.write(section.join("\n") + (++i < 4 ? "\n\n" : "\n"), next);
|
ws.write(section.join("\r\n") + (++i < 4 ? "\r\n\r\n" : "\r\n"), next);
|
||||||
}, function() {
|
}, function() {
|
||||||
rs.pipe(tr);
|
rs.pipe(tr);
|
||||||
tr.pipe(ws).on("close", function() {
|
tr.pipe(ws).on("close", function() {
|
||||||
|
|
Loading…
Reference in a new issue