-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
60 lines (43 loc) · 1.7 KB
/
app.js
File metadata and controls
60 lines (43 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const topService = require('./top/topService');
const survexService = require('./survex/survexService');
var path = require('path')
var fs = require('fs');
var fsw = require('fs');
var path = require('path');
//TODO bug!!! 1.30 se bere kot 1.3!!!!
// var topFile = topService.openTopFromPath('example.top');
// // console.log(topFile.shots.slice(1,3));
// var buffer = fs.readFileSync('./temp/20181209 aja spela proti trubarju.top');
// var topFileFromStream = topService.openTopFromStream(buffer, 'example.top');
// topFileFromStream.fileIdentifier = 'tr01';
// console.log(topFileFromStream);
// // console.log(topFileFromStream.shots.slice(1,3));
// // console.log(topFileFromStream.shots);
// var svxResult = survexService.createSurvexForTopFile(topFileFromStream);
// console.log(svxResult);
// TODO for collection of files
fs.readdir('./temp/', (err, files) => {
console.log(files);
var logger = fs.createWriteStream('./temp/log.txt', {
flags: 'a' // 'a' means appending (old data will be preserved)
});
var i = 0;
for(i = 0; i < files.length; i++){
var file = files[i];
if(path.extname(file) !== '.top'){
continue;
}
var topFile = topService.openTopFromPath('./temp/'+file);
console.log(file);
topFile.forEach(shot => {
if(shot.idFrom != null && shot.idTo != null){
logger.write(`${shot.idFrom.id}\t${shot.idTo.id}\t${shot.dist.toFixed(2)}\t${shot.azimuth.toFixed(2)}\t${shot.incl.toFixed(2)}\r\n`);
}
});
console.log(i);
}
// files.forEach(file => {
// });
console.log('close');
logger.end(); // close string
})