Survey Route Segments Are Rounded Before Totaling
Level 2 · node · Correctness · Premature per-segment rounding in route distance aggregation
Scenario
A fictional indoor surveying system stores coordinate routes by site and returns their total Euclidean distance in integer meters. The current service rounds every segment before summing, which distorts the total for routes with repeated short diagonal segments. Inspect the repository, service, and controller.
Requirements
Accumulate precise floating-point segment lengths and round only the final sum. Preserve route validation, site isolation, unknown-route handling, and copying of input points.
Acceptance criteria
- Sum precise segment lengths and round only once at the end.
- Return the correct length for a single-segment route.
- Routes belonging to another site cannot be retrieved.
- Reject requests for unknown routes.
- Reject routes containing invalid coordinates.
- Changing the original point array after registration does not change the stored route.