drawing-axi 0.1.1 → 0.1.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/README.md CHANGED
@@ -21,7 +21,7 @@ It was built to run inside Comis, and it also works on its own.
21
21
  ## Requirements
22
22
 
23
23
  - Node.js 22.18 or later.
24
- - Drawings plotted to PDF from the CAD file (vector PDF). A scan or a photo holds no lines to measure, and the tool says so.
24
+ - Drawings plotted to PDF from the CAD file (vector PDF), one sheet a page; a file that joins several sheets works too, `--page` picks one. A scan or a photo holds no lines to measure, and the tool says so. So does a print of the drawing through a PDF printer, where the drawing becomes picture tiles under a few real lines such as the column grid: `info` says how much of the page pictures cover, `measure` warns, and `render` shows where the pictures are.
25
25
 
26
26
  ## Install
27
27
 
@@ -115,11 +115,11 @@ sized_by[3]{group,size,label,labelled_m,runs}:
115
115
 
116
116
  ### What the numbers mean
117
117
 
118
- - **Runs.** A pipe is plotted as dashes, and broken where a letter or a label sits on it. A run joins pieces that lie on one line and end near each other, and is measured end to end. A break with a linetype letter in it, such as the F of a fire line, is joined up to twice as wide. Curved pipe and runs shorter than 6 mm on paper are left out.
118
+ - **Runs.** A pipe is plotted as dashes, and broken where a letter or a label sits on it. A run joins pieces that lie on one line and end near each other, and is measured end to end. A break with a linetype letter in it, such as the F of a fire line, is joined up to twice as wide. Some offices plot those letters as strokes on the pipe's layer; their bars join into a sparse line a point or two off the pipe, which is left out and counted in `settings`. When a group's runs would grow by a fifth at a gap half as wide again, `gaps` says so; `--group-gap NAME=MM` sets a gap for that group alone. Curved pipe and runs shorter than 6 mm on paper are left out.
119
119
  - **Scale.** The ratio comes from the title block. A plot is often a little off its stated scale, so the factor is refined from the printed scale bar when one is found. `drawing-axi scale` shows both. Pass `--scale 1:N` or `--pt-per-m` when the sheet is wrong or silent.
120
120
  - **Sizes.** A run takes the size of a label written along it: just beside the line, or in a break left in the line for it. A line that passes through the middle of a label's text is another pipe, and takes nothing. A run without a label takes the size of the runs of its own group that it touches, when they all agree. `labelled_m` is the part sized by a label of its own.
121
- - **System codes.** A label such as `F-Ø4"` or `CW1-Ø3"` starts with its system's code. Name a group by that code (`--group F=<layer>`, `--group CW=<layer>`) and it takes only those labels, and no other group takes them. Digits and dots do not count: `C.W.2` is `CW`. A label written in a break of a line still sizes that line, whatever its group is called. A coded label that sits on no run, as one on a leader does, is listed under `labels_apart`: the sheet names that size for the system, and does not say which pipe. It is a size to confirm, not a measured one.
122
- - **Unsized.** What no label sizes is reported as `unsized`. The tool never guesses a size.
121
+ - **System codes.** A label such as `F-Ø4"` or `CW1-Ø3"` starts with its system's code. Name a group by that code (`--group F=<layer>`, `--group CW=<layer>`) and it takes only those labels and sizes written alone, never a slope label such as `Ø160-1%`, which is a gravity pipe's. No other group takes its labels. The code is the letters before the first digit, dots left out: `C.W.2` is `CW`, `OD7A` is `OD`. A label written in a break of a line still sizes that line, whatever its group is called. A coded label that sits on no run, as one on a leader does, is listed under `labels_apart`: the sheet names that size for the system, and does not say which pipe. It is a size to confirm, not a measured one.
122
+ - **Unsized.** What no label sizes is reported as `unsized`. The tool never guesses a size. `size_labels` says how many more labels a reach twice as wide would place, for an office that writes its sizes a few millimetres off the pipe. `--plain` adds sizes written alone, such as `Ø63`, that no riser tag claims.
123
123
  - **Not on a plan.** Vertical lengths, fittings, hangers and insulation are not drawn to scale on a plan. `tags` and `symbols` count what the sheet marks; the rest needs rules or a person.
124
124
 
125
125
  ### Hebrew and other stroke-font text
