WMS layout:css-legend sometimes causes 360 W coordinate shift

Description

If I make a WMS request with FORMAT_OPTIONS=layout:css-legend, the result will (sometimes) be shifted about 360 degrees west. This appears to occur whenever the WMS bbox has a latitude outside of [-180,180]. See attached screenshots, which represent two otherwise identical WMS requests, with and without layout:css-legend.

Example WMS request:
http://localhost:8080/geoserver/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=dem_large&STYLES=raster&FORMAT_OPTIONS=layout%3Acss-legend%3BfontAntiAliasing%3Atrue&CRS=EPSG%3A4326&WIDTH=733&HEIGHT=300&BBOX=-54,-308,51,-51

So far, I have only observed this with world-spanning raster images, including the Arc_Sample layer included in the default data dir. (This may just be because the style editor wraps vector layers but not raster ones)

This is also adversely affecting the Style Editor, which uses the layout:css-legend option

Environment

None

Status

Assignee

Unassigned

Reporter

Torben Barsballe

Triage

Fix versions

Affects versions

Components

Priority

Medium
Configure