- parse Excel input by header strings (pier, IP, bearing tables) - DMS azimuth parser (E03), input validation (E01, E02) - pure geometry: axis, bearings, stepped coping, column, footing, piles, blinding - warnings W01, W02, W05, W07, I01 - regression tests against spec.md section 12 (P1) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
20 lines
733 B
TypeScript
20 lines
733 B
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
import * as XLSX from 'xlsx';
|
|
import { parseWorkbook } from '../src/core/parseWorkbook';
|
|
import type { PierInput } from '../src/core/types';
|
|
|
|
const P1_PATH = fileURLToPath(new URL('../public/samples/P1.xlsx', import.meta.url));
|
|
|
|
export function loadWorkbook(path: string = P1_PATH): XLSX.WorkBook {
|
|
return XLSX.read(readFileSync(path), { type: 'buffer' });
|
|
}
|
|
|
|
export function loadP1(): PierInput {
|
|
const { piers, issues } = parseWorkbook(loadWorkbook());
|
|
if (issues.length) throw new Error(`P1 parse issues: ${JSON.stringify(issues)}`);
|
|
const p1 = piers.find((p) => p.name === 'P1');
|
|
if (!p1) throw new Error('P1 not found');
|
|
return p1;
|
|
}
|