We must first distinguish between flatness and level.
In mathematics, the flatness of a surface is the degree to which it approximates a mathematical plane. We call this plane level if it is on average orthogonal (at right angles) to gravity. (Sometimes called “in water”) So we only talk about something being level if it is also very flat.
To measure flatness we require a reference plane. To measure level we require a reference to gravity. Typically we measure a matrix of points or angles and interpolate between these discrete measurements.