Stand-in ground for a road with no survey
64-bitThe elevation and extent of the flat ground a corridor is drawn on when the project has no surface.
z = mean of the PVI elevations, rounded to 0.01; margin = (60 m or 200 ft) + 6 × (z_max − z_min)
The mean is a sum in order divided by the count, then rounded with Math.round(× 100) ÷ 100. Without a design profile the elevation is 0. The flat ground is nine points on the alignment's bounding box widened by the margin.
if (prof.ok && (a.pvis || []).length >= 2) z = Math.round((a.pvis.reduce((v, q) => v + q.z, 0) / a.pvis.length) * 100) / 100;
else { basis = 'zero'; z = 0; prof = buildProfile([{ sta: al.start, z: 0 }, { sta: al.end, z: 0 }]); }
// flat ground under the alignment, wide enough for its daylight (the profile's rise and fall at the flattest slope)
const pl = al.polyline(Math.max(al.length / 200, 1));
const zs = basis === 'profile' ? a.pvis.map((q) => q.z) : [0], dz = Math.max(...zs) - Math.min(...zs);
const pad = (m ? 60 : 200) + 6 * dz;
const x0 = Math.min(...pl.map((q) => q.x)) - pad, x1 = Math.max(...pl.map((q) => q.x)) + pad, y0 = Math.min(...pl.map((q) => q.y)) - pad, y1 = Math.max(...pl.map((q) => q.y)) + pad;
const pts = []; for (const x of [x0, (x0 + x1) / 2, x1]) for (const y of [y0, (y0 + y1) / 2, y1]) pts.push({ x, y, z });
const flat = buildSurface({ points: pts }).surface;