SLD - 在每个多点上放置标签

SLD - place label on each multipoint

我有一个多点几何(包含多个点的单个几何),我想在每个点上放置一个标签(标签始终相同)。有可能用 SLD 实现吗?现在标签只显示在一个点上。

我的 SLD 是这样的:

<?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>

默认情况下,GeoServer 标签引擎会很麻烦地避免在同一要素上多次标注,所以这很难!

我最终使用以下(丑陋的)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>

但是,这假设您知道最大的多点中有多少个点,而且这个点非常小(否则需要大量复制和粘贴)。

我原本希望能够使用vertices function or possibly the labelAllGroup vendor option,但遗憾的是两者都无法使用多点。