Negative Coordinates Are Assigned to the Wrong Grid Cell
Level 2 · node · Correctness · Truncation toward zero misindexes negative spatial coordinates
Scenario
A fictional indoor robot mapping service assigns measurements to ten-meter square grid cells extending in both directions from the origin. Positive coordinates map correctly, but negative fractional coordinates are truncated toward zero and assigned to the wrong cells. Trace the conversion through the map repository, service, and controller.
Requirements
Compute each grid index by flooring the coordinate divided by ten, toward negative infinity. Preserve positive coordinates, exact negative boundaries, per-map isolation, and record order. Add no dependencies.
Acceptance criteria
- Positive coordinates map to their expected grid indices.
- Negative fractional X coordinates map to the cell on the left.
- Negative fractional Y coordinates map to the cell below.
- Exact negative integer boundaries keep their expected indices.
- Records from different maps remain isolated.
- An unknown map returns an empty list.