-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtle.js
More file actions
24 lines (22 loc) · 717 Bytes
/
tle.js
File metadata and controls
24 lines (22 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let fs = require("fs")
var jsonfile = require('jsonfile');
const { getLatLngObj } = require("tle.js/dist/tlejs.cjs");
// Intitializing the readFileLines with the file
const readFileLines = filename =>
fs.readFileSync(filename)
.toString('UTF8')
.split('\r\n');
// Calling the readFiles function with file name
let arr = readFileLines('target.txt');
let final_arr = [];
for (let i = 0; i < arr.length - 2; i=i+3) {
let ans = arr.slice(i, i+3);
let latLonObj = getLatLngObj(ans.join('\n'))
let ele = {
lat: latLonObj["lat"],
lng: latLonObj["lng"]
};
// let jsonString = JSON.stringify(ele);
final_arr.push(ele);
};
fs.writeFileSync('target.json', JSON.stringify(final_arr));