[Geoserver-users] Problem with SLD PointPlacement Displacement not working

We are styling an SDE layer of polygons. We want to display the polygon labels offset from the centre of the map image when zoomed into a single polygon, so that the label is readable when zooming to a point (which is using a client-side icon, so obscuring the label).

We are trying to set the SLD PointPlacement Displacement values to do this, but this does not seem to change the location of the generated labels. SLD is below.

Are there any known issues with this? Or is there something wrong with the style?

Version is Geoserver 1.12.1.


<?xml version="1.0" encoding="UTF-8"?>

sld:NamedLayer
sld:NameDefault Styler</sld:Name>
sld:UserStyle
sld:NameDefault Styler</sld:Name>
sld:FeatureTypeStyle
sld:Namename</sld:Name>
sld:Rule
sld:LineSymbolizer
sld:Stroke
<sld:CssParameter name=“stroke”>#FFFFFF</sld:CssParameter>
<sld:CssParameter name=“stroke-width”>4</sld:CssParameter>
</sld:Stroke>
</sld:LineSymbolizer>
sld:LineSymbolizer
sld:Stroke
<sld:CssParameter name=“stroke-width”>2.75</sld:CssParameter>
</sld:Stroke>
</sld:LineSymbolizer>
</sld:Rule>
sld:Rule
sld:TextSymbolizer
sld:Label
ogc:PropertyNameFIRE_CENTRE</ogc:PropertyName>
</sld:Label>
sld:Font
<sld:CssParameter name=“font-family”>Arial</sld:CssParameter>
<sld:CssParameter name=“font-size”>18</sld:CssParameter>
<sld:CssParameter name=“font-style”>normal</sld:CssParameter>
<sld:CssParameter name=“font-weight”>normal</sld:CssParameter>
</sld:Font>
sld:LabelPlacement
sld:PointPlacement
sld:AnchorPoint
sld:AnchorPointX0.5</sld:AnchorPointX>
sld:AnchorPointY0.0</sld:AnchorPointY>
</sld:AnchorPoint>
sld:Displacement
sld:DisplacementX0</sld:DisplacementX>
sld:DisplacementY50</sld:DisplacementY>
</sld:Displacement>
</sld:PointPlacement>
</sld:LabelPlacement>
sld:Halo
sld:Radius3</sld:Radius>
sld:Fill
<sld:CssParameter name=“fill”>#FFFFFF</sld:CssParameter>
</sld:Fill>
</sld:Halo>
sld:Fill
<sld:CssParameter name=“fill”>#000000</sld:CssParameter>
</sld:Fill>
<sld:VendorOption name=“maxDisplacement”>100</sld:VendorOption>
</sld:TextSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
</sld:NamedLayer>
</sld:StyledLayerDescriptor>

No “known issue”, the functionality is simply missing.
Polygon placement is “put the label something in there”, personally never had the need to control
displacement on it, can’t see an existing feature request for it in the tracker either, but settings
are there for polygons too, so they should be honored.

Usual two steps:

  • Feel free to open a ticket for it
  • PR welcomed (in case you’re interested, have a look at LabelCacheImpl in gt-render)
    Cheers

Andrea

···

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Could you work round it by adding a geom tag with a centroid function to get a point?

Ian

···

Ian Turton

Thanks for the assistance.

I will look into logging an issue for this.

For the record, the use cases for this capability are:

  • In the case where there are two polygonal coverage layers containing large jurisdiction boundary polygons, when zoomed far in (so that the map extent is fully inside the polygons), the polygon labels are both at the centre of the map image and one is obscured. By offsetting the labels up and down the goal is to show both
  • On a web map where the client displays point features with clients-side icons, when the map is zoomed to a point feature, the icon is displayed in the centre of the map extent, and obscures the jurisdiction polygon label(s) underneath it. Goal is to make the label visible by offsetting it.

@Ian Turton Not sure your idea will work because the label needs to be place dynamically anchored at the centre of the rendered image (not fixed at the polygon centroid)?

On Tue, Dec 11, 2018 at 12:42 AM Ian Turton <ijturton@anonymised.com> wrote:

Could you work round it by adding a geom tag with a centroid function to get a point?

Ian

On Tue, 11 Dec 2018 at 07:00, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Mon, Dec 10, 2018 at 9:37 PM Martin Davis <mtnclimb@anonymised.com> wrote:

Are there any known issues with this? Or is there something wrong with the style?

No “known issue”, the functionality is simply missing.
Polygon placement is “put the label something in there”, personally never had the need to control
displacement on it, can’t see an existing feature request for it in the tracker either, but settings
are there for polygons too, so they should be honored.

Usual two steps:

  • Feel free to open a ticket for it
  • PR welcomed (in case you’re interested, have a look at LabelCacheImpl in gt-render)
    Cheers

Andrea

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton

