maps-core icon indicating copy to clipboard operation
maps-core copied to clipboard

Store bounding box parameters when moveToBoundingBox is called before viewport size is known

Open Copilot opened this issue 3 months ago • 6 comments

Task: Set Bounds before size changed

Issue: Calling moveToBoundingBox before viewport size is known discards the call because a size is required for calculations.

Goal: Store the bounding box parameters and apply them when viewport size is known.

Implementation Complete ✅

Changed approach based on feedback to modify the public API instead:

  • [x] Explore repository and understand the issue
  • [x] Build and test the codebase (all tests pass)
  • [x] Modify public API moveToBoundingBox to store parameters when viewport size is unknown
  • [x] Apply stored parameters when viewport size becomes known in viewportSizeChanged
  • [x] Implement for both MapCamera2d and MapCamera3d
  • [x] Verify all existing tests still pass (1282 assertions in 46 test cases)

Changes Made

MapCamera2d.h / MapCamera3d.h:

  • Added PendingBoundingBox struct to store parameters for moveToBoundingBox call when viewport size is not yet known
  • Added std::optional<PendingBoundingBox> pendingBoundingBox member variable

MapCamera2d.cpp:

  • Modified moveToBoundingBox() to:
    • Check if viewport size is known (viewportSize.x > 0 && viewportSize.y > 0)
    • Store bounding box parameters in pendingBoundingBox if size is unknown
    • Clear pendingBoundingBox and apply immediately if size is known
  • Modified viewportSizeChanged() to apply pending bounding box when viewport size becomes known

MapCamera3d.cpp:

  • Modified moveToBoundingBox() with same logic as MapCamera2d
  • Modified viewportSizeChanged() to apply pending bounding box when viewport size becomes known

Testing

✅ All existing tests pass without modification (1282 assertions in 46 test cases), confirming backward compatibility and no regressions.

Code Quality

  • Minimal changes - only modified the public API method as requested

  • Consistent with existing code patterns in both camera implementations

  • No breaking changes to the public API behavior

  • Fixes openmobilemaps/maps-core#890

Original prompt

This section details on the original issue you should resolve

<issue_title>Set Bounds before size changed</issue_title> <issue_description>Current: setting camera bounds before size is known will discard the call, because a size is required.

Goal: store the desired bounds, set when size is known.</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes openmobilemaps/maps-core#890

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Nov 22 '25 12:11 Copilot