Repository navigation
feat(lidar): read LAS and LAZ tiles into the scene's world frame (p7-s3) (#243) - #492
Merged
Merged
Conversation
A new kernel module, `roadmaker::lidar`, imports ASPRS point clouds and fits their ground into the scene's height field. It reads LAS 1.0-1.4 and LAZ itself rather than through PDAL, because PDAL hard-requires PROJ 9.0, GDAL 3.8 and libgeotiff -- the dependency ADR-0010 declined two days ago. ADR-0011 records that ruling; the only new dependency here is laz-perf 3.4.0 (Apache-2.0), which decodes the compressed chunk stream and does nothing else. Three things in the design are load-bearing rather than incidental: - Coordinates are floats RELATIVE to a double origin. At a UTM northing near 5.8e6 m a float's quantum is about half a metre, so a cloud held in absolute floats would terrace itself into visible steps. - Decimation is decided from the header, before a single point is read: a tile too large to hold is also too large to read and then thin. The stride is deterministic and the ratio is always reported, because a cloud silently reduced to a twelfth of itself looks like a sparse survey rather than a truncated one. - The ground fit takes the MEAN of the returns a tile classified as bare ground, and only falls back to the lowest return when it classified none. The minimum exists to reject roofs and canopy and pays for it with half a cell of downhill bias on a slope; where the file has already done that work, there is nothing left for it to buy. The CRS comes out of the LAS `LASF_Projection` records through the same bounded family the GIS importer uses -- the GeoTIFF GeoKey reader is lifted out of geotiff.cpp into gis_common so a raster and a tile describing the same place can never disagree -- and anything outside that family is refused by name, citing #485. Fixtures are generated by a standard-library-only script and committed, so a reader is never checked against bytes the same test just built. `amsterdam_tile.laz` needs the codec, so a small standalone tool writes it; that tool deliberately does not link roadmaker::core, and it splices the source's projection records back in because laz-perf's writer emits only its own -- the first version of it silently produced a .laz with no coordinate system at all, and the suite passed anyway. Closes part of #243.
Neutralising each load-bearing rule in turn and re-running showed two of them were not actually pinned by anything. The offset representation. Forcing the cloud origin to zero -- holding absolute coordinates in the floats, the exact defect the design exists to avoid -- left the whole suite green. The reason is arithmetic, not luck: at a northing of 5 803 000 a float's quantum is exactly 0.5 m, and the fixture tile's coordinates are all multiples of 5, so they survive an absolute float untouched. `precision_probe.las` carries centimetre offsets instead, which no float at that magnitude can hold. The ground estimator. Swapping the classified path back to the lowest return also left the suite green, because the error it introduces is about half a cell of grade -- which is exactly the slack a binning fit's tests have to allow. The new gate is exact rather than tolerant, and it can be: with a 5 m lattice under 10 m posts every interior post collects the same 2x2 block, so the mean lands 0.175 m below the plane and the minimum 0.350 m below it. Both are constants, and asserting the first to a millimetre rejects the second outright. Asserting the mean's offset rather than asserting no offset at all is deliberate: the residual is the nearest-post TIE RULE's, not the estimator's, and a test that claimed zero would be wrong about which part of the code it was describing. Also samples inside the tile in the worked example. It was reading the scene origin, a kilometre away, and reporting the field's clamped edge.
std::any_of and std::min arrive transitively through libc++ on macOS, so a clean local build was not evidence the include was there. Linux clang found it. Also adds <cstddef> to the fixture tool, which had the same shape of omission and is EXCLUDE_FROM_ALL, so CI would never have said.
This was referenced Jul 29, 2026
JArmandoAnaya
added a commit
that referenced
this pull request
Jul 29, 2026
Both arrive transitively through libc++ on macOS and not through Linux clang, which is exactly how #492 shipped a green local build that broke CI on the same class of omission.
JArmandoAnaya
added a commit
that referenced
this pull request
Jul 29, 2026
…(p7-s3) (#243) (#493) * feat(editor): see a lidar tile in the scene, and turn it into ground (p7-s3) The editor half of #243. A point cloud becomes the third ReferenceLayerKind, imported with File > Import > Point Cloud... and turned into terrain with Edit > Terrain > Seed from Point Cloud... Everything Layer 2 already guarantees is inherited unchanged: the relative-path contract, re-derivation when the frame changes, the per-entry sidecar tolerance, and the ruling that adding a layer is not an undoable command. Seeding terrain is, and goes through the same edit::set_terrain_field the DEM and elevation-raster paths use, so it is one undo entry. Two things a cloud does NOT inherit from an imagery underlay: - It is not flattened. Vectors and rasters are backdrops drawn at a fixed height; a cloud has real Z and draws depth-sorted with the scene, because its heights are why it was imported at all. - Its vertices stay in the cloud's own frame, with the origin carried as the draw's single instance matrix. Baking the origin into the vertex buffer would put a scene-scale value back into a float and reintroduce the terracing the offset representation exists to prevent -- the same defect the kernel guards, one layer further out. THE PRIMITIVE PATH IS NOW A SWITCH. Drawing points needed a third PrimitiveKind, and the renderer chose its GL primitive with a two-way ternary: `kind == Triangles ? kTriangles : kLines`. A third enumerator added without touching that line would have drawn the cloud as LINE SEGMENTS BETWEEN CONSECUTIVE POINTS -- silently, no warning, no error. Both that site and the two-way branch in the layer bounds are switches now, and a named test pins each. THE SIDECAR'S `kind` STOPS BEING A BOOL. It is the same enum the runtime uses, so a third spelling cannot exist in one and not the other. Older sidecars carry only "vector" and "raster" and load unchanged; an unknown spelling still reads as a raster with a warning rather than dropping the layer. ALSO WIRES UP A PATH THAT SHIPPED DEAD. Document::refit_reference_layers() was added by #242 and called from nowhere: reopening a scene re-derived its layers, but changing the georeference LIVE left them over the wrong ground. GW-2 step 31 asks a hand-runner to check exactly that, and its pass criterion already said a build which mishandles it fails the run -- so the gap was written down before it was closed. #243 would otherwise have added a third layer kind inheriting the same dead path. GW-2 gains steps 34-37 and three pass criteria, the sharpest being that the cloud and the imagery must land on each other: they are read by different parsers but share one CrsTransform, so a visible offset between them is a projection bug and this is the cheapest place in the workflow to notice one. Closes #243. * test(editor): include <filesystem> and <algorithm> explicitly Both arrive transitively through libc++ on macOS and not through Linux clang, which is exactly how #492 shipped a green local build that broke CI on the same class of omission.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The kernel half of #243 (p7-s3): a new
roadmaker::lidarmodule that readsASPRS point clouds, moves them into the scene's world frame, and fits their
ground into the scene height field. Follows ADR-0011 (#491), which ruled that
RoadMaker reads LAS itself rather than through PDAL — PDAL hard-requires PROJ
9.0, GDAL 3.8 and libgeotiff, the dependency ADR-0010 declined two days ago.
The editor half — the point-cloud reference layer, the points render path and the
two menu entries — follows in its own PR.
What landed
LASF_Projectionrecords — GeoKey directory (34735) or OGC WKT (2112) — through the same bounded family the GIS importer usesrm.lidarbesiderm.gis, pluspython/examples/lidar_import.pyThree things that are load-bearing rather than incidental
Coordinates are floats relative to a double origin. At a UTM northing near
5.8 × 10⁶ m a float's quantum is about half a metre, so a cloud held in absolute
floats would terrace itself into visible steps.
Decimation is decided from the header, before a single point is read. A tile
too large to hold is also too large to read and then thin. The stride is
deterministic — every nth point — and the ratio is always reported, because a
cloud silently reduced to a twelfth of itself looks like a sparse survey rather
than a truncated one.
The ground fit takes the mean of the returns a tile classified as bare ground,
and only falls back to the lowest return when it classified none. The minimum
exists to reject roofs and canopy and pays for that with half a cell of downhill
bias on a slope; where the file has already done that work, there is nothing left
for it to buy. Which estimator ran is always named in a diagnostic — they
disagree under a bridge.
Reuse rather than a second implementation
The GeoTIFF GeoKey directory reader moves out of
geotiff.cppintogis_common,so a raster and a lidar tile describing the same place cannot disagree about what
it is. No public API change;
crs_transform's refusal message and its #485citation stay identical across all three importers.
laz-perf is built from source, not through its own CMake
Upstream's
CMakeLists.txtdeclares an explicitSHAREDtarget and addsbenchmarks, tools and install rules unguarded, and its test path runs a
configure-time
file(DOWNLOAD). So it is taken with the repo's existingSOURCE_SUBDIR cmake-disabledidiom and compiled into a smallrm_lazperftarget with upstream's own
LAZPERF_VENDOREDmacro. Pinned by tag +URL_HASH,with its
THIRD_PARTY_LICENSES.mdrow in the same commit.Fixtures are committed, and one of them is a trap for this reader
scripts/gen_lidar_fixtures.pywrites them with the standard library alone, inthe same place as the GIS fixtures — Amsterdam, UTM 31N — so a false easting or a
wrong central meridian cannot hide at (0, 0), and so the two importers can be
checked against each other.
EveryFixtureIsPresentis itself a test.amsterdam_tile.lazneeds the codec, so a small standalone tool writes it. Thattool deliberately does not link
roadmaker::core— a fixture generated bythe reader under test would bake that reader's mistakes into the fixture, and the
comparison would then agree with both of them.
That tool also had a real bug worth recording: laz-perf's writer emits its own
header and only its own VLRs, so the first version of it silently produced a
.lazwith no coordinate system at all — and the suite passed anyway,because it compared coordinates and classification but not CRS. It was found by
running the worked example, not by the tests. Both halves are fixed: the tool
splices the projection records back in (correcting the absolute chunk-table
offset as it does), and
LazDecodesIdenticallyToLasnow asserts CRS equality andnon-emptiness.
Verification
cmake --build --preset ci-macos(-Werror) clean;ctest --preset ci-macos2616/2616.
pytest python/tests381 passed, 1 skipped;python/examples/lidar_import.pyruns end to end.
zero sanitizer findings.
scripts/gen_lidar_fixtures.pyis idempotent — re-running leaves the tree clean.git ls-files '*.cpp' '*.hpp' | xargs clang-format --dry-run --Werrorclean(CI's exact command).
Sabotage matrix — six neutralisations, each rebuilt and re-run
Every sabotage is a runtime neutralisation rather than a deletion, and every run
echoes the build's exit code, so a sabotage that failed to compile cannot report
green off a stale binary.
LegacyFormatsMaskTheClassificationBits,ClassificationSurvivesTheFormatPromotionDecimationHonoursTheBudgetAndSaysSoxyzholds absolute floats (origin forced to 0)DetailFinerThanAFloatsQuantumSurvivesTheReadTheClassifiedFitReadsTheMeanOfItsPost_NotTheLowestReturnEmptyCellsAreInterpolatedNeverWrittenAsZero,TurningClassificationOffChangesTheAnswerWhereItShouldLazDecodesIdenticallyToLasSabotages 3 and 4 passed on the first attempt, which is the useful part of
the run: two rules this PR describes as load-bearing were not pinned by anything.
Both gates in the table are new, and the second commit explains why each earlier
test was blind:
absolute float at UTM magnitude, because the quantum there is exactly 0.5 m.
A new
precision_probe.lascarries centimetre offsets, which are not.slack a binning fit's tests have to allow. The new gate is exact instead: with
a 5 m lattice under 10 m posts every interior post collects the same 2×2 block,
so the mean lands 0.175 m below the plane and the minimum 0.350 m below it.
It asserts the mean's offset rather than no offset, because that residual is
the nearest-post tie rule's and not the estimator's.
Part of #243. Pillar P7, epic #256.