Writes points for a total station as a text file, reads such a file back, and compares as-built points with the design.
How the precision is kept
Points are 64-bit inside the app. The file holds them as text with 3 decimals by default, so a point written and read back agrees with the original to half of the last decimal. The comparison works on the 64-bit values and rounds only the table it prints.
Calculations under this policy
6 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.
Each point's northing, easting and elevation as text.
text = v.toFixed(3); 0 when |v| < 0.0005
The coordinate is rounded once, by toFixed, to the number of decimals asked for (3 by default). A value below half of the last decimal is written as 0 so the file never holds −0.000.
Turns the northing, easting and elevation text of a row into numbers.
x = Number(E); y = Number(N); z = Number(Z) or none
Each number is converted once from the file's text to the nearest 64-bit value, with every digit the file holds. An empty elevation stays empty, it does not become 0.
layout/layout-points.js
lines 81 to 89
CadCraft 0.8.2
const N = c[iN], E = c[iE], Z = c[iZ];
if (!isNum(N) || !isNum(E)) { bad(r, 'ne'); continue; }
if (Z !== undefined && Z !== '' && !isNum(Z)) { bad(r, 'z'); continue; }
let n = iP >= 0 ? String(c[iP] ?? '').trim() : '';
if (iP >= 0 && !n) { bad(r, 'nonum'); continue; }
if (iP < 0) { do n = String(++auto); while (seen.has(n)); }
if (seen.has(n)) { out.duplicates++; bad(r, 'twice', { num: n }); continue; }
seen.add(n);
out.points.push({ n: cleanText(n), x: Number(E), y: Number(N), z: Z === undefined || Z === '' ? null : Number(Z), d: iD >= 0 ? cleanText(c[iD] ?? '') : '' });
Difference between a design and an as-built point
64-bit
The offsets in x, y and height, the horizontal and 3D distance, and whether the point is within tolerance.
dh = √(dx² + dy²); d3 = √(dh² + dz²); out when dh > tol or |dz| > tolZ
The offsets are differences of coordinates that are usually large and close together, so their absolute error is that of the coordinates. The tolerance test adds 1e-9, an absolute allowance in the file's units.
The rows of the comparison as text for the page and the CSV.
text = v.toFixed(3)
Coordinates and differences are written with toFixed, 3 decimals by default. The CSV therefore holds the rounded text, not the full differences.
layout/layout-points.js
lines 183 to 187
CadCraft 0.8.2
export function compareTable(cmp, { head, status, dec = 3 }) {
const f = (v) => (v === null || v === undefined || !Number.isFinite(v) ? '' : v.toFixed(dec));
return [head, ...cmp.rows.map((r) => [r.n, r.built, status[r.status] || r.status, r.d,
f(r.design?.y), f(r.design?.x), f(r.design?.z), f(r.asBuilt?.y), f(r.asBuilt?.x), f(r.asBuilt?.z), f(r.dx), f(r.dy), f(r.dz), f(r.dh)])];
}
In detail
Method
Fixed decimals on writing; JavaScript's Number() on reading; horizontal and 3D distance by Math.hypot; root mean square of the horizontal distances.
Number types
64-bit numbers; text with a fixed number of decimals in the file.
Tolerances
A point is out when its horizontal distance exceeds tol + 1e-9 or its height difference exceeds the height tolerance + 1e-9; the 1e-9 is absolute, in the file's units.
Limits
The exported file carries 3 decimals unless another number is asked for.
Approach: 64-bit, stated limit
The arithmetic is 64-bit, but the method or the data sets the accuracy: a solver tolerance, a mesh, a step size, a datum shift, a table. The limit is stated where the result is shown.