Local placement record
64-bitThe scale, rotation and point pair that tie drawing coordinates to grid coordinates.
scale = m per drawing unit ÷ m per grid unit; from = (x, y); to = (e, n)
The scale is one division of the two unit factors handed in; the placement's point, grid point and rotation are copied unchanged. When the scale is within 1e-12 of 1 and the placement is all zeros, the function returns nothing and the drawing's numbers are used as grid coordinates.
/**
* The drawing's own coordinates in a projected system: `place` {x, y (a drawing point), e, n (where it is on the map grid),
* rot (degrees: the drawing's X axis turned from the grid's east)} and the drawing's metres per unit → a crs.js `local`.
* With drawing units equal to the system's and no placement, null (the drawing's numbers are grid coordinates).
*/
export function drawingLocal(entry, place, mPerUnit, METRES_PER) {
const k = mPerUnit && METRES_PER[entry.unit] ? mPerUnit / METRES_PER[entry.unit] : 1;
const p = place || { x: 0, y: 0, e: 0, n: 0, rot: 0 };
if (Math.abs(k - 1) < 1e-12 && !p.x && !p.y && !p.e && !p.n && !p.rot) return null;
return { scale: k, rotation: p.rot || 0, from: [p.x || 0, p.y || 0], to: [p.e || 0, p.n || 0] };
}