[Geoserver-users] Anyway to determine the width of a label in degrees at a particular zoom level?

Hi,

I am working through some issues with labeling my latitude lines on the extreme right side of a WMS pull. I have the labels generating where I want, but only for a couple of specific zoom levels. What I would like to do is determine how much space a given label would be in degrees (since I am using 4326 for everything) and subtract that from the edge of my wms_bbox. I got the log algorithm from:

http://gis.stackexchange.com/questions/159197/can-textsymbolizer-font-size-be-set-as-a-function-of-the-scale

This is the SLD rule:

sld:Rule

sld:Namedefault rule</sld:Name>

sld:LineSymbolizer

sld:Stroke

<sld:CssParameter name=“stroke”>#66A61E</sld:CssParameter>

</sld:Stroke>

</sld:LineSymbolizer>

sld:TextSymbolizer

sld:Geometry

<ogc:Function name=“geomFromWKT”>

<ogc:Function name=“Concatenate”>

ogc:LiteralPOINT(</ogc:Literal>

<ogc:Function name=“parseDouble”>

<ogc:Function name=“strSubstring”>

ogc:Sub

<ogc:Function name=“strSubString”>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

ogc:Add

<ogc:Function name=“strIndexOf”>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

ogc:Literal:</ogc:Literal>

</ogc:Function>

ogc:Literal2</ogc:Literal>

</ogc:Add>

<ogc:Function name=“strIndexOf”>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

ogc:Literal,</ogc:Literal>

</ogc:Function>

</ogc:Function>

<!—This section is attempting to move the Y coordinate left a little bit to display the text portion →

ogc:Add

ogc:Mul

ogc:Div

ogc:Sub

ogc:Div

ogc:Literal1</ogc:Literal>

<ogc:Function name=“log”>

<ogc:Function name=“env”>

ogc:Literalwms_scale_denominator</ogc:Literal>

</ogc:Function>

</ogc:Function>

</ogc:Div>

ogc:Literal0.0513</ogc:Literal>

</ogc:Sub>

ogc:Literal0.08</ogc:Literal>

</ogc:Div>

ogc:Literal.13</ogc:Literal>

</ogc:Mul>

ogc:Literal1</ogc:Literal>

</ogc:Add>

</ogc:Sub>

ogc:Literal0</ogc:Literal>

ogc:Literal8</ogc:Literal>

</ogc:Function>

</ogc:Function>

ogc:Literal</ogc:Literal>

<ogc:Function name=“getY”><ogc:Function name=“endPoint”>ogc:PropertyNamegeom</ogc:PropertyName></ogc:Function></ogc:Function>

ogc:Literal)</ogc:Literal>

</ogc:Function>

</ogc:Function>

</sld:Geometry>

sld:Label

<ogc:Function name=“strSubstring”>

ogc:PropertyNamebottom</ogc:PropertyName>

<ogc:Function name=“parseInt”>

ogc:Literal0</ogc:Literal>

</ogc:Function>

<ogc:Function name=“strIndexOf”>

ogc:PropertyNamebottom</ogc:PropertyName>

ogc:Literal.</ogc:Literal>

</ogc:Function>

</ogc:Function>

</sld:Label>

sld:Font

<sld:CssParameter name=“font-family”>Arial</sld:CssParameter>

<sld:CssParameter name=“font-size”>15.0</sld:CssParameter>

<sld:CssParameter name=“font-style”>normal</sld:CssParameter>

<sld:CssParameter name=“font-weight”>normal</sld:CssParameter>

</sld:Font>

sld:Fill

<sld:CssParameter name=“fill”>#FF00FF</sld:CssParameter>

</sld:Fill>

</sld:TextSymbolizer>

</sld:Rule>

Chris Snider

Senior Software Engineer

Intelligent Software Solutions, Inc.

Description: Description: Description: cid:image001.png@anonymised.com

I can’t solve that issue but an easier way to do it might be to place the point on the bbox and then use a PointPlacement element with a Displacement to move it by Y pixels.

