-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
82 lines (78 loc) · 2.72 KB
/
index.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
module.exports = {
startCoordinateDataImport: function startCoordinateDataImport(pointsFile, callback) {
var reader = new FileReader();
var blob = new Blob(pointsFile, { type: 'text/plain' });
reader.readAsText(blob);
reader.onloadend = function (e) {
var parsedBlob = reader.result;
var lines = parsedBlob.toString().split(/\r?\n/);
var lineMap = lines.map(function (line, index) {
var coords = line.replace(/\s\s+|\t/g, ' ').split(' ');
var obj = {
x: Number(coords[0]),
y: Number(coords[1]),
z: Number(coords[2])
};
if (!Number.isNaN(obj.x) && !Number.isNaN(obj.y) && !Number.isNaN(obj.z)) {
return obj;
}
});
callback(lineMap.filter(function (line) {
return line !== undefined;
}));
};
},
targetCoordinateDataImport: function targetCoordinateDataImport(pointsFile, callback) {
var reader = new FileReader();
var blob = new Blob(pointsFile, { type: 'text/plain' });
reader.readAsText(blob);
reader.onloadend = function (e) {
var parsedBlob = reader.result;
var lines = parsedBlob.toString().split(/\r?\n/);
var lineMap = lines.map(function (line, index) {
var coords = line.replace(/\s\s+|\t/g, ' ').split(' ');
var obj = {
x: Number(coords[0]),
y: Number(coords[1]),
z: Number(coords[2]),
useX: true,
useY: true,
useZ: true
};
if (!Number.isNaN(obj.x) && !Number.isNaN(obj.y) && !Number.isNaN(obj.z)) {
return obj;
}
});
callback(lineMap.filter(function (line) {
return line !== undefined;
}));
};
},
bundleAdjustmentDataImport: function bundleAdjustmentDataImport(pointsFile, callback) {
var reader = new FileReader();
var blob = new Blob(pointsFile, { type: 'text/plain' });
reader.readAsText(blob);
reader.onloadend = function (e) {
var parsedBlob = reader.result;
var lines = parsedBlob.toString().split(/\r?\n/);
var lineMap = lines.map(function (line, index) {
var coords = line.replace(/\s\s+|\t/g, ' ').split(' ');
var obj = {
stationId: Number(coords[0]),
geometryId: Number(coords[1]),
x: Number(coords[2]),
y: Number(coords[3]),
z: Number(coords[4]),
stdev: Number(coords[5])
};
if (!Number.isNaN(obj.stationId) && !Number.isNaN(obj.geometryId) && !Number.isNaN(obj.x) && !Number.isNaN(obj.y) && !Number.isNaN(obj.z) && !Number.isNaN(obj.stdev)) {
return obj;
}
});
callback(lineMap.filter(function (line) {
return line !== undefined;
}));
};
}
};