SLDReader icon indicating copy to clipboard operation
SLDReader copied to clipboard

Sizes not always Pixels

Open 1Map opened this issue 6 years ago • 3 comments

Although you handle your style sizes as Pixels, that may not always be the case, for example the following means that the font size is 2 meters, not 2 pixels:

          <sld:TextSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
            <sld:Label>
              <ogc:PropertyName>unitno</ogc:PropertyName>
            </sld:Label>
            <sld:Font>
              <sld:CssParameter name="font-family">Arial</sld:CssParameter>
              <sld:CssParameter name="font-size">2</sld:CssParameter>
              <sld:CssParameter name="font-style">normal</sld:CssParameter>
              <sld:CssParameter name="font-weight">normal</sld:CssParameter>
            </sld:Font>
            <sld:LabelPlacement>
              <sld:PointPlacement>
                <sld:AnchorPoint>
                  <sld:AnchorPointX>
                    <ogc:Literal>0.5</ogc:Literal>
                  </sld:AnchorPointX>
                  <sld:AnchorPointY>
                    <ogc:Literal>0.5</ogc:Literal>
                  </sld:AnchorPointY>
                </sld:AnchorPoint>
              </sld:PointPlacement>
            </sld:LabelPlacement>
            <sld:Halo>
              <sld:Radius>
                <ogc:Literal>0.5</ogc:Literal>
              </sld:Radius>
              <sld:Fill>
                <sld:CssParameter name="fill">#FFFFFF</sld:CssParameter>
                <sld:CssParameter name="fill-opacity">0.8</sld:CssParameter>
              </sld:Fill>
            </sld:Halo>
            <sld:Fill>
              <sld:CssParameter name="fill">#000000</sld:CssParameter>
            </sld:Fill>
            <sld:VendorOption name="maxDisplacement">10</sld:VendorOption>
            <sld:VendorOption name="spaceAround">0</sld:VendorOption>
            <sld:VendorOption name="group">false</sld:VendorOption>
            <sld:VendorOption name="repeat">0</sld:VendorOption>
            <sld:VendorOption name="partials">true</sld:VendorOption>
            <sld:VendorOption name="goodnessOfFit">1</sld:VendorOption>
          </sld:TextSymbolizer>

Also the same with PolygonSymbolizer, LineSymbolizer, etc...

1Map avatar Mar 19 '19 17:03 1Map

https://stackoverflow.com/questions/34483178/openlayers-draw-line-string-with-line-width-in-meters It would require passing ol/Map styler.

Razi91 avatar May 25 '20 11:05 Razi91

Yes,

Note: the Unit-of-Measure in the SLD

uom="http://www.opengeospatial.org/se/units/metre"

1Map avatar May 25 '20 11:05 1Map

It's technically possible to support non-pixel uom on a symbolizer, but also a lot of work.

The style function recycles OpenLayers style objects with static properties (like a line symbolizer that's always 4px wide). But when you start using meters for instance, all dimension-related symbolizer properties will have to be dynamically modified at each zoom (and possibly pan) of the map.

Furthermore, according to the SLD spec you can override any uom set on the symbolizer by appending 'px' to a property (like '5px'). This means that units of measure can be mixed within a symbolizer, which in turn means that all numeric symbolizer properties relating to dimension should keep track of their own units of measure.

ajkopinga avatar May 27 '20 17:05 ajkopinga