Files
Pier_v1/tests/dxf-table.test.ts
T
ypshimandClaude Haiku 5.5 4048c326e3 feat(view): read the bearing ELEVATION TABLE from a DXF drawing (교각도(2) P1) by position
The reader takes TEXT and MTEXT entities (x, y, text). The EL.X header row names the columns; the No column holds the
bearing numbers; each value is the nearest entry under its header on the same row. On the 운곡교 교각도(2) drawing all ten
bearings read back the reference values (EL.X, h1, h2). The 도면 불러오기 button accepts .dxf as well as sheets. The test
fixture holds only the table's text entries.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-23 14:34:33 +09:00

30 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { readFileSync } from 'node:fs';
import { BEARING_ELEVATION_REF } from '../src/core/bearing-ref';
import { parseBearingElevationTable, readDxfTexts, type DxfText } from '../src/core/dxf-table';
const texts = JSON.parse(readFileSync(new URL('./fixtures/bearing-table-texts.json', import.meta.url), 'utf-8')) as DxfText[];
describe('도면 받침 ELEVATION TABLE 읽기 (DXF 텍스트, 승인 2026-10-23)', () => {
it('reads all ten bearings from the 운곡교 교각도(2) table', () => {
const r = parseBearingElevationTable(texts);
expect(r.errors).toEqual([]);
expect(r.drawing.map((d) => d.no)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
});
it('the values equal the reference table used for the 도면 비교 (EL.X, h1, h2 on every bearing)', () => {
const r = parseBearingElevationTable(texts);
for (const ref of BEARING_ELEVATION_REF) {
const got = r.drawing.find((d) => d.no === ref.no)!;
expect(got.elx, `No ${ref.no} EL.X`).toBeCloseTo(ref.elx, 3);
expect(got.h1, `No ${ref.no} h1`).toBe(ref.h1);
expect(got.h2, `No ${ref.no} h2`).toBe(ref.h2);
}
});
it('reads TEXT entities from DXF text (x, y, string)', () => {
const dxf = ['0', 'SECTION', '2', 'ENTITIES', '0', 'TEXT', '10', '100.5', '20', '200.25', '1', 'EL. "X"', '0', 'ENDSEC'].join('\n');
expect(readDxfTexts(dxf)).toEqual([{ x: 100.5, y: 200.25, text: 'EL. "X"' }]);
});
});