1

I use GeoServer 2.1.1. and have an SLD to serve a layer with labels in OpenLayers. I noticed that some labels are not displayed because other labels are to near. GeoServer wants to make your labels look nice. Weird enough: I don't. Using the VendorOptions in the SLD I figured out some of the problems. I read the SLD cookbook. I am now using:

<TextSymbolizer>
 ...
 <VendorOption name="spaceAround">-1</VendorOption>
 <VendorOption name="conflictResolution">false</VendorOption>
 ...
</TextSymbolizer>

These two options makes GeoServer draw multiple labels on top of each other even though it will render the labels unreadable (which is what I require).

The problem that still remains is the positioning of the labels. I have the labels set to:

<LabelPlacement>
 <PointPlacement>
  <AnchorPoint>
   <AnchorPointX>0.5</AnchorPointX>
   <AnchorPointY>0.5</AnchorPointY>
  </AnchorPoint>
 </PointPlacement>
</LabelPlacement>

But as soon as the labels are to near of the edge of the image/bounds the it no longer centers the labels but will anchor it left or right depending on the position.

My question if someone knows how I can make GeoServer ignore trying to make it look so damn nice (I know it sounds weird!) and just let my labels run out of the image/bounds.

1 Answer 1

2

Check out GeoWebCache, the tile cache engine that comes with GeoServer. You can specify the gutter parameter. According to the docs:

"the gutter parameter is specified in pixels and represents extra padding around the image that is sliced away when the tiles are created. Certain WMS server have edge effects that can be eliminated this way, but it can also result in labels being cut off".

Particularly the last statement indicates this may solve your use case.

Another approach would be to simply request a larger image than the viewport of OpenLayers using the ratio parameter. Thus, labels that appear at the edge of the viewport are still labeled centered on their anchor location as there is still enough of the WMS map image that's simply not visible outside the OL viewport.

1
  • I just read some of the documentation on GeoWebCache. Your solutions seems a good fit. Only problem is that it would take a lot of time to rewrite the application to work with tiles.
    – Ivo Limmen
    Jan 18, 2012 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.