Styling: Wrong graphic size on custom DPIs

Description

Dear GeoTools-Community,

currently graphics using real-world units as size are rendered too small when a custom DPI is requested via WMS vendor parameter.

Consider the following CSS rule:

What happens is the following:

  1. A style visitor rescales the size due to the DPI vendor parameter, but as a result the unit of the size is omitted (GraphicsAwareDpiRescaleStyleVisitor)

  2. Another style visitor rescales the size due the real world unit, calculates the pixel size. However, the result is wrong because 1) has omitted the unit.

In my opinion the problem is RescaleMode.Pixels.rescaleToStringInternal(), which should conditionally return the unit. RescaleMode.Pixels.rescaleToExpression() already behaves like this.

I did some research in the code and found a unit test for the DpiRescaleStyleVisitorTest.
However, it tests RescaleMode.Pixels.rescaleToExpression() only.

I have extended the test to exercise RescaleMode.Pixels.rescaleToStringInternal(), too, extended RescaleMode.Pixels.rescaleToStringInternal() and added a more complex test for this issue in GraphicsAwareDpiRescaleStyleVisitorTest.

I will provide a pull request as proposed solution. I would be glad if somebody could review and hopefully merge it.

With best regards,
Andreas

BTW: The GeoTools functionality is pretty impressive. Good job!

Environment

None

Assignee

Unassigned

Reporter

Andreas W

Triage

None

Components

Affects versions

Priority

Medium
Configure