@speleotica/frcsdata 5.0.0-beta.1 → 5.0.0-beta.3
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.js +4 -4
- package/ParseIssue.js.map +1 -1
- package/SourceLoc.js +5 -5
- package/SourceLoc.js.map +1 -1
- package/chunksToLines.js +29 -131
- package/chunksToLines.js.map +1 -1
- 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.map +1 -1
- package/cli/check-survey.js +14 -75
- package/cli/check-survey.js.map +1 -1
- package/cli/parse-survey.js +4 -26
- package/cli/parse-survey.js.map +1 -1
- 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.js +61 -72
- package/cli.js.map +1 -1
- 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.js +13 -13
- package/node/index.d.ts +3 -1
- package/node/index.d.ts.map +1 -1
- package/node/index.js +5 -19
- package/node/index.js.map +1 -1
- package/package.json +1 -1
- 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/cli/check-survey-correspondence.ts +49 -0
- package/src/cli/check-survey.ts +8 -69
- package/src/cli/summarize-survey.ts +28 -0
- package/src/cli.ts +33 -0
- package/src/formatFrcsTripSummaryFile.ts +45 -0
- package/src/formatIssues.ts +97 -0
- package/src/parseFrcsTripSummaryFile.ts +8 -2
- package/src/survey/FrcsSurveyFile.ts +3 -1
- package/src/survey/ZodFrcsSurveyFileJson.ts +15 -4
- package/src/survey/ZodFrcsSurveyFileToJson.ts +15 -4
- package/src/survey/normalizeTeamMemberName.ts +3 -6
- package/src/survey/parseFrcsSurveyFile.ts +9 -25
- package/src/survey/summarizeSurvey.ts +51 -0
- package/src/unwrapInvalid.ts +3 -0
- package/string/index.d.ts +3 -1
- package/string/index.d.ts.map +1 -1
- package/string/index.js +7 -41
- package/string/index.js.map +1 -1
- package/survey/FrcsSurveyFile.d.ts +1 -1
- package/survey/FrcsSurveyFile.d.ts.map +1 -1
- package/survey/FrcsSurveyFile.js +1 -1
- package/survey/FrcsSurveyFile.js.map +1 -1
- package/survey/ZodFrcsSurveyFileJson.d.ts +13083 -457
- package/survey/ZodFrcsSurveyFileJson.d.ts.map +1 -1
- package/survey/ZodFrcsSurveyFileJson.js +89 -87
- package/survey/ZodFrcsSurveyFileJson.js.map +1 -1
- package/survey/ZodFrcsSurveyFileToJson.d.ts +12860 -234
- package/survey/ZodFrcsSurveyFileToJson.d.ts.map +1 -1
- package/survey/ZodFrcsSurveyFileToJson.js +83 -89
- package/survey/ZodFrcsSurveyFileToJson.js.map +1 -1
- package/survey/formatFrcsShot.js +45 -43
- package/survey/formatFrcsShot.js.map +1 -1
- package/survey/formatFrcsSurveyFile.js +52 -130
- package/survey/formatFrcsSurveyFile.js.map +1 -1
- package/survey/getColumnRanges.js +11 -19
- package/survey/getColumnRanges.js.map +1 -1
- package/survey/normalizeTeamMemberName.d.ts.map +1 -1
- package/survey/normalizeTeamMemberName.js +1 -5
- package/survey/normalizeTeamMemberName.js.map +1 -1
- package/survey/parseFrcsSurveyFile.d.ts.map +1 -1
- package/survey/parseFrcsSurveyFile.js +560 -750
- package/survey/parseFrcsSurveyFile.js.map +1 -1
- package/survey/parsers.js +20 -20
- package/survey/parsers.js.map +1 -1
- 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/underlineSource.js +9 -17
- package/underlineSource.js.map +1 -1
- 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.js +56 -116
- package/web/index.js.map +1 -1
|
@@ -1,15 +1,9 @@
|
|
|
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
|
+
exports.default = parseFrcsSurveyFile;
|
|
13
7
|
var _FrcsSurveyFile = require("./FrcsSurveyFile.js");
|
|
14
8
|
var _unitized = require("@speleotica/unitized");
|
|
15
9
|
var _chunksToLines = require("../chunksToLines.js");
|
|
@@ -17,10 +11,7 @@ var _validators = require("./validators.js");
|
|
|
17
11
|
var _getColumnRanges = require("./getColumnRanges.js");
|
|
18
12
|
var _parsers = require("./parsers.js");
|
|
19
13
|
var _normalizeTeamMemberName = require("./normalizeTeamMemberName.js");
|
|
20
|
-
|
|
21
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
-
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"); }
|
|
23
|
-
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 _unwrapInvalid = require("../unwrapInvalid.js");
|
|
24
15
|
/**
|
|
25
16
|
* Parses a raw cdata.fr survey file. These look like so:
|
|
26
17
|
*
|
|
@@ -66,753 +57,572 @@ function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r
|
|
|
66
57
|
...</pre>
|
|
67
58
|
*
|
|
68
59
|
*/
|
|
69
|
-
function parseFrcsSurveyFile(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
async function parseFrcsSurveyFile(file,
|
|
61
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
62
|
+
chunks, {
|
|
63
|
+
columns = _FrcsSurveyFile.defaultFrcsShotColumnConfig,
|
|
64
|
+
outputColumns = false,
|
|
65
|
+
normalizeNames = true,
|
|
66
|
+
suppressWarnings
|
|
67
|
+
} = {}) {
|
|
68
|
+
const columnRanges = (0, _getColumnRanges.getColumnRanges)(columns);
|
|
69
|
+
const maxRange = Math.max(...Object.values(columnRanges.decimal).map(r => r[1]));
|
|
70
|
+
let cave = undefined;
|
|
71
|
+
let location = undefined;
|
|
72
|
+
const trips = [];
|
|
73
|
+
const issues = [];
|
|
74
|
+
let tripName;
|
|
75
|
+
let tripTeam;
|
|
76
|
+
let tripDate;
|
|
77
|
+
let inTripComment = true;
|
|
78
|
+
let tripCommentStartLine = 1;
|
|
79
|
+
let tripCommentEndLine = -1;
|
|
80
|
+
const tripComment = [];
|
|
81
|
+
const commentLines = [];
|
|
82
|
+
let trip = undefined;
|
|
83
|
+
let inBlockComment = false;
|
|
84
|
+
let section;
|
|
85
|
+
const commentFromStationLruds = new Map();
|
|
86
|
+
let unitsChanged = false;
|
|
87
|
+
let alternateUnits;
|
|
88
|
+
let nextShotUnits;
|
|
89
|
+
let lineNumber = 0;
|
|
90
|
+
let line;
|
|
91
|
+
let lineStartIndex = 0;
|
|
92
|
+
let lineIssues = [];
|
|
93
|
+
let tripIssues = [];
|
|
94
|
+
let began = false;
|
|
95
|
+
for await ({
|
|
96
|
+
line,
|
|
97
|
+
startIndex: lineStartIndex
|
|
98
|
+
} of (0, _chunksToLines.chunksToLines)(chunks)) {
|
|
99
|
+
if (lineIssues.length) lineIssues = [];
|
|
100
|
+
lineNumber++;
|
|
101
|
+
if (!began) {
|
|
102
|
+
began = true;
|
|
103
|
+
if (/^\s+\*/.test(line)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const match = /^\s*([^,]+)(,(.*))?/.exec(line);
|
|
107
|
+
if (match) {
|
|
108
|
+
cave = match[1].trim();
|
|
109
|
+
if (match[3]) {
|
|
110
|
+
location = match[3].trim();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (unitsChanged) {
|
|
115
|
+
unitsChanged = false;
|
|
116
|
+
alternateUnits = parseUnits();
|
|
117
|
+
nextShotUnits = alternateUnits;
|
|
118
|
+
} else if (/^\s{1,8}\*(?!\*)/.test(line)) {
|
|
119
|
+
inTripComment = !inTripComment;
|
|
120
|
+
alternateUnits = nextShotUnits = undefined;
|
|
121
|
+
unitsChanged = false;
|
|
122
|
+
if (inTripComment) {
|
|
123
|
+
section = undefined;
|
|
124
|
+
tripTeam = undefined;
|
|
125
|
+
tripDate = undefined;
|
|
126
|
+
tripComment.length = 0;
|
|
127
|
+
tripCommentStartLine = lineNumber;
|
|
128
|
+
} else {
|
|
129
|
+
tripCommentEndLine = lineNumber;
|
|
130
|
+
}
|
|
131
|
+
} else if (inTripComment) {
|
|
132
|
+
if (lineNumber === tripCommentStartLine + 1) {
|
|
133
|
+
tripName = line && line.trim();
|
|
134
|
+
} else if (lineNumber === tripCommentStartLine + 2) {
|
|
135
|
+
const dateMatch = /(?:[-.]\s*)?((\d+)[-/](\d+)[-/](\d{2,4})|((\d+)[-/ ](january|february|march|april|may|june|july|august|september|october|november|december|(?:jan|feb|mar|apr|jun|jul|aug|sept?|oct|nov|dec)\.?)[-/ ](\d{2,4}))|((january|february|march|april|may|june|july|august|september|october|november|december|(?:jan|feb|mar|apr|jun|jul|aug|sept?|oct|nov|dec)\.?)\s+(\d+)(?:,\s*|,?\s+)(\d{2,4})))/i.exec(line);
|
|
136
|
+
if (dateMatch) {
|
|
137
|
+
const team = line.substring(0, dateMatch.index);
|
|
138
|
+
tripTeam = team.split(team.indexOf(';') >= 0 ? ';' : ',').flatMap(member => member.trim() || []);
|
|
139
|
+
if (!tripTeam.length) {
|
|
140
|
+
addIssue('warning', 'missingTripTeam', 'Missing team', 0, dateMatch.index, tripIssues);
|
|
141
|
+
}
|
|
142
|
+
if (normalizeNames) tripTeam = tripTeam.map(_normalizeTeamMemberName.normalizeTeamMemberName);
|
|
143
|
+
let month, day, year;
|
|
144
|
+
if (dateMatch[2]) {
|
|
145
|
+
month = parseInt(dateMatch[2]);
|
|
146
|
+
day = parseInt(dateMatch[3]);
|
|
147
|
+
year = parseInt(dateMatch[4]);
|
|
148
|
+
} else if (dateMatch[6]) {
|
|
149
|
+
day = parseInt(dateMatch[6]);
|
|
150
|
+
month = (0, _parsers.parseMonth)(dateMatch[7]);
|
|
151
|
+
year = parseInt(dateMatch[8]);
|
|
152
|
+
} else {
|
|
153
|
+
month = (0, _parsers.parseMonth)(dateMatch[10]);
|
|
154
|
+
day = parseInt(dateMatch[11]);
|
|
155
|
+
year = parseInt(dateMatch[12]);
|
|
156
|
+
}
|
|
157
|
+
tripDate = new Date(year < 60 ? year + 2000 : year, month - 1, day);
|
|
158
|
+
} else {
|
|
159
|
+
addIssue('warning', 'missingTripDate', 'Missing date', line.length, line.length, tripIssues);
|
|
160
|
+
}
|
|
161
|
+
} else if (lineNumber > 1) {
|
|
162
|
+
tripComment.push(line);
|
|
163
|
+
}
|
|
164
|
+
const match = /^\*\*\*([^*]+)\*\*\*/.exec(line);
|
|
165
|
+
if (match) {
|
|
166
|
+
section = match[1].trim();
|
|
167
|
+
}
|
|
168
|
+
} else if (/^(\s{9,}|)\*(?!\*)/.test(line)) {
|
|
169
|
+
if (/^\*\s*%NC(\b|$)/.test(line)) {
|
|
170
|
+
unitsChanged = true;
|
|
171
|
+
}
|
|
172
|
+
if (/^\*\s*%/.test(line)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (/[^\s*]/.test(line)) {
|
|
176
|
+
addCommentLine(line.replace(/^\s*\*/, ''));
|
|
177
|
+
inBlockComment = false;
|
|
178
|
+
} else {
|
|
179
|
+
inBlockComment = !inBlockComment;
|
|
180
|
+
if (inBlockComment) commentLines.length = 0;
|
|
181
|
+
}
|
|
182
|
+
} else if (inBlockComment) {
|
|
183
|
+
addCommentLine(line);
|
|
184
|
+
} else if (lineNumber === tripCommentEndLine + 1) {
|
|
185
|
+
if (trip) trips.push(trip);
|
|
186
|
+
const header = {
|
|
187
|
+
name: tripName || '',
|
|
188
|
+
comment: tripComment && tripComment.join('\n') || undefined,
|
|
189
|
+
section,
|
|
190
|
+
date: tripDate,
|
|
191
|
+
team: tripTeam
|
|
192
|
+
};
|
|
193
|
+
const units = parseUnits();
|
|
194
|
+
if ('INVALID' in units || tripIssues.some(i => issues[i]?.type === 'error')) {
|
|
195
|
+
trip = {
|
|
196
|
+
INVALID: {
|
|
197
|
+
header,
|
|
198
|
+
units,
|
|
199
|
+
shots: []
|
|
200
|
+
},
|
|
201
|
+
...(tripIssues.length ? {
|
|
202
|
+
issues: tripIssues
|
|
203
|
+
} : {})
|
|
204
|
+
};
|
|
205
|
+
} else {
|
|
206
|
+
trip = {
|
|
207
|
+
tripNumber: 1,
|
|
208
|
+
header,
|
|
209
|
+
units,
|
|
210
|
+
shots: []
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
tripIssues = [];
|
|
214
|
+
} else if (trip) {
|
|
215
|
+
let distanceUnit = (0, _unwrapInvalid.unwrapInvalid)(alternateUnits)?.distanceUnit || (0, _unwrapInvalid.unwrapInvalid)((0, _unwrapInvalid.unwrapInvalid)(trip).units).distanceUnit || _unitized.Length.feet;
|
|
216
|
+
const azimuthUnit = (0, _unwrapInvalid.unwrapInvalid)(alternateUnits)?.azimuthUnit || (0, _unwrapInvalid.unwrapInvalid)((0, _unwrapInvalid.unwrapInvalid)(trip).units).azimuthUnit || _unitized.Angle.degrees;
|
|
217
|
+
const inclinationUnit = (0, _unwrapInvalid.unwrapInvalid)(alternateUnits)?.inclinationUnit || (0, _unwrapInvalid.unwrapInvalid)((0, _unwrapInvalid.unwrapInvalid)(trip).units).inclinationUnit || _unitized.Angle.degrees;
|
|
218
|
+
const inches = distanceUnit === _unitized.Length.inches;
|
|
219
|
+
if (inches) distanceUnit = _unitized.Length.feet;
|
|
220
|
+
const ranges = inches ? columnRanges.feetAndInches : columnRanges.decimal;
|
|
221
|
+
|
|
222
|
+
// from station name
|
|
223
|
+
if (!/\S/.test(line.substring(...ranges.fromStation))) continue;
|
|
224
|
+
const fromStr = validate(...ranges.fromStation, 'from station', _validators.isValidStation);
|
|
225
|
+
const from = fromStr.trim();
|
|
226
|
+
|
|
227
|
+
// Sadly I have found negative LRUD values in Chip's format and apparently
|
|
228
|
+
// his program doesn't fail on them, so I have to accept them here
|
|
229
|
+
// isValidOptFloat instead of isValidOptUFloat
|
|
230
|
+
const lStr = validate(...ranges.left, 'left', _validators.isValidOptFloat);
|
|
231
|
+
const rStr = validate(...ranges.right, 'right', _validators.isValidOptFloat);
|
|
232
|
+
const uStr = validate(...ranges.up, 'up', _validators.isValidOptFloat);
|
|
233
|
+
const dStr = validate(...ranges.down, 'down', _validators.isValidOptFloat);
|
|
234
|
+
const up = (0, _parsers.parseLrud)(uStr, distanceUnit);
|
|
235
|
+
const down = (0, _parsers.parseLrud)(dStr, distanceUnit);
|
|
236
|
+
const left = (0, _parsers.parseLrud)(lStr, distanceUnit);
|
|
237
|
+
const right = (0, _parsers.parseLrud)(rStr, distanceUnit);
|
|
238
|
+
|
|
239
|
+
// to station name
|
|
240
|
+
const toStr = line.substring(...ranges.toStation);
|
|
241
|
+
if (!toStr.trim()) {
|
|
242
|
+
const shot = {
|
|
243
|
+
from,
|
|
244
|
+
to: undefined,
|
|
245
|
+
distance: new _unitized.UnitizedNumber(0, distanceUnit),
|
|
246
|
+
frontsightAzimuth: undefined,
|
|
247
|
+
backsightAzimuth: undefined,
|
|
248
|
+
frontsightInclination: undefined,
|
|
249
|
+
backsightInclination: undefined,
|
|
250
|
+
fromLruds: {
|
|
251
|
+
left,
|
|
252
|
+
right,
|
|
253
|
+
up,
|
|
254
|
+
down
|
|
255
|
+
},
|
|
256
|
+
excludeDistance: true,
|
|
257
|
+
comment: getComment()
|
|
258
|
+
};
|
|
259
|
+
addShot(lineIssues.length ? {
|
|
260
|
+
INVALID: shot,
|
|
261
|
+
issues: lineIssues
|
|
262
|
+
} : shot);
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (!(0, _validators.isValidStation)(toStr)) {
|
|
266
|
+
addIssue('error', 'invalidStationName', 'Invalid station name', ...ranges.toStation);
|
|
267
|
+
}
|
|
268
|
+
let fromLruds = commentFromStationLruds.get(from);
|
|
269
|
+
if (fromLruds) {
|
|
270
|
+
commentFromStationLruds.delete(from);
|
|
271
|
+
} else {
|
|
272
|
+
const fromLrudMatch = new RegExp(`^\\s+${fromStr.trim().replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}((\\s+(\\d+(\\.\\d*)?|\\.\\d+)){4})`).exec(line.substring(maxRange));
|
|
273
|
+
if (fromLrudMatch) {
|
|
274
|
+
const [left, right, up, down] = fromLrudMatch[1].trim().split(/\s+/g).map(s => (0, _parsers.parseLrud)(s, distanceUnit));
|
|
275
|
+
fromLruds = {
|
|
276
|
+
left,
|
|
277
|
+
right,
|
|
278
|
+
up,
|
|
279
|
+
down
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const comment = getComment();
|
|
284
|
+
|
|
285
|
+
// azimuth and inclination
|
|
286
|
+
const azmFsStr = validate(ranges.frontsightAzimuth[0], ranges.frontsightAzimuth[1], 'azimuth', _validators.isValidOptUFloat);
|
|
287
|
+
const azmBsStr = validate(...ranges.backsightAzimuth, 'azimuth', _validators.isValidOptUFloat);
|
|
288
|
+
const incFsStr = line.substring(...ranges.frontsightInclination);
|
|
289
|
+
const incBsStr = line.substring(...ranges.backsightInclination);
|
|
290
|
+
let distance;
|
|
291
|
+
let horizontalDistance;
|
|
292
|
+
let verticalDistance;
|
|
293
|
+
let frontsightInclination;
|
|
294
|
+
let backsightInclination;
|
|
295
|
+
|
|
296
|
+
// parse distance
|
|
297
|
+
if (inches) {
|
|
298
|
+
const feetStr = validate(...ranges.distanceFeet, 'feet', _validators.isValidOptUFloat);
|
|
299
|
+
const inchesStr = validate(...ranges.distanceInches, 'inches', _validators.isValidOptUFloat);
|
|
300
|
+
if (!/\S/.test(feetStr) && !/\S/.test(inchesStr)) {
|
|
301
|
+
addIssue('error', 'missingDistance', 'Missing distance', ranges.distanceFeet[0], ranges.distanceInches[1]);
|
|
302
|
+
}
|
|
303
|
+
// sometimes inches are omitted, hence the || 0...I'm assuming it's possible
|
|
304
|
+
// for feet to be omitted as well
|
|
305
|
+
else if ((0, _validators.isValidUInt)(feetStr) && (0, _validators.isValidOptUFloat)(inchesStr) || (0, _validators.isValidOptUFloat)(feetStr) && (0, _validators.isValidUInt)(inchesStr)) {
|
|
306
|
+
distance = _unitized.Unitize.inches(parseFloat(inchesStr) || 0).add(_unitized.Unitize.feet(parseFloat(feetStr) || 0));
|
|
307
|
+
}
|
|
308
|
+
// NOTE there are two columns around here that can contain a *.
|
|
309
|
+
// I think they might represent different values, but thisis confused by
|
|
310
|
+
// the fact that for ft/in shots, if there is a D or H flag it occupies the
|
|
311
|
+
// first column that can contain a * for decimal feet shots
|
|
312
|
+
} else {
|
|
313
|
+
const distStr = validate(...ranges.distance, 'distance', _validators.isValidUFloat);
|
|
314
|
+
const distNum = parseFloat(distStr);
|
|
315
|
+
distance = Number.isFinite(distNum) ? new _unitized.UnitizedNumber(distNum, distanceUnit) : undefined;
|
|
316
|
+
}
|
|
317
|
+
const specialKindStr = line.substring(...ranges.kind).trim();
|
|
318
|
+
const exclude = line.substring(...ranges.exclude).trim();
|
|
319
|
+
const specialKind = (0, _parsers.parseSpecialKind)(specialKindStr);
|
|
320
|
+
if (specialKindStr && !specialKind) {
|
|
321
|
+
addIssue('error', 'invalidShotType', 'Invalid shot type', ranges.kind[0], ranges.kind[1]);
|
|
322
|
+
}
|
|
323
|
+
const excludeDistance = exclude === '*' || exclude === 's';
|
|
324
|
+
const isSplay = exclude === 's';
|
|
325
|
+
if (exclude && !excludeDistance) {
|
|
326
|
+
addIssue('error', 'invalidShotFlag', 'Invalid shot flag', ranges.exclude[0], ranges.exclude[1]);
|
|
327
|
+
}
|
|
328
|
+
if (specialKind) {
|
|
329
|
+
validate(...ranges.frontsightInclination, 'vertical-distance', _validators.isValidFloat);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// convert horizontal and diagonal shots to standard
|
|
333
|
+
// in this case incFs is the vertical offset between stations
|
|
334
|
+
// fortunately it appears we can always count on incFs being specified
|
|
335
|
+
// and incBs not being specified for these types of shots
|
|
336
|
+
if (specialKind === 'horizontal') {
|
|
337
|
+
// distance is horizontal offset and incFsStr is vertical offset
|
|
338
|
+
horizontalDistance = distance;
|
|
339
|
+
const h = horizontalDistance?.get(distanceUnit) ?? NaN;
|
|
340
|
+
const v = parseFloat(incFsStr);
|
|
341
|
+
verticalDistance = Number.isFinite(v) ? new _unitized.UnitizedNumber(v, distanceUnit) : undefined;
|
|
342
|
+
distance = new _unitized.UnitizedNumber(Math.sqrt(h * h + v * v), distanceUnit);
|
|
343
|
+
frontsightInclination = verticalDistance && horizontalDistance ? _unitized.Angle.atan2(verticalDistance, horizontalDistance).in(inclinationUnit) : undefined;
|
|
344
|
+
backsightInclination = undefined;
|
|
345
|
+
} else if (specialKind === 'diagonal') {
|
|
346
|
+
// distance is as usual, but incFsStr is vertical offset
|
|
347
|
+
const d = distance?.get(distanceUnit) ?? NaN;
|
|
348
|
+
const v = parseFloat(incFsStr);
|
|
349
|
+
verticalDistance = Number.isFinite(v) ? new _unitized.UnitizedNumber(v, distanceUnit) : undefined;
|
|
350
|
+
frontsightInclination = _unitized.Angle.asin(v / d).in(inclinationUnit);
|
|
351
|
+
backsightInclination = undefined;
|
|
352
|
+
} else {
|
|
353
|
+
// frontsight inclination
|
|
354
|
+
validate(...ranges.frontsightInclination, 'inclination', _validators.isValidOptFloat);
|
|
355
|
+
// backsight inclination
|
|
356
|
+
validate(...ranges.backsightInclination, 'inclination', _validators.isValidOptFloat);
|
|
357
|
+
frontsightInclination = (0, _parsers.parseNumber)(incFsStr, inclinationUnit);
|
|
358
|
+
backsightInclination = (0, _parsers.parseNumber)(incBsStr, inclinationUnit);
|
|
359
|
+
}
|
|
360
|
+
const frontsightAzimuth = (0, _parsers.parseAzimuth)(azmFsStr, azimuthUnit);
|
|
361
|
+
const backsightAzimuth = (0, _parsers.parseAzimuth)(azmBsStr, azimuthUnit);
|
|
362
|
+
if (!/\S/.test(incFsStr) && !/\S/.test(incBsStr)) {
|
|
363
|
+
frontsightInclination = _unitized.Unitize.degrees(0);
|
|
364
|
+
}
|
|
365
|
+
if (from && distance && !lineIssues.length) {
|
|
366
|
+
const shot = {
|
|
367
|
+
from,
|
|
368
|
+
to: toStr.trim(),
|
|
369
|
+
specialKind,
|
|
370
|
+
distance,
|
|
371
|
+
frontsightAzimuth,
|
|
372
|
+
backsightAzimuth,
|
|
373
|
+
frontsightInclination,
|
|
374
|
+
backsightInclination,
|
|
375
|
+
toLruds: {
|
|
376
|
+
left,
|
|
377
|
+
right,
|
|
378
|
+
up,
|
|
379
|
+
down
|
|
380
|
+
},
|
|
381
|
+
excludeDistance,
|
|
382
|
+
comment
|
|
383
|
+
};
|
|
384
|
+
if (isSplay) shot.isSplay = true;
|
|
385
|
+
if (fromLruds) shot.fromLruds = fromLruds;
|
|
386
|
+
if (horizontalDistance) shot.horizontalDistance = horizontalDistance;
|
|
387
|
+
if (verticalDistance) shot.verticalDistance = verticalDistance;
|
|
388
|
+
addShot(shot);
|
|
389
|
+
} else {
|
|
390
|
+
const shot = {
|
|
391
|
+
from,
|
|
392
|
+
to: toStr.trim(),
|
|
393
|
+
specialKind,
|
|
394
|
+
distance,
|
|
395
|
+
frontsightAzimuth,
|
|
396
|
+
backsightAzimuth,
|
|
397
|
+
frontsightInclination,
|
|
398
|
+
backsightInclination,
|
|
399
|
+
toLruds: {
|
|
400
|
+
left,
|
|
401
|
+
right,
|
|
402
|
+
up,
|
|
403
|
+
down
|
|
404
|
+
},
|
|
405
|
+
excludeDistance,
|
|
406
|
+
comment
|
|
407
|
+
};
|
|
408
|
+
if (isSplay) shot.isSplay = true;
|
|
409
|
+
if (fromLruds) shot.fromLruds = fromLruds;
|
|
410
|
+
if (horizontalDistance) shot.horizontalDistance = horizontalDistance;
|
|
411
|
+
if (verticalDistance) shot.verticalDistance = verticalDistance;
|
|
412
|
+
addShot({
|
|
413
|
+
INVALID: shot,
|
|
414
|
+
issues: lineIssues
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (trip) trips.push(trip);
|
|
420
|
+
trips.forEach((trip, index) => (0, _unwrapInvalid.unwrapInvalid)(trip).tripNumber = index + 1);
|
|
421
|
+
if (!issues.some(i => i.type === 'error') && trips.every(t => !('INVALID' in t))) {
|
|
422
|
+
return {
|
|
86
423
|
cave,
|
|
424
|
+
columns: outputColumns ? columns : undefined,
|
|
87
425
|
location,
|
|
88
426
|
trips,
|
|
89
|
-
issues
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
alternateUnits,
|
|
104
|
-
nextShotUnits,
|
|
105
|
-
lineNumber,
|
|
106
|
-
line,
|
|
107
|
-
lineStartIndex,
|
|
108
|
-
lineIssues,
|
|
109
|
-
tripIssues,
|
|
110
|
-
began,
|
|
111
|
-
_iteratorAbruptCompletion,
|
|
112
|
-
_didIteratorError,
|
|
113
|
-
_iteratorError,
|
|
114
|
-
_loop,
|
|
115
|
-
_ret,
|
|
116
|
-
_iterator,
|
|
117
|
-
_step,
|
|
118
|
-
getComment,
|
|
119
|
-
addCommentLine,
|
|
120
|
-
addIssue,
|
|
121
|
-
parseUnits,
|
|
122
|
-
validate,
|
|
123
|
-
addShot,
|
|
124
|
-
_args2 = arguments;
|
|
125
|
-
return _regenerator["default"].wrap(function _callee$(_context2) {
|
|
126
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
127
|
-
case 0:
|
|
128
|
-
addShot = function _addShot(shot) {
|
|
129
|
-
if (!trip) return;
|
|
130
|
-
if (alternateUnits) {
|
|
131
|
-
var recorded = shot;
|
|
132
|
-
if ('INVALID' in shot) {
|
|
133
|
-
shot.INVALID = _objectSpread(_objectSpread({}, shot.INVALID), {}, {
|
|
134
|
-
recorded: recorded
|
|
135
|
-
});
|
|
136
|
-
} else if ('INVALID' in recorded) {
|
|
137
|
-
shot = {
|
|
138
|
-
INVALID: _objectSpread(_objectSpread({}, shot), {}, {
|
|
139
|
-
recorded: recorded
|
|
140
|
-
})
|
|
141
|
-
};
|
|
142
|
-
} else {
|
|
143
|
-
shot = _objectSpread(_objectSpread({}, shot), {}, {
|
|
144
|
-
recorded: recorded
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (nextShotUnits) {
|
|
148
|
-
unwrapInvalid(recorded).units = nextShotUnits;
|
|
149
|
-
nextShotUnits = undefined;
|
|
150
|
-
}
|
|
151
|
-
var _unwrapInvalid5 = unwrapInvalid(unwrapInvalid(trip).units),
|
|
152
|
-
backsightAzimuthCorrected = _unwrapInvalid5.backsightAzimuthCorrected,
|
|
153
|
-
backsightInclinationCorrected = _unwrapInvalid5.backsightInclinationCorrected,
|
|
154
|
-
distanceUnit = _unwrapInvalid5.distanceUnit,
|
|
155
|
-
azimuthUnit = _unwrapInvalid5.azimuthUnit,
|
|
156
|
-
inclinationUnit = _unwrapInvalid5.inclinationUnit;
|
|
157
|
-
var unwrappedAlternateUnits = unwrapInvalid(alternateUnits);
|
|
158
|
-
var unwrappedShot = unwrapInvalid(shot);
|
|
159
|
-
{
|
|
160
|
-
var _alternateUnits = unwrappedAlternateUnits;
|
|
161
|
-
var _shot3 = unwrappedShot;
|
|
162
|
-
if (_alternateUnits.backsightAzimuthCorrected !== backsightAzimuthCorrected) {
|
|
163
|
-
_shot3.backsightAzimuth = _shot3.backsightAzimuth ? _unitized.Angle.opposite(_shot3.backsightAzimuth) : undefined;
|
|
164
|
-
}
|
|
165
|
-
if (_alternateUnits.backsightInclinationCorrected !== backsightInclinationCorrected) {
|
|
166
|
-
var _shot3$backsightIncli;
|
|
167
|
-
_shot3.backsightInclination = (_shot3$backsightIncli = _shot3.backsightInclination) === null || _shot3$backsightIncli === void 0 ? void 0 : _shot3$backsightIncli.negate();
|
|
168
|
-
}
|
|
169
|
-
if (distanceUnit && distanceUnit !== _alternateUnits.distanceUnit) {
|
|
170
|
-
var _shot3$distance;
|
|
171
|
-
_shot3.distance = (_shot3$distance = _shot3.distance) === null || _shot3$distance === void 0 ? void 0 : _shot3$distance["in"](distanceUnit);
|
|
172
|
-
if (_shot3.fromLruds) {
|
|
173
|
-
var _shot3$fromLruds$left, _shot3$fromLruds$righ, _shot3$fromLruds$up, _shot3$fromLruds$down;
|
|
174
|
-
_shot3.fromLruds.left = (_shot3$fromLruds$left = _shot3.fromLruds.left) === null || _shot3$fromLruds$left === void 0 ? void 0 : _shot3$fromLruds$left["in"](distanceUnit);
|
|
175
|
-
_shot3.fromLruds.right = (_shot3$fromLruds$righ = _shot3.fromLruds.right) === null || _shot3$fromLruds$righ === void 0 ? void 0 : _shot3$fromLruds$righ["in"](distanceUnit);
|
|
176
|
-
_shot3.fromLruds.up = (_shot3$fromLruds$up = _shot3.fromLruds.up) === null || _shot3$fromLruds$up === void 0 ? void 0 : _shot3$fromLruds$up["in"](distanceUnit);
|
|
177
|
-
_shot3.fromLruds.down = (_shot3$fromLruds$down = _shot3.fromLruds.down) === null || _shot3$fromLruds$down === void 0 ? void 0 : _shot3$fromLruds$down["in"](distanceUnit);
|
|
178
|
-
}
|
|
179
|
-
if (_shot3.toLruds) {
|
|
180
|
-
var _shot3$toLruds$left, _shot3$toLruds$right, _shot3$toLruds$up, _shot3$toLruds$down;
|
|
181
|
-
_shot3.toLruds.left = (_shot3$toLruds$left = _shot3.toLruds.left) === null || _shot3$toLruds$left === void 0 ? void 0 : _shot3$toLruds$left["in"](distanceUnit);
|
|
182
|
-
_shot3.toLruds.right = (_shot3$toLruds$right = _shot3.toLruds.right) === null || _shot3$toLruds$right === void 0 ? void 0 : _shot3$toLruds$right["in"](distanceUnit);
|
|
183
|
-
_shot3.toLruds.up = (_shot3$toLruds$up = _shot3.toLruds.up) === null || _shot3$toLruds$up === void 0 ? void 0 : _shot3$toLruds$up["in"](distanceUnit);
|
|
184
|
-
_shot3.toLruds.down = (_shot3$toLruds$down = _shot3.toLruds.down) === null || _shot3$toLruds$down === void 0 ? void 0 : _shot3$toLruds$down["in"](distanceUnit);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (azimuthUnit && azimuthUnit !== _alternateUnits.azimuthUnit) {
|
|
188
|
-
var _shot3$frontsightAzim, _shot3$backsightAzimu;
|
|
189
|
-
_shot3.frontsightAzimuth = (_shot3$frontsightAzim = _shot3.frontsightAzimuth) === null || _shot3$frontsightAzim === void 0 ? void 0 : _shot3$frontsightAzim["in"](azimuthUnit);
|
|
190
|
-
_shot3.backsightAzimuth = (_shot3$backsightAzimu = _shot3.backsightAzimuth) === null || _shot3$backsightAzimu === void 0 ? void 0 : _shot3$backsightAzimu["in"](azimuthUnit);
|
|
191
|
-
}
|
|
192
|
-
if (inclinationUnit && inclinationUnit !== _alternateUnits.inclinationUnit) {
|
|
193
|
-
var _shot3$frontsightIncl, _shot3$backsightIncli2;
|
|
194
|
-
_shot3.frontsightInclination = (_shot3$frontsightIncl = _shot3.frontsightInclination) === null || _shot3$frontsightIncl === void 0 ? void 0 : _shot3$frontsightIncl["in"](inclinationUnit);
|
|
195
|
-
_shot3.backsightInclination = (_shot3$backsightIncli2 = _shot3.backsightInclination) === null || _shot3$backsightIncli2 === void 0 ? void 0 : _shot3$backsightIncli2["in"](inclinationUnit);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
if ('INVALID' in trip) {
|
|
200
|
-
trip.INVALID.shots.push(shot);
|
|
201
|
-
} else if ('INVALID' in shot) {
|
|
202
|
-
trip = {
|
|
203
|
-
INVALID: trip
|
|
204
|
-
};
|
|
205
|
-
trip.INVALID.shots.push(shot);
|
|
206
|
-
} else {
|
|
207
|
-
trip.shots.push(shot);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
validate = function _validate(startColumn, endColumn, fieldName, validator) {
|
|
211
|
-
var field = line.substring(startColumn, endColumn);
|
|
212
|
-
if (!validator(field)) {
|
|
213
|
-
addIssue('error', "".concat(field.trim() ? 'invalid' : 'missing').concat(fieldName[0].toUpperCase()).concat(fieldName.substring(1)), (field.trim() ? 'Invalid ' : 'Missing ') + fieldName, startColumn, endColumn);
|
|
214
|
-
}
|
|
215
|
-
return field;
|
|
216
|
-
};
|
|
217
|
-
parseUnits = function _parseUnits() {
|
|
218
|
-
// FT CC DD
|
|
219
|
-
// 01234567
|
|
220
|
-
var distanceUnit = (0, _parsers.parseLengthUnit)(line.slice(0, 2));
|
|
221
|
-
if (!distanceUnit) {
|
|
222
|
-
addIssue('error', 'invalidDistanceUnit', 'Invalid distance unit', 0, 2);
|
|
223
|
-
}
|
|
224
|
-
var azimuthUnit = (0, _parsers.parseAngleUnit)(line[6]);
|
|
225
|
-
if (!azimuthUnit) {
|
|
226
|
-
addIssue('error', 'invalidAzimuthUnit', 'Invalid azimuth unit', 6, 7);
|
|
227
|
-
}
|
|
228
|
-
var inclinationUnit = (0, _parsers.parseAngleUnit)(line[7]);
|
|
229
|
-
if (!inclinationUnit) {
|
|
230
|
-
addIssue('error', 'invalidInclinationUnit', 'Invalid inclination unit', 7, 8);
|
|
231
|
-
}
|
|
232
|
-
var backsightAzimuthCorrected = line[3] === 'C';
|
|
233
|
-
var backsightInclinationCorrected = line[4] === 'C';
|
|
234
|
-
var hasBacksightAzimuth = line[3] !== ' ' && line[3] !== '-';
|
|
235
|
-
var hasBacksightInclination = line[4] !== ' ' && line[4] !== '-';
|
|
236
|
-
if (!/[-CB ]/.test(line[3])) {
|
|
237
|
-
addIssue('error', 'invalidBacksightAzimuthType', 'Invalid backsight azimuth type', 3, 4);
|
|
238
|
-
}
|
|
239
|
-
if (!/[-CB ]/.test(line[4])) {
|
|
240
|
-
addIssue('error', 'invalidBacksightInclinationType', 'Invalid backsight inclination type', 4, 5);
|
|
241
|
-
}
|
|
242
|
-
if (!distanceUnit || !azimuthUnit || !inclinationUnit) {
|
|
243
|
-
return {
|
|
244
|
-
INVALID: {
|
|
245
|
-
distanceUnit: distanceUnit,
|
|
246
|
-
azimuthUnit: azimuthUnit,
|
|
247
|
-
inclinationUnit: inclinationUnit,
|
|
248
|
-
backsightAzimuthCorrected: backsightAzimuthCorrected,
|
|
249
|
-
backsightInclinationCorrected: backsightInclinationCorrected,
|
|
250
|
-
hasBacksightAzimuth: hasBacksightAzimuth,
|
|
251
|
-
hasBacksightInclination: hasBacksightInclination
|
|
252
|
-
},
|
|
253
|
-
issues: lineIssues
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
return {
|
|
257
|
-
distanceUnit: distanceUnit,
|
|
258
|
-
azimuthUnit: azimuthUnit,
|
|
259
|
-
inclinationUnit: inclinationUnit,
|
|
260
|
-
backsightAzimuthCorrected: backsightAzimuthCorrected,
|
|
261
|
-
backsightInclinationCorrected: backsightInclinationCorrected,
|
|
262
|
-
hasBacksightAzimuth: hasBacksightAzimuth,
|
|
263
|
-
hasBacksightInclination: hasBacksightInclination
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
addIssue = function _addIssue(type, code, message, startColumn, endColumn, indicesArray) {
|
|
267
|
-
if (suppressWarnings && type === 'warning' && (suppressWarnings === true || 'code' in suppressWarnings && suppressWarnings[code] === true)) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
issues.push({
|
|
271
|
-
type: type,
|
|
272
|
-
code: code,
|
|
273
|
-
message: message,
|
|
274
|
-
loc: {
|
|
275
|
-
start: {
|
|
276
|
-
line: lineNumber,
|
|
277
|
-
column: startColumn,
|
|
278
|
-
index: lineStartIndex + startColumn
|
|
279
|
-
},
|
|
280
|
-
end: {
|
|
281
|
-
line: lineNumber,
|
|
282
|
-
column: endColumn,
|
|
283
|
-
index: lineStartIndex + endColumn
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
if (!lineIssues) lineIssues = [];
|
|
288
|
-
lineIssues.push(issues.length - 1);
|
|
289
|
-
indicesArray === null || indicesArray === void 0 || indicesArray.push(issues.length - 1);
|
|
290
|
-
};
|
|
291
|
-
addCommentLine = function _addCommentLine(comment) {
|
|
292
|
-
if (trip) {
|
|
293
|
-
var _unwrapInvalid4;
|
|
294
|
-
var distanceUnit = ((_unwrapInvalid4 = unwrapInvalid(alternateUnits)) === null || _unwrapInvalid4 === void 0 ? void 0 : _unwrapInvalid4.distanceUnit) || unwrapInvalid(unwrapInvalid(trip).units).distanceUnit || _unitized.Length.feet;
|
|
295
|
-
var parsedFromStationLruds = (0, _parsers.parseFromStationLruds)(comment, distanceUnit);
|
|
296
|
-
if (parsedFromStationLruds) {
|
|
297
|
-
commentFromStationLruds.set(parsedFromStationLruds[0], parsedFromStationLruds[1]);
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
if (commentLines) {
|
|
302
|
-
commentLines.push(comment);
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
getComment = function _getComment() {
|
|
306
|
-
if (!(commentLines !== null && commentLines !== void 0 && commentLines.length)) return undefined;
|
|
307
|
-
var comment = commentLines.join('\n').trim();
|
|
308
|
-
commentLines.length = 0;
|
|
309
|
-
return comment || undefined;
|
|
310
|
-
};
|
|
311
|
-
_ref = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {}, _ref$columns = _ref.columns, columns = _ref$columns === void 0 ? _FrcsSurveyFile.defaultFrcsShotColumnConfig : _ref$columns, _ref$outputColumns = _ref.outputColumns, outputColumns = _ref$outputColumns === void 0 ? false : _ref$outputColumns, _ref$normalizeNames = _ref.normalizeNames, normalizeNames = _ref$normalizeNames === void 0 ? true : _ref$normalizeNames, suppressWarnings = _ref.suppressWarnings;
|
|
312
|
-
columnRanges = (0, _getColumnRanges.getColumnRanges)(columns);
|
|
313
|
-
maxRange = Math.max.apply(Math, (0, _toConsumableArray2["default"])(Object.values(columnRanges.decimal).map(function (r) {
|
|
314
|
-
return r[1];
|
|
315
|
-
})));
|
|
316
|
-
cave = undefined;
|
|
317
|
-
location = undefined;
|
|
318
|
-
trips = [];
|
|
319
|
-
issues = [];
|
|
320
|
-
inTripComment = true;
|
|
321
|
-
tripCommentStartLine = 1;
|
|
322
|
-
tripCommentEndLine = -1;
|
|
323
|
-
tripComment = [];
|
|
324
|
-
commentLines = [];
|
|
325
|
-
trip = undefined;
|
|
326
|
-
inBlockComment = false;
|
|
327
|
-
commentFromStationLruds = new Map();
|
|
328
|
-
unitsChanged = false;
|
|
329
|
-
lineNumber = 0;
|
|
330
|
-
lineStartIndex = 0;
|
|
331
|
-
lineIssues = [];
|
|
332
|
-
tripIssues = [];
|
|
333
|
-
began = false;
|
|
334
|
-
_iteratorAbruptCompletion = false;
|
|
335
|
-
_didIteratorError = false;
|
|
336
|
-
_context2.prev = 29;
|
|
337
|
-
_loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {
|
|
338
|
-
var _step$value, match, dateMatch, team, month, day, year, _match, header, units, _unwrapInvalid, _unwrapInvalid2, _unwrapInvalid3, _line, _line2, _line3, _line4, _line5, _line6, distanceUnit, azimuthUnit, inclinationUnit, inches, ranges, fromStr, from, lStr, rStr, uStr, dStr, up, down, left, right, toStr, shot, fromLruds, fromLrudMatch, _fromLrudMatch$1$trim, _fromLrudMatch$1$trim2, _left, _right, _up, _down, comment, azmFsStr, azmBsStr, incFsStr, incBsStr, distance, horizontalDistance, verticalDistance, frontsightInclination, backsightInclination, feetStr, inchesStr, distStr, distNum, specialKindStr, exclude, specialKind, excludeDistance, isSplay, _horizontalDistance$g, _horizontalDistance, h, v, _distance$get, _distance, d, _v, frontsightAzimuth, backsightAzimuth, _shot, _shot2;
|
|
339
|
-
return _regenerator["default"].wrap(function _loop$(_context) {
|
|
340
|
-
while (1) switch (_context.prev = _context.next) {
|
|
341
|
-
case 0:
|
|
342
|
-
_step$value = _step.value;
|
|
343
|
-
line = _step$value.line;
|
|
344
|
-
lineStartIndex = _step$value.startIndex;
|
|
345
|
-
if (lineIssues.length) lineIssues = [];
|
|
346
|
-
lineNumber++;
|
|
347
|
-
if (began) {
|
|
348
|
-
_context.next = 11;
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
began = true;
|
|
352
|
-
if (!/^\s+\*/.test(line)) {
|
|
353
|
-
_context.next = 9;
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
return _context.abrupt("return", 0);
|
|
357
|
-
case 9:
|
|
358
|
-
match = /^\s*([^,]+)(,(.*))?/.exec(line);
|
|
359
|
-
if (match) {
|
|
360
|
-
cave = match[1].trim();
|
|
361
|
-
if (match[3]) {
|
|
362
|
-
location = match[3].trim();
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
case 11:
|
|
366
|
-
if (!unitsChanged) {
|
|
367
|
-
_context.next = 17;
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
unitsChanged = false;
|
|
371
|
-
alternateUnits = parseUnits();
|
|
372
|
-
nextShotUnits = alternateUnits;
|
|
373
|
-
_context.next = 95;
|
|
374
|
-
break;
|
|
375
|
-
case 17:
|
|
376
|
-
if (!/^\s{1,8}\*(?!\*)/.test(line)) {
|
|
377
|
-
_context.next = 24;
|
|
378
|
-
break;
|
|
379
|
-
}
|
|
380
|
-
inTripComment = !inTripComment;
|
|
381
|
-
alternateUnits = nextShotUnits = undefined;
|
|
382
|
-
unitsChanged = false;
|
|
383
|
-
if (inTripComment) {
|
|
384
|
-
section = undefined;
|
|
385
|
-
tripTeam = undefined;
|
|
386
|
-
tripDate = undefined;
|
|
387
|
-
tripComment.length = 0;
|
|
388
|
-
tripCommentStartLine = lineNumber;
|
|
389
|
-
} else {
|
|
390
|
-
tripCommentEndLine = lineNumber;
|
|
391
|
-
}
|
|
392
|
-
_context.next = 95;
|
|
393
|
-
break;
|
|
394
|
-
case 24:
|
|
395
|
-
if (!inTripComment) {
|
|
396
|
-
_context.next = 30;
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
399
|
-
if (lineNumber === tripCommentStartLine + 1) {
|
|
400
|
-
tripName = line && line.trim();
|
|
401
|
-
} else if (lineNumber === tripCommentStartLine + 2) {
|
|
402
|
-
dateMatch = /(?:[-.]\s*)?((\d+)[-/](\d+)[-/](\d{2,4})|((\d+)[-/ ](january|february|march|april|may|june|july|august|september|october|november|december|(?:jan|feb|mar|apr|jun|jul|aug|sept?|oct|nov|dec)\.?)[-/ ](\d{2,4}))|((january|february|march|april|may|june|july|august|september|october|november|december|(?:jan|feb|mar|apr|jun|jul|aug|sept?|oct|nov|dec)\.?)\s+(\d+)(?:,\s*|,?\s+)(\d{2,4})))/i.exec(line);
|
|
403
|
-
if (dateMatch) {
|
|
404
|
-
team = line.substring(0, dateMatch.index);
|
|
405
|
-
tripTeam = team.split(team.indexOf(';') >= 0 ? ';' : ',').flatMap(function (member) {
|
|
406
|
-
return member.trim() || [];
|
|
407
|
-
});
|
|
408
|
-
if (!tripTeam.length) {
|
|
409
|
-
addIssue('warning', 'missingTripTeam', 'Missing team', 0, dateMatch.index, tripIssues);
|
|
410
|
-
}
|
|
411
|
-
if (normalizeNames) tripTeam = tripTeam.map(_normalizeTeamMemberName.normalizeTeamMemberName);
|
|
412
|
-
if (dateMatch[2]) {
|
|
413
|
-
month = parseInt(dateMatch[2]);
|
|
414
|
-
day = parseInt(dateMatch[3]);
|
|
415
|
-
year = parseInt(dateMatch[4]);
|
|
416
|
-
} else if (dateMatch[6]) {
|
|
417
|
-
day = parseInt(dateMatch[6]);
|
|
418
|
-
month = (0, _parsers.parseMonth)(dateMatch[7]);
|
|
419
|
-
year = parseInt(dateMatch[8]);
|
|
420
|
-
} else {
|
|
421
|
-
month = (0, _parsers.parseMonth)(dateMatch[10]);
|
|
422
|
-
day = parseInt(dateMatch[11]);
|
|
423
|
-
year = parseInt(dateMatch[12]);
|
|
424
|
-
}
|
|
425
|
-
tripDate = new Date(year < 70 ? year + 2000 : year, month - 1, day);
|
|
426
|
-
} else {
|
|
427
|
-
addIssue('warning', 'missingTripDate', 'Missing date', line.length, line.length, tripIssues);
|
|
428
|
-
}
|
|
429
|
-
} else if (lineNumber > 1) {
|
|
430
|
-
tripComment.push(line);
|
|
431
|
-
}
|
|
432
|
-
_match = /^\*\*\*([^*]+)\*\*\*/.exec(line);
|
|
433
|
-
if (_match) {
|
|
434
|
-
section = _match[1].trim();
|
|
435
|
-
}
|
|
436
|
-
_context.next = 95;
|
|
437
|
-
break;
|
|
438
|
-
case 30:
|
|
439
|
-
if (!/^(\s{9,}|)\*(?!\*)/.test(line)) {
|
|
440
|
-
_context.next = 37;
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
if (/^\*\s*%NC(\b|$)/.test(line)) {
|
|
444
|
-
unitsChanged = true;
|
|
445
|
-
}
|
|
446
|
-
if (!/^\*\s*%/.test(line)) {
|
|
447
|
-
_context.next = 34;
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
return _context.abrupt("return", 0);
|
|
451
|
-
case 34:
|
|
452
|
-
if (/[^\s*]/.test(line)) {
|
|
453
|
-
addCommentLine(line.replace(/^\s*\*/, ''));
|
|
454
|
-
inBlockComment = false;
|
|
455
|
-
} else {
|
|
456
|
-
inBlockComment = !inBlockComment;
|
|
457
|
-
if (inBlockComment) commentLines.length = 0;
|
|
458
|
-
}
|
|
459
|
-
_context.next = 95;
|
|
460
|
-
break;
|
|
461
|
-
case 37:
|
|
462
|
-
if (!inBlockComment) {
|
|
463
|
-
_context.next = 41;
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
466
|
-
addCommentLine(line);
|
|
467
|
-
_context.next = 95;
|
|
468
|
-
break;
|
|
469
|
-
case 41:
|
|
470
|
-
if (!(lineNumber === tripCommentEndLine + 1)) {
|
|
471
|
-
_context.next = 49;
|
|
472
|
-
break;
|
|
473
|
-
}
|
|
474
|
-
if (trip) trips.push(trip);
|
|
475
|
-
header = {
|
|
476
|
-
name: tripName || '',
|
|
477
|
-
comment: tripComment && tripComment.join('\n') || undefined,
|
|
478
|
-
section: section,
|
|
479
|
-
date: tripDate,
|
|
480
|
-
team: tripTeam
|
|
481
|
-
};
|
|
482
|
-
units = parseUnits();
|
|
483
|
-
if ('INVALID' in units || tripIssues.some(function (i) {
|
|
484
|
-
var _issues$i;
|
|
485
|
-
return ((_issues$i = issues[i]) === null || _issues$i === void 0 ? void 0 : _issues$i.type) === 'error';
|
|
486
|
-
})) {
|
|
487
|
-
trip = _objectSpread({
|
|
488
|
-
INVALID: {
|
|
489
|
-
header: header,
|
|
490
|
-
units: units,
|
|
491
|
-
shots: []
|
|
492
|
-
}
|
|
493
|
-
}, tripIssues.length ? {
|
|
494
|
-
issues: tripIssues
|
|
495
|
-
} : {});
|
|
496
|
-
} else {
|
|
497
|
-
trip = {
|
|
498
|
-
tripNumber: 1,
|
|
499
|
-
header: header,
|
|
500
|
-
units: units,
|
|
501
|
-
shots: []
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
tripIssues = [];
|
|
505
|
-
_context.next = 95;
|
|
506
|
-
break;
|
|
507
|
-
case 49:
|
|
508
|
-
if (!trip) {
|
|
509
|
-
_context.next = 95;
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
512
|
-
distanceUnit = ((_unwrapInvalid = unwrapInvalid(alternateUnits)) === null || _unwrapInvalid === void 0 ? void 0 : _unwrapInvalid.distanceUnit) || unwrapInvalid(unwrapInvalid(trip).units).distanceUnit || _unitized.Length.feet;
|
|
513
|
-
azimuthUnit = ((_unwrapInvalid2 = unwrapInvalid(alternateUnits)) === null || _unwrapInvalid2 === void 0 ? void 0 : _unwrapInvalid2.azimuthUnit) || unwrapInvalid(unwrapInvalid(trip).units).azimuthUnit || _unitized.Angle.degrees;
|
|
514
|
-
inclinationUnit = ((_unwrapInvalid3 = unwrapInvalid(alternateUnits)) === null || _unwrapInvalid3 === void 0 ? void 0 : _unwrapInvalid3.inclinationUnit) || unwrapInvalid(unwrapInvalid(trip).units).inclinationUnit || _unitized.Angle.degrees;
|
|
515
|
-
inches = distanceUnit === _unitized.Length.inches;
|
|
516
|
-
if (inches) distanceUnit = _unitized.Length.feet;
|
|
517
|
-
ranges = inches ? columnRanges.feetAndInches : columnRanges.decimal; // from station name
|
|
518
|
-
if (/\S/.test((_line = line).substring.apply(_line, (0, _toConsumableArray2["default"])(ranges.fromStation)))) {
|
|
519
|
-
_context.next = 58;
|
|
520
|
-
break;
|
|
521
|
-
}
|
|
522
|
-
return _context.abrupt("return", 0);
|
|
523
|
-
case 58:
|
|
524
|
-
fromStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.fromStation).concat(['from station', _validators.isValidStation]));
|
|
525
|
-
from = fromStr.trim(); // Sadly I have found negative LRUD values in Chip's format and apparently
|
|
526
|
-
// his program doesn't fail on them, so I have to accept them here
|
|
527
|
-
// isValidOptFloat instead of isValidOptUFloat
|
|
528
|
-
lStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.left).concat(['left', _validators.isValidOptFloat]));
|
|
529
|
-
rStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.right).concat(['right', _validators.isValidOptFloat]));
|
|
530
|
-
uStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.up).concat(['up', _validators.isValidOptFloat]));
|
|
531
|
-
dStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.down).concat(['down', _validators.isValidOptFloat]));
|
|
532
|
-
up = (0, _parsers.parseLrud)(uStr, distanceUnit);
|
|
533
|
-
down = (0, _parsers.parseLrud)(dStr, distanceUnit);
|
|
534
|
-
left = (0, _parsers.parseLrud)(lStr, distanceUnit);
|
|
535
|
-
right = (0, _parsers.parseLrud)(rStr, distanceUnit); // to station name
|
|
536
|
-
toStr = (_line2 = line).substring.apply(_line2, (0, _toConsumableArray2["default"])(ranges.toStation));
|
|
537
|
-
if (toStr.trim()) {
|
|
538
|
-
_context.next = 73;
|
|
539
|
-
break;
|
|
540
|
-
}
|
|
541
|
-
shot = {
|
|
542
|
-
from: from,
|
|
543
|
-
to: undefined,
|
|
544
|
-
distance: new _unitized.UnitizedNumber(0, distanceUnit),
|
|
545
|
-
frontsightAzimuth: undefined,
|
|
546
|
-
backsightAzimuth: undefined,
|
|
547
|
-
frontsightInclination: undefined,
|
|
548
|
-
backsightInclination: undefined,
|
|
549
|
-
fromLruds: {
|
|
550
|
-
left: left,
|
|
551
|
-
right: right,
|
|
552
|
-
up: up,
|
|
553
|
-
down: down
|
|
554
|
-
},
|
|
555
|
-
excludeDistance: true,
|
|
556
|
-
comment: getComment()
|
|
557
|
-
};
|
|
558
|
-
addShot(lineIssues.length ? {
|
|
559
|
-
INVALID: shot,
|
|
560
|
-
issues: lineIssues
|
|
561
|
-
} : shot);
|
|
562
|
-
return _context.abrupt("return", 0);
|
|
563
|
-
case 73:
|
|
564
|
-
if (!(0, _validators.isValidStation)(toStr)) {
|
|
565
|
-
addIssue.apply(void 0, ['error', 'invalidStationName', 'Invalid station name'].concat((0, _toConsumableArray2["default"])(ranges.toStation)));
|
|
566
|
-
}
|
|
567
|
-
fromLruds = commentFromStationLruds.get(from);
|
|
568
|
-
if (fromLruds) {
|
|
569
|
-
commentFromStationLruds["delete"](from);
|
|
570
|
-
} else {
|
|
571
|
-
fromLrudMatch = new RegExp("^\\s+".concat(fromStr.trim().replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "((\\s+(\\d+(\\.\\d*)?|\\.\\d+)){4})")).exec(line.substring(maxRange));
|
|
572
|
-
if (fromLrudMatch) {
|
|
573
|
-
_fromLrudMatch$1$trim = fromLrudMatch[1].trim().split(/\s+/g).map(function (s) {
|
|
574
|
-
return (0, _parsers.parseLrud)(s, distanceUnit);
|
|
575
|
-
}), _fromLrudMatch$1$trim2 = (0, _slicedToArray2["default"])(_fromLrudMatch$1$trim, 4), _left = _fromLrudMatch$1$trim2[0], _right = _fromLrudMatch$1$trim2[1], _up = _fromLrudMatch$1$trim2[2], _down = _fromLrudMatch$1$trim2[3];
|
|
576
|
-
fromLruds = {
|
|
577
|
-
left: _left,
|
|
578
|
-
right: _right,
|
|
579
|
-
up: _up,
|
|
580
|
-
down: _down
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
comment = getComment(); // azimuth and inclination
|
|
585
|
-
azmFsStr = validate(ranges.frontsightAzimuth[0], ranges.frontsightAzimuth[1], 'azimuth', _validators.isValidOptUFloat);
|
|
586
|
-
azmBsStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.backsightAzimuth).concat(['azimuth', _validators.isValidOptUFloat]));
|
|
587
|
-
incFsStr = (_line3 = line).substring.apply(_line3, (0, _toConsumableArray2["default"])(ranges.frontsightInclination));
|
|
588
|
-
incBsStr = (_line4 = line).substring.apply(_line4, (0, _toConsumableArray2["default"])(ranges.backsightInclination));
|
|
589
|
-
// parse distance
|
|
590
|
-
if (inches) {
|
|
591
|
-
feetStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.distanceFeet).concat(['feet', _validators.isValidOptUFloat]));
|
|
592
|
-
inchesStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.distanceInches).concat(['inches', _validators.isValidOptUFloat]));
|
|
593
|
-
if (!/\S/.test(feetStr) && !/\S/.test(inchesStr)) {
|
|
594
|
-
addIssue('error', 'missingDistance', 'Missing distance', ranges.distanceFeet[0], ranges.distanceInches[1]);
|
|
595
|
-
}
|
|
596
|
-
// sometimes inches are omitted, hence the || 0...I'm assuming it's possible
|
|
597
|
-
// for feet to be omitted as well
|
|
598
|
-
else if ((0, _validators.isValidUInt)(feetStr) && (0, _validators.isValidOptUFloat)(inchesStr) || (0, _validators.isValidOptUFloat)(feetStr) && (0, _validators.isValidUInt)(inchesStr)) {
|
|
599
|
-
distance = _unitized.Unitize.inches(parseFloat(inchesStr) || 0).add(_unitized.Unitize.feet(parseFloat(feetStr) || 0));
|
|
600
|
-
}
|
|
601
|
-
// NOTE there are two columns around here that can contain a *.
|
|
602
|
-
// I think they might represent different values, but thisis confused by
|
|
603
|
-
// the fact that for ft/in shots, if there is a D or H flag it occupies the
|
|
604
|
-
// first column that can contain a * for decimal feet shots
|
|
605
|
-
} else {
|
|
606
|
-
distStr = validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.distance).concat(['distance', _validators.isValidUFloat]));
|
|
607
|
-
distNum = parseFloat(distStr);
|
|
608
|
-
distance = Number.isFinite(distNum) ? new _unitized.UnitizedNumber(distNum, distanceUnit) : undefined;
|
|
609
|
-
}
|
|
610
|
-
specialKindStr = (_line5 = line).substring.apply(_line5, (0, _toConsumableArray2["default"])(ranges.kind)).trim();
|
|
611
|
-
exclude = (_line6 = line).substring.apply(_line6, (0, _toConsumableArray2["default"])(ranges.exclude)).trim();
|
|
612
|
-
specialKind = (0, _parsers.parseSpecialKind)(specialKindStr);
|
|
613
|
-
if (specialKindStr && !specialKind) {
|
|
614
|
-
addIssue('error', 'invalidShotType', 'Invalid shot type', ranges.kind[0], ranges.kind[1]);
|
|
615
|
-
}
|
|
616
|
-
excludeDistance = exclude === '*' || exclude === 's';
|
|
617
|
-
isSplay = exclude === 's';
|
|
618
|
-
if (exclude && !excludeDistance) {
|
|
619
|
-
addIssue('error', 'invalidShotFlag', 'Invalid shot flag', ranges.exclude[0], ranges.exclude[1]);
|
|
620
|
-
}
|
|
621
|
-
if (specialKind) {
|
|
622
|
-
validate.apply(void 0, (0, _toConsumableArray2["default"])(ranges.frontsightInclination).concat(['vertical-distance', _validators.isValidFloat]));
|
|
623
|
-
}
|
|
427
|
+
...(issues.length ? {
|
|
428
|
+
issues
|
|
429
|
+
} : undefined)
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
return {
|
|
433
|
+
INVALID: {
|
|
434
|
+
cave,
|
|
435
|
+
columns: outputColumns ? columns : undefined,
|
|
436
|
+
location,
|
|
437
|
+
trips
|
|
438
|
+
},
|
|
439
|
+
issues
|
|
440
|
+
};
|
|
624
441
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
442
|
+
////////////////////////////////////////////////////////////////////////////////////////////
|
|
443
|
+
|
|
444
|
+
function getComment() {
|
|
445
|
+
if (!commentLines?.length) return undefined;
|
|
446
|
+
const comment = commentLines.join('\n').trim();
|
|
447
|
+
commentLines.length = 0;
|
|
448
|
+
return comment || undefined;
|
|
449
|
+
}
|
|
450
|
+
function addCommentLine(comment) {
|
|
451
|
+
if (trip) {
|
|
452
|
+
const distanceUnit = (0, _unwrapInvalid.unwrapInvalid)(alternateUnits)?.distanceUnit || (0, _unwrapInvalid.unwrapInvalid)((0, _unwrapInvalid.unwrapInvalid)(trip).units).distanceUnit || _unitized.Length.feet;
|
|
453
|
+
const parsedFromStationLruds = (0, _parsers.parseFromStationLruds)(comment, distanceUnit);
|
|
454
|
+
if (parsedFromStationLruds) {
|
|
455
|
+
commentFromStationLruds.set(parsedFromStationLruds[0], parsedFromStationLruds[1]);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (commentLines) {
|
|
460
|
+
commentLines.push(comment);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function addIssue(type, code, message, startColumn, endColumn, indicesArray) {
|
|
464
|
+
if (suppressWarnings && type === 'warning' && (suppressWarnings === true || 'code' in suppressWarnings && suppressWarnings[code] === true)) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
issues.push({
|
|
468
|
+
type,
|
|
469
|
+
code,
|
|
470
|
+
message,
|
|
471
|
+
loc: {
|
|
472
|
+
start: {
|
|
473
|
+
line: lineNumber,
|
|
474
|
+
column: startColumn,
|
|
475
|
+
index: lineStartIndex + startColumn
|
|
476
|
+
},
|
|
477
|
+
end: {
|
|
478
|
+
line: lineNumber,
|
|
479
|
+
column: endColumn,
|
|
480
|
+
index: lineStartIndex + endColumn
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
if (!lineIssues) lineIssues = [];
|
|
485
|
+
lineIssues.push(issues.length - 1);
|
|
486
|
+
indicesArray?.push(issues.length - 1);
|
|
487
|
+
}
|
|
488
|
+
function parseUnits() {
|
|
489
|
+
// FT CC DD
|
|
490
|
+
// 01234567
|
|
491
|
+
const distanceUnit = (0, _parsers.parseLengthUnit)(line.slice(0, 2));
|
|
492
|
+
if (!distanceUnit) {
|
|
493
|
+
addIssue('error', 'invalidDistanceUnit', 'Invalid distance unit', 0, 2);
|
|
494
|
+
}
|
|
495
|
+
const azimuthUnit = (0, _parsers.parseAngleUnit)(line[6]);
|
|
496
|
+
if (!azimuthUnit) {
|
|
497
|
+
addIssue('error', 'invalidAzimuthUnit', 'Invalid azimuth unit', 6, 7);
|
|
498
|
+
}
|
|
499
|
+
const inclinationUnit = (0, _parsers.parseAngleUnit)(line[7]);
|
|
500
|
+
if (!inclinationUnit) {
|
|
501
|
+
addIssue('error', 'invalidInclinationUnit', 'Invalid inclination unit', 7, 8);
|
|
502
|
+
}
|
|
503
|
+
const backsightAzimuthCorrected = line[3] === 'C';
|
|
504
|
+
const backsightInclinationCorrected = line[4] === 'C';
|
|
505
|
+
const hasBacksightAzimuth = line[3] !== ' ' && line[3] !== '-';
|
|
506
|
+
const hasBacksightInclination = line[4] !== ' ' && line[4] !== '-';
|
|
507
|
+
if (!/[-CB ]/.test(line[3])) {
|
|
508
|
+
addIssue('error', 'invalidBacksightAzimuthType', 'Invalid backsight azimuth type', 3, 4);
|
|
509
|
+
}
|
|
510
|
+
if (!/[-CB ]/.test(line[4])) {
|
|
511
|
+
addIssue('error', 'invalidBacksightInclinationType', 'Invalid backsight inclination type', 4, 5);
|
|
512
|
+
}
|
|
513
|
+
if (!distanceUnit || !azimuthUnit || !inclinationUnit) {
|
|
514
|
+
return {
|
|
515
|
+
INVALID: {
|
|
516
|
+
distanceUnit,
|
|
517
|
+
azimuthUnit,
|
|
518
|
+
inclinationUnit,
|
|
519
|
+
backsightAzimuthCorrected,
|
|
520
|
+
backsightInclinationCorrected,
|
|
521
|
+
hasBacksightAzimuth,
|
|
522
|
+
hasBacksightInclination
|
|
523
|
+
},
|
|
524
|
+
issues: lineIssues
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
return {
|
|
528
|
+
distanceUnit,
|
|
529
|
+
azimuthUnit,
|
|
530
|
+
inclinationUnit,
|
|
531
|
+
backsightAzimuthCorrected,
|
|
532
|
+
backsightInclinationCorrected,
|
|
533
|
+
hasBacksightAzimuth,
|
|
534
|
+
hasBacksightInclination
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function validate(startColumn, endColumn, fieldName, validator) {
|
|
538
|
+
const field = line.substring(startColumn, endColumn);
|
|
539
|
+
if (!validator(field)) {
|
|
540
|
+
addIssue('error', `${field.trim() ? 'invalid' : 'missing'}${fieldName[0].toUpperCase()}${fieldName.substring(1)}`, (field.trim() ? 'Invalid ' : 'Missing ') + fieldName, startColumn, endColumn);
|
|
541
|
+
}
|
|
542
|
+
return field;
|
|
543
|
+
}
|
|
544
|
+
function addShot(shot) {
|
|
545
|
+
if (!trip) return;
|
|
546
|
+
if (alternateUnits) {
|
|
547
|
+
const recorded = shot;
|
|
548
|
+
if ('INVALID' in shot) {
|
|
549
|
+
shot = {
|
|
550
|
+
INVALID: {
|
|
551
|
+
...shot.INVALID,
|
|
552
|
+
recorded: shot
|
|
553
|
+
},
|
|
554
|
+
issues: shot.issues
|
|
555
|
+
};
|
|
556
|
+
} else {
|
|
557
|
+
shot = {
|
|
558
|
+
...shot,
|
|
559
|
+
recorded: shot
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
if (nextShotUnits) {
|
|
563
|
+
(0, _unwrapInvalid.unwrapInvalid)(recorded).units = nextShotUnits;
|
|
564
|
+
nextShotUnits = undefined;
|
|
565
|
+
}
|
|
566
|
+
const {
|
|
567
|
+
backsightAzimuthCorrected,
|
|
568
|
+
backsightInclinationCorrected,
|
|
569
|
+
distanceUnit,
|
|
570
|
+
azimuthUnit,
|
|
571
|
+
inclinationUnit
|
|
572
|
+
} = (0, _unwrapInvalid.unwrapInvalid)((0, _unwrapInvalid.unwrapInvalid)(trip).units);
|
|
573
|
+
const unwrappedAlternateUnits = (0, _unwrapInvalid.unwrapInvalid)(alternateUnits);
|
|
574
|
+
const unwrappedShot = (0, _unwrapInvalid.unwrapInvalid)(shot);
|
|
575
|
+
{
|
|
576
|
+
const alternateUnits = unwrappedAlternateUnits;
|
|
577
|
+
const shot = unwrappedShot;
|
|
578
|
+
if (alternateUnits.backsightAzimuthCorrected !== backsightAzimuthCorrected) {
|
|
579
|
+
shot.backsightAzimuth = shot.backsightAzimuth ? _unitized.Angle.opposite(shot.backsightAzimuth) : undefined;
|
|
580
|
+
}
|
|
581
|
+
if (alternateUnits.backsightInclinationCorrected !== backsightInclinationCorrected) {
|
|
582
|
+
shot.backsightInclination = shot.backsightInclination?.negate();
|
|
583
|
+
}
|
|
584
|
+
if (distanceUnit && distanceUnit !== alternateUnits.distanceUnit) {
|
|
585
|
+
shot.distance = shot.distance?.in(distanceUnit);
|
|
586
|
+
if (shot.fromLruds) {
|
|
587
|
+
shot.fromLruds = {
|
|
588
|
+
...shot.fromLruds
|
|
589
|
+
};
|
|
590
|
+
shot.fromLruds.left = shot.fromLruds.left?.in(distanceUnit);
|
|
591
|
+
shot.fromLruds.right = shot.fromLruds.right?.in(distanceUnit);
|
|
592
|
+
shot.fromLruds.up = shot.fromLruds.up?.in(distanceUnit);
|
|
593
|
+
shot.fromLruds.down = shot.fromLruds.down?.in(distanceUnit);
|
|
759
594
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
case 57:
|
|
764
|
-
return _context2.finish(48);
|
|
765
|
-
case 58:
|
|
766
|
-
if (trip) trips.push(trip);
|
|
767
|
-
trips.map(function (trip, index) {
|
|
768
|
-
return {
|
|
769
|
-
trip: unwrapInvalid(trip),
|
|
770
|
-
index: index
|
|
595
|
+
if (shot.toLruds) {
|
|
596
|
+
shot.toLruds = {
|
|
597
|
+
...shot.toLruds
|
|
771
598
|
};
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
}).forEach(function (_ref2, index) {
|
|
777
|
-
var trip = _ref2.trip;
|
|
778
|
-
return trip.tripNumber = index + 1;
|
|
779
|
-
});
|
|
780
|
-
if (!(!issues.some(function (i) {
|
|
781
|
-
return i.type === 'error';
|
|
782
|
-
}) && trips.every(function (t) {
|
|
783
|
-
return !('INVALID' in t);
|
|
784
|
-
}))) {
|
|
785
|
-
_context2.next = 62;
|
|
786
|
-
break;
|
|
599
|
+
shot.toLruds.left = shot.toLruds.left?.in(distanceUnit);
|
|
600
|
+
shot.toLruds.right = shot.toLruds.right?.in(distanceUnit);
|
|
601
|
+
shot.toLruds.up = shot.toLruds.up?.in(distanceUnit);
|
|
602
|
+
shot.toLruds.down = shot.toLruds.down?.in(distanceUnit);
|
|
787
603
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
return _context2.abrupt("return", {
|
|
798
|
-
INVALID: {
|
|
799
|
-
cave: cave,
|
|
800
|
-
columns: outputColumns ? columns : undefined,
|
|
801
|
-
location: location,
|
|
802
|
-
trips: trips
|
|
803
|
-
},
|
|
804
|
-
issues: issues
|
|
805
|
-
});
|
|
806
|
-
case 63:
|
|
807
|
-
case "end":
|
|
808
|
-
return _context2.stop();
|
|
604
|
+
}
|
|
605
|
+
if (azimuthUnit && azimuthUnit !== alternateUnits.azimuthUnit) {
|
|
606
|
+
shot.frontsightAzimuth = shot.frontsightAzimuth?.in(azimuthUnit);
|
|
607
|
+
shot.backsightAzimuth = shot.backsightAzimuth?.in(azimuthUnit);
|
|
608
|
+
}
|
|
609
|
+
if (inclinationUnit && inclinationUnit !== alternateUnits.inclinationUnit) {
|
|
610
|
+
shot.frontsightInclination = shot.frontsightInclination?.in(inclinationUnit);
|
|
611
|
+
shot.backsightInclination = shot.backsightInclination?.in(inclinationUnit);
|
|
612
|
+
}
|
|
809
613
|
}
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
|
|
614
|
+
}
|
|
615
|
+
if ('INVALID' in trip) {
|
|
616
|
+
trip.INVALID.shots.push(shot);
|
|
617
|
+
} else if ('INVALID' in shot) {
|
|
618
|
+
trip = {
|
|
619
|
+
INVALID: trip
|
|
620
|
+
};
|
|
621
|
+
trip.INVALID.shots.push(shot);
|
|
622
|
+
} else {
|
|
623
|
+
trip.shots.push(shot);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
816
626
|
}
|
|
817
627
|
module.exports = exports.default;
|
|
818
628
|
//# sourceMappingURL=parseFrcsSurveyFile.js.map
|