Skip to content

Fix svg displacement#5323

Open
jyrimatti wants to merge 3 commits into
geotools:mainfrom
jyrimatti:fix-svg-displacement
Open

Fix svg displacement#5323
jyrimatti wants to merge 3 commits into
geotools:mainfrom
jyrimatti:fix-svg-displacement

Conversation

@jyrimatti

@jyrimatti jyrimatti commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

I had encountered some problems during rendering which looked like the displacement wasn't being applied correctly. I had some trouble figuring out why it doesn't happen always, but finally realized that rendering SVG icons takes a different code path than rendering raster icons. My current workaround of using a certain kind of AnchorPoint instead of a correct one with an appropriate Displacement works, but is so hideously ugly that I'd prefer having things work as they should.

This PR fixes the order of transformations in org.geotools.renderer.lite.StyledShapePainter IconStyle2D branch.
As documented in org.geotools.api.style.Graphic.getDisplacement, the displacement should happen after rotation. The GraphicStyle2D branch seems to have it already correct.

This PR also adds some tests to the raster branch (ExternalGraphicTest) to ensure the already correct behavior there when AnchorPoint, Rotation and Displacement are all being used. Another test in DrawTest is added to reproduce the actual bug and verify the fix.

The expected images (under test-data) at least in my opinion look correct, but please do let me know if I have thoroughly misunderstood something. Also please let me know if you need anything more from this PR.

Checklist

For core and extension modules:

  • New unit tests have been added covering the changes.
  • Documentation has been updated (if change is visible to end users).
  • There is an issue in GeoTools Jira (except for changes not visible to end users).
  • Commit message(s) must be in the form [GEOT-XYZW] Title of the Jira ticket.
  • Bug fixes and small new features are presented as a single commit.
  • The commit targets a single objective (if multiple focuses cannot be avoided, each one is in its own commit, and has a separate ticket describing it).

@jyrimatti jyrimatti force-pushed the fix-svg-displacement branch from 37a2e33 to e450236 Compare October 25, 2025 15:18
@jyrimatti jyrimatti force-pushed the fix-svg-displacement branch from e450236 to 530e3a3 Compare December 1, 2025 17:23
@mprins mprins added needs_cla Needs a committer agreement needs_Jira_ticket labels Dec 2, 2025
to verify correct behavior for anchor+rotation with/without displacement
According to org.geotools.api.style.Graphic.getDisplacement(), displacement should happen _after_ rotation. GraphicStyle2D branch was already working correctly.
@jyrimatti jyrimatti force-pushed the fix-svg-displacement branch from 530e3a3 to a20f8e4 Compare March 5, 2026 18:14
@stale

stale Bot commented Jun 6, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the stale label Jun 6, 2026
@ianturton

Copy link
Copy Markdown
Member

This fix can not be merged until a CLA is filed with OSGeo and a jira ticket is provided and referenced in the title of this PR

@stale stale Bot removed the stale label Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs_cla Needs a committer agreement needs_Jira_ticket

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants