Skip to content

Fix Grid Layer label rendering and placement on rotated maps#4066

Closed
sbrunner wants to merge 7 commits intomasterfrom
fix-2004
Closed

Fix Grid Layer label rendering and placement on rotated maps#4066
sbrunner wants to merge 7 commits intomasterfrom
fix-2004

Conversation

@sbrunner
Copy link
Copy Markdown
Member

Fixes #2004

Description

This PR addresses issues with Grid Layer labels when the map is rotated:

  1. Label Rotation: Labels were not rotating correctly with the map. The rotation logic has been moved and simplified in GridLayer.java.
  2. Label Placement (Offsets): Labels were being placed incorrectly when using verticalXOffset or horizontalYOffset on a rotated map. The fix ensures offsets are applied in screen coordinates (before rotation), making them consistent regardless of map rotation.

Changes

  • Modified GridLayer.java to apply label rotation explicitly and apply offsets before rotation.
  • Reverted changes to RotationQuadrant.java.
  • Added new regression tests:
    • CreateMapProcessorGridFixedNumlinesLinesRotatedTest: Tests grid lines with various rotation angles.
    • CreateMapProcessorGridFixedNumlinesLinesRotatedOffsetTest: Tests grid lines with rotation AND offsets to verify correct placement.
  • Updated existing reference images for affected tests.

Verification

  • Run ./gradlew core:test --tests "org.mapfish.print.processor.map.CreateMapProcessorGridFixedNumlinesLinesRotatedTest"
  • Run ./gradlew core:test --tests "org.mapfish.print.processor.map.CreateMapProcessorGridFixedNumlinesLinesRotatedOffsetTest"

Fix incorrect label placement and rotation when map is rotated.
Move label rotation logic from RotationQuadrant to GridLayer.
Update GridLayer to apply rotation before offsets.
Add regression test CreateMapProcessorGridFixedNumlinesLinesRotatedTest.
Update existing tests and reference images to reflect correct behavior.
Restore applying label offsets in screen coordinates instead of rotated map coordinates.
This ensures verticalXOffset and horizontalYOffset behave consistently regardless of map rotation.
Previously, offsets were applied after rotation, causing them to be relative to the rotated grid lines, which was incorrect if users expected screen-relative shifts.
Add CreateMapProcessorGridFixedNumlinesLinesRotatedOffsetTest to verify that label offsets are applied correctly (screen-relative) when the map is rotated.
@sbrunner sbrunner marked this pull request as draft March 10, 2026 12:19
@sbrunner sbrunner closed this Mar 10, 2026
@sbrunner sbrunner deleted the fix-2004 branch March 10, 2026 12:24
@sbrunner sbrunner restored the fix-2004 branch March 10, 2026 12:27
@sbrunner sbrunner reopened this Mar 10, 2026
…ectors in screen coordinates

Replace RotationQuadrant with new logic in GridLayer and GridUtils.
Calculate text rotation and alignment dynamically based on map rotation and side.
Apply indentation perpendicular to the map border (screen coordinates).
Apply offsets relative to the text orientation.
Update regression tests and reference images.
Remove unused RotationQuadrant class.
@sbrunner sbrunner closed this Mar 16, 2026
@sbrunner sbrunner deleted the fix-2004 branch March 24, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grid Layer labels rendered incorrectly when Map Rotation value is not 0

1 participant