@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZodFrcsSurveyFileToJson.js","names":["_unitized","require","_zod","_interopRequireDefault","_ParseIssue","ZodLengthUnit","z","Unit","transform","unit","Length","meters","kilometers","centimeters","feet","inches","yards","miles","Error","ZodAngleUnit","Angle","degrees","radians","gradians","milsNATO","percentGrade","ZodLength","UnitizedNumber","length","get","parse","ZodAngle","angle","ZodSourceLoc","strictObject","start","index","number","line","column","end","ZodFrcsShotBase","from","string","to","optional","specialKind","distance","horizontalDistance","verticalDistance","frontsightAzimuth","frontsightInclination","backsightAzimuth","backsightInclination","fromLruds","left","right","up","down","toLruds","excludeDistance","b","undefined","isSplay","comment","loc","locs","ZodFrcsUnits","distanceUnit","azimuthUnit","inclinationUnit","backsightAzimuthCorrected","backsightInclinationCorrected","hasBacksightAzimuth","hasBacksightInclination","ZodFrcsShot","extend","recorded","units","ZodDate","date","d","toISOString","substring","ZodFrcsTripHeader","name","section","team","array","ZodFrcsTrip","tripNumber","min","header","shots","ZodFrcsSurveyFileToJson","exports","cave","columns","toStation","fromStation","distanceFeet","distanceInches","kind","exclude","location","trips","issues","ParseIssue","Invalid","schema","INVALID","ZodInvalidFrcsShot","partial","ZodInvalidFrcsUnits","ZodInvalidFrcsTripHeader","ZodInvalidFrcsTrip","union","ZodInvalidFrcsSurveyFileToJson","ZodValidOrInvalidFrcsSurveyFileToJson"],"sources":["../../src/survey/ZodFrcsSurveyFileToJson.ts"],"sourcesContent":["import { Angle, Length, Unit, UnitizedNumber } from '@speleotica/unitized'\nimport z from 'zod'\nimport type { DeepMapJson, JsonAngle, JsonLength } from './FrcsSurveyFileJson'\nimport type { SourceLoc } from '../SourceLoc'\nimport type {\n FrcsShot,\n FrcsSurveyFile,\n FrcsTrip,\n FrcsTripHeader,\n FrcsUnits,\n InvalidFrcsShot,\n InvalidFrcsSurveyFile,\n InvalidFrcsTrip,\n InvalidFrcsTripHeader,\n InvalidFrcsUnits,\n} from './FrcsSurveyFile'\nimport { ParseIssue } from '../ParseIssue'\n\ntype DeepMapJsonSchema<T> = z.ZodType<DeepMapJson<T>, any, T>\n\nconst ZodLengthUnit = z\n .instanceof<typeof Unit<Length>>(Unit)\n .transform((unit) => {\n switch (unit) {\n case Length.meters:\n return 'm'\n case Length.kilometers:\n return 'km'\n case Length.centimeters:\n return 'cm'\n case Length.feet:\n return 'ft'\n case Length.inches:\n return 'in'\n case Length.yards:\n return 'yd'\n case Length.miles:\n return 'mi'\n }\n throw new Error('invalid unit')\n })\n\nZodLengthUnit satisfies DeepMapJsonSchema<Unit<Length>>\n\nconst ZodAngleUnit = z\n .instanceof<typeof Unit<Angle>>(Unit)\n .transform((unit) => {\n switch (unit) {\n case Angle.degrees:\n return 'deg'\n case Angle.radians:\n return 'rad'\n case Angle.gradians:\n return 'grad'\n case Angle.milsNATO:\n return 'mil'\n case Angle.percentGrade:\n return '%'\n }\n throw new Error('invalid unit')\n })\n\nZodAngleUnit satisfies DeepMapJsonSchema<Unit<Angle>>\n\nconst ZodLength = z\n .instanceof<typeof UnitizedNumber<Length>>(UnitizedNumber)\n .transform(\n (length) =>\n [\n length.get(length.unit),\n ZodLengthUnit.parse(length.unit),\n ] satisfies JsonLength\n )\n\nZodLength satisfies DeepMapJsonSchema<UnitizedNumber<Length>>\n\nconst ZodAngle = z\n .instanceof<typeof UnitizedNumber<Angle>>(UnitizedNumber)\n .transform(\n (angle) =>\n [\n angle.get(angle.unit),\n ZodAngleUnit.parse(angle.unit),\n ] satisfies JsonAngle\n )\n\nZodAngle satisfies DeepMapJsonSchema<UnitizedNumber<Angle>>\n\nconst ZodSourceLoc = z.strictObject({\n start: z.strictObject({\n index: z.number(),\n line: z.number(),\n column: z.number(),\n }),\n end: z.strictObject({\n index: z.number(),\n line: z.number(),\n column: z.number(),\n }),\n})\n\nZodSourceLoc satisfies DeepMapJsonSchema<SourceLoc>\n\nconst ZodFrcsShotBase = z.strictObject({\n from: z.string(),\n to: z.string().optional(),\n specialKind: z.enum(['horizontal', 'diagonal']).optional(),\n distance: ZodLength,\n horizontalDistance: ZodLength.optional(),\n verticalDistance: ZodLength.optional(),\n frontsightAzimuth: ZodAngle.optional(),\n frontsightInclination: ZodAngle.optional(),\n backsightAzimuth: ZodAngle.optional(),\n backsightInclination: ZodAngle.optional(),\n /**\n * LRUDs at from station\n */\n fromLruds: z\n .strictObject({\n left: ZodLength.optional(),\n right: ZodLength.optional(),\n up: ZodLength.optional(),\n down: ZodLength.optional(),\n })\n .optional(),\n /**\n * LRUDs at to station\n */\n toLruds: z\n .strictObject({\n left: ZodLength.optional(),\n right: ZodLength.optional(),\n up: ZodLength.optional(),\n down: ZodLength.optional(),\n })\n .optional(),\n\n excludeDistance: z\n .boolean()\n .optional()\n .transform((b) => b || undefined),\n isSplay: z\n .boolean()\n .optional()\n .transform((b) => b || undefined),\n comment: z.string().optional(),\n loc: ZodSourceLoc.optional(),\n locs: z\n .strictObject({\n comment: ZodSourceLoc.optional(),\n })\n .optional(),\n})\n\nconst ZodFrcsUnits = z.strictObject({\n distanceUnit: ZodLengthUnit,\n azimuthUnit: ZodAngleUnit,\n inclinationUnit: ZodAngleUnit,\n backsightAzimuthCorrected: z.boolean().optional(),\n backsightInclinationCorrected: z.boolean().optional(),\n hasBacksightAzimuth: z.boolean().optional(),\n hasBacksightInclination: z.boolean().optional(),\n loc: ZodSourceLoc.optional(),\n locs: z\n .strictObject({\n distanceUnit: ZodSourceLoc.optional(),\n azimuthUnit: ZodSourceLoc.optional(),\n inclinationUnit: ZodSourceLoc.optional(),\n backsightAzimuthCorrected: ZodSourceLoc.optional(),\n backsightInclinationCorrected: ZodSourceLoc.optional(),\n hasBacksightAzimuth: ZodSourceLoc.optional(),\n hasBacksightInclination: ZodSourceLoc.optional(),\n })\n .optional(),\n})\n\nZodFrcsUnits satisfies DeepMapJsonSchema<FrcsUnits>\n\nconst ZodFrcsShot = ZodFrcsShotBase.extend({\n recorded: ZodFrcsShotBase.extend({\n units: ZodFrcsUnits.optional(),\n }).optional(),\n})\n\nZodFrcsShot satisfies DeepMapJsonSchema<FrcsShot>\n\nconst ZodDate = z.date().transform((d) => d.toISOString().substring(0, 10))\n\nconst ZodFrcsTripHeader = z.strictObject({\n name: z.string(),\n comment: z.string().optional(),\n section: z.string().optional(),\n date: ZodDate.optional(),\n team: z.array(z.string()).optional(),\n loc: ZodSourceLoc.optional(),\n locs: z\n .strictObject({\n name: ZodSourceLoc,\n comment: ZodSourceLoc.optional(),\n section: ZodSourceLoc.optional(),\n date: ZodSourceLoc.optional(),\n team: z.array(ZodSourceLoc).optional(),\n })\n .optional(),\n})\n\nZodFrcsTripHeader satisfies DeepMapJsonSchema<FrcsTripHeader>\n\nconst ZodFrcsTrip = z.strictObject({\n tripNumber: z.number().int().min(1),\n header: ZodFrcsTripHeader,\n units: ZodFrcsUnits,\n shots: z.array(ZodFrcsShot),\n loc: ZodSourceLoc.optional(),\n})\n\nZodFrcsTrip satisfies DeepMapJsonSchema<FrcsTrip>\n\nexport const ZodFrcsSurveyFileToJson = z.strictObject({\n cave: z.string().optional(),\n columns: z\n .strictObject({\n toStation: z.number(),\n fromStation: z.number(),\n distance: z.number(),\n distanceFeet: z.number(),\n distanceInches: z.number(),\n kind: z.number(),\n exclude: z.number(),\n frontsightAzimuth: z.number(),\n backsightAzimuth: z.number(),\n frontsightInclination: z.number(),\n backsightInclination: z.number(),\n left: z.number(),\n right: z.number(),\n up: z.number(),\n down: z.number(),\n })\n .optional(),\n location: z.string().optional(),\n comment: z.string().optional(),\n trips: z.array(ZodFrcsTrip),\n locs: z\n .strictObject({\n cave: ZodSourceLoc.optional(),\n location: ZodSourceLoc.optional(),\n comment: ZodSourceLoc.optional(),\n })\n .optional(),\n issues: z.array(ParseIssue).optional(),\n})\n\nZodFrcsSurveyFileToJson satisfies DeepMapJsonSchema<FrcsSurveyFile>\n\nfunction Invalid<T extends z.ZodTypeAny>(schema: T) {\n return z.strictObject({\n INVALID: schema,\n issues: z.array(z.number()).optional(),\n })\n}\n\nconst ZodInvalidFrcsShot = Invalid(ZodFrcsShot.partial())\n\nZodInvalidFrcsShot satisfies DeepMapJsonSchema<InvalidFrcsShot>\n\nconst ZodInvalidFrcsUnits = Invalid(ZodFrcsUnits.partial())\n\nZodInvalidFrcsUnits satisfies DeepMapJsonSchema<InvalidFrcsUnits>\n\nconst ZodInvalidFrcsTripHeader = Invalid(ZodFrcsTripHeader.partial())\n\nZodInvalidFrcsTripHeader satisfies DeepMapJsonSchema<InvalidFrcsTripHeader>\n\nconst ZodInvalidFrcsTrip = Invalid(\n z.strictObject({\n tripNumber: z.number().int().min(1).optional(),\n header: z.union([ZodInvalidFrcsTripHeader, ZodFrcsTripHeader]),\n units: z.union([ZodInvalidFrcsUnits, ZodFrcsUnits]),\n shots: z.array(z.union([ZodInvalidFrcsShot, ZodFrcsShot])),\n })\n)\n\nZodInvalidFrcsTrip satisfies DeepMapJsonSchema<InvalidFrcsTrip>\n\nexport const ZodInvalidFrcsSurveyFileToJson = z.strictObject({\n INVALID: ZodFrcsSurveyFileToJson.extend({\n trips: z.array(z.union([ZodInvalidFrcsTrip, ZodFrcsTrip])),\n }),\n issues: z.array(ParseIssue),\n})\n\nZodInvalidFrcsSurveyFileToJson satisfies DeepMapJsonSchema<InvalidFrcsSurveyFile>\n\nexport const ZodValidOrInvalidFrcsSurveyFileToJson = z.union([\n ZodInvalidFrcsSurveyFileToJson,\n ZodFrcsSurveyFileTo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H,eAAC,CAAC8G,KAAK,CAAC,CAC3DC,8BAA8B,EAC9BvB,uBAAuB,CACxB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ZodFrcsSurveyFileToJson.js","names":["_unitized","require","_zod","_interopRequireDefault","_ParseIssue","ZodLengthUnit","z","instanceof","Unit","transform","unit","Length","meters","kilometers","centimeters","feet","inches","yards","miles","Error","ZodAngleUnit","Angle","degrees","radians","gradians","milsNATO","percentGrade","ZodLength","UnitizedNumber","length","get","parse","ZodAngle","angle","ZodSourceLoc","strictObject","start","index","number","line","column","end","ZodFrcsShotBase","from","string","to","optional","specialKind","enum","distance","horizontalDistance","verticalDistance","frontsightAzimuth","frontsightInclination","backsightAzimuth","backsightInclination","fromLruds","left","right","up","down","toLruds","excludeDistance","boolean","b","undefined","isSplay","comment","loc","locs","ZodFrcsUnits","distanceUnit","azimuthUnit","inclinationUnit","backsightAzimuthCorrected","backsightInclinationCorrected","hasBacksightAzimuth","hasBacksightInclination","ZodFrcsShot","extend","recorded","units","ZodDate","date","d","toISOString","substring","ZodFrcsTripHeader","name","section","team","array","ZodFrcsTrip","tripNumber","int","min","header","shots","ZodFrcsSurveyFileToJson","exports","cave","columns","toStation","fromStation","distanceFeet","distanceInches","kind","exclude","location","trips","issues","ParseIssue","Invalid","schema","INVALID","ZodInvalidFrcsUnits","partial","ZodInvalidFrcsShot","union","shape","ZodInvalidFrcsTripHeader","ZodInvalidFrcsTrip","ZodInvalidFrcsSurveyFileToJson","ZodValidOrInvalidFrcsSurveyFileToJson"],"sources":["../../src/survey/ZodFrcsSurveyFileToJson.ts"],"sourcesContent":["import { Angle, Length, Unit, UnitizedNumber } from '@speleotica/unitized'\nimport z from 'zod'\nimport type { DeepMapJson, JsonAngle, JsonLength } from './FrcsSurveyFileJson'\nimport type { SourceLoc } from '../SourceLoc'\nimport type {\n FrcsShot,\n FrcsSurveyFile,\n FrcsTrip,\n FrcsTripHeader,\n FrcsUnits,\n InvalidFrcsShot,\n InvalidFrcsSurveyFile,\n InvalidFrcsTrip,\n InvalidFrcsTripHeader,\n InvalidFrcsUnits,\n} from './FrcsSurveyFile'\nimport { ParseIssue } from '../ParseIssue'\n\ntype DeepMapJsonSchema<T> = z.ZodType<DeepMapJson<T>, any, T>\n\nconst ZodLengthUnit = z\n .instanceof<typeof Unit<Length>>(Unit)\n .transform((unit) => {\n switch (unit) {\n case Length.meters:\n return 'm'\n case Length.kilometers:\n return 'km'\n case Length.centimeters:\n return 'cm'\n case Length.feet:\n return 'ft'\n case Length.inches:\n return 'in'\n case Length.yards:\n return 'yd'\n case Length.miles:\n return 'mi'\n }\n throw new Error('invalid unit')\n })\n\nZodLengthUnit satisfies DeepMapJsonSchema<Unit<Length>>\n\nconst ZodAngleUnit = z\n .instanceof<typeof Unit<Angle>>(Unit)\n .transform((unit) => {\n switch (unit) {\n case Angle.degrees:\n return 'deg'\n case Angle.radians:\n return 'rad'\n case Angle.gradians:\n return 'grad'\n case Angle.milsNATO:\n return 'mil'\n case Angle.percentGrade:\n return '%'\n }\n throw new Error('invalid unit')\n })\n\nZodAngleUnit satisfies DeepMapJsonSchema<Unit<Angle>>\n\nconst ZodLength = z\n .instanceof<typeof UnitizedNumber<Length>>(UnitizedNumber)\n .transform(\n (length) =>\n [\n length.get(length.unit),\n ZodLengthUnit.parse(length.unit),\n ] satisfies JsonLength\n )\n\nZodLength satisfies DeepMapJsonSchema<UnitizedNumber<Length>>\n\nconst ZodAngle = z\n .instanceof<typeof UnitizedNumber<Angle>>(UnitizedNumber)\n .transform(\n (angle) =>\n [\n angle.get(angle.unit),\n ZodAngleUnit.parse(angle.unit),\n ] satisfies JsonAngle\n )\n\nZodAngle satisfies DeepMapJsonSchema<UnitizedNumber<Angle>>\n\nconst ZodSourceLoc = z.strictObject({\n start: z.strictObject({\n index: z.number(),\n line: z.number(),\n column: z.number(),\n }),\n end: z.strictObject({\n index: z.number(),\n line: z.number(),\n column: z.number(),\n }),\n})\n\nZodSourceLoc satisfies DeepMapJsonSchema<SourceLoc>\n\nconst ZodFrcsShotBase = z.strictObject({\n from: z.string(),\n to: z.string().optional(),\n specialKind: z.enum(['horizontal', 'diagonal']).optional(),\n distance: ZodLength,\n horizontalDistance: ZodLength.optional(),\n verticalDistance: ZodLength.optional(),\n frontsightAzimuth: ZodAngle.optional(),\n frontsightInclination: ZodAngle.optional(),\n backsightAzimuth: ZodAngle.optional(),\n backsightInclination: ZodAngle.optional(),\n /**\n * LRUDs at from station\n */\n fromLruds: z\n .strictObject({\n left: ZodLength.optional(),\n right: ZodLength.optional(),\n up: ZodLength.optional(),\n down: ZodLength.optional(),\n })\n .optional(),\n /**\n * LRUDs at to station\n */\n toLruds: z\n .strictObject({\n left: ZodLength.optional(),\n right: ZodLength.optional(),\n up: ZodLength.optional(),\n down: ZodLength.optional(),\n })\n .optional(),\n\n excludeDistance: z\n .boolean()\n .optional()\n .transform((b) => b || undefined),\n isSplay: z\n .boolean()\n .optional()\n .transform((b) => b || undefined),\n comment: z.string().optional(),\n loc: ZodSourceLoc.optional(),\n locs: z\n .strictObject({\n comment: ZodSourceLoc.optional(),\n })\n .optional(),\n})\n\nconst ZodFrcsUnits = z.strictObject({\n distanceUnit: ZodLengthUnit,\n azimuthUnit: ZodAngleUnit,\n inclinationUnit: ZodAngleUnit,\n backsightAzimuthCorrected: z.boolean().optional(),\n backsightInclinationCorrected: z.boolean().optional(),\n hasBacksightAzimuth: z.boolean().optional(),\n hasBacksightInclination: z.boolean().optional(),\n loc: ZodSourceLoc.optional(),\n locs: z\n .strictObject({\n distanceUnit: ZodSourceLoc.optional(),\n azimuthUnit: ZodSourceLoc.optional(),\n inclinationUnit: ZodSourceLoc.optional(),\n backsightAzimuthCorrected: ZodSourceLoc.optional(),\n backsightInclinationCorrected: ZodSourceLoc.optional(),\n hasBacksightAzimuth: ZodSourceLoc.optional(),\n hasBacksightInclination: ZodSourceLoc.optional(),\n })\n .optional(),\n})\n\nZodFrcsUnits satisfies DeepMapJsonSchema<FrcsUnits>\n\nconst ZodFrcsShot = ZodFrcsShotBase.extend({\n recorded: ZodFrcsShotBase.extend({\n units: ZodFrcsUnits.optional(),\n }).optional(),\n})\n\nZodFrcsShot satisfies DeepMapJsonSchema<FrcsShot>\n\nconst ZodDate = z.date().transform((d) => d.toISOString().substring(0, 10))\n\nconst ZodFrcsTripHeader = z.strictObject({\n name: z.string(),\n comment: z.string().optional(),\n section: z.string().optional(),\n date: ZodDate.optional(),\n team: z.array(z.string()).optional(),\n loc: ZodSourceLoc.optional(),\n locs: z\n .strictObject({\n name: ZodSourceLoc,\n comment: ZodSourceLoc.optional(),\n section: ZodSourceLoc.optional(),\n date: ZodSourceLoc.optional(),\n team: z.array(ZodSourceLoc).optional(),\n })\n .optional(),\n})\n\nZodFrcsTripHeader satisfies DeepMapJsonSchema<FrcsTripHeader>\n\nconst ZodFrcsTrip = z.strictObject({\n tripNumber: z.number().int().min(1),\n header: ZodFrcsTripHeader,\n units: ZodFrcsUnits,\n shots: z.array(ZodFrcsShot),\n loc: ZodSourceLoc.optional(),\n})\n\nZodFrcsTrip satisfies DeepMapJsonSchema<FrcsTrip>\n\nexport const ZodFrcsSurveyFileToJson = z.strictObject({\n cave: z.string().optional(),\n columns: z\n .strictObject({\n toStation: z.number(),\n fromStation: z.number(),\n distance: z.number(),\n distanceFeet: z.number(),\n distanceInches: z.number(),\n kind: z.number(),\n exclude: z.number(),\n frontsightAzimuth: z.number(),\n backsightAzimuth: z.number(),\n frontsightInclination: z.number(),\n backsightInclination: z.number(),\n left: z.number(),\n right: z.number(),\n up: z.number(),\n down: z.number(),\n })\n .optional(),\n location: z.string().optional(),\n comment: z.string().optional(),\n trips: z.array(ZodFrcsTrip),\n locs: z\n .strictObject({\n cave: ZodSourceLoc.optional(),\n location: ZodSourceLoc.optional(),\n comment: ZodSourceLoc.optional(),\n })\n .optional(),\n issues: z.array(ParseIssue).optional(),\n})\n\nZodFrcsSurveyFileToJson satisfies DeepMapJsonSchema<FrcsSurveyFile>\n\nfunction Invalid<T extends z.ZodTypeAny>(schema: T) {\n return z.strictObject({\n INVALID: schema,\n issues: z.array(z.number()).optional(),\n })\n}\n\nconst ZodInvalidFrcsUnits = Invalid(ZodFrcsUnits.partial())\n\nZodInvalidFrcsUnits satisfies DeepMapJsonSchema<InvalidFrcsUnits>\n\nconst ZodInvalidFrcsShot = Invalid(\n ZodFrcsShot.extend({\n recorded: z.union([\n ZodFrcsShot.shape.recorded,\n Invalid(\n ZodFrcsShotBase.extend({\n units: z.union([ZodFrcsUnits, ZodInvalidFrcsUnits]),\n }).partial()\n ),\n ]),\n }).partial()\n)\n\nZodInvalidFrcsShot satisfies DeepMapJsonSchema<InvalidFrcsShot>\n\nconst ZodInvalidFrcsTripHeader = Invalid(ZodFrcsTripHeader.partial())\n\nZodInvalidFrcsTripHeader satisfies DeepMapJsonSchema<InvalidFrcsTripHeader>\n\nconst ZodInvalidFrcsTrip = Invalid(\n z.strictObject({\n tripNumber: z.number().int().min(1).optional(),\n header: z.union([ZodInvalidFrcsTripHeader, ZodFrcsTripHeader]),\n units: z.union([ZodInvalidFrcsUnits, ZodFrcsUnits]),\n shots: z.array(z.union([ZodInvalidFrcsShot, ZodFrcsShot])),\n })\n)\n\nZodInvalidFrcsTrip satisfies DeepMapJsonSchema<InvalidFrcsTrip>\n\nexport const ZodInvalidFrcsSurveyFileToJson = z.strictObject({\n INVALID: ZodFrcsSurveyFileToJson.extend({\n trips: z.array(z.union([ZodInvalidFrcsTrip, ZodFrcsTrip])),\n }),\n issues: z.array(ParseIssue),\n})\n\nZodInvalidFrcsSurveyFileToJson satisfies DeepMapJsonSchema<InvalidFrcsSurveyFile>\n\nexport const ZodValidOrInvalidFrcsSurveyFileToJson = z.union([\n ZodInvalidFrcsSurveyFileToJson,\n ZodFrcsSurveyFileToJson,\n])\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AAeA,IAAAG,WAAA,GAAAH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AACqF,KAAK,CAACoB,sBAAU;AAC5B,CAAC,CAAC;AAEFW,8BAA8B;AAEvB,MAAMC,qCAAqC,GAAAxB,OAAA,CAAAwB,qCAAA,GAAGrH,YAAC,CAACgH,KAAK,CAAC,CAC3DI,8BAA8B,EAC9BxB,uBAAuB,CACxB,CAAC","ignoreList":[]}
|
package/survey/formatFrcsShot.js
CHANGED
|
@@ -3,24 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
exports.makeFormatFrcsShot = makeFormatFrcsShot;
|
|
8
8
|
var _unitized = require("@speleotica/unitized");
|
|
9
9
|
var _FrcsSurveyFile = require("./FrcsSurveyFile.js");
|
|
10
|
-
function makeFormatFrcsShot(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var EMPTY_TO_STATION = ' '.repeat(columns.toStation);
|
|
10
|
+
function makeFormatFrcsShot({
|
|
11
|
+
columns = _FrcsSurveyFile.defaultFrcsShotColumnConfig
|
|
12
|
+
} = {}) {
|
|
13
|
+
const EMPTY_TO_STATION = ' '.repeat(columns.toStation);
|
|
15
14
|
function formatFromStation(station) {
|
|
16
15
|
if (station.length > columns.fromStation) {
|
|
17
|
-
throw new Error(
|
|
16
|
+
throw new Error(`station is too long: ${station}`);
|
|
18
17
|
}
|
|
19
18
|
return station.padStart(columns.fromStation, ' ');
|
|
20
19
|
}
|
|
21
20
|
function formatToStation(station) {
|
|
22
21
|
if (station.length > columns.toStation) {
|
|
23
|
-
throw new Error(
|
|
22
|
+
throw new Error(`station is too long: ${station}`);
|
|
24
23
|
}
|
|
25
24
|
return station.padStart(columns.toStation, ' ');
|
|
26
25
|
}
|
|
@@ -34,72 +33,75 @@ function makeFormatFrcsShot() {
|
|
|
34
33
|
return ' ';
|
|
35
34
|
}
|
|
36
35
|
function trimZeroes(str) {
|
|
37
|
-
|
|
36
|
+
const match = /(-?\d+)(\.[1-9]*)0+$/.exec(str);
|
|
38
37
|
if (!match) return str;
|
|
39
38
|
return match[2].length > 1 ? match[1] + match[2] : match[1];
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
const formatNumber = width => {
|
|
42
41
|
function formatNum(num, unit, verbatim) {
|
|
43
42
|
if (num instanceof _unitized.UnitizedNumber) {
|
|
44
43
|
return formatNum(num.get(verbatim ? num.unit : unit || num.unit));
|
|
45
44
|
}
|
|
46
45
|
if (num == null || !Number.isFinite(num)) return ' '.repeat(width);
|
|
47
|
-
|
|
46
|
+
const formatted = trimZeroes(num.toFixed(2));
|
|
48
47
|
if (formatted.length <= width) return formatted.padStart(width, ' ');
|
|
49
48
|
if (formatted.length > width + 2) return formatted.substring(0, width);
|
|
50
49
|
return trimZeroes(num.toFixed(2 - formatted.length + width)).padStart(width, ' ');
|
|
51
50
|
}
|
|
52
51
|
return formatNum;
|
|
53
52
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
const formatLeft = formatNumber(columns.left);
|
|
54
|
+
const formatRight = formatNumber(columns.right);
|
|
55
|
+
const formatUp = formatNumber(columns.up);
|
|
56
|
+
const formatDown = formatNumber(columns.down);
|
|
57
|
+
const EMPTY_DISTANCE = ' '.repeat(columns.distance);
|
|
58
|
+
const formatDistance = formatNumber(columns.distance);
|
|
59
|
+
const EMPTY_FS_AZIMUTH = ' '.repeat(columns.frontsightAzimuth);
|
|
60
|
+
const formatFsAzimuth = formatNumber(columns.frontsightAzimuth);
|
|
61
|
+
const EMPTY_BS_AZIMUTH = ' '.repeat(columns.backsightAzimuth);
|
|
62
|
+
const formatBsAzimuth = formatNumber(columns.backsightAzimuth);
|
|
63
|
+
const EMPTY_FS_INCLINATION = ' '.repeat(columns.frontsightInclination);
|
|
64
|
+
const formatFsInclination = formatNumber(columns.frontsightInclination);
|
|
65
|
+
const EMPTY_BS_INCLINATION = ' '.repeat(columns.backsightInclination);
|
|
66
|
+
const formatBsInclination = formatNumber(columns.backsightInclination);
|
|
67
|
+
const formatVerticalDistance = formatNumber(columns.frontsightInclination);
|
|
68
|
+
const EMPTY_FEET = ' '.repeat(columns.distanceFeet);
|
|
70
69
|
function formatFeet(distance) {
|
|
71
70
|
if (!distance) return EMPTY_FEET;
|
|
72
71
|
return formatNumber(columns.distanceFeet)(Math.trunc(distance.get(_unitized.Length.feet)));
|
|
73
72
|
}
|
|
74
|
-
|
|
73
|
+
const EMPTY_INCHES = ' '.repeat(columns.distanceInches);
|
|
75
74
|
function formatInches(distance) {
|
|
76
75
|
if (!distance) return EMPTY_INCHES;
|
|
77
76
|
return formatNumber(columns.distanceInches)(Math.round(distance.get(_unitized.Length.inches) % 12));
|
|
78
77
|
}
|
|
79
78
|
return function formatFrcsShot(shot, header) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
inclinationUnit
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
const {
|
|
80
|
+
azimuthUnit,
|
|
81
|
+
inclinationUnit
|
|
82
|
+
} = header;
|
|
83
|
+
let {
|
|
84
|
+
distanceUnit
|
|
85
|
+
} = header;
|
|
86
|
+
const inches = distanceUnit === _unitized.Length.inches;
|
|
85
87
|
if (inches) distanceUnit = _unitized.Length.feet;
|
|
86
|
-
|
|
88
|
+
const isRecorded = shot.recorded !== null;
|
|
87
89
|
if (!shot.to) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
const {
|
|
91
|
+
left,
|
|
92
|
+
right,
|
|
93
|
+
up,
|
|
94
|
+
down
|
|
95
|
+
} = shot.recorded?.fromLruds || shot.fromLruds || {};
|
|
94
96
|
return [EMPTY_TO_STATION, formatFromStation(shot.from), EMPTY_DISTANCE, ' ',
|
|
95
97
|
// kind
|
|
96
98
|
' ',
|
|
97
99
|
// exclude
|
|
98
100
|
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('');
|
|
99
101
|
}
|
|
100
|
-
|
|
101
|
-
return [formatToStation(shot.to), formatFromStation(shot.from), inches ? formatFeet(distColumnValue) : formatDistance(distColumnValue, distanceUnit, isRecorded), inches ? formatInches(distColumnValue) : formatSpecialKind(shot.specialKind), inches ? formatSpecialKind(shot.specialKind) : shot.excludeDistance ? '*' : ' ', formatFsAzimuth(shot.frontsightAzimuth, azimuthUnit, isRecorded), formatBsAzimuth(shot.backsightAzimuth, azimuthUnit, isRecorded), shot.specialKind ? formatVerticalDistance(shot.verticalDistance, distanceUnit, isRecorded) : formatFsInclination(shot.frontsightInclination, inclinationUnit, isRecorded), shot.specialKind ? EMPTY_BS_INCLINATION : formatBsInclination(shot.backsightInclination, inclinationUnit, isRecorded), formatLeft(
|
|
102
|
+
const distColumnValue = shot.specialKind === 'horizontal' ? shot.horizontalDistance : shot.distance;
|
|
103
|
+
return [formatToStation(shot.to), formatFromStation(shot.from), inches ? formatFeet(distColumnValue) : formatDistance(distColumnValue, distanceUnit, isRecorded), inches ? formatInches(distColumnValue) : formatSpecialKind(shot.specialKind), inches ? formatSpecialKind(shot.specialKind) : shot.excludeDistance ? '*' : ' ', formatFsAzimuth(shot.frontsightAzimuth, azimuthUnit, isRecorded), formatBsAzimuth(shot.backsightAzimuth, azimuthUnit, isRecorded), shot.specialKind ? formatVerticalDistance(shot.verticalDistance, distanceUnit, isRecorded) : formatFsInclination(shot.frontsightInclination, inclinationUnit, isRecorded), shot.specialKind ? EMPTY_BS_INCLINATION : formatBsInclination(shot.backsightInclination, inclinationUnit, isRecorded), formatLeft(shot.toLruds?.left, distanceUnit, isRecorded), formatRight(shot.toLruds?.right, distanceUnit, isRecorded), formatUp(shot.toLruds?.up, distanceUnit, isRecorded), formatDown(shot.toLruds?.down, distanceUnit, isRecorded)].join('');
|
|
102
104
|
};
|
|
103
105
|
}
|
|
104
|
-
var _default = exports
|
|
106
|
+
var _default = exports.default = makeFormatFrcsShot();
|
|
105
107
|
//# sourceMappingURL=formatFrcsShot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatFrcsShot.js","names":["_unitized","require","_FrcsSurveyFile","makeFormatFrcsShot","_ref","arguments","length","undefined","_ref$columns","columns","defaultFrcsShotColumnConfig","EMPTY_TO_STATION","repeat","toStation","formatFromStation","station","fromStation","Error","concat","padStart","formatToStation","formatSpecialKind","specialKind","trimZeroes","str","match","exec","formatNumber","width","formatNum","num","unit","verbatim","UnitizedNumber","get","Number","isFinite","formatted","toFixed","substring","formatLeft","left","formatRight","right","formatUp","up","formatDown","down","EMPTY_DISTANCE","distance","formatDistance","EMPTY_FS_AZIMUTH","frontsightAzimuth","formatFsAzimuth","EMPTY_BS_AZIMUTH","backsightAzimuth","formatBsAzimuth","EMPTY_FS_INCLINATION","frontsightInclination","formatFsInclination","EMPTY_BS_INCLINATION","backsightInclination","formatBsInclination","formatVerticalDistance","EMPTY_FEET","distanceFeet","formatFeet","Math","trunc","Length","feet","EMPTY_INCHES","distanceInches","formatInches","round","inches","formatFrcsShot","shot","header","_shot$toLruds","_shot$toLruds2","_shot$toLruds3","_shot$toLruds4","azimuthUnit","inclinationUnit","distanceUnit","isRecorded","recorded","to","_shot$recorded","_ref2","fromLruds","from","join","distColumnValue","horizontalDistance","excludeDistance","verticalDistance","toLruds","_default","exports"],"sources":["../../src/survey/formatFrcsShot.ts"],"sourcesContent":["import type { FrcsUnits, FrcsShot } from './FrcsSurveyFile'\nimport { Length, Unit, UnitType, UnitizedNumber } from '@speleotica/unitized'\nimport {\n type FrcsShotColumnConfig,\n defaultFrcsShotColumnConfig,\n} from './FrcsSurveyFile'\n\nexport function makeFormatFrcsShot({\n columns = defaultFrcsShotColumnConfig,\n}: { columns?: FrcsShotColumnConfig } = {}) {\n const EMPTY_TO_STATION = ' '.repeat(columns.toStation)\n\n function formatFromStation(station: string): string {\n if (station.length > columns.fromStation) {\n throw new Error(`station is too long: ${station}`)\n }\n return station.padStart(columns.fromStation, ' ')\n }\n function formatToStation(station: string): string {\n if (station.length > columns.toStation) {\n throw new Error(`station is too long: ${station}`)\n }\n return station.padStart(columns.toStation, ' ')\n }\n\n function formatSpecialKind(specialKind: FrcsShot['specialKind']): string {\n switch (specialKind) {\n case 'diagonal':\n return 'D'\n case 'horizontal':\n return 'H'\n }\n return ' '\n }\n\n function trimZeroes(str: string): string {\n const match = /(-?\\d+)(\\.[1-9]*)0+$/.exec(str)\n if (!match) return str\n return match[2].length > 1 ? match[1] + match[2] : match[1]\n }\n\n const formatNumber = (width: number) => {\n function formatNum(num: number | null | undefined): string\n function formatNum<T extends UnitType<T>>(\n num: UnitizedNumber<T> | null | undefined,\n unit: Unit<T>,\n verbatim?: boolean\n ): string\n function formatNum<T extends UnitType<T>>(\n num: number | UnitizedNumber<T> | null | undefined,\n unit?: Unit<T>,\n verbatim?: boolean\n ): string {\n if (num instanceof UnitizedNumber) {\n return formatNum(num.get(verbatim ? num.unit : unit || num.unit))\n }\n if (num == null || !Number.isFinite(num)) return ' '.repeat(width)\n const formatted = trimZeroes(num.toFixed(2))\n if (formatted.length <= width) return formatted.padStart(width, ' ')\n if (formatted.length > width + 2) return formatted.substring(0, width)\n return trimZeroes(num.toFixed(2 - formatted.length + width)).padStart(\n width,\n ' '\n )\n }\n return formatNum\n }\n\n const formatLeft = formatNumber(columns.left)\n const formatRight = formatNumber(columns.right)\n const formatUp = formatNumber(columns.up)\n const formatDown = formatNumber(columns.down)\n\n const EMPTY_DISTANCE = ' '.repeat(columns.distance)\n const formatDistance = formatNumber(columns.distance)\n\n const EMPTY_FS_AZIMUTH = ' '.repeat(columns.frontsightAzimuth)\n const formatFsAzimuth = formatNumber(columns.frontsightAzimuth)\n const EMPTY_BS_AZIMUTH = ' '.repeat(columns.backsightAzimuth)\n const formatBsAzimuth = formatNumber(columns.backsightAzimuth)\n\n const EMPTY_FS_INCLINATION = ' '.repeat(columns.frontsightInclination)\n const formatFsInclination = formatNumber(columns.frontsightInclination)\n const EMPTY_BS_INCLINATION = ' '.repeat(columns.backsightInclination)\n const formatBsInclination = formatNumber(columns.backsightInclination)\n\n const formatVerticalDistance = formatNumber(columns.frontsightInclination)\n\n const EMPTY_FEET = ' '.repeat(columns.distanceFeet)\n\n function formatFeet(distance: UnitizedNumber<Length> | null | void): string {\n if (!distance) return EMPTY_FEET\n return formatNumber(columns.distanceFeet)(\n Math.trunc(distance.get(Length.feet))\n )\n }\n\n const EMPTY_INCHES = ' '.repeat(columns.distanceInches)\n\n function formatInches(\n distance: UnitizedNumber<Length> | null | void\n ): string {\n if (!distance) return EMPTY_INCHES\n return formatNumber(columns.distanceInches)(\n Math.round(distance.get(Length.inches) % 12)\n )\n }\n\n return function formatFrcsShot(shot: FrcsShot, header: FrcsUnits): string {\n const { azimuthUnit, inclinationUnit } = header\n let { distanceUnit } = header\n\n const inches = distanceUnit === Length.inches\n if (inches) distanceUnit = Length.feet\n\n const isRecorded = shot.recorded !== null\n\n if (!shot.to) {\n const { left, right, up, down } =\n shot.recorded?.fromLruds || shot.fromLruds || {}\n return [\n EMPTY_TO_STATION,\n formatFromStation(shot.from),\n EMPTY_DISTANCE,\n ' ', // kind\n ' ', // exclude\n EMPTY_FS_AZIMUTH,\n EMPTY_BS_AZIMUTH,\n EMPTY_FS_INCLINATION,\n EMPTY_BS_INCLINATION,\n formatLeft(left, distanceUnit, isRecorded),\n formatRight(right, distanceUnit, isRecorded),\n formatUp(up, distanceUnit, isRecorded),\n formatDown(down, distanceUnit, isRecorded),\n ].join('')\n }\n\n const distColumnValue =\n shot.specialKind === 'horizontal'\n ? shot.horizontalDistance\n : shot.distance\n\n return [\n formatToStation(shot.to),\n formatFromStation(shot.from),\n inches\n ? formatFeet(distColumnValue)\n : formatDistance(distColumnValue, distanceUnit, isRecorded),\n inches\n ? formatInches(distColumnValue)\n : formatSpecialKind(shot.specialKind),\n inches\n ? formatSpecialKind(shot.specialKind)\n : shot.excludeDistance\n ? '*'\n : ' ',\n formatFsAzimuth(shot.frontsightAzimuth, azimuthUnit, isRecorded),\n formatBsAzimuth(shot.backsightAzimuth, azimuthUnit, isRecorded),\n shot.specialKind\n ? formatVerticalDistance(\n shot.verticalDistance,\n distanceUnit,\n isRecorded\n )\n : formatFsInclination(\n shot.frontsightInclination,\n inclinationUnit,\n isRecorded\n ),\n shot.specialKind\n ? EMPTY_BS_INCLINATION\n : formatBsInclination(\n shot.backsightInclination,\n inclinationUnit,\n isRecorded\n ),\n formatLeft(shot.toLruds?.left, distanceUnit, isRecorded),\n formatRight(shot.toLruds?.right, distanceUnit, isRecorded),\n formatUp(shot.toLruds?.up, distanceUnit, isRecorded),\n formatDown(shot.toLruds?.down, distanceUnit, isRecorded),\n ].join('')\n }\n}\n\nexport default makeFormatFrcsShot()\n"],"mappings":";;;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAKO,SAASE,kBAAkBA,CAAA,EAEU;EAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAJ,CAAC,CAAC;IAAAG,YAAA,GAAAJ,IAAA,CADxCK,OAAO;IAAPA,OAAO,GAAAD,YAAA,cAAGE,2CAA2B,GAAAF,YAAA;EAErC,IAAMG,gBAAgB,GAAG,GAAG,CAACC,MAAM,CAACH,OAAO,CAACI,SAAS,CAAC;EAEtD,SAASC,iBAAiBA,CAACC,OAAe,EAAU;IAClD,IAAIA,OAAO,CAACT,MAAM,GAAGG,OAAO,CAACO,WAAW,EAAE;MACxC,MAAM,IAA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,CAAcpC,EAAE,EAAEwC,YAAY,EAAEC,UAAU,CAAC,EACpDxC,UAAU,EAAAoC,cAAA,GAACL,IAAI,CAACqB,OAAO,cAAAhB,cAAA,uBAAZA,cAAA,CAAcnC,IAAI,EAAEsC,YAAY,EAAEC,UAAU,CAAC,CACzD,CAACO,IAAI,CAAC,EAAE,CAAC;EACZ,CAAC;AACH;AAAC,IAAAM,QAAA,GAAAC,OAAA,cAEcjG,kBAAkB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"formatFrcsShot.js","names":["_unitized","require","_FrcsSurveyFile","makeFormatFrcsShot","columns","defaultFrcsShotColumnConfig","EMPTY_TO_STATION","repeat","toStation","formatFromStation","station","length","fromStation","Error","padStart","formatToStation","formatSpecialKind","specialKind","trimZeroes","str","match","exec","formatNumber","width","formatNum","num","unit","verbatim","UnitizedNumber","get","Number","isFinite","formatted","toFixed","substring","formatLeft","left","formatRight","right","formatUp","up","formatDown","down","EMPTY_DISTANCE","distance","formatDistance","EMPTY_FS_AZIMUTH","frontsightAzimuth","formatFsAzimuth","EMPTY_BS_AZIMUTH","backsightAzimuth","formatBsAzimuth","EMPTY_FS_INCLINATION","frontsightInclination","formatFsInclination","EMPTY_BS_INCLINATION","backsightInclination","formatBsInclination","formatVerticalDistance","EMPTY_FEET","distanceFeet","formatFeet","Math","trunc","Length","feet","EMPTY_INCHES","distanceInches","formatInches","round","inches","formatFrcsShot","shot","header","azimuthUnit","inclinationUnit","distanceUnit","isRecorded","recorded","to","fromLruds","from","join","distColumnValue","horizontalDistance","excludeDistance","verticalDistance","toLruds","_default","exports","default"],"sources":["../../src/survey/formatFrcsShot.ts"],"sourcesContent":["import type { FrcsUnits, FrcsShot } from './FrcsSurveyFile'\nimport { Length, Unit, UnitType, UnitizedNumber } from '@speleotica/unitized'\nimport {\n type FrcsShotColumnConfig,\n defaultFrcsShotColumnConfig,\n} from './FrcsSurveyFile'\n\nexport function makeFormatFrcsShot({\n columns = defaultFrcsShotColumnConfig,\n}: { columns?: FrcsShotColumnConfig } = {}) {\n const EMPTY_TO_STATION = ' '.repeat(columns.toStation)\n\n function formatFromStation(station: string): string {\n if (station.length > columns.fromStation) {\n throw new Error(`station is too long: ${station}`)\n }\n return station.padStart(columns.fromStation, ' ')\n }\n function formatToStation(station: string): string {\n if (station.length > columns.toStation) {\n throw new Error(`station is too long: ${station}`)\n }\n return station.padStart(columns.toStation, ' ')\n }\n\n function formatSpecialKind(specialKind: FrcsShot['specialKind']): string {\n switch (specialKind) {\n case 'diagonal':\n return 'D'\n case 'horizontal':\n return 'H'\n }\n return ' '\n }\n\n function trimZeroes(str: string): string {\n const match = /(-?\\d+)(\\.[1-9]*)0+$/.exec(str)\n if (!match) return str\n return match[2].length > 1 ? match[1] + match[2] : match[1]\n }\n\n const formatNumber = (width: number) => {\n function formatNum(num: number | null | undefined): string\n function formatNum<T extends UnitType<T>>(\n num: UnitizedNumber<T> | null | undefined,\n unit: Unit<T>,\n verbatim?: boolean\n ): string\n function formatNum<T extends UnitType<T>>(\n num: number | UnitizedNumber<T> | null | undefined,\n unit?: Unit<T>,\n verbatim?: boolean\n ): string {\n if (num instanceof UnitizedNumber) {\n return formatNum(num.get(verbatim ? num.unit : unit || num.unit))\n }\n if (num == null || !Number.isFinite(num)) return ' '.repeat(width)\n const formatted = trimZeroes(num.toFixed(2))\n if (formatted.length <= width) return formatted.padStart(width, ' ')\n if (formatted.length > width + 2) return formatted.substring(0, width)\n return trimZeroes(num.toFixed(2 - formatted.length + width)).padStart(\n width,\n ' '\n )\n }\n return formatNum\n }\n\n const formatLeft = formatNumber(columns.left)\n const formatRight = formatNumber(columns.right)\n const formatUp = formatNumber(columns.up)\n const formatDown = formatNumber(columns.down)\n\n const EMPTY_DISTANCE = ' '.repeat(columns.distance)\n const formatDistance = formatNumber(columns.distance)\n\n const EMPTY_FS_AZIMUTH = ' '.repeat(columns.frontsightAzimuth)\n const formatFsAzimuth = formatNumber(columns.frontsightAzimuth)\n const EMPTY_BS_AZIMUTH = ' '.repeat(columns.backsightAzimuth)\n const formatBsAzimuth = formatNumber(columns.backsightAzimuth)\n\n const EMPTY_FS_INCLINATION = ' '.repeat(columns.frontsightInclination)\n const formatFsInclination = formatNumber(columns.frontsightInclination)\n const EMPTY_BS_INCLINATION = ' '.repeat(columns.backsightInclination)\n const formatBsInclination = formatNumber(columns.backsightInclination)\n\n const formatVerticalDistance = formatNumber(columns.frontsightInclination)\n\n const EMPTY_FEET = ' '.repeat(columns.distanceFeet)\n\n function formatFeet(distance: UnitizedNumber<Length> | null | void): string {\n if (!distance) return EMPTY_FEET\n return formatNumber(columns.distanceFeet)(\n Math.trunc(distance.get(Length.feet))\n )\n }\n\n const EMPTY_INCHES = ' '.repeat(columns.distanceInches)\n\n function formatInches(\n distance: UnitizedNumber<Length> | null | void\n ): string {\n if (!distance) return EMPTY_INCHES\n return formatNumber(columns.distanceInches)(\n Math.round(distance.get(Length.inches) % 12)\n )\n }\n\n return function formatFrcsShot(shot: FrcsShot, header: FrcsUnits): string {\n const { azimuthUnit, inclinationUnit } = header\n let { distanceUnit } = header\n\n const inches = distanceUnit === Length.inches\n if (inches) distanceUnit = Length.feet\n\n const isRecorded = shot.recorded !== null\n\n if (!shot.to) {\n const { left, right, up, down } =\n shot.recorded?.fromLruds || shot.fromLruds || {}\n return [\n EMPTY_TO_STATION,\n formatFromStation(shot.from),\n EMPTY_DISTANCE,\n ' ', // kind\n ' ', // exclude\n EMPTY_FS_AZIMUTH,\n EMPTY_BS_AZIMUTH,\n EMPTY_FS_INCLINATION,\n EMPTY_BS_INCLINATION,\n formatLeft(left, distanceUnit, isRecorded),\n formatRight(right, distanceUnit, isRecorded),\n formatUp(up, distanceUnit, isRecorded),\n formatDown(down, distanceUnit, isRecorded),\n ].join('')\n }\n\n const distColumnValue =\n shot.specialKind === 'horizontal'\n ? shot.horizontalDistance\n : shot.distance\n\n return [\n formatToStation(shot.to),\n formatFromStation(shot.from),\n inches\n ? formatFeet(distColumnValue)\n : formatDistance(distColumnValue, distanceUnit, isRecorded),\n inches\n ? formatInches(distColumnValue)\n : formatSpecialKind(shot.specialKind),\n inches\n ? formatSpecialKind(shot.specialKind)\n : shot.excludeDistance\n ? '*'\n : ' ',\n formatFsAzimuth(shot.frontsightAzimuth, azimuthUnit, isRecorded),\n formatBsAzimuth(shot.backsightAzimuth, azimuthUnit, isRecorded),\n shot.specialKind\n ? formatVerticalDistance(\n shot.verticalDistance,\n distanceUnit,\n isRecorded\n )\n : formatFsInclination(\n shot.frontsightInclination,\n inclinationUnit,\n isRecorded\n ),\n shot.specialKind\n ? EMPTY_BS_INCLINATION\n : formatBsInclination(\n shot.backsightInclination,\n inclinationUnit,\n isRecorded\n ),\n formatLeft(shot.toLruds?.left, distanceUnit, isRecorded),\n formatRight(shot.toLruds?.right, distanceUnit, isRecorded),\n formatUp(shot.toLruds?.up, distanceUnit, isRecorded),\n formatDown(shot.toLruds?.down, distanceUnit, isRecorded),\n ].join('')\n }\n}\n\nexport default makeFormatFrcsShot()\n"],"mappings":";;;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAKO,SAASE,kBAAkBA,CAAC;EACjCC,OAAO,GAAGC;AACwB,CAAC,GAAG,CAAC,CAAC,EAAE;EAC1C,MAAMC,gBAAgB,GAAG,GAAG,CAACC,MAAM,CAACH,OAAO,CAACI,SAAS,CAAC;EAEtD,SAASC,iBAAiBA,CAACC,OAAe,EAAU;IAClD,IAAIA,OAAO,CAACC,MAAM,GAAGP,OAAO,CAACQ,WAAW,EAAE;MACxC,MAAM,IAAIC,KAAK,CAAC,wBAAwBH,OAAO,EAAE,CAAC;IACpD;IACA,OAAOA,OAAO,CAACI,QAAQ,CAACV,OAAO,CAACQ,WAAW,EAAE,GAAG,CAAC;EACnD;EACA,SAASG,eAAeA,CAACL,OAAe,EAAU;IAChD,IAAIA,OAAO,CAACC,MAAM,GAAGP,OAAO,CAACI,SAAS,EAAE;MACtC,MAAM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wB,WAAW,EAAEG,UAAU,CAAC,EAC/DL,IAAI,CAACvD,WAAW,GACZyC,sBAAsB,CACpBc,IAAI,CAACc,gBAAgB,EACrBV,YAAY,EACZC,UACF,CAAC,GACDvB,mBAAmB,CACjBkB,IAAI,CAACnB,qBAAqB,EAC1BsB,eAAe,EACfE,UACF,CAAC,EACLL,IAAI,CAACvD,WAAW,GACZsC,oBAAoB,GACpBE,mBAAmB,CACjBe,IAAI,CAAChB,oBAAoB,EACzBmB,eAAe,EACfE,UACF,CAAC,EACL1C,UAAU,CAACqC,IAAI,CAACe,OAAO,EAAEnD,IAAI,EAAEwC,YAAY,EAAEC,UAAU,CAAC,EACxDxC,WAAW,CAACmC,IAAI,CAACe,OAAO,EAAEjD,KAAK,EAAEsC,YAAY,EAAEC,UAAU,CAAC,EAC1DtC,QAAQ,CAACiC,IAAI,CAACe,OAAO,EAAE/C,EAAE,EAAEoC,YAAY,EAAEC,UAAU,CAAC,EACpDpC,UAAU,CAAC+B,IAAI,CAACe,OAAO,EAAE7C,IAAI,EAAEkC,YAAY,EAAEC,UAAU,CAAC,CACzD,CAACK,IAAI,CAAC,EAAE,CAAC;EACZ,CAAC;AACH;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcvF,kBAAkB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,144 +1,66 @@
|
|
|
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
6
|
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
7
|
var _unitized = require("@speleotica/unitized");
|
|
13
8
|
var _formatFrcsShot = require("./formatFrcsShot.js");
|
|
14
|
-
function formatFrcsSurveyFile(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
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(units);
|
|
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 || units).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();
|
|
9
|
+
async function* formatFrcsSurveyFile(file) {
|
|
10
|
+
const formatFrcsShot = (0, _formatFrcsShot.makeFormatFrcsShot)(file);
|
|
11
|
+
if (file.cave) {
|
|
12
|
+
yield ` ${file.cave}${file.location ? `, ${file.location}` : ''}\n`;
|
|
13
|
+
}
|
|
14
|
+
for (let tripIndex = 0; tripIndex < file.trips.length; tripIndex++) {
|
|
15
|
+
const trip = file.trips[tripIndex];
|
|
16
|
+
const {
|
|
17
|
+
shots,
|
|
18
|
+
header,
|
|
19
|
+
units
|
|
20
|
+
} = trip;
|
|
21
|
+
const {
|
|
22
|
+
name,
|
|
23
|
+
team,
|
|
24
|
+
date,
|
|
25
|
+
comment
|
|
26
|
+
} = header;
|
|
27
|
+
if (tripIndex > 0) yield ' *\n';
|
|
28
|
+
yield name.replace(/\n?$/, '\n');
|
|
29
|
+
const line2 = [...(team?.length ? [team.join(', ')] : []), ...(date ? [formatDate(date)] : [])].join('. ');
|
|
30
|
+
if (line2) yield `${line2}\n`;
|
|
31
|
+
if (comment) yield comment.replace(/\n?$/, '\n');
|
|
32
|
+
yield ' *\n';
|
|
33
|
+
yield formatUnits(units);
|
|
34
|
+
let alternateUnits;
|
|
35
|
+
for (let i = 0; i < shots.length; i++) {
|
|
36
|
+
const shot = shots[i];
|
|
37
|
+
if (shot.comment) {
|
|
38
|
+
const lines = shot.comment.split(/\n/gm);
|
|
39
|
+
yield '*\n';
|
|
40
|
+
for (let i = 0; i < lines.length - 1; i++) {
|
|
41
|
+
yield lines[i].replace(/\n?$/, '\n');
|
|
42
|
+
}
|
|
43
|
+
yield `* ${lines[lines.length - 1].replace(/\n?$/, '\n')}`;
|
|
127
44
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
45
|
+
if (shot.recorded?.units) {
|
|
46
|
+
alternateUnits = shot.recorded.units;
|
|
47
|
+
yield `* %NC\n`;
|
|
48
|
+
yield formatUnits(shot.recorded.units);
|
|
49
|
+
}
|
|
50
|
+
yield formatFrcsShot(shot.recorded || shot, alternateUnits || units).replace(/\n?$/, '\n');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
131
53
|
}
|
|
132
54
|
function formatUnits(units) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return
|
|
55
|
+
const distUnit = formatLengthUnit(units.distanceUnit);
|
|
56
|
+
const azmMode = units.hasBacksightAzimuth ? units.backsightAzimuthCorrected ? 'C' : 'B' : ' ';
|
|
57
|
+
const incMode = units.hasBacksightInclination ? units.backsightInclinationCorrected ? 'C' : 'B' : ' ';
|
|
58
|
+
const azmUnit = formatAngleUnit(units.azimuthUnit);
|
|
59
|
+
const incUnit = formatAngleUnit(units.inclinationUnit);
|
|
60
|
+
return `${distUnit} ${azmMode}${incMode} ${azmUnit}${incUnit}\n`;
|
|
139
61
|
}
|
|
140
62
|
function formatDate(date) {
|
|
141
|
-
return
|
|
63
|
+
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear() % 100}`;
|
|
142
64
|
}
|
|
143
65
|
function formatLengthUnit(unit) {
|
|
144
66
|
switch (unit) {
|
|
@@ -149,7 +71,7 @@ function formatLengthUnit(unit) {
|
|
|
149
71
|
case _unitized.Length.inches:
|
|
150
72
|
return 'FI';
|
|
151
73
|
default:
|
|
152
|
-
throw new Error(
|
|
74
|
+
throw new Error(`invalid length unit: ${unit}`);
|
|
153
75
|
}
|
|
154
76
|
}
|
|
155
77
|
function formatAngleUnit(unit) {
|
|
@@ -159,7 +81,7 @@ function formatAngleUnit(unit) {
|
|
|
159
81
|
case _unitized.Angle.gradians:
|
|
160
82
|
return 'G';
|
|
161
83
|
default:
|
|
162
|
-
throw new Error(
|
|
84
|
+
throw new Error(`invalid angle unit: ${unit}`);
|
|
163
85
|
}
|
|
164
86
|
}
|
|
165
87
|
//# sourceMappingURL=formatFrcsSurveyFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatFrcsSurveyFile.js","names":["_unitized","require","_formatFrcsShot","formatFrcsSurveyFile","
|
|
1
|
+
{"version":3,"file":"formatFrcsSurveyFile.js","names":["_unitized","require","_formatFrcsShot","formatFrcsSurveyFile","file","formatFrcsShot","makeFormatFrcsShot","cave","location","tripIndex","trips","length","trip","shots","header","units","name","team","date","comment","replace","line2","join","formatDate","formatUnits","alternateUnits","i","shot","lines","split","recorded","distUnit","formatLengthUnit","distanceUnit","azmMode","hasBacksightAzimuth","backsightAzimuthCorrected","incMode","hasBacksightInclination","backsightInclinationCorrected","azmUnit","formatAngleUnit","azimuthUnit","incUnit","inclinationUnit","getMonth","getDate","getFullYear","unit","Length","meters","feet","inches","Error","Angle","degrees","gradians"],"sources":["../../src/survey/formatFrcsSurveyFile.ts"],"sourcesContent":["import { Angle, Length, Unit } from '@speleotica/unitized'\nimport type { FrcsSurveyFile, FrcsUnits } from './FrcsSurveyFile'\nimport { makeFormatFrcsShot } from './formatFrcsShot'\n\nexport async function* formatFrcsSurveyFile(\n file: FrcsSurveyFile\n): AsyncIterable<string> {\n const formatFrcsShot = makeFormatFrcsShot(file)\n if (file.cave) {\n yield ` ${file.cave}${file.location ? `, ${file.location}` : ''}\\n`\n }\n for (let tripIndex = 0; tripIndex < file.trips.length; tripIndex++) {\n const trip = file.trips[tripIndex]\n const { shots, header, units } = trip\n const { name, team, date, comment } = header\n if (tripIndex > 0) yield ' *\\n'\n yield name.replace(/\\n?$/, '\\n')\n const line2 = [\n ...(team?.length ? [team.join(', ')] : []),\n ...(date ? [formatDate(date)] : []),\n ].join('. ')\n if (line2) yield `${line2}\\n`\n if (comment) yield comment.replace(/\\n?$/, '\\n')\n yield ' *\\n'\n yield formatUnits(units)\n\n let alternateUnits: FrcsUnits | undefined\n\n for (let i = 0; i < shots.length; i++) {\n const shot = shots[i]\n if (shot.comment) {\n const lines = shot.comment.split(/\\n/gm)\n yield '*\\n'\n for (let i = 0; i < lines.length - 1; i++) {\n yield lines[i].replace(/\\n?$/, '\\n')\n }\n yield `* ${lines[lines.length - 1].replace(/\\n?$/, '\\n')}`\n }\n if (shot.recorded?.units) {\n alternateUnits = shot.recorded.units\n yield `* %NC\\n`\n yield formatUnits(shot.recorded.units)\n }\n yield formatFrcsShot(\n shot.recorded || shot,\n alternateUnits || units\n ).replace(/\\n?$/, '\\n')\n }\n }\n}\n\nfunction formatUnits(units: FrcsUnits): string {\n const distUnit = formatLengthUnit(units.distanceUnit)\n const azmMode = units.hasBacksightAzimuth\n ? units.backsightAzimuthCorrected\n ? 'C'\n : 'B'\n : ' '\n const incMode = units.hasBacksightInclination\n ? units.backsightInclinationCorrected\n ? 'C'\n : 'B'\n : ' '\n const azmUnit = formatAngleUnit(units.azimuthUnit)\n const incUnit = formatAngleUnit(units.inclinationUnit)\n\n return `${distUnit} ${azmMode}${incMode} ${azmUnit}${incUnit}\\n`\n}\n\nfunction formatDate(date: Date): string {\n return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear() % 100}`\n}\n\nfunction formatLengthUnit(unit: Unit<Length>): string {\n switch (unit) {\n case Length.meters:\n return 'M '\n case Length.feet:\n return 'FT'\n case Length.inches:\n return 'FI'\n default:\n throw new Error(`invalid length unit: ${unit}`)\n }\n}\n\nfunction formatAngleUnit(unit: Unit<Angle>): string {\n switch (unit) {\n case Angle.degrees:\n return 'D'\n case Angle.gradians:\n return 'G'\n default:\n throw new Error(`invalid angle unit: ${unit}`)\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAEO,gBAAgBE,oBAAoBA,CACzCC,IAAoB,EACG;EACvB,MAAMC,cAAc,GAAG,IAAAC,kCAAkB,EAACF,IAAI,CAAC;EAC/C,IAAIA,IAAI,CAACG,IAAI,EAAE;IACb,MAAM,SAASH,IAAI,CAACG,IAAI,GAAGH,IAAI,CAACI,QAAQ,GAAG,KAAKJ,IAAI,CAACI,QAAQ,EAAE,GAAG,EAAE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