Default symbology styles in Mango are fixed across all zoom levels, which is preferable in most mapping use cases. However, there are many cases where a symbol would ideally be scaled relative to real-world units of measurement. Using Custom SLD, it's possible to set a ground unit (feet or metres), and scale symbology accordingly.
This method works for line features (both stroke and outline), polygon strokes, standard point markers, as well as custom graphic markers.
Defining a ground unit in SLD
By adding the uom parameter to uom="http://www.opengeospatial.org/se/units/{unit}"
to the Line, Point or Polygon Symbolizer, the related size attribute will be rendered at that size, relative to ground.
Available options for {unit} are:
- uom="http://www.opengeospatial.org/se/metre"
- uom="http://www.opengeospatial.org/se/foot"
- uom="http://www.opengeospatial.org/se/pixels" (this is the default, and is fixed across all zoom levels)
Note that ground scaling should be used as a visual reference only, and not for critical decision making or in lieu of measurement. Rendered lines and widths are accurate only at the equator, and are not "latitude aware". A line with a width of 100m at the equator will be displayed correctly. A line in Winipeg at 50° N will be displayed around 35% narrower than true ground scale.
A 100m stroke using UOM scaling at the equator
A 100m stroke using UOM scaling at 50° N
PointSymbolizer
The resulting point will be 10m in diameter relative to ground.
<sld:PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
<sld:Geometry>
<ogc:PropertyName>the_geom</ogc:PropertyName>
</sld:Geometry>
<sld:Graphic>
<sld:Mark>
<sld:WellKnownName>circle</sld:WellKnownName>
<sld:Fill>
<sld:CssParameter name="fill">#ffeb3b</sld:CssParameter>
<sld:CssParameter name="fill-opacity">0.3</sld:CssParameter>
</sld:Fill>
</sld:Mark>
<sld:Size>10</sld:Size>
</sld:Graphic>
</sld:PointSymbolizer>
LineSymbolizer
This line will render as 60m relative to ground.
<LineSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
<Stroke>
<CssParameter name="stroke-width">60</CssParameter>
<CssParameter name="stroke">#FF4000</CssParameter>
<CssParameter name="stroke-linejoin">round</CssParameter>
<CssParameter name="stroke-linecap">round</CssParameter>
</Stroke>
</LineSymbolizer>
This line will render as a 10m white line with a 5m black outline on each side.
Note that the outline stroke is a separate stroke, so it's width must accommodate the inner line width.
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
<NamedLayer>
<Name>Default Styler</Name>
<UserStyle>
<Name>Default Styler</Name>
<FeatureTypeStyle>
<Name>name</Name>
<Rule>
<LineSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">20</CssParameter>
<CssParameter name="stroke-linejoin">round</CssParameter>
<CssParameter name="stroke-linecap">round</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
<Rule>
<LineSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
<Stroke>
<CssParameter name="stroke">#ffffff</CssParameter>
<CssParameter name="stroke-width">10</CssParameter>
<CssParameter name="stroke-linejoin">round</CssParameter>
<CssParameter name="stroke-linecap">round</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
In this example, the black 'outline' stroke will appear as a 5m black border around the 10m white stroke.
PolygonSymbolizer
This polygon's stroke will be 12m relative to ground, and will be offset to the inside of the polygon.
<sld:PolygonSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
<sld:Stroke>
<CssParameter name="stroke-width">12</CssParameter>
<sld:CssParameter name="stroke">#424242</sld:CssParameter>
<sld:CssParameter name="stroke-opacity">1</sld:CssParameter>
</sld:Stroke>
</sld:PolygonSymbolizer>
Custom graphic point markers
This point will be rendered as a custom external PNG image at 15m tall, relative to ground.
<PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
<Graphic>
<ExternalGraphic>
<OnlineResource xlink:type="extended" xlink:href="https://path.to/image.png" />
<Format>image/png</Format>
</ExternalGraphic>
<Size>15</Size>
</Graphic>
</PointSymbolizer>
Want to see this integrated into our style builder UI? Let us know!