GeoServer中多边形内多个标签问题
GeoServer在生成多边形切片时会产生重复标签
这个问题可以使用过滤器的质心功能,中心位置。
|Name|Arguments|Description| |centroid|geometry:Geometry|Returns the centroid of the geometry. Can be often used as a label point for polygons, though there is no guarantee it will actually lie inside the geometry|
<Rule>
<TextSymbolizer>
<Label><ogc:PropertyName>NAME</ogc:PropertyName></Label>
<Fill><CssParameter name="fill">#666666</CssParameter></Fill>
<Geometry>
<ogc:Function name="centroid">
<ogc:PropertyName>geom</ogc:PropertyName>
</ogc:Function>
</Geometry>
<VendorOption name="spaceAround">10</VendorOption>
<VendorOption name="autoWrap">85</VendorOption>
<VendorOption name="group">yes</VendorOption>
</TextSymbolizer>
</Rule>
使用后如下效果
但声明时没有保证一定在多边形内部有可能出现如下效果(需要注意):