feat(geo): add geographic foundations - #4
Merged
Merged
Conversation
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.
Summary
Implements Phase 3 of the Roadrunner roadmap with validated geographic values and straight-line distance calculations in
roadrunner-core.CoordinatevaluesBoundingBoxvaluesMeters,Seconds, andKilometersPerHourdomain typesDistanceas Roadrunner's canonical meter-based distance typehaversine_distance(Coordinate, Coordinate) -> MetersNodevalues with validated coordinatesValidation boundaries
Coordinates reject non-finite values, latitudes outside
[-90, 90], and longitudes outside[-180, 180].Physical units reject negative, NaN, and infinite values. Their Serde implementations deserialize through the same validated constructors instead of bypassing invariants.
Bounding boxes require a south-west corner that does not exceed the north-east corner on either axis. Antimeridian-crossing boxes are explicitly deferred and rejected by this initial axis-aligned representation. Bounding-box deserialization also revalidates these invariants.
Haversine implementation
The calculation uses the Haversine formula with the mean Earth radius and clamps the intermediate Haversine value to
[0, 1]to contain floating-point drift before the inverse trigonometric step.Tests cover:
The function returns
Metersdirectly and represents straight-line surface distance, not road-network travel distance.Graph integration
Node::newnow requires a validatedCoordinate, and nodes expose that coordinate through a typed accessor. Existing topology tests and the generated graph benchmark useCoordinate::ORIGIN, keeping benchmark behavior focused on adjacency traversal.No edge cost, travel-time calculation, or routing algorithm is introduced; those remain assigned to later phases.
Validation
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --workspace --all-features --locked— 27 tests passcargo bench -p roadrunner-core --bench graph_traversal --no-run --lockedRUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps --lockedgit diff --check main...HEAD