I realized that I can solve the issue of two centred labels obscuring each other by using the VendorOptions maxDisplacement and spaceAround. This may also help with client-side icons being obscured. Although I suspect that one of the labels will still be centred. However, the other label should be visible, which should help.

On Tue, Dec 11, 2018 at 10:40 AM Martin Davis <mtnclimb@anonymised.com> wrote:

Thanks for the assistance.

I will look into logging an issue for this.

For the record, the use cases for this capability are:

  • In the case where there are two polygonal coverage layers containing large jurisdiction boundary polygons, when zoomed far in (so that the map extent is fully inside the polygons), the polygon labels are both at the centre of the map image and one is obscured. By offsetting the labels up and down the goal is to show both
  • On a web map where the client displays point features with clients-side icons, when the map is zoomed to a point feature, the icon is displayed in the centre of the map extent, and obscures the jurisdiction polygon label(s) underneath it. Goal is to make the label visible by offsetting it.

@Ian Turton Not sure your idea will work because the label needs to be place dynamically anchored at the centre of the rendered image (not fixed at the polygon centroid)?

On Tue, Dec 11, 2018 at 12:42 AM Ian Turton <ijturton@anonymised.com> wrote:

Could you work round it by adding a geom tag with a centroid function to get a point?

Ian

On Tue, 11 Dec 2018 at 07:00, Andrea Aime <andrea.aime@anonymised.com07…> wrote:

On Mon, Dec 10, 2018 at 9:37 PM Martin Davis <mtnclimb@anonymised.com> wrote:

Are there any known issues with this? Or is there something wrong with the style?

No “known issue”, the functionality is simply missing.
Polygon placement is “put the label something in there”, personally never had the need to control
displacement on it, can’t see an existing feature request for it in the tracker either, but settings
are there for polygons too, so they should be honored.

Usual two steps:

  • Feel free to open a ticket for it
  • PR welcomed (in case you’re interested, have a look at LabelCacheImpl in gt-render)
    Cheers

Andrea

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton

Why use a static displacement, the maxDisplacement vendor option should let GeoServer apply a suitable offset for you
in case the target location is already busy?

Cheers
Andrea

···

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

The maxDisplacement vendor option works well for separating two labels which are both being rendered at the centre of the image (e.g. due to the map extent being wholly inside both polygons). Actually I needed to use spaceAround as well, to provide some separation between the two labels.

The problem is that in our application there client-side point feature layers, with icons being rendered client-side (by Leaflet). When the map is zoomed to one of the client-side point features, the icon obscures the label underneath it. And actually a bigger concern is that the map area around the icon is obscured by the label behind it.

We might be able to remedy this by forcing the zoom function to move the map so the feature location is above or below the centre of the map extent. But it seems cleaner and more versatile to force the underlying labels away from the map centre.

Perhaps the general requirement here is to have more control over where labels are placed in map image space, for the case of large “regional” polygon features (which are often rendered at a scale where the map extent is inside the polygon). The SLD Displacement parameter is one way to control this. I could imagine a more sophisticated layout control allowing labels to be anchored relative to the map extent box, as well.

On Tue, Dec 11, 2018 at 11:05 AM Andrea Aime <andrea.aime@anonymised.com> wrote:

On Tue, Dec 11, 2018 at 7:41 PM Martin Davis <mtnclimb@anonymised.com> wrote:

Thanks for the assistance.

I will look into logging an issue for this.

For the record, the use cases for this capability are:

  • In the case where there are two polygonal coverage layers containing large jurisdiction boundary polygons, when zoomed far in (so that the map extent is fully inside the polygons), the polygon labels are both at the centre of the map image and one is obscured. By offsetting the labels up and down the goal is to show both
  • On a web map where the client displays point features with clients-side icons, when the map is zoomed to a point feature, the icon is displayed in the centre of the map extent, and obscures the jurisdiction polygon label(s) underneath it. Goal is to make the label visible by offsetting it.

Why use a static displacement, the maxDisplacement vendor option should let GeoServer apply a suitable offset for you
in case the target location is already busy?

Cheers
Andrea

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Issue created: https://osgeo-org.atlassian.net/browse/GEOS-9056

On Mon, Dec 10, 2018 at 10:57 PM Andrea Aime <andrea.aime@anonymised.com> wrote:

On Mon, Dec 10, 2018 at 9:37 PM Martin Davis <mtnclimb@anonymised.com84…> wrote:

Are there any known issues with this? Or is there something wrong with the style?

No “known issue”, the functionality is simply missing.
Polygon placement is “put the label something in there”, personally never had the need to control
displacement on it, can’t see an existing feature request for it in the tracker either, but settings
are there for polygons too, so they should be honored.

Usual two steps:

  • Feel free to open a ticket for it
  • PR welcomed (in case you’re interested, have a look at LabelCacheImpl in gt-render)
    Cheers

Andrea

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.