I think that should work

Ian

image001.png

···

On 26 October 2016 at 22:49, Chris Snider <chris.snider@…3225…> wrote:

Hi,

I am working through some issues with labeling my latitude lines on the extreme right side of a WMS pull. I have the labels generating where I want, but only for a couple of specific zoom levels. What I would like to do is determine how much space a given label would be in degrees (since I am using 4326 for everything) and subtract that from the edge of my wms_bbox. I got the log algorithm from:

http://gis.stackexchange.com/questions/159197/can-textsymbolizer-font-size-be-set-as-a-function-of-the-scale

This is the SLD rule:

sld:Rule

sld:Namedefault rule</sld:Name>

sld:LineSymbolizer

sld:Stroke

<sld:CssParameter name=“stroke”>#66A61E</sld:CssParameter>

</sld:Stroke>

</sld:LineSymbolizer>

sld:TextSymbolizer

sld:Geometry

<ogc:Function name=“geomFromWKT”>

<ogc:Function name=“Concatenate”>

ogc:LiteralPOINT(</ogc:Literal>

<ogc:Function name=“parseDouble”>

<ogc:Function name=“strSubstring”>

ogc:Sub

<ogc:Function name=“strSubString”>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

ogc:Add

<ogc:Function name=“strIndexOf”>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

ogc:Literal:</ogc:Literal>

</ogc:Function>

ogc:Literal2</ogc:Literal>

</ogc:Add>

<ogc:Function name=“strIndexOf”>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

ogc:Literal,</ogc:Literal>

</ogc:Function>

</ogc:Function>

<!—This section is attempting to move the Y coordinate left a little bit to display the text portion →

ogc:Add

ogc:Mul

ogc:Div

ogc:Sub

ogc:Div

ogc:Literal1</ogc:Literal>

<ogc:Function name=“log”>

<ogc:Function name=“env”>

ogc:Literalwms_scale_denominator</ogc:Literal>

</ogc:Function>

</ogc:Function>

</ogc:Div>

ogc:Literal0.0513</ogc:Literal>

</ogc:Sub>

ogc:Literal0.08</ogc:Literal>

</ogc:Div>

ogc:Literal.13</ogc:Literal>

</ogc:Mul>

ogc:Literal1</ogc:Literal>

</ogc:Add>

</ogc:Sub>

ogc:Literal0</ogc:Literal>

ogc:Literal8</ogc:Literal>

</ogc:Function>

</ogc:Function>

ogc:Literal</ogc:Literal>

<ogc:Function name=“getY”><ogc:Function name=“endPoint”>ogc:PropertyNamegeom</ogc:PropertyName></ogc:Function></ogc:Function>

ogc:Literal)</ogc:Literal>

</ogc:Function>

</ogc:Function>

</sld:Geometry>

sld:Label

<ogc:Function name=“strSubstring”>

ogc:PropertyNamebottom</ogc:PropertyName>

<ogc:Function name=“parseInt”>

ogc:Literal0</ogc:Literal>

</ogc:Function>

<ogc:Function name=“strIndexOf”>

ogc:PropertyNamebottom</ogc:PropertyName>

ogc:Literal.</ogc:Literal>

</ogc:Function>

</ogc:Function>

</sld:Label>

sld:Font

<sld:CssParameter name=“font-family”>Arial</sld:CssParameter>

<sld:CssParameter name=“font-size”>15.0</sld:CssParameter>

<sld:CssParameter name=“font-style”>normal</sld:CssParameter>

<sld:CssParameter name=“font-weight”>normal</sld:CssParameter>

</sld:Font>

sld:Fill

<sld:CssParameter name=“fill”>#FF00FF</sld:CssParameter>

</sld:Fill>

</sld:TextSymbolizer>

</sld:Rule>

Chris Snider

Senior Software Engineer

Intelligent Software Solutions, Inc.

Description: Description: Description: cid:image001.png@...5633...


The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik


Geoserver-users mailing list
Geoserver-users@…382…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton