Details
Description
The provided patch adds support for rescaling symbolizers according to their Unit of Measure (UOM). This feature allows for symbolizers to have a "real-world" size (e.g., size given in meters or feet), so that they grow as you zoom in.
There are several issues in the implementation that may require a discussion before commiting:
- The approach used was to implement a UomRescaleStyleVisitor class for rescaling Symbolizers according to their Unit Of Measure (i.e., compute their sizes in pixels), and use that in SLDStyleFactory whenever a Style2D is created. In order to do that, the current map scale is needed (i.e., how screen units relate to real-world units, or how many meters are covered by each pixel). In this implementation, this scale was extracted from the SLDStyleFactory.createStyle's ScaleRange parameter, which was seen to be set to (scaleDenominator,scaleDenominator) in the renderers. However, maybe it would make more sense to pass on the scaleDenominator directly. Another issue is that the ScaleRange is measured in "meters per millimeters" and, in order to convert this to the needed "pixels per meter" value for UOM rescaling, we need a DPI parameter that is controllable via Hints. This is a little awkward, since the "pixels per meter" value could have been computed directly from the world2screen transform, without ever having to explicitly define DPI. Besides, the LabelCache does not have a Hints parameter. So, maybe it would be easier to pass around a scale parameter already measured in pixels per meter.
- Methods were added to RendererUtilities.java to help compute the pixels per meter ratio (in order to convert sizes in meters/feet/etc to pixels).
- In SLDStyleFactory, both createStyleInternal and createDynamicStyle were modified to rescale the given symbolizer. It was not clear whether createDynamicStyle is needed or where it is used.
- Style2D objects created by SLDStyleFactory should always be rescaled according to the UOM, but for one case: in Drawer.java (used for legend icons), the rendering must be done WITHOUT rescaling the symbolizer, since a legend has no scale. This was currently implemented adding a createStyleNoUOMRescaling method, because as such less GeoTools code would be changed. But maybe it would be better if SLDStyleFactory never rescaled anything and classes such as StreamingRenderer explicitly rescaled the symbolizer to pixels and then called SLDStyleFactory normally.
- The UomRescaleStyleVisitor could be discussed as well. For simplicity, overriding visit() methods to add rescaling was done only on the Symbolizer level, where the UOM parameter is available. The alternative would be to implement visit(Graphic), visit(Stroke), etc. and have the UOM parameter be included in the visitor's state.
Issue Links
- is related to
-
GEOT-1536
ImageLoader overhaul needed
-