package/dist/cli/parse.js CHANGED
@@ -34,7 +34,7 @@ export function parseCommand(spec, argv) {
34
34
  continue;
35
35
  const f = spec.flags[token.name];
36
36
  if (!f) {
37
- throw usage(`Unknown flag${shownFlag(token.rawName)} for \`${name}\`. ${valid.length ? `Valid flags: ${valid.join(', ')}.` : 'It takes no flags.'}`);
37
+ throw usage(`Unknown flag${shownFlag(token.rawName)} for \`${name}\`.${/\s/.test(token.rawName) ? ' The flag held a space, as a shell gives when a variable of several flags is not split into words; pass each flag as its own argument.' : ''} ${valid.length ? `Valid flags: ${valid.join(', ')}.` : 'It takes no flags.'}`);
38
38
  }
39
39
  if (f.type === 'boolean' && token.inlineValue)
40
40
  throw usage(`--${token.name} takes no value.`);
package/dist/cli/run.js CHANGED
@@ -19,6 +19,12 @@ const GAP = {
19
19
  value: '<mm>',
20
20
  summary: 'Join pieces up to this far apart on paper, default 8',
21
21
  };
22
+ const GROUP_GAP = {
23
+ type: 'string',
24
+ multiple: true,
25
+ value: '<name>=<mm>',
26
+ summary: 'A gap for one group, when its dashes are farther apart',
27
+ };
22
28
  const MIN = {
23
29
  type: 'string',
24
30
  value: '<mm>',
@@ -158,6 +164,7 @@ export const COMMANDS = [
158
164
  layer: LAYER,
159
165
  group: GROUP,
160
166
  gap: GAP,
167
+ 'group-gap': GROUP_GAP,
161
168
  min: MIN,
162
169
  ...AREA_FLAGS,
163
170
  ...SCALE_FLAGS,
@@ -176,6 +183,7 @@ export const COMMANDS = [
176
183
  group: GROUP,
177
184
  layer: LAYER,
178
185
  gap: GAP,
186
+ 'group-gap': GROUP_GAP,
179
187
  min: MIN,
180
188
  reach: {
181
189
  type: 'string',
@@ -184,7 +192,7 @@ export const COMMANDS = [
184
192
  },
185
193
  plain: {
186
194
  type: 'boolean',
187
- summary: 'Also use sizes written alone, without a slope or system prefix',
195
+ summary: 'Also use sizes written alone, without a slope or system prefix, that no riser tag claims',
188
196
  },
189
197
  ...AREA_FLAGS,
190
198
  ...SCALE_FLAGS,
@@ -356,6 +356,12 @@ export function linetypeLetters(sheet) {
356
356
  .filter((l) => /^[A-Za-z]{1,3}$/.test(l.text.trim()))
357
357
  .map((l) => ({ x: (l.x0 + l.x1) / 2, y: (l.y0 + l.y1) / 2 }));
358
358
  }
359
+ /** Pictures over this share of a page make it a picture page. */
360
+ export const PICTURED = 0.5;
361
+ /** Pictures over this share are worth a warning beside measured lengths. */
362
+ export const PICTURE_NOTE = 0.05;
363
+ /** A share from 0 to 1 as a whole percentage, never 0% for a real share. */
364
+ export const percent = (share) => `${share > 0 && share < 0.01 ? '<1' : Math.round(share * 100)}%`;
359
365
  /** A break with a linetype letter in it is joined up to this many gaps wide. */
360
366
  export const LETTER_GAPS = 2;
361
367
  export function strokesOf(sheet, pick) {
@@ -5,7 +5,7 @@ import { nominalPtPerM } from '../drawing/scale.js';
5
5
  import { sizeLabels } from '../drawing/sizes.js';
6
6
  import { AxiError } from '../errors.js';
7
7
  import { recordOutput } from '../output/views.js';
8
- import { openSheet, round, save, scaleOf, sheetSize, str } from './common.js';
8
+ import { openSheet, PICTURED, percent, round, save, scaleOf, sheetSize, str, } from './common.js';
9
9
  /** How the scale was found, in words. */
10
10
  function basisText(scale) {
11
11
  if (scale.basis === 'flag' && !scale.bar)
@@ -42,13 +42,18 @@ export function info(input) {
42
42
  const hidden = sheet.layers.filter((l) => l.hidden).length;
43
43
  const used = new Set(sheet.strokes.filter((s) => s.layer >= 0).map((s) => s.layer)).size;
44
44
  const notes = [];
45
+ // Most of the page a picture: whatever lines the file holds are what was
46
+ // drawn over it, such as a grid, so no advice about layers or colours.
47
+ const pictured = sheet.pictureShare >= PICTURED;
45
48
  if (!sheet.strokes.length && sheet.images)
46
49
  notes.push('This page is a picture, such as a scan: it holds no lines to measure. Ask for the PDF plotted from the CAD file.');
50
+ else if (pictured)
51
+ notes.push(`Pictures cover ${percent(sheet.pictureShare)} of this page: the drawing is a picture. A pipe drawn in a picture is not a line, so it is not measured, and \`render\` shows only where the pictures are. Ask for the PDF plotted from the CAD file, not a print of it.`);
47
52
  else if (!sheet.strokes.length)
48
53
  notes.push('This page holds no lines.');
49
- if (sheet.strokes.length && sheet.layers.length && !used)
54
+ if (!pictured && sheet.strokes.length && sheet.layers.length && !used)
50
55
  notes.push('No line on this page is on a layer. Tell systems apart by colour: `drawing-axi layers <file.pdf> --split`.');
51
- if (sheet.strokes.length && !sheet.layers.length)
56
+ if (!pictured && sheet.strokes.length && !sheet.layers.length)
52
57
  notes.push('The file keeps no layers. Tell systems apart by colour: `drawing-axi layers <file.pdf> --split`.');
53
58
  if (sheet.strokes.length && !sheet.labels.length)
54
59
  notes.push('The file keeps no text. Sizes and names must come from looking at the sheet: `drawing-axi render`.');
@@ -66,6 +71,11 @@ export function info(input) {
66
71
  scale,
67
72
  layers: `${used} with ink on this page, ${sheet.layers.length} in the file${hidden ? ` (${hidden} switched off)` : ''}`,
68
73
  geometry: `${sheet.strokes.length} strokes, ${sheet.fills.length} fills, ${sheet.images} images`,
74
+ ...(sheet.images
75
+ ? {
76
+ pictures: `${sheet.images}, covering ${percent(sheet.pictureShare)} of the page`,
77
+ }
78
+ : {}),
69
79
  labels: `${count.shx} stroke-font, ${count.text} font text, ${count.note} notes`,
70
80
  size_labels: `${sizes.length} (${sizes.filter((s) => s.onRun).length} carry a slope or a system code, as a label on a pipe does)`,
71
81
  notes,
@@ -1,11 +1,12 @@
1
1
  // `runs`: the straight runs on chosen layers. `measure`: their length by
2
2
  // group and pipe size, the table a bill of quantities is built from.
3
- import { buildRuns, segmentsOf } from '../drawing/runs.js';
3
+ import { buildRuns, dropShadows, segmentsOf } from '../drawing/runs.js';
4
4
  import { codeOf, sizeLabels, sizeRuns, } from '../drawing/sizes.js';
5
+ import { findTags } from '../drawing/tags.js';
5
6
  import { usage } from '../errors.js';
6
7
  import { bounded, render } from '../output/toon.js';
7
8
  import { countLine, listOutput, plural, tableRow, } from '../output/views.js';
8
- import { areaOf, clipStrokes, inArea, LETTER_GAPS, linetypeLetters, list, openSheet, paperMm, pickLayer, pickLayers, positiveInt, positiveNumber, round, save, scaleOf, str, strokesOf, wholeSheet, } from './common.js';
9
+ import { areaOf, clipStrokes, inArea, LETTER_GAPS, linetypeLetters, list, openSheet, PICTURE_NOTE, paperMm, percent, pickLayer, pickLayers, positiveInt, positiveNumber, round, save, scaleOf, str, strokesOf, wholeSheet, } from './common.js';
9
10
  import { scaleLine } from './info.js';
10
11
  /** A group's name is the caller's own words: anything printable, up to 60 characters. */
11
12
  const GROUP_NAME = /^[^=\p{Cc}\p{Cf}]{1,60}$/u;
@@ -43,26 +44,74 @@ function settingsOf(input) {
43
44
  gapMm: positiveNumber(input.values, 'gap', 8, 100),
44
45
  minMm: positiveNumber(input.values, 'min', 6, 1000),
45
46
  area: areaOf(input.values),
47
+ groupGaps: groupGapsOf(input),
46
48
  };
47
49
  }
48
- function runsOf(sheet, groups, settings) {
50
+ /** `--group-gap NAME=MM`: a gap for one group. */
51
+ function groupGapsOf(input) {
52
+ const out = new Map();
53
+ for (const spec of list(input.values, 'group-gap')) {
54
+ const eq = spec.lastIndexOf('=');
55
+ const mm = Number(spec.slice(eq + 1));
56
+ if (eq < 1 || !Number.isFinite(mm) || mm <= 0 || mm > 100)
57
+ throw usage('--group-gap takes <name>=<mm>, a gap above 0 and at most 100 mm.');
58
+ out.set(spec.slice(0, eq), mm);
59
+ }
60
+ return out;
61
+ }
62
+ function runsOf(sheet, groups, settings, notes) {
63
+ for (const name of settings.groupGaps.keys())
64
+ if (!groups.some((g) => g.name === name))
65
+ throw usage(`--group-gap names no group called ${JSON.stringify(name)}; the groups are ${groups.map((g) => g.name).join(', ')}.`);
49
66
  const out = [];
50
67
  const min = paperMm(settings.minMm);
51
68
  const letters = linetypeLetters(sheet);
69
+ // Runs of one layer at a gap, with the runs that ride along others left out.
70
+ const build = (segs, gapMm) => {
71
+ const all = buildRuns(segs, {
72
+ gap: paperMm(gapMm),
73
+ letters,
74
+ letterGap: paperMm(gapMm * LETTER_GAPS),
75
+ }).filter((r) => r.length >= min);
76
+ return dropShadows(all);
77
+ };
52
78
  groups.forEach((group, index) => {
79
+ const gapMm = settings.groupGaps.get(group.name) ?? settings.gapMm;
80
+ let pt = 0;
81
+ let widerPt = 0;
53
82
  for (const pick of group.picks) {
54
- const strokes = clipStrokes(strokesOf(sheet, pick), settings.area);
55
- for (const run of buildRuns(segmentsOf(strokes), {
56
- gap: paperMm(settings.gapMm),
57
- letters,
58
- letterGap: paperMm(settings.gapMm * LETTER_GAPS),
59
- }))
60
- if (run.length >= min)
61
- out.push({ ...run, group: index, layer: pick.name });
83
+ const segs = segmentsOf(clipStrokes(strokesOf(sheet, pick), settings.area));
84
+ const { kept, dropped } = build(segs, gapMm);
85
+ for (const run of kept) {
86
+ out.push({ ...run, group: index, layer: pick.name });
87
+ pt += run.length;
88
+ }
89
+ if (notes && dropped) {
90
+ notes.shadows += dropped;
91
+ const all = buildRuns(segs, {
92
+ gap: paperMm(gapMm),
93
+ letters,
94
+ letterGap: paperMm(gapMm * LETTER_GAPS),
95
+ }).filter((r) => r.length >= min);
96
+ notes.shadowPt +=
97
+ all.reduce((s, r) => s + r.length, 0) -
98
+ kept.reduce((s, r) => s + r.length, 0);
99
+ }
100
+ if (notes && !settings.groupGaps.has(group.name))
101
+ widerPt += build(segs, gapMm * WIDER).kept.reduce((s, r) => s + r.length, 0);
62
102
  }
103
+ // Dashes farther apart than the gap: the group's runs grow by a fifth
104
+ // or more, and by a metre on paper's scale, at a gap half as wide again.
105
+ if (notes &&
106
+ !settings.groupGaps.has(group.name) &&
107
+ widerPt >= pt * 1.2 &&
108
+ widerPt - pt >= paperMm(10))
109
+ notes.wider.push({ group: index, gapMm: gapMm * WIDER, pt, widerPt });
63
110
  });
64
111
  return out;
65
112
  }
113
+ /** The wider gap tried for the hint, as a share of the gap. */
114
+ const WIDER = 1.5;
66
115
  /** Which part of the sheet was read, in words. */
67
116
  function areaText(area) {
68
117
  if (wholeSheet(area))
@@ -74,7 +123,11 @@ function areaText(area) {
74
123
  ? `inside the region, outside ${boxes}`
75
124
  : 'inside the region only';
76
125
  }
77
- const settingsLine = (s, extra = '') => `pieces up to ${s.gapMm} mm apart on paper are joined, and up to ${s.gapMm * LETTER_GAPS} mm where a linetype letter sits in the break; runs under ${s.minMm} mm on paper are left out${extra}; ${areaText(s.area)}`;
126
+ const settingsLine = (s, extra = '', notes, m) => `pieces up to ${s.gapMm} mm apart on paper are joined, and up to ${s.gapMm * LETTER_GAPS} mm where a linetype letter sits in the break${[
127
+ ...s.groupGaps,
128
+ ]
129
+ .map(([name, mm]) => `; group ${name} joins pieces up to ${mm} mm apart`)
130
+ .join('')}; runs under ${s.minMm} mm on paper are left out${notes?.shadows && m ? `; ${notes.shadows} run${notes.shadows === 1 ? '' : 's'} that ride${notes.shadows === 1 ? 's' : ''} along another, ${round(m(notes.shadowPt), 1)} m, left out as linetype lettering` : ''}${extra}; ${areaText(s.area)}`;
78
131
  const point = (x, y) => `${Math.round(x)},${Math.round(y)}`;
79
132
  export function runs(input) {
80
133
  const { sheet, name } = openSheet(input);
@@ -83,7 +136,8 @@ export function runs(input) {
83
136
  const scale = scaleOf(input.values, sheet);
84
137
  const limit = positiveInt(input.values, 'limit', 20);
85
138
  const full = input.values.full === true;
86
- const found = runsOf(sheet, groups, settings).sort((a, b) => b.length - a.length);
139
+ const notes = { shadows: 0, shadowPt: 0, wider: [] };
140
+ const found = runsOf(sheet, groups, settings, notes).sort((a, b) => b.length - a.length);
87
141
  const rows = found.map((r) => ({
88
142
  group: groups[r.group].name,
89
143
  length_m: round(r.length / scale.ptPerM, 2),
@@ -106,7 +160,7 @@ export function runs(input) {
106
160
  head: {
107
161
  file: name,
108
162
  scale: scaleLine(scale),
109
- settings: settingsLine(settings),
163
+ settings: settingsLine(settings, '', notes, (pt) => pt / scale.ptPerM),
110
164
  saved,
111
165
  },
112
166
  rows: shown,
@@ -132,8 +186,15 @@ export function measure(input) {
132
186
  const scale = scaleOf(input.values, sheet);
133
187
  const limit = positiveInt(input.values, 'limit', 40);
134
188
  const full = input.values.full === true;
135
- const found = runsOf(sheet, groups, settings);
136
- const labels = sizeLabels(sheet.labels.filter((l) => inArea(settings.area, (l.x0 + l.x1) / 2, (l.y0 + l.y1) / 2))).filter((l) => plain || l.onRun);
189
+ const notes = { shadows: 0, shadowPt: 0, wider: [] };
190
+ const found = runsOf(sheet, groups, settings, notes);
191
+ const inside = sheet.labels.filter((l) => inArea(settings.area, (l.x0 + l.x1) / 2, (l.y0 + l.y1) / 2));
192
+ // With --plain, a size written alone counts too, unless a riser tag
193
+ // claims it: that size is the riser's, not the pipe's beside it.
194
+ const tagged = plain
195
+ ? new Set(findTags(inside).map((t) => t.sizeLabel))
196
+ : new Set();
197
+ const labels = sizeLabels(inside.filter((l) => !tagged.has(l))).filter((l) => l.onRun || (plain && l.alone));
137
198
  // A group named by the code its labels carry (F, CW, HF) takes only those
138
199
  // labels, and gives them to no other group.
139
200
  const labelCodes = new Set(labels.map((l) => l.code));
@@ -144,9 +205,25 @@ export function measure(input) {
144
205
  const boundCodes = codes.filter((c) => c !== null);
145
206
  const placed = { count: 0, missed: [] };
146
207
  const sized = sizeRuns(found, labels, { reach: paperMm(reachMm), codes }, placed);
147
- const labelsLine = `${placed.count} of ${labels.length} size labels in the area sit on a measured run${labels.length > placed.count ? '; the others belong to pipe that is not in these groups, or fit no run' : ''}`;
148
- const settingsText = settingsLine(settings, `; a size label counts within ${reachMm} mm of its run${plain ? ', plain sizes included' : ''}${boundCodes.length ? `; labels coded ${boundCodes.join(', ')} go only to the groups of those names` : ''}`);
208
+ // Labels a reach twice as wide would place: an office may write its sizes
209
+ // a few millimetres off the pipe.
210
+ const wideReach = reachMm * 2;
211
+ const reachable = { count: 0 };
212
+ if (placed.missed.length)
213
+ sizeRuns(found, labels, { reach: paperMm(wideReach), codes }, reachable);
214
+ const more = reachable.count - placed.count;
215
+ const picturesLine = sheet.pictureShare >= PICTURE_NOTE
216
+ ? `pictures cover ${percent(sheet.pictureShare)} of the page; pipes drawn in them are not measured`
217
+ : '';
218
+ const labelsLine = `${placed.count} of ${labels.length} size labels in the area sit on a measured run${labels.length > placed.count ? '; the others belong to pipe that is not in these groups, or fit no run' : ''}${more > 0 ? `; ${more} more sit${more === 1 ? 's' : ''} within ${wideReach} mm of a run: try --reach ${wideReach} and check sized_by` : ''}`;
219
+ const settingsText = settingsLine(settings, `; a size label counts within ${reachMm} mm of its run${plain ? ', plain sizes no tag claims included' : ''}${boundCodes.length ? `; labels coded ${boundCodes.join(', ')} go only to the groups of those names` : ''}`, notes, (pt) => pt / scale.ptPerM);
149
220
  const m = (pt) => pt / scale.ptPerM;
221
+ const gapsLine = notes.wider
222
+ .map(({ group, gapMm, pt, widerPt }) => {
223
+ const name = groups[group].name;
224
+ return `group ${name}: at ${gapMm} mm its pieces join into ${round(m(widerPt), 1)} m, not ${round(m(pt), 1)} m; its dashes may be farther apart than --gap. Check with \`drawing-axi runs\`, then pass --group-gap ${name}=${gapMm}`;
225
+ })
226
+ .join('. ');
150
227
  const groupRows = groups.map((group, index) => {
151
228
  const mine = sized.filter((r) => r.group === index);
152
229
  const length = mine.reduce((s, r) => s + r.length, 0);
@@ -253,6 +330,8 @@ export function measure(input) {
253
330
  text: scaleLine(scale),
254
331
  },
255
332
  size_labels: labelsLine,
333
+ ...(picturesLine ? { pictures: picturesLine } : {}),
334
+ ...(gapsLine ? { gaps: gapsLine } : {}),
256
335
  settings_text: settingsText,
257
336
  settings: {
258
337
  gap_mm: settings.gapMm,
@@ -262,7 +341,18 @@ export function measure(input) {
262
341
  region: settings.area.region,
263
342
  exclude: settings.area.exclude,
264
343
  },
265
- groups: groupRows,
344
+ groups: groupRows.map((row, index) => ({
345
+ ...row,
346
+ layers: groups[index].picks.map((p) => p.name),
347
+ })),
348
+ // Every size label that found no run, with its place, to look at.
349
+ unplaced: placed.missed.map((l) => ({
350
+ label: l.text,
351
+ size: l.size,
352
+ code: l.code,
353
+ x: Math.round((l.x0 + l.x1) / 2),
354
+ y: Math.round((l.y0 + l.y1) / 2),
355
+ })),
266
356
  sizes: sizeRows,
267
357
  labels: labelRows,
268
358
  labels_apart: apartRows,
@@ -304,6 +394,8 @@ export function measure(input) {
304
394
  scale: scaleLine(scale),
305
395
  settings: settingsText,
306
396
  size_labels: labelsLine,
397
+ ...(picturesLine ? { pictures: picturesLine } : {}),
398
+ ...(gapsLine ? { gaps: gapsLine } : {}),
307
399
  ...(saved ? { saved } : {}),
308
400
  groups: screen(groupRows).map((r) => tableRow(r, ['group', 'length_m', 'runs', 'sized_m', 'unsized_m'], fieldLimit)),
309
401
  sizes: screen(sizeRows)
@@ -311,6 +403,11 @@ export function measure(input) {
311
403
  .map((r) => tableRow(r, columns, fieldLimit)),
312
404
  // Which label sized what: a label of another system here is a
313
405
  // wrong pairing to check.
406
+ ...(labelRows.length > 12
407
+ ? {
408
+ sized_by_shown: `the first 12 of ${labelRows.length}; --save writes all`,
409
+ }
410
+ : {}),
314
411
  ...(labelRows.length
315
412
  ? {
316
413
  sized_by: screen(labelRows)
@@ -320,6 +417,11 @@ export function measure(input) {
320
417
  : {}),
321
418
  // A size the sheet names for a system, away from any pipe: it is
322
419
  // for the owner to confirm, not a measured size.
420
+ ...(apartRows.length > 12
421
+ ? {
422
+ labels_apart_shown: `the first 12 of ${apartRows.length}; --save writes all`,
423
+ }
424
+ : {}),
323
425
  ...(apartRows.length
324
426
  ? {
325
427
  labels_apart: apartRows
@@ -137,6 +137,7 @@ export function renderCommand(input) {
137
137
  try {
138
138
  picture = renderSvg(strokes, shownLabels, {
139
139
  ...region,
140
+ pictures: sheet.pictures,
140
141
  width,
141
142
  labels: input.values.labels === true,
142
143
  grid: input.values.grid === true,
@@ -10,6 +10,38 @@ const MAX_LABELS = 200_000;
10
10
  const MAX_FORM_DEPTH = 12;
11
11
  /** The longest side a sheet may have, in points: 200 inches at a unit of 20. */
12
12
  const MAX_SHEET = 288_000;
13
+ /** The most layers a sheet learns from its pages when the catalog lists none. */
14
+ const MAX_LAYERS = 10_000;
15
+ /** The most picture boxes a sheet keeps; the count goes on past it. */
16
+ const MAX_PICTURES = 5000;
17
+ /** Cells along each side when measuring how much pictures cover. */
18
+ const SHARE_CELLS = 100;
19
+ /**
20
+ * How much of a sheet the boxes cover, from 0 to 1, on a grid of cells: a
21
+ * box covers the cells whose centre it holds. Overlaps count once.
22
+ */
23
+ export function pictureShare(boxes, width, height) {
24
+ if (!boxes.length || width <= 0 || height <= 0)
25
+ return 0;
26
+ const n = SHARE_CELLS;
27
+ const cells = new Uint8Array(n * n);
28
+ let covered = 0;
29
+ for (const b of boxes) {
30
+ const c0 = Math.max(0, Math.ceil((b.x0 / width) * n - 0.5));
31
+ const c1 = Math.min(n - 1, Math.floor((b.x1 / width) * n - 0.5));
32
+ const r0 = Math.max(0, Math.ceil((b.y0 / height) * n - 0.5));
33
+ const r1 = Math.min(n - 1, Math.floor((b.y1 / height) * n - 0.5));
34
+ for (let r = r0; r <= r1; r++)
35
+ for (let c = c0; c <= c1; c++)
36
+ if (!cells[r * n + c]) {
37
+ cells[r * n + c] = 1;
38
+ covered++;
39
+ }
40
+ if (covered === n * n)
41
+ break;
42
+ }
43
+ return covered / (n * n);
44
+ }
13
45
  const CURVE_STEPS = 8;
14
46
  export class DrawingTooLarge extends Error {
15
47
  constructor() {
@@ -130,6 +162,31 @@ export function readSheet(doc, pageIndex, options = {}) {
130
162
  const texts = [];
131
163
  const skipped = new Set();
132
164
  let images = 0;
165
+ const pictures = [];
166
+ // A picture fills the unit square of its transform.
167
+ const picture = (ctm) => {
168
+ images++;
169
+ if (pictures.length >= MAX_PICTURES)
170
+ return;
171
+ const xs = [
172
+ ctm[4],
173
+ ctm[0] + ctm[4],
174
+ ctm[2] + ctm[4],
175
+ ctm[0] + ctm[2] + ctm[4],
176
+ ];
177
+ const ys = [
178
+ ctm[5],
179
+ ctm[1] + ctm[5],
180
+ ctm[3] + ctm[5],
181
+ ctm[1] + ctm[3] + ctm[5],
182
+ ];
183
+ const x0 = Math.max(0, Math.min(...xs));
184
+ const x1 = Math.min(width, Math.max(...xs));
185
+ const y0 = Math.max(0, Math.min(...ys));
186
+ const y1 = Math.min(height, Math.max(...ys));
187
+ if (x1 > x0 && y1 > y0 && Number.isFinite(x0 + x1 + y0 + y1))
188
+ pictures.push({ x0, y0, x1, y1 });
189
+ };
133
190
  let coords = 0;
134
191
  const formCache = new Map();
135
192
  const fontCache = new Map();
@@ -150,6 +207,20 @@ export function readSheet(doc, pageIndex, options = {}) {
150
207
  const dict = doc.dict(target);
151
208
  if (!dict)
152
209
  return -1;
210
+ // A layer the catalog does not list: a tool that joins sheets into one
211
+ // file drops the list, and each page still names its own layers.
212
+ const type = dict.get('Type');
213
+ if (target instanceof Ref &&
214
+ type instanceof Name &&
215
+ type.name === 'OCG' &&
216
+ layers.length < MAX_LAYERS) {
217
+ byObject.set(target.num, layers.length);
218
+ layers.push({
219
+ name: doc.text(dict.get('Name')) ?? `layer ${layers.length + 1}`,
220
+ hidden: false,
221
+ });
222
+ return layers.length - 1;
223
+ }
153
224
  const groups = dict.get('OCGs');
154
225
  if (groups instanceof Ref)
155
226
  return ocLayer(groups);
@@ -612,7 +683,7 @@ export function readSheet(doc, pageIndex, options = {}) {
612
683
  break;
613
684
  const subtype = target.dict.get('Subtype');
614
685
  if (subtype instanceof Name && subtype.name === 'Image') {
615
- images++;
686
+ picture(gs.ctm);
616
687
  break;
617
688
  }
618
689
  if (!(subtype instanceof Name && subtype.name === 'Form'))
@@ -660,7 +731,7 @@ export function readSheet(doc, pageIndex, options = {}) {
660
731
  p++;
661
732
  }
662
733
  lex.pos = Math.min(end, p + 2);
663
- images++;
734
+ picture(gs.ctm);
664
735
  break;
665
736
  }
666
737
  default:
@@ -735,6 +806,8 @@ export function readSheet(doc, pageIndex, options = {}) {
735
806
  fills,
736
807
  labels: [...comments, ...texts],
737
808
  images,
809
+ pictures,
810
+ pictureShare: pictureShare(pictures, width, height),
738
811
  skipped: outside
739
812
  ? [...skipped, `${outside} items far outside the sheet`]
740
813
  : [...skipped],
@@ -97,19 +97,19 @@ export function readLegend(strokes, labels, options) {
97
97
  }
98
98
  let kept = pairs;
99
99
  if (options.aligned) {
100
- // A legend's samples are one length and start in one column. The column
101
- // most captions share is the legend; rows beside it belong to it too.
102
- const columnOf = (sample) => `${Math.round(sample.x0 / 4)}|${Math.round((sample.x1 - sample.x0) / 4)}`;
103
- const columns = new Map();
100
+ const fits = (column, sample) => Math.abs(sample.x0 - column.x0) <= 6 &&
101
+ Math.abs(sample.x1 - sample.x0 - column.length) <=
102
+ Math.max(4, column.length * 0.1);
103
+ const columns = [];
104
104
  for (const { label, sample } of pairs) {
105
105
  const kind = `${sample.layer}|${sample.color}`;
106
- const column = columns.get(columnOf(sample));
106
+ const column = columns.find((c) => fits(c, sample));
107
107
  if (column) {
108
108
  column.labels.add(label);
109
109
  column.kinds.add(kind);
110
110
  }
111
111
  else
112
- columns.set(columnOf(sample), {
112
+ columns.push({
113
113
  labels: new Set([label]),
114
114
  kinds: new Set([kind]),
115
115
  x0: sample.x0,
@@ -119,7 +119,7 @@ export function readLegend(strokes, labels, options) {
119
119
  // A legend shows many systems, so its samples differ; a table of notes
120
120
  // with ruled lines does not.
121
121
  let best = null;
122
- for (const column of columns.values())
122
+ for (const column of columns)
123
123
  if (!best ||
124
124
  column.kinds.size > best.kinds.size ||
125
125
  (column.kinds.size === best.kinds.size &&
@@ -127,20 +127,44 @@ export function readLegend(strokes, labels, options) {
127
127
  best = column;
128
128
  if (!best || best.labels.size < 3 || best.kinds.size < 2)
129
129
  return [];
130
+ const column = best;
131
+ // Its captions line up on one edge: the left for Latin text, the right
132
+ // for Hebrew. A row whose caption lines up there belongs to the legend
133
+ // even when its sample is indented, if the sample is the legend's length.
134
+ const median = (values) => [...values].sort((a, b) => a - b)[Math.floor(values.length / 2)];
135
+ const left = median([...column.labels].map((l) => l.x0));
136
+ const right = median([...column.labels].map((l) => l.x1));
137
+ const aligned = (label) => Math.abs(label.x0 - left) <= 4 || Math.abs(label.x1 - right) <= 4;
138
+ const belongs = ({ label, sample }) => fits(column, sample) ||
139
+ (aligned(label) &&
140
+ Math.abs(sample.x1 - sample.x0 - column.length) <=
141
+ Math.max(4, column.length * 0.1));
142
+ // The legend runs on while its rows follow each other closely: from the
143
+ // column's own rows, a row joins when it is within 60 points of the
144
+ // legend so far. A line of the background plan that happens to cross a
145
+ // caption's row is neither the legend's length nor in its column.
146
+ const candidates = pairs.filter(belongs);
130
147
  let top = Infinity;
131
148
  let bottom = -Infinity;
132
- for (const label of best.labels) {
149
+ for (const label of column.labels) {
133
150
  top = Math.min(top, label.y0);
134
151
  bottom = Math.max(bottom, label.y1);
135
152
  }
136
- // A legend's own samples start together and are one length. A line of
137
- // the background plan that happens to cross a caption's row is neither.
138
- const x0 = best.x0;
139
- const length = best.length;
140
- kept = pairs.filter(({ label, sample }) => Math.abs(sample.x0 - x0) <= 6 &&
141
- Math.abs(sample.x1 - sample.x0 - length) <= Math.max(4, length * 0.1) &&
142
- label.y1 >= top - 60 &&
143
- label.y0 <= bottom + 60);
153
+ const inside = new Set();
154
+ for (let grew = true; grew;) {
155
+ grew = false;
156
+ for (const pair of candidates) {
157
+ if (inside.has(pair))
158
+ continue;
159
+ if (pair.label.y1 >= top - 60 && pair.label.y0 <= bottom + 60) {
160
+ inside.add(pair);
161
+ top = Math.min(top, pair.label.y0);
162
+ bottom = Math.max(bottom, pair.label.y1);
163
+ grew = true;
164
+ }
165
+ }
166
+ }
167
+ kept = candidates.filter((pair) => inside.has(pair));
144
168
  }
145
169
  const seen = new Set();
146
170
  const entries = [];
@@ -293,3 +293,75 @@ export function distanceToRun(x, y, run) {
293
293
  export function runsTouch(a, b, tolerance) {
294
294
  return (Math.min(distanceToRun(a.x0, a.y0, b), distanceToRun(a.x1, a.y1, b), distanceToRun(b.x0, b.y0, a), distanceToRun(b.x1, b.y1, a)) < tolerance);
295
295
  }
296
+ /** How far, in points, a shadow run may lie from the run it follows. */
297
+ const SHADOW_OFFSET = 5;
298
+ /** The share of a run's length that carries ink, from 0 to 1. */
299
+ export function inkShare(run) {
300
+ if (!run.length)
301
+ return 0;
302
+ let ink = 0;
303
+ for (let i = 0; i < run.drawn.length; i += 2)
304
+ ink += run.drawn[i + 1] - run.drawn[i];
305
+ return Math.min(1, ink / run.length);
306
+ }
307
+ /**
308
+ * Leaves out runs that ride along a longer run: a row of linetype letters
309
+ * plotted as strokes beside its pipe joins into a sparse line a point or two
310
+ * off the pipe. A run is left out when it lies within a few points of a
311
+ * longer run, along at least 70% of its own length, in the same direction,
312
+ * and carries under half as much ink, which the other beats by a fifth. The
313
+ * side lines of a pipe drawn with three lines are solid and stay.
314
+ */
315
+ export function dropShadows(runs) {
316
+ const sinMax = Math.sin((4 * Math.PI) / 180);
317
+ const ink = runs.map(inkShare);
318
+ const boxes = runs.map((r, i) => ({
319
+ i,
320
+ x0: Math.min(r.x0, r.x1) - SHADOW_OFFSET,
321
+ x1: Math.max(r.x0, r.x1) + SHADOW_OFFSET,
322
+ y0: Math.min(r.y0, r.y1) - SHADOW_OFFSET,
323
+ y1: Math.max(r.y0, r.y1) + SHADOW_OFFSET,
324
+ }));
325
+ boxes.sort((a, b) => a.x0 - b.x0);
326
+ const shadow = new Uint8Array(runs.length);
327
+ for (let a = 0; a < boxes.length; a++) {
328
+ const A = boxes[a];
329
+ for (let b = a + 1; b < boxes.length; b++) {
330
+ const B = boxes[b];
331
+ if (B.x0 > A.x1)
332
+ break;
333
+ if (B.y0 > A.y1 || B.y1 < A.y0)
334
+ continue;
335
+ for (const [s, p] of [
336
+ [A.i, B.i],
337
+ [B.i, A.i],
338
+ ]) {
339
+ const short = runs[s];
340
+ const long = runs[p];
341
+ if (shadow[s] || long.length < short.length)
342
+ continue;
343
+ if (!(ink[s] < 0.5 &&
344
+ ink[p] >= ink[s] + 0.2))
345
+ continue;
346
+ const ux = (long.x1 - long.x0) / long.length;
347
+ const uy = (long.y1 - long.y0) / long.length;
348
+ const vx = (short.x1 - short.x0) / (short.length || 1);
349
+ const vy = (short.y1 - short.y0) / (short.length || 1);
350
+ if (Math.abs(ux * vy - uy * vx) > sinMax)
351
+ continue;
352
+ const off = (x, y) => Math.abs((x - long.x0) * uy - (y - long.y0) * ux);
353
+ if (off(short.x0, short.y0) > SHADOW_OFFSET ||
354
+ off(short.x1, short.y1) > SHADOW_OFFSET)
355
+ continue;
356
+ const t0 = (short.x0 - long.x0) * ux + (short.y0 - long.y0) * uy;
357
+ const t1 = (short.x1 - long.x0) * ux + (short.y1 - long.y0) * uy;
358
+ const over = Math.min(long.length, Math.max(t0, t1)) -
359
+ Math.max(0, Math.min(t0, t1));
360
+ if (over >= short.length * 0.7)
361
+ shadow[s] = 1;
362
+ }
363
+ }
364
+ }
365
+ const kept = runs.filter((_, i) => !shadow[i]);
366
+ return { kept, dropped: runs.length - kept.length };
367
+ }
@@ -107,8 +107,17 @@ export function findScaleBar(sheet, ratio) {
107
107
  const cells = barCells(ink, a, b);
108
108
  if (cells < 4)
109
109
  continue;
110
- if (!best || cells > best.cells)
110
+ // A scale bar stands alone. A hatch, such as paving drawn in the plan,
111
+ // is a field: the same ink goes on beyond the band on both sides. Of
112
+ // equal bars, the one with the least ink beside it is taken.
113
+ const beside = besideInk(ink, a, b);
114
+ if (beside === null)
115
+ continue;
116
+ if (!best ||
117
+ cells > best.cells ||
118
+ (cells === best.cells && beside < best.beside))
111
119
  best = {
120
+ beside,
112
121
  ptPerM: length / metres,
113
122
  cells,
114
123
  bar: {
@@ -153,6 +162,38 @@ function inkIndex(sheet) {
153
162
  * How many alternating cells lie between two edges, or 0. A bar is one row of
154
163
  * dark and light cells, or two rows in a checker pattern.
155
164
  */
165
+ /** The ink that lies within a band along a bar, at an offset across it. */
166
+ function bandInk(ink, a, from, to) {
167
+ const length = a.to - a.from;
168
+ const x0 = a.horizontal ? a.from : from;
169
+ const x1 = a.horizontal ? a.to : to;
170
+ const y0 = a.horizontal ? from : a.from;
171
+ const y1 = a.horizontal ? to : a.to;
172
+ let total = 0;
173
+ for (let gx = Math.floor(x0 / INK_CELL); gx <= Math.floor(x1 / INK_CELL); gx++)
174
+ for (let gy = Math.floor(y0 / INK_CELL); gy <= Math.floor(y1 / INK_CELL); gy++)
175
+ for (const mark of ink.get(gx * 100_003 + gy) ?? []) {
176
+ if (mark.size > length * 0.35)
177
+ continue;
178
+ if (mark.x > x0 && mark.x < x1 && mark.y > y0 && mark.y < y1)
179
+ total += mark.weight;
180
+ }
181
+ return total;
182
+ }
183
+ /**
184
+ * The ink beside a bar's band, as a share of the band's own: the bands of
185
+ * the same depth on each side. Null when the bar sits in a field of the same
186
+ * ink, both sides holding at least half as much as the bar.
187
+ */
188
+ function besideInk(ink, a, b) {
189
+ const depth = b.at - a.at;
190
+ const own = bandInk(ink, a, a.at, b.at);
191
+ if (own <= 0)
192
+ return 0;
193
+ const before = bandInk(ink, a, a.at - depth, a.at) / own;
194
+ const after = bandInk(ink, a, b.at, b.at + depth) / own;
195
+ return before >= 0.5 && after >= 0.5 ? null : before + after;
196
+ }
156
197
  function barCells(ink, a, b) {
157
198
  const length = a.to - a.from;
158
199
  const depth = b.at - a.at;
@@ -161,7 +161,9 @@ export function decodeLabels(labels) {
161
161
  if (l.source !== 'shx' || (s.match(/[a-z]/g)?.length ?? 0) < 4)
162
162
  return;
163
163
  samples++;
164
- if (plausibleHebrew(keyed(s)))
164
+ // A Latin code in brackets after the words does not count against them.
165
+ const words = s.trim().replace(/\s*\)[A-Za-z]{1,3}\(\s*$/, '');
166
+ if (plausibleHebrew(keyed(words)))
165
167
  plausible++;
166
168
  });
167
169
  const hebrewKeys = samples >= 3 && plausible / samples >= 0.6;
@@ -177,12 +179,20 @@ export function decodeLabels(labels) {
177
179
  return;
178
180
  }
179
181
  if (hebrewKeys && /[a-z]/.test(s)) {
180
- const mapped = keyed(s);
181
- if (plausibleHebrew(mapped)) {
182
- l.text = orderRuns([...mapped])
183
- .join('')
184
- .replace(/(?<=[\u05d0-\u05ea])''(?=[\u05d0-\u05ea])/g, '"')
185
- .trim();
182
+ const hebrew = (text) => orderRuns([...keyed(text)])
183
+ .join('')
184
+ .replace(/(?<=[\u05d0-\u05ea])''(?=[\u05d0-\u05ea])/g, '"')
185
+ .trim();
186
+ if (plausibleHebrew(keyed(s))) {
187
+ l.text = hebrew(s);
188
+ return;
189
+ }
190
+ // A system code in brackets after the words, such as (O) or (OD),
191
+ // was typed in Latin letters and is stored back to front.
192
+ const coded = /^(.*\S)\s*\)([A-Za-z]{1,3})\(\s*$/.exec(s.trim());
193
+ if (coded && plausibleHebrew(keyed(coded[1]))) {
194
+ const code = [...coded[2]].reverse().join('').toUpperCase();
195
+ l.text = `${hebrew(coded[1])} (${code})`;
186
196
  return;
187
197
  }
188
198
  }
@@ -12,9 +12,16 @@ const INCH = /(?:\u00d8\s*)?(\d{1,2}(?:\.\d+)?(?:\s*\d\/\d)?|\d\/\d)\s*"/;
12
12
  const DN = /\bDN\s*(\d{2,4})\b/i;
13
13
  const SLOPE = /\d\s*-\s*\d+(?:\.\d+)?\s*%|\d\s*%/;
14
14
  const PREFIX = /^[A-Za-z][A-Za-z0-9.]{0,5}\s*-/;
15
- /** A system code reduced to its letters: "C.W.2-" and "CW1" are both CW. */
15
+ /** A size and nothing else: Ø63, 4", 3/4", DN100. */
16
+ const ALONE = /^(?:\u00d8\s*\d+(?:[.,]\d+)?|\d+(?:\/\d+)?(?:\s*\d\/\d)?\s*"|DN\s*\d+)$/i;
17
+ /**
18
+ * A system code: the letters before the first digit, dots left out. "C.W.2-"
19
+ * and "CW1" are both CW, and "OD7A" is OD: a letter after the number names
20
+ * one line of the system, not another system.
21
+ */
16
22
  export function codeOf(text) {
17
- const letters = text.replace(/[^A-Za-z]/g, '').toUpperCase();
23
+ const head = /^[^0-9]*/.exec(text)?.[0] ?? '';
24
+ const letters = head.replace(/[^A-Za-z]/g, '').toUpperCase();
18
25
  return letters || null;
19
26
  }
20
27
  /** The pipe size a label states, or null. */
@@ -45,6 +52,7 @@ export function sizeLabels(labels) {
45
52
  size,
46
53
  text: label.text.trim(),
47
54
  code: prefix ? codeOf(prefix[0]) : null,
55
+ alone: ALONE.test(label.text.trim()),
48
56
  onRun: SLOPE.test(label.text) || prefix !== null,
49
57
  x0: label.x0,
50
58
  y0: label.y0,
@@ -103,17 +111,19 @@ placed) {
103
111
  continue;
104
112
  tried.add(index);
105
113
  const groupCode = codes[out[index].group] ?? null;
114
+ // A group named by a code takes only labels of that code, and sizes
115
+ // written alone; never a slope label, which is a gravity pipe's.
116
+ if (groupCode !== null && label.code !== groupCode && !label.alone)
117
+ continue;
106
118
  const score = fit(label, cx, cy, out[index], options);
107
- // A label written in a break of a line is that line's, whatever
108
- // the groups are called. Beside a line, a coded label belongs to
109
- // the group of that code, when there is one, and never to a group
110
- // of another code.
111
- if (score >= 1 && label.code !== null) {
112
- if (bound.has(label.code) && groupCode !== label.code)
113
- continue;
114
- if (groupCode !== null && groupCode !== label.code)
115
- continue;
116
- }
119
+ // A label written in a break of an unnamed group's line is that
120
+ // line's. Beside a line, a coded label belongs to the group of its
121
+ // code, when there is one.
122
+ if (score >= 1 &&
123
+ label.code !== null &&
124
+ bound.has(label.code) &&
125
+ groupCode !== label.code)
126
+ continue;
117
127
  if (score < bestScore) {
118
128
  best = index;
119
129
  bestScore = score;
@@ -86,6 +86,16 @@ export function renderSvg(strokes, labels, options) {
86
86
  `<svg xmlns="http://www.w3.org/2000/svg" width="${options.width}" height="${height}" viewBox="${n1(x0)} ${n1(y0)} ${n1(w)} ${n1(h)}">`,
87
87
  `<rect x="${n1(x0)}" y="${n1(y0)}" width="${n1(w)}" height="${n1(h)}" fill="#ffffff"/>`,
88
88
  ];
89
+ // The sheet's own pictures are not drawn; a box with a cross shows where
90
+ // each one is, so lines missing from the picture are not taken for absent.
91
+ const inside = (options.pictures ?? []).filter((b) => b.x1 >= x0 && b.x0 <= x1 && b.y1 >= y0 && b.y0 <= y1);
92
+ if (inside.length) {
93
+ const line = n1((w / options.width) * 0.6);
94
+ out.push(`<g fill="#f2f2f2" stroke="#b0b0b0" stroke-width="${line}"><title>picture: not drawn</title>`);
95
+ for (const b of inside)
96
+ out.push(`<rect class="picture" x="${n1(b.x0)}" y="${n1(b.y0)}" width="${n1(b.x1 - b.x0)}" height="${n1(b.y1 - b.y0)}"/><path fill="none" d="M${n1(b.x0)} ${n1(b.y0)}L${n1(b.x1)} ${n1(b.y1)}M${n1(b.x1)} ${n1(b.y0)}L${n1(b.x0)} ${n1(b.y1)}"/>`);
97
+ out.push('</g>');
98
+ }
89
99
  if (options.grid) {
90
100
  const step = niceStep(Math.max(w, h));
91
101
  const size = n1((w / options.width) * 11);
@@ -67,6 +67,7 @@ export function findTags(labels) {
67
67
  size,
68
68
  x: (best.x0 + best.x1) / 2,
69
69
  y: (best.y0 + best.y1) / 2,
70
+ sizeLabel: label,
70
71
  });
71
72
  }
72
73
  return tags;
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Kept equal to package.json by test/unit/version.test.ts.
2
- export const VERSION = '0.1.1';
2
+ export const VERSION = '0.1.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drawing-axi",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "A command-line tool that lets AI agents read CAD drawings saved as PDF: layers, labels, scale, pipe runs and counts",
5
5
  "license": "MIT",
6
6
  "type": "module",