@speleotica/frcsdata 4.3.1 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ParseIssue.d.ts +98 -0
- package/ParseIssue.d.ts.map +1 -0
- package/ParseIssue.js +17 -0
- package/ParseIssue.js.map +1 -0
- package/SourceLoc.d.ts +67 -0
- package/SourceLoc.d.ts.map +1 -0
- package/SourceLoc.js +18 -0
- package/SourceLoc.js.map +1 -0
- package/chunksToLines.d.ts +5 -0
- package/chunksToLines.d.ts.map +1 -0
- package/chunksToLines.js +37 -0
- package/chunksToLines.js.map +1 -0
- package/cli/check-survey-correspondence.d.ts +2 -0
- package/cli/check-survey-correspondence.d.ts.map +1 -0
- package/cli/check-survey-correspondence.js +44 -0
- package/cli/check-survey-correspondence.js.map +1 -0
- package/cli/check-survey.d.ts +2 -0
- package/cli/check-survey.d.ts.map +1 -0
- package/cli/check-survey.js +27 -0
- package/cli/check-survey.js.map +1 -0
- package/cli/parse-survey.d.ts +2 -0
- package/cli/parse-survey.d.ts.map +1 -0
- package/cli/parse-survey.js +15 -0
- package/cli/parse-survey.js.map +1 -0
- package/cli/summarize-survey.d.ts +2 -0
- package/cli/summarize-survey.d.ts.map +1 -0
- package/cli/summarize-survey.js +33 -0
- package/cli/summarize-survey.js.map +1 -0
- package/cli.d.ts +2 -0
- package/cli.d.ts.map +1 -0
- package/cli.js +72 -0
- package/cli.js.map +1 -0
- package/formatFrcsTripSummaryFile.d.ts +3 -0
- package/formatFrcsTripSummaryFile.d.ts.map +1 -0
- package/formatFrcsTripSummaryFile.js +33 -0
- package/formatFrcsTripSummaryFile.js.map +1 -0
- package/formatIssues.d.ts +10 -0
- package/formatIssues.d.ts.map +1 -0
- package/formatIssues.js +52 -0
- package/formatIssues.js.map +1 -0
- package/index.d.ts +5 -7
- package/index.d.ts.map +1 -1
- package/index.js +16 -49
- package/index.js.map +1 -1
- package/node/index.d.ts +4 -2
- package/node/index.d.ts.map +1 -1
- package/node/index.js +6 -12
- package/node/index.js.map +1 -1
- package/package.json +8 -6
- package/parseFrcsPlotFile.js +112 -245
- package/parseFrcsPlotFile.js.map +1 -1
- package/parseFrcsTripSummaryFile.d.ts +3 -1
- package/parseFrcsTripSummaryFile.d.ts.map +1 -1
- package/parseFrcsTripSummaryFile.js +53 -119
- package/parseFrcsTripSummaryFile.js.map +1 -1
- package/src/ParseIssue.ts +19 -0
- package/src/SourceLoc.ts +13 -0
- package/src/chunksToLines.ts +26 -0
- package/src/cli/check-survey-correspondence.ts +49 -0
- package/src/cli/check-survey.ts +23 -0
- package/src/cli/parse-survey.ts +10 -0
- package/src/cli/summarize-survey.ts +28 -0
- package/src/cli.ts +63 -0
- package/src/formatFrcsTripSummaryFile.ts +45 -0
- package/src/formatIssues.ts +97 -0
- package/src/index.ts +9 -7
- package/src/node/index.ts +18 -5
- package/src/parseFrcsTripSummaryFile.ts +8 -2
- package/src/string/index.ts +18 -5
- package/src/survey/FrcsSurveyFile.ts +217 -0
- package/src/survey/FrcsSurveyFileJson.ts +46 -0
- package/src/survey/ZodFrcsSurveyFileJson.ts +260 -0
- package/src/survey/ZodFrcsSurveyFileToJson.ts +297 -0
- package/src/{formatFrcsShot.ts → survey/formatFrcsShot.ts} +39 -22
- package/src/{formatFrcsSurveyFile.ts → survey/formatFrcsSurveyFile.ts} +4 -5
- package/src/survey/getColumnRanges.ts +82 -0
- package/src/survey/normalizeTeamMemberName.ts +7 -0
- package/src/survey/parseFrcsSurveyFile.ts +848 -0
- package/src/survey/parsers.ts +128 -0
- package/src/survey/summarizeSurvey.ts +51 -0
- package/src/survey/validators.ts +24 -0
- package/src/underlineSource.ts +34 -0
- package/src/unwrapInvalid.ts +3 -0
- package/src/web/index.ts +27 -21
- package/string/index.d.ts +4 -2
- package/string/index.d.ts.map +1 -1
- package/string/index.js +8 -34
- package/string/index.js.map +1 -1
- package/survey/FrcsSurveyFile.d.ts +172 -0
- package/survey/FrcsSurveyFile.d.ts.map +1 -0
- package/{FrcsSurveyFile.js → survey/FrcsSurveyFile.js} +3 -1
- package/survey/FrcsSurveyFile.js.map +1 -0
- package/survey/FrcsSurveyFileJson.d.ts +15 -0
- package/survey/FrcsSurveyFileJson.d.ts.map +1 -0
- package/{FrcsTrip.js → survey/FrcsSurveyFileJson.js} +1 -1
- package/survey/FrcsSurveyFileJson.js.map +1 -0
- package/survey/ZodFrcsSurveyFileJson.d.ts +60549 -0
- package/survey/ZodFrcsSurveyFileJson.d.ts.map +1 -0
- package/survey/ZodFrcsSurveyFileJson.js +186 -0
- package/survey/ZodFrcsSurveyFileJson.js.map +1 -0
- package/survey/ZodFrcsSurveyFileToJson.d.ts +60390 -0
- package/survey/ZodFrcsSurveyFileToJson.d.ts.map +1 -0
- package/survey/ZodFrcsSurveyFileToJson.js +209 -0
- package/survey/ZodFrcsSurveyFileToJson.js.map +1 -0
- package/{formatFrcsShot.d.ts → survey/formatFrcsShot.d.ts} +2 -3
- package/survey/formatFrcsShot.d.ts.map +1 -0
- package/survey/formatFrcsShot.js +107 -0
- package/survey/formatFrcsShot.js.map +1 -0
- package/survey/formatFrcsSurveyFile.d.ts +3 -0
- package/survey/formatFrcsSurveyFile.d.ts.map +1 -0
- package/survey/formatFrcsSurveyFile.js +87 -0
- package/survey/formatFrcsSurveyFile.js.map +1 -0
- package/survey/getColumnRanges.d.ts +24 -0
- package/survey/getColumnRanges.d.ts.map +1 -0
- package/survey/getColumnRanges.js +62 -0
- package/survey/getColumnRanges.js.map +1 -0
- package/survey/normalizeTeamMemberName.d.ts +2 -0
- package/survey/normalizeTeamMemberName.d.ts.map +1 -0
- package/survey/normalizeTeamMemberName.js +12 -0
- package/survey/normalizeTeamMemberName.js.map +1 -0
- package/{parseFrcsSurveyFile.d.ts → survey/parseFrcsSurveyFile.d.ts} +2 -5
- package/survey/parseFrcsSurveyFile.d.ts.map +1 -0
- package/survey/parseFrcsSurveyFile.js +626 -0
- package/survey/parseFrcsSurveyFile.js.map +1 -0
- package/survey/parsers.d.ts +11 -0
- package/survey/parsers.d.ts.map +1 -0
- package/survey/parsers.js +119 -0
- package/survey/parsers.js.map +1 -0
- package/survey/summarizeSurvey.d.ts +6 -0
- package/survey/summarizeSurvey.d.ts.map +1 -0
- package/survey/summarizeSurvey.js +58 -0
- package/survey/summarizeSurvey.js.map +1 -0
- package/survey/validators.d.ts +7 -0
- package/survey/validators.d.ts.map +1 -0
- package/survey/validators.js +36 -0
- package/survey/validators.js.map +1 -0
- package/underlineSource.d.ts +6 -0
- package/underlineSource.d.ts.map +1 -0
- package/underlineSource.js +22 -0
- package/underlineSource.js.map +1 -0
- package/unwrapInvalid.d.ts +4 -0
- package/unwrapInvalid.d.ts.map +1 -0
- package/unwrapInvalid.js +10 -0
- package/unwrapInvalid.js.map +1 -0
- package/web/index.d.ts +6 -6
- package/web/index.d.ts.map +1 -1
- package/web/index.js +60 -118
- package/web/index.js.map +1 -1
- package/FrcsShot.d.ts +0 -57
- package/FrcsShot.d.ts.map +0 -1
- package/FrcsShot.js +0 -13
- package/FrcsShot.js.map +0 -1
- package/FrcsSurveyFile.d.ts +0 -29
- package/FrcsSurveyFile.d.ts.map +0 -1
- package/FrcsSurveyFile.js.map +0 -1
- package/FrcsTrip.d.ts +0 -23
- package/FrcsTrip.d.ts.map +0 -1
- package/FrcsTrip.js.map +0 -1
- package/formatFrcsShot.d.ts.map +0 -1
- package/formatFrcsShot.js +0 -96
- package/formatFrcsShot.js.map +0 -1
- package/formatFrcsSurveyFile.d.ts +0 -3
- package/formatFrcsSurveyFile.d.ts.map +0 -1
- package/formatFrcsSurveyFile.js +0 -165
- package/formatFrcsSurveyFile.js.map +0 -1
- package/parseFrcsSurveyFile.d.ts.map +0 -1
- package/parseFrcsSurveyFile.js +0 -812
- package/parseFrcsSurveyFile.js.map +0 -1
- package/src/FrcsShot.ts +0 -56
- package/src/FrcsSurveyFile.ts +0 -47
- package/src/FrcsTrip.ts +0 -25
- package/src/parseFrcsSurveyFile.ts +0 -788
package/parseFrcsPlotFile.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
|
+
exports.default = parseFrcsPlotFile;
|
|
10
7
|
var _unitized = require("@speleotica/unitized");
|
|
11
8
|
var _parseSegment = require("parse-segment");
|
|
12
|
-
function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
13
|
-
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
|
14
9
|
/**
|
|
15
10
|
* Parses data from a calculated survey file. These look like so:
|
|
16
11
|
<pre> 123.182259
|
|
@@ -25,245 +20,117 @@ function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r
|
|
|
25
20
|
AE12 8 9 -1019 2175 -4630 -369 336 221 -201 40 40 1
|
|
26
21
|
AE11 9 10 -1516 1289 -3919 -348 195 610 -342 50 10 1</pre>
|
|
27
22
|
*/
|
|
28
|
-
function parseFrcsPlotFile(
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
return _context.abrupt("continue", 65);
|
|
141
|
-
case 36:
|
|
142
|
-
easting = parseLength(line, 17, 25, 'easting', 100);
|
|
143
|
-
if (easting) {
|
|
144
|
-
_context.next = 39;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
return _context.abrupt("continue", 65);
|
|
148
|
-
case 39:
|
|
149
|
-
northing = parseLength(line, 25, 33, 'northing', 100);
|
|
150
|
-
if (northing) {
|
|
151
|
-
_context.next = 42;
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
return _context.abrupt("continue", 65);
|
|
155
|
-
case 42:
|
|
156
|
-
elevation = parseLength(line, 33, 40, 'elevation', 100);
|
|
157
|
-
if (elevation) {
|
|
158
|
-
_context.next = 45;
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
return _context.abrupt("continue", 65);
|
|
162
|
-
case 45:
|
|
163
|
-
leftEasting = parseLength(line, 40, 46, 'left wall easting', 100);
|
|
164
|
-
if (leftEasting) {
|
|
165
|
-
_context.next = 48;
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
return _context.abrupt("continue", 65);
|
|
169
|
-
case 48:
|
|
170
|
-
leftNorthing = parseLength(line, 46, 52, 'left wall northing', 100);
|
|
171
|
-
if (leftNorthing) {
|
|
172
|
-
_context.next = 51;
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
return _context.abrupt("continue", 65);
|
|
176
|
-
case 51:
|
|
177
|
-
rightEasting = parseLength(line, 52, 58, 'right wall easting', 100);
|
|
178
|
-
if (rightEasting) {
|
|
179
|
-
_context.next = 54;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
return _context.abrupt("continue", 65);
|
|
183
|
-
case 54:
|
|
184
|
-
rightNorthing = parseLength(line, 58, 64, 'right wall northing', 100);
|
|
185
|
-
if (rightNorthing) {
|
|
186
|
-
_context.next = 57;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
return _context.abrupt("continue", 65);
|
|
190
|
-
case 57:
|
|
191
|
-
up = parseLength(line, 64, 68, 'up', 10);
|
|
192
|
-
if (up) {
|
|
193
|
-
_context.next = 60;
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
return _context.abrupt("continue", 65);
|
|
197
|
-
case 60:
|
|
198
|
-
down = parseLength(line, 68, 72, 'down', 10);
|
|
199
|
-
if (down) {
|
|
200
|
-
_context.next = 63;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
return _context.abrupt("continue", 65);
|
|
204
|
-
case 63:
|
|
205
|
-
tripNumber = parseOptionalUint(line, 72, 78, 'trip number');
|
|
206
|
-
shots.push({
|
|
207
|
-
toName: toName,
|
|
208
|
-
isSurface: isSurface,
|
|
209
|
-
fromNumber: fromNumber,
|
|
210
|
-
toNumber: toNumber,
|
|
211
|
-
easting: easting,
|
|
212
|
-
northing: northing,
|
|
213
|
-
elevation: elevation,
|
|
214
|
-
leftEasting: leftEasting,
|
|
215
|
-
leftNorthing: leftNorthing,
|
|
216
|
-
rightEasting: rightEasting,
|
|
217
|
-
rightNorthing: rightNorthing,
|
|
218
|
-
up: up,
|
|
219
|
-
down: down,
|
|
220
|
-
tripNumber: tripNumber
|
|
221
|
-
});
|
|
222
|
-
case 65:
|
|
223
|
-
_iteratorAbruptCompletion = false;
|
|
224
|
-
_context.next = 12;
|
|
225
|
-
break;
|
|
226
|
-
case 68:
|
|
227
|
-
_context.next = 74;
|
|
228
|
-
break;
|
|
229
|
-
case 70:
|
|
230
|
-
_context.prev = 70;
|
|
231
|
-
_context.t0 = _context["catch"](10);
|
|
232
|
-
_didIteratorError = true;
|
|
233
|
-
_iteratorError = _context.t0;
|
|
234
|
-
case 74:
|
|
235
|
-
_context.prev = 74;
|
|
236
|
-
_context.prev = 75;
|
|
237
|
-
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
238
|
-
_context.next = 79;
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
_context.next = 79;
|
|
242
|
-
return _iterator["return"]();
|
|
243
|
-
case 79:
|
|
244
|
-
_context.prev = 79;
|
|
245
|
-
if (!_didIteratorError) {
|
|
246
|
-
_context.next = 82;
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
throw _iteratorError;
|
|
250
|
-
case 82:
|
|
251
|
-
return _context.finish(79);
|
|
252
|
-
case 83:
|
|
253
|
-
return _context.finish(74);
|
|
254
|
-
case 84:
|
|
255
|
-
return _context.abrupt("return", {
|
|
256
|
-
totalLength: totalLength,
|
|
257
|
-
shots: shots,
|
|
258
|
-
errors: errors
|
|
259
|
-
});
|
|
260
|
-
case 85:
|
|
261
|
-
case "end":
|
|
262
|
-
return _context.stop();
|
|
263
|
-
}
|
|
264
|
-
}, _callee, null, [[10, 70, 74, 84], [75,, 79, 83]]);
|
|
265
|
-
}));
|
|
266
|
-
return _parseFrcsPlotFile.apply(this, arguments);
|
|
23
|
+
async function parseFrcsPlotFile(file, lines) {
|
|
24
|
+
let totalLength = _unitized.Unitize.feet(NaN);
|
|
25
|
+
const shots = [];
|
|
26
|
+
const errors = [];
|
|
27
|
+
let lineNumber = 0;
|
|
28
|
+
const error = (message, line, startColumn, endColumn) => {
|
|
29
|
+
errors.push(new _parseSegment.SegmentParseError(message, new _parseSegment.Segment({
|
|
30
|
+
value: line,
|
|
31
|
+
source: file,
|
|
32
|
+
startLine: lineNumber - 1,
|
|
33
|
+
startCol: 0
|
|
34
|
+
}).substring(startColumn, endColumn)));
|
|
35
|
+
};
|
|
36
|
+
function parseUint(line, startColumn, endColumn, fieldName) {
|
|
37
|
+
const str = line.substring(startColumn, endColumn);
|
|
38
|
+
if (!/\S/.test(str)) {
|
|
39
|
+
error(`Missing ${fieldName}`, line, startColumn, endColumn);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (!/^\s*\d+\s*$/.test(str)) {
|
|
43
|
+
error(`Invalid ${fieldName}`, line, startColumn, endColumn);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return parseInt(str);
|
|
47
|
+
}
|
|
48
|
+
function parseOptionalUint(line, startColumn, endColumn, fieldName) {
|
|
49
|
+
const str = line.substring(startColumn, endColumn);
|
|
50
|
+
if (!/\S/.test(str)) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (!/^\s*\d+\s*$/.test(str)) {
|
|
54
|
+
error(`Invalid ${fieldName}`, line, startColumn, endColumn);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return parseInt(str);
|
|
58
|
+
}
|
|
59
|
+
function parseLength(line, startColumn, endColumn, fieldName, divisor) {
|
|
60
|
+
const str = line.substring(startColumn, endColumn);
|
|
61
|
+
if (!/^\s*-?\d+\s*$/.test(str)) {
|
|
62
|
+
error(`Invalid ${fieldName}`, line, startColumn, endColumn);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const value = parseFloat(str);
|
|
66
|
+
if (isNaN(value)) {
|
|
67
|
+
error(`Missing ${fieldName}`, line, startColumn, endColumn);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return _unitized.Unitize.feet(value / divisor);
|
|
71
|
+
}
|
|
72
|
+
for await (const line of lines) {
|
|
73
|
+
lineNumber++;
|
|
74
|
+
if (lineNumber === 1) {
|
|
75
|
+
totalLength = _unitized.Unitize.feet(parseFloat(line));
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (!/\S/.test(line)) continue;
|
|
79
|
+
const toName = line.substring(0, 6).trim();
|
|
80
|
+
if (!toName) {
|
|
81
|
+
error('Invalid to station name', line, 0, 6);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (/[^ S]/.test(line[6])) {
|
|
85
|
+
error('Invalid flag', line, 6, 7);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const isSurface = line[6] === 'S';
|
|
89
|
+
const fromNumber = parseUint(line, 7, 12, 'from station number');
|
|
90
|
+
if (fromNumber == null) continue;
|
|
91
|
+
const toNumber = parseUint(line, 12, 17, 'to station number');
|
|
92
|
+
if (toNumber == null) continue;
|
|
93
|
+
const easting = parseLength(line, 17, 25, 'easting', 100);
|
|
94
|
+
if (!easting) continue;
|
|
95
|
+
const northing = parseLength(line, 25, 33, 'northing', 100);
|
|
96
|
+
if (!northing) continue;
|
|
97
|
+
const elevation = parseLength(line, 33, 40, 'elevation', 100);
|
|
98
|
+
if (!elevation) continue;
|
|
99
|
+
const leftEasting = parseLength(line, 40, 46, 'left wall easting', 100);
|
|
100
|
+
if (!leftEasting) continue;
|
|
101
|
+
const leftNorthing = parseLength(line, 46, 52, 'left wall northing', 100);
|
|
102
|
+
if (!leftNorthing) continue;
|
|
103
|
+
const rightEasting = parseLength(line, 52, 58, 'right wall easting', 100);
|
|
104
|
+
if (!rightEasting) continue;
|
|
105
|
+
const rightNorthing = parseLength(line, 58, 64, 'right wall northing', 100);
|
|
106
|
+
if (!rightNorthing) continue;
|
|
107
|
+
const up = parseLength(line, 64, 68, 'up', 10);
|
|
108
|
+
if (!up) continue;
|
|
109
|
+
const down = parseLength(line, 68, 72, 'down', 10);
|
|
110
|
+
if (!down) continue;
|
|
111
|
+
const tripNumber = parseOptionalUint(line, 72, 78, 'trip number');
|
|
112
|
+
shots.push({
|
|
113
|
+
toName,
|
|
114
|
+
isSurface,
|
|
115
|
+
fromNumber,
|
|
116
|
+
toNumber,
|
|
117
|
+
easting,
|
|
118
|
+
northing,
|
|
119
|
+
elevation,
|
|
120
|
+
leftEasting,
|
|
121
|
+
leftNorthing,
|
|
122
|
+
rightEasting,
|
|
123
|
+
rightNorthing,
|
|
124
|
+
up,
|
|
125
|
+
down,
|
|
126
|
+
tripNumber
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
totalLength,
|
|
131
|
+
shots,
|
|
132
|
+
errors
|
|
133
|
+
};
|
|
267
134
|
}
|
|
268
135
|
module.exports = exports.default;
|
|
269
136
|
//# sourceMappingURL=parseFrcsPlotFile.js.map
|
package/parseFrcsPlotFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFrcsPlotFile.js","names":["_unitized","require","_parseSegment","_asyncIterator","r","n","t","o","e","Symbol","asyncIterator","iterator","call","AsyncFromSyncIterator","TypeError","AsyncFromSyncIteratorContinuation","Object","Promise","reject","done","resolve","value","then","s","next","prototype","apply","arguments","_return","_throw","parseFrcsPlotFile","_x","_x2","_parseFrcsPlotFile","_asyncToGenerator2","_regenerator","mark","_callee","file","lines","totalLength","shots","errors","lineNumber","error","parseUint","parseOptionalUint","parseLength","_iteratorAbruptCompletion","_didIteratorError","_iteratorError","_iterator","_step","line","toName","isSurface","fromNumber","toNumber","easting","northing","elevation","leftEasting","leftNorthing","rightEasting","rightNorthing","up","down","tripNumber","wrap","_callee$","_context","prev","_parseLength","startColumn","endColumn","fieldName","divisor","str","substring","test","concat","parseFloat","isNaN","Unitize","feet","_parseOptionalUint","parseInt","_parseUint","NaN","message","push","SegmentParseError","Segment","source","startLine","startCol","sent","abrupt","trim","t0","finish","stop","module","exports","default"],"sources":["src/parseFrcsPlotFile.ts"],"sourcesContent":["import { FrcsPlotShot } from './FrcsPlotShot'\nimport { FrcsPlotFile } from './FrcsPlotFile'\nimport { Length, UnitizedNumber, Unitize } from '@speleotica/unitized'\nimport { Segment, SegmentParseError } from 'parse-segment'\n\n/**\n * Parses data from a calculated survey file. These look like so:\n<pre> 123.182259\n AE20 1 1 0 0 0 153 -257 -51 85 0 20 1\n AE19 1 2 653 402 -548 1046 -587 -174 97 0 200 1\n AE18 2 3 669 449 -3002 995 94 -597 -56 250 0 1\n AE17 3 4 539 1217 -2770 497 47 -298 -28 0 0 1\n AE16 4 5 544 1230 -3441 411 -284 -246 170 60 10 1\n AE15 5 6 1679 1663 -3833 0 0 -282 283 20 10 1\n AE14 6 7 2026 2617 -3730 446 225 -446 -225 0 30 1\n AE13 7 8 391 3152 -5788 -111 691 0 0 200 50 1\n AE12 8 9 -1019 2175 -4630 -369 336 221 -201 40 40 1\n AE11 9 10 -1516 1289 -3919 -348 195 610 -342 50 10 1</pre>\n */\nexport default async function parseFrcsPlotFile(\n file: string,\n lines: AsyncIterable<string>\n): Promise<FrcsPlotFile> {\n let totalLength: UnitizedNumber<Length> = Unitize.feet(NaN)\n const shots: Array<FrcsPlotShot> = []\n const errors: Array<SegmentParseError> = []\n\n let lineNumber = 0\n\n const error = (\n message: string,\n line: string,\n startColumn: number,\n endColumn: number\n ): void => {\n errors.push(\n new SegmentParseError(\n message,\n new Segment({\n value: line,\n source: file,\n startLine: lineNumber - 1,\n startCol: 0,\n }).substring(startColumn, endColumn)\n )\n )\n }\n\n function parseUint(\n line: string,\n startColumn: number,\n endColumn: number,\n fieldName: string\n ): number | null {\n const str = line.substring(startColumn, endColumn)\n if (!/\\S/.test(str)) {\n error(`Missing ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n if (!/^\\s*\\d+\\s*$/.test(str)) {\n error(`Invalid ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n return parseInt(str)\n }\n\n function parseOptionalUint(\n line: string,\n startColumn: number,\n endColumn: number,\n fieldName: string\n ): number | null {\n const str = line.substring(startColumn, endColumn)\n if (!/\\S/.test(str)) {\n return null\n }\n if (!/^\\s*\\d+\\s*$/.test(str)) {\n error(`Invalid ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n return parseInt(str)\n }\n\n function parseLength(\n line: string,\n startColumn: number,\n endColumn: number,\n fieldName: string,\n divisor: number\n ): UnitizedNumber<Length> | null {\n const str = line.substring(startColumn, endColumn)\n if (!/^\\s*-?\\d+\\s*$/.test(str)) {\n error(`Invalid ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n const value = parseFloat(str)\n if (isNaN(value)) {\n error(`Missing ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n return Unitize.feet(value / divisor)\n }\n\n for await (const line of lines) {\n lineNumber++\n if (lineNumber === 1) {\n totalLength = Unitize.feet(parseFloat(line))\n continue\n }\n if (!/\\S/.test(line)) continue\n const toName = line.substring(0, 6).trim()\n if (!toName) {\n error('Invalid to station name', line, 0, 6)\n continue\n }\n if (/[^ S]/.test(line[6])) {\n error('Invalid flag', line, 6, 7)\n continue\n }\n const isSurface = line[6] === 'S'\n const fromNumber = parseUint(line, 7, 12, 'from station number')\n if (fromNumber == null) continue\n const toNumber = parseUint(line, 12, 17, 'to station number')\n if (toNumber == null) continue\n const easting = parseLength(line, 17, 25, 'easting', 100)\n if (!easting) continue\n const northing = parseLength(line, 25, 33, 'northing', 100)\n if (!northing) continue\n const elevation = parseLength(line, 33, 40, 'elevation', 100)\n if (!elevation) continue\n const leftEasting = parseLength(line, 40, 46, 'left wall easting', 100)\n if (!leftEasting) continue\n const leftNorthing = parseLength(line, 46, 52, 'left wall northing', 100)\n if (!leftNorthing) continue\n const rightEasting = parseLength(line, 52, 58, 'right wall easting', 100)\n if (!rightEasting) continue\n const rightNorthing = parseLength(line, 58, 64, 'right wall northing', 100)\n if (!rightNorthing) continue\n const up = parseLength(line, 64, 68, 'up', 10)\n if (!up) continue\n const down = parseLength(line, 68, 72, 'down', 10)\n if (!down) continue\n const tripNumber = parseOptionalUint(line, 72, 78, 'trip number')\n\n shots.push({\n toName,\n isSurface,\n fromNumber,\n toNumber,\n easting,\n northing,\n elevation,\n leftEasting,\n leftNorthing,\n rightEasting,\n rightNorthing,\n up,\n down,\n tripNumber,\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QAAA,CAAA6B,EAAA;QAAA;UAAA7B,QAAA,CAAAC,IAAA;UAAAD,QAAA,CAAAC,IAAA;UAAA,MAAAvB,yBAAA,IAAAG,SAAA;YAAAmB,QAAA,CAAA9C,IAAA;YAAA;UAAA;UAAA8C,QAAA,CAAA9C,IAAA;UAAA,OAAA2B,SAAA;QAAA;UAAAmB,QAAA,CAAAC,IAAA;UAAA,KAAAtB,iBAAA;YAAAqB,QAAA,CAAA9C,IAAA;YAAA;UAAA;UAAA,MAAA0B,cAAA;QAAA;UAAA,OAAAoB,QAAA,CAAA8B,MAAA;QAAA;UAAA,OAAA9B,QAAA,CAAA8B,MAAA;QAAA;UAAA,OAAA9B,QAAA,CAAA2B,MAAA,WAGG;YACLzD,WAAW,EAAXA,WAAW;YACXC,KAAK,EAALA,KAAK;YACLC,MAAM,EAANA;UACF,CAAC;QAAA;QAAA;UAAA,OAAA4B,QAAA,CAAA+B,IAAA;MAAA;IAAA,GAAAhE,OAAA;EAAA,CACF;EAAA,OAAAJ,kBAAA,CAAAP,KAAA,OAAAC,SAAA;AAAA;AAAA2E,MAAA,CAAAC,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"parseFrcsPlotFile.js","names":["_unitized","require","_parseSegment","parseFrcsPlotFile","file","lines","totalLength","Unitize","feet","NaN","shots","errors","lineNumber","error","message","line","startColumn","endColumn","push","SegmentParseError","Segment","value","source","startLine","startCol","substring","parseUint","fieldName","str","test","parseInt","parseOptionalUint","parseLength","divisor","parseFloat","isNaN","toName","trim","isSurface","fromNumber","toNumber","easting","northing","elevation","leftEasting","leftNorthing","rightEasting","rightNorthing","up","down","tripNumber","module","exports","default"],"sources":["src/parseFrcsPlotFile.ts"],"sourcesContent":["import { FrcsPlotShot } from './FrcsPlotShot'\nimport { FrcsPlotFile } from './FrcsPlotFile'\nimport { Length, UnitizedNumber, Unitize } from '@speleotica/unitized'\nimport { Segment, SegmentParseError } from 'parse-segment'\n\n/**\n * Parses data from a calculated survey file. These look like so:\n<pre> 123.182259\n AE20 1 1 0 0 0 153 -257 -51 85 0 20 1\n AE19 1 2 653 402 -548 1046 -587 -174 97 0 200 1\n AE18 2 3 669 449 -3002 995 94 -597 -56 250 0 1\n AE17 3 4 539 1217 -2770 497 47 -298 -28 0 0 1\n AE16 4 5 544 1230 -3441 411 -284 -246 170 60 10 1\n AE15 5 6 1679 1663 -3833 0 0 -282 283 20 10 1\n AE14 6 7 2026 2617 -3730 446 225 -446 -225 0 30 1\n AE13 7 8 391 3152 -5788 -111 691 0 0 200 50 1\n AE12 8 9 -1019 2175 -4630 -369 336 221 -201 40 40 1\n AE11 9 10 -1516 1289 -3919 -348 195 610 -342 50 10 1</pre>\n */\nexport default async function parseFrcsPlotFile(\n file: string,\n lines: AsyncIterable<string>\n): Promise<FrcsPlotFile> {\n let totalLength: UnitizedNumber<Length> = Unitize.feet(NaN)\n const shots: Array<FrcsPlotShot> = []\n const errors: Array<SegmentParseError> = []\n\n let lineNumber = 0\n\n const error = (\n message: string,\n line: string,\n startColumn: number,\n endColumn: number\n ): void => {\n errors.push(\n new SegmentParseError(\n message,\n new Segment({\n value: line,\n source: file,\n startLine: lineNumber - 1,\n startCol: 0,\n }).substring(startColumn, endColumn)\n )\n )\n }\n\n function parseUint(\n line: string,\n startColumn: number,\n endColumn: number,\n fieldName: string\n ): number | null {\n const str = line.substring(startColumn, endColumn)\n if (!/\\S/.test(str)) {\n error(`Missing ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n if (!/^\\s*\\d+\\s*$/.test(str)) {\n error(`Invalid ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n return parseInt(str)\n }\n\n function parseOptionalUint(\n line: string,\n startColumn: number,\n endColumn: number,\n fieldName: string\n ): number | null {\n const str = line.substring(startColumn, endColumn)\n if (!/\\S/.test(str)) {\n return null\n }\n if (!/^\\s*\\d+\\s*$/.test(str)) {\n error(`Invalid ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n return parseInt(str)\n }\n\n function parseLength(\n line: string,\n startColumn: number,\n endColumn: number,\n fieldName: string,\n divisor: number\n ): UnitizedNumber<Length> | null {\n const str = line.substring(startColumn, endColumn)\n if (!/^\\s*-?\\d+\\s*$/.test(str)) {\n error(`Invalid ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n const value = parseFloat(str)\n if (isNaN(value)) {\n error(`Missing ${fieldName}`, line, startColumn, endColumn)\n return null\n }\n return Unitize.feet(value / divisor)\n }\n\n for await (const line of lines) {\n lineNumber++\n if (lineNumber === 1) {\n totalLength = Unitize.feet(parseFloat(line))\n continue\n }\n if (!/\\S/.test(line)) continue\n const toName = line.substring(0, 6).trim()\n if (!toName) {\n error('Invalid to station name', line, 0, 6)\n continue\n }\n if (/[^ S]/.test(line[6])) {\n error('Invalid flag', line, 6, 7)\n continue\n }\n const isSurface = line[6] === 'S'\n const fromNumber = parseUint(line, 7, 12, 'from station number')\n if (fromNumber == null) continue\n const toNumber = parseUint(line, 12, 17, 'to station number')\n if (toNumber == null) continue\n const easting = parseLength(line, 17, 25, 'easting', 100)\n if (!easting) continue\n const northing = parseLength(line, 25, 33, 'northing', 100)\n if (!northing) continue\n const elevation = parseLength(line, 33, 40, 'elevation', 100)\n if (!elevation) continue\n const leftEasting = parseLength(line, 40, 46, 'left wall easting', 100)\n if (!leftEasting) continue\n const leftNorthing = parseLength(line, 46, 52, 'left wall northing', 100)\n if (!leftNorthing) continue\n const rightEasting = parseLength(line, 52, 58, 'right wall easting', 100)\n if (!rightEasting) continue\n const rightNorthing = parseLength(line, 58, 64, 'right wall northing', 100)\n if (!rightNorthing) continue\n const up = parseLength(line, 64, 68, 'up', 10)\n if (!up) continue\n const down = parseLength(line, 68, 72, 'down', 10)\n if (!down) continue\n const tripNumber = parseOptionalUint(line, 72, 78, 'trip number')\n\n shots.push({\n toName,\n isSurface,\n fromNumber,\n toNumber,\n easting,\n northing,\n elevation,\n leftEasting,\n leftNorthing,\n rightEasting,\n rightNorthing,\n up,\n down,\n tripNumber,\n })\n }\n\n return {\n totalLength,\n shots,\n errors,\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,eAAeE,iBAAiBA,CAC7CC,IAAY,EACZC,KAA4B,EACL;EACvB,IAAIC,WAAmC,GAAGC,iBAAO,CAACC,IAAI,CAACC,GAAG,CAAC;EAC3D,MAAMC,KAA0B,GAAG,EAAE;EACrC,MAAMC,MAAgC,GAAG,EAAE;EAE3C,IAAIC,UAAU,GAAG,CAAC;EAElB,MAAMC,KAAK,GAAGA,CACZC,OAAe,EACfC,IAAY,EACZC,WAAmB,EACnBC,SAAiB,KACR;IACTN,MAAM,CAACO,IAAI,CACT,IAAIC,+BAAiB,CACnBL,OAAO,EACP,IAAIM,qBAAO,CAAC;MACVC,KAAK,EAAEN,IAAI;MACXO,MAAM,EAAElB,IAAI;MACZmB,SAAS,EAAEX,UAAU,GAAG,CAAC;MACzBY,QAAQ,EAAE;IACZ,CAAC,CAAC,CAACC,SAAS,CAACT,WAAW,EAAEC,SAAS,CACrC,CACF,CAAC;EACH,CAAC;EAED,SAASS,SAASA,CAChBX,IAAY,EACZC,WAAmB,EACnBC,SAAiB,EACjBU,SAAiB,EACF;IACf,MAAMC,GAAG,GAAGb,IAAI,CAACU,SAAS,CAACT,WAAW,EAAEC,SAAS,CAAC;IAClD,IAAI,CAAC,IAAI,CAACY,IAAI,CAACD,GAAG,CAAC,EAAE;MACnBf,KAAK,CAAC,WAAWc,SAAS,EAAE,EAAEZ,IAAI,EAAEC,WAAW,EAAEC,SAAS,CAAC;MAC3D,OAAO,IAAI;IACb;IACA,IAAI,CAAC,aAAa,CAACY,IAAI,CAACD,GAAG,CAAC,EAAE;MAC5Bf,KAAK,CAAC,WAAWc,SAAS,EAAE,EAAEZ,IAAI,EAAEC,WAA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C,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -13,5 +13,7 @@ import { FrcsTripSummaryFile } from './FrcsTripSummaryFile';
|
|
|
13
13
|
B6-B18 B17 SIDE B19-B38 B32 SIDE
|
|
14
14
|
BS1-BS5 C1-C18 </pre>
|
|
15
15
|
*/
|
|
16
|
-
export default function parseFrcsTripSummaryFile(file: string, lines: AsyncIterable<string
|
|
16
|
+
export default function parseFrcsTripSummaryFile(file: string, lines: AsyncIterable<string>, { indexBy, }?: {
|
|
17
|
+
indexBy?: 'tripNumber' | 'occurrence';
|
|
18
|
+
}): Promise<FrcsTripSummaryFile>;
|
|
17
19
|
//# sourceMappingURL=parseFrcsTripSummaryFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFrcsTripSummaryFile.d.ts","sourceRoot":"","sources":["src/parseFrcsTripSummaryFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAM3D;;;;;;;;;;;;;GAaG;AACH,wBAA8B,wBAAwB,CACpD,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"parseFrcsTripSummaryFile.d.ts","sourceRoot":"","sources":["src/parseFrcsTripSummaryFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAM3D;;;;;;;;;;;;;GAaG;AACH,wBAA8B,wBAAwB,CACpD,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,EAC5B,EACE,OAAsB,GACvB,GAAE;IACD,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,CAAA;CACjC,GACL,OAAO,CAAC,mBAAmB,CAAC,CAoD9B"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
|
+
exports.default = parseFrcsTripSummaryFile;
|
|
11
7
|
var _unitized = require("@speleotica/unitized");
|
|
12
|
-
|
|
13
|
-
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
|
14
|
-
var tripSummaryRegex = /^\s*(\d+)\s+(\d{1,2})\/(\s\d|\d\d)\/(\d{2,4})\s+(\d+(?:\.\d*)?)\s+(\d+)\s+(\S.*)EXCLUDED:\s*(\d+(?:\.\d{2})?)\s*(\d+)/;
|
|
8
|
+
const tripSummaryRegex = /^\s*(\d+)\s+(\d{1,2})\/(\s\d|\d\d)\/(\d{2,4})\s+(\d+(?:\.\d*)?)\s+(\d+)\s+(\S.*)EXCLUDED:\s*(\d+(?:\.\d{2})?)\s*(\d+)/;
|
|
15
9
|
/**
|
|
16
10
|
* Parses data from a STAT_sum.txt file. Here is an excerpt of the format:
|
|
17
11
|
<pre> 1 2/15/81 258.60 17 ENTRANCE DROPS, JOE'S "I LOVE MY WIFE TRAVERSE", TRICKY TRAVERSE EXCLUDED: 0.00 0
|
|
@@ -26,117 +20,57 @@ var tripSummaryRegex = /^\s*(\d+)\s+(\d{1,2})\/(\s\d|\d\d)\/(\d{2,4})\s+(\d+(?:\
|
|
|
26
20
|
B6-B18 B17 SIDE B19-B38 B32 SIDE
|
|
27
21
|
BS1-BS5 C1-C18 </pre>
|
|
28
22
|
*/
|
|
29
|
-
function parseFrcsTripSummaryFile(
|
|
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
|
-
totalLength: totalLength,
|
|
81
|
-
numShots: numShots,
|
|
82
|
-
name: name,
|
|
83
|
-
excludedLength: excludedLength,
|
|
84
|
-
numExcludedShots: numExcludedShots,
|
|
85
|
-
team: team,
|
|
86
|
-
shots: shots
|
|
87
|
-
};
|
|
88
|
-
return _context.abrupt("continue", 33);
|
|
89
|
-
case 32:
|
|
90
|
-
if (lineNumber === tripStartLine + 1) {
|
|
91
|
-
(_team = team).push.apply(_team, (0, _toConsumableArray2["default"])(line.trim().split(/\s\s+|\t+/g)));
|
|
92
|
-
} else {
|
|
93
|
-
trimmed = line.trim();
|
|
94
|
-
if (trimmed) (_shots = shots).push.apply(_shots, (0, _toConsumableArray2["default"])(trimmed.split(/\s\s+|\t+/)));
|
|
95
|
-
}
|
|
96
|
-
case 33:
|
|
97
|
-
_iteratorAbruptCompletion = false;
|
|
98
|
-
_context.next = 10;
|
|
99
|
-
break;
|
|
100
|
-
case 36:
|
|
101
|
-
_context.next = 42;
|
|
102
|
-
break;
|
|
103
|
-
case 38:
|
|
104
|
-
_context.prev = 38;
|
|
105
|
-
_context.t0 = _context["catch"](8);
|
|
106
|
-
_didIteratorError = true;
|
|
107
|
-
_iteratorError = _context.t0;
|
|
108
|
-
case 42:
|
|
109
|
-
_context.prev = 42;
|
|
110
|
-
_context.prev = 43;
|
|
111
|
-
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
112
|
-
_context.next = 47;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
_context.next = 47;
|
|
116
|
-
return _iterator["return"]();
|
|
117
|
-
case 47:
|
|
118
|
-
_context.prev = 47;
|
|
119
|
-
if (!_didIteratorError) {
|
|
120
|
-
_context.next = 50;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
throw _iteratorError;
|
|
124
|
-
case 50:
|
|
125
|
-
return _context.finish(47);
|
|
126
|
-
case 51:
|
|
127
|
-
return _context.finish(42);
|
|
128
|
-
case 52:
|
|
129
|
-
return _context.abrupt("return", {
|
|
130
|
-
errors: errors,
|
|
131
|
-
tripSummaries: tripSummaries
|
|
132
|
-
});
|
|
133
|
-
case 53:
|
|
134
|
-
case "end":
|
|
135
|
-
return _context.stop();
|
|
136
|
-
}
|
|
137
|
-
}, _callee, null, [[8, 38, 42, 52], [43,, 47, 51]]);
|
|
138
|
-
}));
|
|
139
|
-
return _parseFrcsTripSummaryFile.apply(this, arguments);
|
|
23
|
+
async function parseFrcsTripSummaryFile(file, lines, {
|
|
24
|
+
indexBy = 'tripNumber'
|
|
25
|
+
} = {}) {
|
|
26
|
+
const errors = [];
|
|
27
|
+
const tripSummaries = [];
|
|
28
|
+
let tripStartLine = -2;
|
|
29
|
+
let lineNumber = 0;
|
|
30
|
+
let team = [];
|
|
31
|
+
let shots = [];
|
|
32
|
+
for await (const line of lines) {
|
|
33
|
+
lineNumber++;
|
|
34
|
+
const match = tripSummaryRegex.exec(line);
|
|
35
|
+
if (match) {
|
|
36
|
+
tripStartLine = lineNumber;
|
|
37
|
+
const tripNumber = parseInt(match[1]);
|
|
38
|
+
const tripIndex = indexBy === 'tripNumber' ? tripNumber - 1 : tripSummaries.length;
|
|
39
|
+
let year = parseInt(match[4]);
|
|
40
|
+
if (year < 1000) year += 1900;
|
|
41
|
+
const date = new Date(year, parseInt(match[2]) - 1, parseInt(match[3]));
|
|
42
|
+
const totalLength = _unitized.Unitize.feet(parseFloat(match[5]));
|
|
43
|
+
const numShots = parseInt(match[6]);
|
|
44
|
+
const name = match[7].trim();
|
|
45
|
+
const excludedLength = _unitized.Unitize.feet(parseFloat(match[8]));
|
|
46
|
+
const numExcludedShots = parseInt(match[9]);
|
|
47
|
+
team = [];
|
|
48
|
+
shots = [];
|
|
49
|
+
tripSummaries[tripIndex] = {
|
|
50
|
+
tripNumber,
|
|
51
|
+
tripIndex,
|
|
52
|
+
date,
|
|
53
|
+
totalLength,
|
|
54
|
+
numShots,
|
|
55
|
+
name,
|
|
56
|
+
excludedLength,
|
|
57
|
+
numExcludedShots,
|
|
58
|
+
team,
|
|
59
|
+
shots
|
|
60
|
+
};
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (lineNumber === tripStartLine + 1) {
|
|
64
|
+
team.push(...line.trim().split(/\s\s+|\t+/g));
|
|
65
|
+
} else {
|
|
66
|
+
const trimmed = line.trim();
|
|
67
|
+
if (trimmed) shots.push(...trimmed.split(/\s\s+|\t+/));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
errors,
|
|
72
|
+
tripSummaries
|
|
73
|
+
};
|
|
140
74
|
}
|
|
141
75
|
module.exports = exports.default;
|
|
142
76
|
//# sourceMappingURL=parseFrcsTripSummaryFile.js.map
|