@speleotica/frcsdata 4.1.1 → 4.3.0

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/FrcsShot.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { UnitizedNumber, Length, Angle } from '@speleotica/unitized';
2
+ import { FrcsUnits } from './FrcsTrip';
2
3
  export declare enum FrcsShotKind {
3
4
  Normal = " ",
4
5
  Horizontal = "H",
@@ -42,4 +43,14 @@ export type FrcsShot = {
42
43
  excludeDistance?: boolean | null;
43
44
  isSplay?: boolean | null;
44
45
  comment?: string | null;
46
+ /**
47
+ * In the edge case that the surveyors changed measurement units or
48
+ * corrected/uncorrected backsights in the middle of a trip, the measurements
49
+ * will be normalized to the initial trip settings, and this field will contain
50
+ * the actual values recorded, verbatim. The first shot of the group with
51
+ * changed units will include the changed units.
52
+ */
53
+ recorded?: FrcsShot & {
54
+ units?: FrcsUnits;
55
+ };
45
56
  };
@@ -2,8 +2,27 @@ import { FrcsTrip } from './FrcsTrip';
2
2
  import { SegmentParseError } from 'parse-segment';
3
3
  export type FrcsSurveyFile = {
4
4
  cave?: string | null;
5
+ columns?: FrcsShotColumnConfig;
5
6
  location?: string | null;
6
7
  comment?: string | null;
7
8
  trips: Array<FrcsTrip>;
8
9
  errors?: Array<SegmentParseError> | null;
9
10
  };
11
+ export type FrcsShotColumnConfig = {
12
+ toStation: number;
13
+ fromStation: number;
14
+ distance: number;
15
+ distanceFeet: number;
16
+ distanceInches: number;
17
+ kind: number;
18
+ exclude: number;
19
+ frontsightAzimuth: number;
20
+ backsightAzimuth: number;
21
+ frontsightInclination: number;
22
+ backsightInclination: number;
23
+ left: number;
24
+ right: number;
25
+ up: number;
26
+ down: number;
27
+ };
28
+ export declare const defaultFrcsShotColumnConfig: FrcsShotColumnConfig;
package/FrcsSurveyFile.js CHANGED
@@ -2,4 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+ exports.defaultFrcsShotColumnConfig = void 0;
7
+ var defaultFrcsShotColumnConfig = exports.defaultFrcsShotColumnConfig = {
8
+ toStation: 5,
9
+ fromStation: 5,
10
+ distance: 6,
11
+ distanceFeet: 4,
12
+ distanceInches: 3,
13
+ kind: 1,
14
+ exclude: 1,
15
+ frontsightAzimuth: 6,
16
+ backsightAzimuth: 6,
17
+ frontsightInclination: 5,
18
+ backsightInclination: 5,
19
+ left: 3,
20
+ right: 3,
21
+ up: 3,
22
+ down: 3
23
+ };
package/FrcsTrip.d.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  import { Unit, Length, Angle } from '@speleotica/unitized';
2
2
  import { FrcsShot } from './FrcsShot';
3
- export type FrcsTripHeader = {
4
- name: string;
5
- comment?: string | null;
6
- section?: string | null;
7
- date?: Date | null;
8
- team?: Array<string> | null;
3
+ export type FrcsUnits = {
9
4
  distanceUnit: Unit<Length>;
10
5
  azimuthUnit: Unit<Angle>;
11
6
  inclinationUnit: Unit<Angle>;
@@ -14,6 +9,13 @@ export type FrcsTripHeader = {
14
9
  hasBacksightAzimuth?: boolean | null;
15
10
  hasBacksightInclination?: boolean | null;
16
11
  };
12
+ export type FrcsTripHeader = FrcsUnits & {
13
+ name: string;
14
+ comment?: string | null;
15
+ section?: string | null;
16
+ date?: Date | null;
17
+ team?: Array<string> | null;
18
+ };
17
19
  export type FrcsTrip = {
18
20
  header: FrcsTripHeader;
19
21
  shots: Array<FrcsShot>;
@@ -1,3 +1,8 @@
1
- import { FrcsTripHeader } from './FrcsTrip';
1
+ import { FrcsUnits } from './FrcsTrip';
2
2
  import { FrcsShot } from './FrcsShot';
3
- export default function formatFrcsShot(shot: FrcsShot, header: FrcsTripHeader): string;
3
+ import { FrcsShotColumnConfig } from './FrcsSurveyFile';
4
+ export declare function makeFormatFrcsShot({ columns, }?: {
5
+ columns?: FrcsShotColumnConfig;
6
+ }): (shot: FrcsShot, header: FrcsUnits) => string;
7
+ declare const _default: (shot: FrcsShot, header: FrcsUnits) => string;
8
+ export default _default;
package/formatFrcsShot.js CHANGED
@@ -3,71 +3,94 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = formatFrcsShot;
6
+ exports["default"] = void 0;
7
+ exports.makeFormatFrcsShot = makeFormatFrcsShot;
7
8
  var _FrcsShot = require("./FrcsShot.js");
8
9
  var _unitized = require("@speleotica/unitized");
9
- var STATION_WIDTH = 5;
10
- var EMPTY_STATION = ' '.repeat(STATION_WIDTH);
11
- function formatStation(station) {
12
- if (station.length > STATION_WIDTH) {
13
- throw new Error("station is too long: ".concat(station));
10
+ var _FrcsSurveyFile = require("./FrcsSurveyFile.js");
11
+ function makeFormatFrcsShot() {
12
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
13
+ _ref$columns = _ref.columns,
14
+ columns = _ref$columns === void 0 ? _FrcsSurveyFile.defaultFrcsShotColumnConfig : _ref$columns;
15
+ var EMPTY_TO_STATION = ' '.repeat(columns.toStation);
16
+ function formatFromStation(station) {
17
+ if (station.length > columns.fromStation) {
18
+ throw new Error("station is too long: ".concat(station));
19
+ }
20
+ return station.padStart(columns.fromStation, ' ');
14
21
  }
15
- return station.padStart(STATION_WIDTH, ' ');
16
- }
17
- function trimZeroes(str) {
18
- var match = /(-?\d+)(\.[1-9]*)0+$/.exec(str);
19
- if (!match) return str;
20
- return match[2].length > 1 ? match[1] + match[2] : match[1];
21
- }
22
- var formatNumber = function formatNumber(width) {
23
- return function (num) {
24
- if (num == null || !Number.isFinite(num)) return ' '.repeat(width);
25
- var formatted = trimZeroes(num.toFixed(2));
26
- if (formatted.length <= width) return formatted.padStart(width, ' ');
27
- if (formatted.length > width + 2) return formatted.substring(0, width);
28
- return trimZeroes(num.toFixed(2 - formatted.length + width)).padStart(width, ' ');
22
+ function formatToStation(station) {
23
+ if (station.length > columns.toStation) {
24
+ throw new Error("station is too long: ".concat(station));
25
+ }
26
+ return station.padStart(columns.toStation, ' ');
27
+ }
28
+ function trimZeroes(str) {
29
+ var match = /(-?\d+)(\.[1-9]*)0+$/.exec(str);
30
+ if (!match) return str;
31
+ return match[2].length > 1 ? match[1] + match[2] : match[1];
32
+ }
33
+ var formatNumber = function formatNumber(width) {
34
+ function formatNum(num, unit, verbatim) {
35
+ if (num instanceof _unitized.UnitizedNumber) {
36
+ return formatNum(num.get(verbatim ? num.unit : unit || num.unit));
37
+ }
38
+ if (num == null || !Number.isFinite(num)) return ' '.repeat(width);
39
+ var formatted = trimZeroes(num.toFixed(2));
40
+ if (formatted.length <= width) return formatted.padStart(width, ' ');
41
+ if (formatted.length > width + 2) return formatted.substring(0, width);
42
+ return trimZeroes(num.toFixed(2 - formatted.length + width)).padStart(width, ' ');
43
+ }
44
+ return formatNum;
29
45
  };
30
- };
31
- var LRUD_WIDTH = 3;
32
- var formatLrud = formatNumber(LRUD_WIDTH);
33
- var DISTANCE_WIDTH = 6;
34
- var EMPTY_DISTANCE = ' '.repeat(DISTANCE_WIDTH);
35
- var formatDistance = formatNumber(DISTANCE_WIDTH);
36
- var AZIMUTH_WIDTH = 6;
37
- var EMPTY_AZIMUTH = ' '.repeat(AZIMUTH_WIDTH);
38
- var formatAzimuth = formatNumber(AZIMUTH_WIDTH);
39
- var INCLINATION_WIDTH = 5;
40
- var EMPTY_INCLINATION = ' '.repeat(INCLINATION_WIDTH);
41
- var formatInclination = formatNumber(INCLINATION_WIDTH);
42
- var formatVerticalDistance = formatNumber(INCLINATION_WIDTH);
43
- var FEET_WIDTH = 4;
44
- var EMPTY_FEET = ' '.repeat(FEET_WIDTH);
45
- function formatFeet(distance) {
46
- if (!distance) return EMPTY_FEET;
47
- return formatNumber(FEET_WIDTH)(Math.trunc(distance.get(_unitized.Length.feet)));
48
- }
49
- var INCHES_WIDTH = 3;
50
- var EMPTY_INCHES = ' '.repeat(INCHES_WIDTH);
51
- function formatInches(distance) {
52
- if (!distance) return EMPTY_INCHES;
53
- return formatNumber(INCHES_WIDTH)(Math.round(distance.get(_unitized.Length.inches) % 12));
54
- }
55
- function formatFrcsShot(shot, header) {
56
- var _shot$frontsightAzimu, _shot$backsightAzimut, _shot$frontsightIncli, _shot$verticalDistanc, _shot$backsightInclin, _shot$toLruds, _shot$toLruds2, _shot$toLruds3, _shot$toLruds4;
57
- var azimuthUnit = header.azimuthUnit,
58
- inclinationUnit = header.inclinationUnit;
59
- var distanceUnit = header.distanceUnit;
60
- var inches = distanceUnit === _unitized.Length.inches;
61
- if (inches) distanceUnit = _unitized.Length.feet;
62
- if (!shot.to) {
63
- var _shot$fromLruds, _shot$fromLruds2, _shot$fromLruds3, _shot$fromLruds4;
64
- return [formatStation(shot.from), EMPTY_STATION, EMPTY_DISTANCE, ' ',
65
- // kind
66
- ' ',
67
- // exclude
68
- EMPTY_AZIMUTH, EMPTY_AZIMUTH, EMPTY_INCLINATION, EMPTY_INCLINATION, formatLrud((_shot$fromLruds = shot.fromLruds) === null || _shot$fromLruds === void 0 || (_shot$fromLruds = _shot$fromLruds.left) === null || _shot$fromLruds === void 0 ? void 0 : _shot$fromLruds.get(distanceUnit)), formatLrud((_shot$fromLruds2 = shot.fromLruds) === null || _shot$fromLruds2 === void 0 || (_shot$fromLruds2 = _shot$fromLruds2.right) === null || _shot$fromLruds2 === void 0 ? void 0 : _shot$fromLruds2.get(distanceUnit)), formatLrud((_shot$fromLruds3 = shot.fromLruds) === null || _shot$fromLruds3 === void 0 || (_shot$fromLruds3 = _shot$fromLruds3.up) === null || _shot$fromLruds3 === void 0 ? void 0 : _shot$fromLruds3.get(distanceUnit)), formatLrud((_shot$fromLruds4 = shot.fromLruds) === null || _shot$fromLruds4 === void 0 || (_shot$fromLruds4 = _shot$fromLruds4.down) === null || _shot$fromLruds4 === void 0 ? void 0 : _shot$fromLruds4.get(distanceUnit))].join('');
46
+ var formatLeft = formatNumber(columns.left);
47
+ var formatRight = formatNumber(columns.right);
48
+ var formatUp = formatNumber(columns.up);
49
+ var formatDown = formatNumber(columns.down);
50
+ var EMPTY_DISTANCE = ' '.repeat(columns.distance);
51
+ var formatDistance = formatNumber(columns.distance);
52
+ var EMPTY_FS_AZIMUTH = ' '.repeat(columns.frontsightAzimuth);
53
+ var formatFsAzimuth = formatNumber(columns.frontsightAzimuth);
54
+ var EMPTY_BS_AZIMUTH = ' '.repeat(columns.backsightAzimuth);
55
+ var formatBsAzimuth = formatNumber(columns.backsightAzimuth);
56
+ var EMPTY_FS_INCLINATION = ' '.repeat(columns.frontsightInclination);
57
+ var formatFsInclination = formatNumber(columns.frontsightInclination);
58
+ var EMPTY_BS_INCLINATION = ' '.repeat(columns.backsightInclination);
59
+ var formatBsInclination = formatNumber(columns.backsightInclination);
60
+ var formatVerticalDistance = formatNumber(columns.frontsightInclination);
61
+ var EMPTY_FEET = ' '.repeat(columns.distanceFeet);
62
+ function formatFeet(distance) {
63
+ if (!distance) return EMPTY_FEET;
64
+ return formatNumber(columns.distanceFeet)(Math.trunc(distance.get(_unitized.Length.feet)));
69
65
  }
70
- var distColumnValue = shot.kind === _FrcsShot.FrcsShotKind.Horizontal ? shot.horizontalDistance : shot.distance;
71
- return [formatStation(shot.to), formatStation(shot.from), inches ? formatFeet(distColumnValue) : formatDistance(distColumnValue === null || distColumnValue === void 0 ? void 0 : distColumnValue.get(distanceUnit)), inches ? formatInches(distColumnValue) : shot.kind, inches ? shot.kind : shot.excludeDistance ? '*' : ' ', formatAzimuth((_shot$frontsightAzimu = shot.frontsightAzimuth) === null || _shot$frontsightAzimu === void 0 ? void 0 : _shot$frontsightAzimu.get(azimuthUnit)), formatAzimuth((_shot$backsightAzimut = shot.backsightAzimuth) === null || _shot$backsightAzimut === void 0 ? void 0 : _shot$backsightAzimut.get(azimuthUnit)), shot.kind === _FrcsShot.FrcsShotKind.Normal ? formatInclination((_shot$frontsightIncli = shot.frontsightInclination) === null || _shot$frontsightIncli === void 0 ? void 0 : _shot$frontsightIncli.get(inclinationUnit)) : formatVerticalDistance((_shot$verticalDistanc = shot.verticalDistance) === null || _shot$verticalDistanc === void 0 ? void 0 : _shot$verticalDistanc.get(distanceUnit)), shot.kind === _FrcsShot.FrcsShotKind.Normal ? formatInclination((_shot$backsightInclin = shot.backsightInclination) === null || _shot$backsightInclin === void 0 ? void 0 : _shot$backsightInclin.get(inclinationUnit)) : EMPTY_INCLINATION, formatLrud((_shot$toLruds = shot.toLruds) === null || _shot$toLruds === void 0 || (_shot$toLruds = _shot$toLruds.left) === null || _shot$toLruds === void 0 ? void 0 : _shot$toLruds.get(distanceUnit)), formatLrud((_shot$toLruds2 = shot.toLruds) === null || _shot$toLruds2 === void 0 || (_shot$toLruds2 = _shot$toLruds2.right) === null || _shot$toLruds2 === void 0 ? void 0 : _shot$toLruds2.get(distanceUnit)), formatLrud((_shot$toLruds3 = shot.toLruds) === null || _shot$toLruds3 === void 0 || (_shot$toLruds3 = _shot$toLruds3.up) === null || _shot$toLruds3 === void 0 ? void 0 : _shot$toLruds3.get(distanceUnit)), formatLrud((_shot$toLruds4 = shot.toLruds) === null || _shot$toLruds4 === void 0 || (_shot$toLruds4 = _shot$toLruds4.down) === null || _shot$toLruds4 === void 0 ? void 0 : _shot$toLruds4.get(distanceUnit))].join('');
66
+ var EMPTY_INCHES = ' '.repeat(columns.distanceInches);
67
+ function formatInches(distance) {
68
+ if (!distance) return EMPTY_INCHES;
69
+ return formatNumber(columns.distanceInches)(Math.round(distance.get(_unitized.Length.inches) % 12));
70
+ }
71
+ return function formatFrcsShot(shot, header) {
72
+ var _shot$toLruds, _shot$toLruds2, _shot$toLruds3, _shot$toLruds4;
73
+ var azimuthUnit = header.azimuthUnit,
74
+ inclinationUnit = header.inclinationUnit;
75
+ var distanceUnit = header.distanceUnit;
76
+ var inches = distanceUnit === _unitized.Length.inches;
77
+ if (inches) distanceUnit = _unitized.Length.feet;
78
+ var isRecorded = shot.recorded !== null;
79
+ if (!shot.to) {
80
+ var _shot$recorded;
81
+ var _ref2 = ((_shot$recorded = shot.recorded) === null || _shot$recorded === void 0 ? void 0 : _shot$recorded.fromLruds) || shot.fromLruds || {},
82
+ left = _ref2.left,
83
+ right = _ref2.right,
84
+ up = _ref2.up,
85
+ down = _ref2.down;
86
+ return [EMPTY_TO_STATION, formatFromStation(shot.from), EMPTY_DISTANCE, ' ',
87
+ // kind
88
+ ' ',
89
+ // exclude
90
+ EMPTY_FS_AZIMUTH, EMPTY_BS_AZIMUTH, EMPTY_FS_INCLINATION, EMPTY_BS_INCLINATION, formatLeft(left, distanceUnit, isRecorded), formatRight(right, distanceUnit, isRecorded), formatUp(up, distanceUnit, isRecorded), formatDown(down, distanceUnit, isRecorded)].join('');
91
+ }
92
+ var distColumnValue = shot.kind === _FrcsShot.FrcsShotKind.Horizontal ? shot.horizontalDistance : shot.distance;
93
+ return [formatToStation(shot.to), formatFromStation(shot.from), inches ? formatFeet(distColumnValue) : formatDistance(distColumnValue, distanceUnit, isRecorded), inches ? formatInches(distColumnValue) : shot.kind, inches ? shot.kind : shot.excludeDistance ? '*' : ' ', formatFsAzimuth(shot.frontsightAzimuth, azimuthUnit, isRecorded), formatBsAzimuth(shot.backsightAzimuth, azimuthUnit, isRecorded), shot.kind === _FrcsShot.FrcsShotKind.Normal ? formatFsInclination(shot.frontsightInclination, inclinationUnit, isRecorded) : formatVerticalDistance(shot.verticalDistance, distanceUnit, isRecorded), shot.kind === _FrcsShot.FrcsShotKind.Normal ? formatBsInclination(shot.backsightInclination, inclinationUnit, isRecorded) : EMPTY_BS_INCLINATION, formatLeft((_shot$toLruds = shot.toLruds) === null || _shot$toLruds === void 0 ? void 0 : _shot$toLruds.left, distanceUnit, isRecorded), formatRight((_shot$toLruds2 = shot.toLruds) === null || _shot$toLruds2 === void 0 ? void 0 : _shot$toLruds2.right, distanceUnit, isRecorded), formatUp((_shot$toLruds3 = shot.toLruds) === null || _shot$toLruds3 === void 0 ? void 0 : _shot$toLruds3.up, distanceUnit, isRecorded), formatDown((_shot$toLruds4 = shot.toLruds) === null || _shot$toLruds4 === void 0 ? void 0 : _shot$toLruds4.down, distanceUnit, isRecorded)].join('');
94
+ };
72
95
  }
73
- module.exports = exports.default;
96
+ var _default = exports["default"] = makeFormatFrcsShot();
@@ -0,0 +1,2 @@
1
+ import { FrcsSurveyFile } from './FrcsSurveyFile';
2
+ export declare function formatFrcsSurveyFile(file: FrcsSurveyFile): AsyncIterable<string>;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.formatFrcsSurveyFile = formatFrcsSurveyFile;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
11
+ var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
12
+ var _unitized = require("@speleotica/unitized");
13
+ var _formatFrcsShot = require("./formatFrcsShot.js");
14
+ function formatFrcsSurveyFile(_x) {
15
+ return _formatFrcsSurveyFile.apply(this, arguments);
16
+ }
17
+ function _formatFrcsSurveyFile() {
18
+ _formatFrcsSurveyFile = (0, _wrapAsyncGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
19
+ var formatFrcsShot, tripIndex, trip, shots, header, name, team, date, comment, line2, alternateUnits, i, _shot$recorded, shot, lines, _i;
20
+ return _regenerator["default"].wrap(function _callee$(_context) {
21
+ while (1) switch (_context.prev = _context.next) {
22
+ case 0:
23
+ formatFrcsShot = (0, _formatFrcsShot.makeFormatFrcsShot)(file);
24
+ if (!file.cave) {
25
+ _context.next = 4;
26
+ break;
27
+ }
28
+ _context.next = 4;
29
+ return " ".concat(file.cave).concat(file.location ? ", ".concat(file.location) : '', "\n");
30
+ case 4:
31
+ tripIndex = 0;
32
+ case 5:
33
+ if (!(tripIndex < file.trips.length)) {
34
+ _context.next = 56;
35
+ break;
36
+ }
37
+ trip = file.trips[tripIndex];
38
+ shots = trip.shots, header = trip.header;
39
+ name = header.name, team = header.team, date = header.date, comment = header.comment;
40
+ if (!(tripIndex > 0)) {
41
+ _context.next = 12;
42
+ break;
43
+ }
44
+ _context.next = 12;
45
+ return ' *\n';
46
+ case 12:
47
+ _context.next = 14;
48
+ return name.replace(/\n?$/, '\n');
49
+ case 14:
50
+ line2 = [].concat((0, _toConsumableArray2["default"])(team !== null && team !== void 0 && team.length ? [team.join(', ')] : []), (0, _toConsumableArray2["default"])(date ? [formatDate(date)] : [])).join('. ');
51
+ if (!line2) {
52
+ _context.next = 18;
53
+ break;
54
+ }
55
+ _context.next = 18;
56
+ return "".concat(line2, "\n");
57
+ case 18:
58
+ if (!comment) {
59
+ _context.next = 21;
60
+ break;
61
+ }
62
+ _context.next = 21;
63
+ return comment.replace(/\n?$/, '\n');
64
+ case 21:
65
+ _context.next = 23;
66
+ return ' *\n';
67
+ case 23:
68
+ _context.next = 25;
69
+ return formatUnits(header);
70
+ case 25:
71
+ alternateUnits = void 0;
72
+ i = 0;
73
+ case 27:
74
+ if (!(i < shots.length)) {
75
+ _context.next = 53;
76
+ break;
77
+ }
78
+ shot = shots[i];
79
+ if (!shot.comment) {
80
+ _context.next = 42;
81
+ break;
82
+ }
83
+ lines = shot.comment.split(/\n/gm);
84
+ _context.next = 33;
85
+ return '*\n';
86
+ case 33:
87
+ _i = 0;
88
+ case 34:
89
+ if (!(_i < lines.length - 1)) {
90
+ _context.next = 40;
91
+ break;
92
+ }
93
+ _context.next = 37;
94
+ return lines[_i].replace(/\n?$/, '\n');
95
+ case 37:
96
+ _i++;
97
+ _context.next = 34;
98
+ break;
99
+ case 40:
100
+ _context.next = 42;
101
+ return "* ".concat(lines[lines.length - 1].replace(/\n?$/, '\n'));
102
+ case 42:
103
+ if (!((_shot$recorded = shot.recorded) !== null && _shot$recorded !== void 0 && _shot$recorded.units)) {
104
+ _context.next = 48;
105
+ break;
106
+ }
107
+ alternateUnits = shot.recorded.units;
108
+ _context.next = 46;
109
+ return "* %NC\n";
110
+ case 46:
111
+ _context.next = 48;
112
+ return formatUnits(shot.recorded.units);
113
+ case 48:
114
+ _context.next = 50;
115
+ return formatFrcsShot(shot.recorded || shot, alternateUnits || header).replace(/\n?$/, '\n');
116
+ case 50:
117
+ i++;
118
+ _context.next = 27;
119
+ break;
120
+ case 53:
121
+ tripIndex++;
122
+ _context.next = 5;
123
+ break;
124
+ case 56:
125
+ case "end":
126
+ return _context.stop();
127
+ }
128
+ }, _callee);
129
+ }));
130
+ return _formatFrcsSurveyFile.apply(this, arguments);
131
+ }
132
+ function formatUnits(units) {
133
+ var distUnit = formatLengthUnit(units.distanceUnit);
134
+ var azmMode = units.hasBacksightAzimuth ? units.backsightAzimuthCorrected ? 'C' : 'B' : ' ';
135
+ var incMode = units.hasBacksightInclination ? units.backsightInclinationCorrected ? 'C' : 'B' : ' ';
136
+ var azmUnit = formatAngleUnit(units.azimuthUnit);
137
+ var incUnit = formatAngleUnit(units.inclinationUnit);
138
+ return "".concat(distUnit, " ").concat(azmMode).concat(incMode, " ").concat(azmUnit).concat(incUnit, "\n");
139
+ }
140
+ function formatDate(date) {
141
+ return "".concat(date.getMonth() + 1, "/").concat(date.getDate(), "/").concat(date.getFullYear() % 100);
142
+ }
143
+ function formatLengthUnit(unit) {
144
+ switch (unit) {
145
+ case _unitized.Length.meters:
146
+ return 'M ';
147
+ case _unitized.Length.feet:
148
+ return 'FT';
149
+ case _unitized.Length.inches:
150
+ return 'FI';
151
+ default:
152
+ throw new Error("invalid length unit: ".concat(unit));
153
+ }
154
+ }
155
+ function formatAngleUnit(unit) {
156
+ switch (unit) {
157
+ case _unitized.Angle.degrees:
158
+ return 'D';
159
+ case _unitized.Angle.gradians:
160
+ return 'G';
161
+ default:
162
+ throw new Error("invalid angle unit: ".concat(unit));
163
+ }
164
+ }
package/index.d.ts CHANGED
@@ -9,4 +9,5 @@ import { FrcsTripSummary } from './FrcsTripSummary';
9
9
  import { FrcsTripSummaryFile } from './FrcsTripSummaryFile';
10
10
  import parseFrcsTripSummaryFile from './parseFrcsTripSummaryFile';
11
11
  import formatFrcsShot from './formatFrcsShot';
12
- export { FrcsShot, FrcsShotKind, FrcsSurveyFile, FrcsTrip, FrcsTripHeader, parseFrcsSurveyFile, FrcsPlotShot, FrcsPlotFile, parseFrcsPlotFile, FrcsTripSummary, FrcsTripSummaryFile, parseFrcsTripSummaryFile, formatFrcsShot, };
12
+ import { formatFrcsSurveyFile } from './formatFrcsSurveyFile';
13
+ export { FrcsShot, FrcsShotKind, FrcsSurveyFile, FrcsTrip, FrcsTripHeader, parseFrcsSurveyFile, FrcsPlotShot, FrcsPlotFile, parseFrcsPlotFile, FrcsTripSummary, FrcsTripSummaryFile, parseFrcsTripSummaryFile, formatFrcsShot, formatFrcsSurveyFile, };
package/index.js CHANGED
@@ -64,6 +64,12 @@ Object.defineProperty(exports, "formatFrcsShot", {
64
64
  return _formatFrcsShot["default"];
65
65
  }
66
66
  });
67
+ Object.defineProperty(exports, "formatFrcsSurveyFile", {
68
+ enumerable: true,
69
+ get: function get() {
70
+ return _formatFrcsSurveyFile.formatFrcsSurveyFile;
71
+ }
72
+ });
67
73
  Object.defineProperty(exports, "parseFrcsPlotFile", {
68
74
  enumerable: true,
69
75
  get: function get() {
@@ -92,4 +98,5 @@ var _parseFrcsPlotFile = _interopRequireDefault(require("./parseFrcsPlotFile.js"
92
98
  var _FrcsTripSummary = require("./FrcsTripSummary.js");
93
99
  var _FrcsTripSummaryFile = require("./FrcsTripSummaryFile.js");
94
100
  var _parseFrcsTripSummaryFile = _interopRequireDefault(require("./parseFrcsTripSummaryFile.js"));
95
- var _formatFrcsShot = _interopRequireDefault(require("./formatFrcsShot.js"));
101
+ var _formatFrcsShot = _interopRequireDefault(require("./formatFrcsShot.js"));
102
+ var _formatFrcsSurveyFile = require("./formatFrcsSurveyFile.js");
package/node/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare const parseFrcsSurveyFile: (file: string) => Promise<import("..").FrcsSurveyFile>;
1
+ export declare const parseFrcsSurveyFile: (file: string, rest_0?: import("../parseFrcsSurveyFile").ParseFrcsSurveyFileOptions | undefined) => Promise<import("..").FrcsSurveyFile>;
2
2
  export declare const parseFrcsPlotFile: (file: string) => Promise<import("..").FrcsPlotFile>;
3
3
  export declare const parseFrcsTripSummaryFile: (file: string) => Promise<import("..").FrcsTripSummaryFile>;
package/node/index.js CHANGED
@@ -12,7 +12,10 @@ var _parseFrcsPlotFile2 = _interopRequireDefault(require("../parseFrcsPlotFile.j
12
12
  var _parseFrcsTripSummaryFile2 = _interopRequireDefault(require("../parseFrcsTripSummaryFile.js"));
13
13
  var convert = function convert(fn) {
14
14
  return function (file) {
15
- return fn(file, _readline["default"].createInterface(_fs["default"].createReadStream(file)));
15
+ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
16
+ rest[_key - 1] = arguments[_key];
17
+ }
18
+ return fn.apply(void 0, [file, _readline["default"].createInterface(_fs["default"].createReadStream(file))].concat(rest));
16
19
  };
17
20
  };
18
21
  var parseFrcsSurveyFile = exports.parseFrcsSurveyFile = convert(_parseFrcsSurveyFile2["default"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speleotica/frcsdata",
3
- "version": "4.1.1",
3
+ "version": "4.3.0",
4
4
  "description": "parser for Chip Hopper's survey data format used in Fisher Ridge Cave System",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "@babel/runtime": "^7.18.6",
24
24
  "@speleotica/unitized": "^2.0.0",
25
- "parse-segment": "^1.5.1"
25
+ "parse-segment": "^1.5.4"
26
26
  },
27
27
  "main": "index.js",
28
28
  "types": "index.d.ts",
@@ -1,48 +1,51 @@
1
- import { FrcsSurveyFile } from './FrcsSurveyFile';
1
+ import { FrcsShotColumnConfig, FrcsSurveyFile } from './FrcsSurveyFile';
2
+ export type ParseFrcsSurveyFileOptions = {
3
+ columns?: FrcsShotColumnConfig;
4
+ };
2
5
  /**
3
- * Parses a raw cdata.fr survey file. These look like so:
4
- *
5
- <pre> Fisher Ridge Cave System, Hart Co., KY
6
- ENTRANCE DROPS, JOE'S "I LOVE MY WIFE TRAVERSE", TRICKY TRAVERSE
7
- PETER QUICK, KEITH ORTIZ - 2-15-81
8
- This File has Crumps test connected. 11/20/12
9
- *
10
- FT C DD A
11
- AE20 0 1 3 0 2
12
- * %FS
13
- * AE20 0 0 0 Bug-can't put before so put after-so can't make 2 fixed 10/28/12
14
- AE19 AE20 9.3 60.0 60.0-36.0 2 12 0 20
15
- AE18 AE19 24.5 0.0 0.0-90.0 6 10 25 0
16
- AE17 AE18 8.0 350.5 350.5 17.0 3 5 0 0
17
- AE16 AE17 6.7 0.0 0.0-90.0 3 5 6 1
18
- AE15 AE16 12.6 70.5 71.0-18.0 4 0 2 1
19
- AE14 AE15 10.0 21.5 20.0 6.0 5 5 0 3
20
- AE13 AE14 26.8 288.0 286.0-50.0 0 7 20 5
21
- *
22
- *SHORT CANYON AT THE BASE OF THE SECOND DROP
23
- AE12 AE13 20.7 236.0 236.0 34.0 3 5 4 4
24
- AE11 AE12 12.4 210.0 210.0 35.0 7 4 5 1
25
- AE10 AE13 25.7 40.0 40.0 -9.0 2 2 3 6
26
- *
27
- *AE10 AT JOE'S " I LOVE MY WIFE TRAVERSE "
28
- AE9 AE10 17.8 32.5 31.0 23.0 4 5 20 15
29
- AE1 AE9 13.7 82.0 82.0-13.0
30
- A1 AE1 34.3 46.0 48.0-17.5
31
- *
32
- *SURVEY TO DOME NEAR THE ENTRANCE DOME (ABOVE THE SECOND DROP)
33
- AD1 AE15 8.0 200.0 200.0 0.0 3 1 1 1
34
- AD2 AD1 17.7 161.0 161.0 7.0 1 4 25 1
35
- AD3 AD2 10.4 180.0 180.0 50.0 4 1 15 5
36
- *
37
- TRICKY TRAVERSE AND THEN FIRST SURVEY IN UPPER CROWLWAY
38
- DAN CROWL, KEITH ORTIZ, CHIP HOPPER, PETER QUICK, LARRY BEAN 14 FEB 1981
39
- *
40
- FI B DD
41
- A2 A1 48 10 292.0 110.0-42.0 5 10 35 5
42
- A3 A2 12 5 333.5 153.5 35.0 3 1 15 5
43
- A4 A3 4 2 0.0 0.0 90.0 3 1 10 10
44
- ...</pre>
45
- *
46
- */
6
+ * Parses a raw cdata.fr survey file. These look like so:
7
+ *
8
+ <pre> Fisher Ridge Cave System, Hart Co., KY
9
+ ENTRANCE DROPS, JOE'S "I LOVE MY WIFE TRAVERSE", TRICKY TRAVERSE
10
+ PETER QUICK, KEITH ORTIZ - 2-15-81
11
+ This File has Crumps test connected. 11/20/12
12
+ *
13
+ FT C DD A
14
+ AE20 0 1 3 0 2
15
+ * %FS
16
+ * AE20 0 0 0 Bug-can't put before so put after-so can't make 2 fixed 10/28/12
17
+ AE19 AE20 9.3 60.0 60.0-36.0 2 12 0 20
18
+ AE18 AE19 24.5 0.0 0.0-90.0 6 10 25 0
19
+ AE17 AE18 8.0 350.5 350.5 17.0 3 5 0 0
20
+ AE16 AE17 6.7 0.0 0.0-90.0 3 5 6 1
21
+ AE15 AE16 12.6 70.5 71.0-18.0 4 0 2 1
22
+ AE14 AE15 10.0 21.5 20.0 6.0 5 5 0 3
23
+ AE13 AE14 26.8 288.0 286.0-50.0 0 7 20 5
24
+ *
25
+ *SHORT CANYON AT THE BASE OF THE SECOND DROP
26
+ AE12 AE13 20.7 236.0 236.0 34.0 3 5 4 4
27
+ AE11 AE12 12.4 210.0 210.0 35.0 7 4 5 1
28
+ AE10 AE13 25.7 40.0 40.0 -9.0 2 2 3 6
29
+ *
30
+ *AE10 AT JOE'S " I LOVE MY WIFE TRAVERSE "
31
+ AE9 AE10 17.8 32.5 31.0 23.0 4 5 20 15
32
+ AE1 AE9 13.7 82.0 82.0-13.0
33
+ A1 AE1 34.3 46.0 48.0-17.5
34
+ *
35
+ *SURVEY TO DOME NEAR THE ENTRANCE DOME (ABOVE THE SECOND DROP)
36
+ AD1 AE15 8.0 200.0 200.0 0.0 3 1 1 1
37
+ AD2 AD1 17.7 161.0 161.0 7.0 1 4 25 1
38
+ AD3 AD2 10.4 180.0 180.0 50.0 4 1 15 5
39
+ *
40
+ TRICKY TRAVERSE AND THEN FIRST SURVEY IN UPPER CROWLWAY
41
+ DAN CROWL, KEITH ORTIZ, CHIP HOPPER, PETER QUICK, LARRY BEAN 14 FEB 1981
42
+ *
43
+ FI B DD
44
+ A2 A1 48 10 292.0 110.0-42.0 5 10 35 5
45
+ A3 A2 12 5 333.5 153.5 35.0 3 1 15 5
46
+ A4 A3 4 2 0.0 0.0 90.0 3 1 10 10
47
+ ...</pre>
48
+ *
49
+ */
47
50
  export default function parseFrcsSurveyFile(file: any, // eslint-disable-line @typescript-eslint/no-explicit-any
48
- lines: AsyncIterable<string>): Promise<FrcsSurveyFile>;
51
+ lines: AsyncIterable<string>, { columns }?: ParseFrcsSurveyFileOptions): Promise<FrcsSurveyFile>;