Keep curvature calculations finite for valid road geometry - #101
Merged
pfeiferj merged 3 commits intoSep 7, 2026
Conversation
FrogAi
force-pushed
the
codex/keep-curvature-geometry-finite
branch
from
August 10, 2026 02:54
d068322 to
d7c5918
Compare
FrogAi
force-pushed
the
codex/keep-curvature-geometry-finite
branch
from
September 4, 2026 21:28
d7c5918 to
b49258c
Compare
FrogAi
added a commit
to FrogAi/mapd
that referenced
this pull request
Sep 4, 2026
Retain the original PR commits and the tested rewrite. The resulting file tree is identical to b49258c.
Replace the earlier implementation with the simplified version.
FrogAi
force-pushed
the
codex/keep-curvature-geometry-finite
branch
from
September 4, 2026 21:50
e5b55ac to
2a6c183
Compare
This was referenced Sep 5, 2026
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.
Straight and nearly straight road points can produce nonfinite curvature in the upstream calculation. Keep internal distances in float64, calculate the curve angle with a bounded asin, and give a zero-curvature segment its endpoint span so it contributes to smoothing.
Use sorted-side Heron arithmetic to limit cancellation near a straight line, and clamp the haversine term's upper rounding error before the square roots. The public distance interface still returns float32. Duplicates retain zero numeric fields at the middle point.
Road-connection decisions use curvature in m^-1. Keeping these values finite preserves valid connections and the weights used by smoothing and target-speed calculation. This is a numerical correction at the shared geometry owner; downstream policy is unchanged.
2.885660024e-7 m^-1, unchanged on reversalAntipodal endpoints test the public coordinate domain; they are not realistic road segments. Stable area arithmetic does not remove all float64 distance rounding, and this PR does not claim universal coordinate accuracy, a measured driving benefit, or a timing improvement.
Numerical rationale and reproducible validation
The product of the four sorted-side Heron factors is sixteen times area squared. Its square root therefore supplies the curvature numerator directly. The calculation keeps the nonnegative clamp, finite straight fallback and bounded asin. An arbitrary epsilon threshold would discard small valid curvature and is unnecessary here.
Tested source and validation scope
7201c6b4b4ec1b0b9ea21daa8c05b80fdd7e01ee.9d61f06, tree49fbfb3dfb3c59b956f314233274083b0e26d74d.Checks described here used Go 1.25.1 on Linux amd64 with isolated fixtures and networking disabled during behavior tests. Existing repository tests remain unchanged; the extra reproductions below are deliberately outside the committed source. These are local execution results, not physical-device validation. The PR's Checks tab provides the published workflow result.
Focused checks exercised duplicates, ordinary circles, reversal, public float32 compatibility, connection thresholds 0.1/0.15/0.3 m^-1, smoothing and target-speed behavior. Repository tests and vet passed. The larger 3,004-triple side/coordinate-oracle diagnostics are supplementary local evidence; the complete public check below verifies the antipodal and nearly straight cases. The side oracle conditions on rounded computed distances; the coordinate oracle uses higher-precision spherical distances, so they answer different accuracy questions.
This compact check uses only the public API. Run it from a checkout containing the PR head below, with Linux Go 1.25.1 and its go.mod dependencies already available in the Go module cache. It copies source and dependencies to a temporary harness and does not execute the daemon. The source checkout is unchanged.
The public check passes at the PR head above. It tests finite results, the near-straight coordinate oracle and reversal stability. The coordinate-oracle tolerance includes remaining float64 distance rounding for this exact fixture.
The larger local numerical check uses 3,004 triples (seed 101 plus four fixed cases), an 80-digit exact-computed-side Decimal oracle, and a separate 90-digit exact-coordinate spherical oracle. The full seeded/oracle and downstream harnesses are not attached to the public PR; this embedded snippet makes the two numerical checks independently reproducible without claiming public access to the larger local evidence package.
Combined validation: exact source tree
a4c306906627db3ac7a8ab768651c8628d55465acombines #1019d61f06a1288ec4ea6f74f7d56a3057444316a13, #10320e7c25b054b6399360676a7f539a39b4fbf855c, #105bfcfe77be066634e36054327b20cfa6541063b54, #1078e5e677d1196838069e9665d4e9d962bcc1e116b, #1166fd5bbd6cf617c24a7fefd5e302fd36688a1a63b, #13630e8ce98ea7a4c8401dbb5bfc62120c84fc689e4. The only overlapping file issettings/download.go; the resolution retains #136's selected-row loop and #107's progress publication inside it.Combined Linux amd64 tests (including the scratch regression fixtures), race checks, vet and build passed. Under ARM64 emulation, the existing Makefile build stage (
make GO_CAPNP_PATH=/usr/local/go-capnp/std), committed repository tests, vet and both CLI help commands passed with Go1.25.1;go.mod/go.sumstayed unchanged and the resulting executable is AArch64. The ARM64 run does not include the extra amd64 scratch tests. It used an isolated retained build image, not a new dependency-install/image rebuild or physical device. No archive payload or live params were accessed. #105 still requires runtime-first rollout before regenerated tiles are distributed.