I have a multipoint geometry (a single geometry containing multiple points) and I want to place a label on each of the points (the label is always the same). Is it possible to achieve this with SLD? Right now the label is only displayed on a single point.
My SLD looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>Multipoint with labels</Name>
<UserStyle>
<Title>Default Point</Title>
<Abstract>A sample style that draws a point</Abstract>
<FeatureTypeStyle>
<Rule>
<Name>rule1</Name>
<Title>Red Square</Title>
<Abstract>A 6 pixel square with a red fill and no stroke</Abstract>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>square</WellKnownName>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
</Fill>
</Mark>
<Size>6</Size>
</Graphic>
</PointSymbolizer>
<TextSymbolizer>
<Label>NAME</Label>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
By default the GeoServer label engine goes to a lot of trouble to not label multiple times on the same feature, so this is hard!
I finally managed it using the following (ugly) SLD:
<Rule>
<Title>Capitals</Title>
<TextSymbolizer>
<Geometry>
<ogc:Function name="getGeometryN">
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Literal>0</ogc:Literal>
</ogc:Function>
</Geometry>
<Label>ID</Label>
</TextSymbolizer>
<TextSymbolizer>
<Geometry>
<ogc:Function name="getGeometryN">
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
</ogc:Function>
</Geometry>
<Label>ID</Label>
</TextSymbolizer>
<TextSymbolizer>
<Geometry>
<ogc:Function name="getGeometryN">
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Literal>2</ogc:Literal>
</ogc:Function>
</Geometry>
<Label>ID</Label>
</TextSymbolizer>
<TextSymbolizer>
<Geometry>
<ogc:Function name="getGeometryN">
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Literal>3</ogc:Literal>
</ogc:Function>
</Geometry>
<Label>ID</Label>
</TextSymbolizer>
</Rule>
However this assumes you know how many points there are in your largest multi-point, and that is quite small (otherwise it's a lot of copy & paste).
I had originally hoped to be able to use the vertices function or possibly the labelAllGroup vendor option, but sadly neither worked with multi-points.