[Geoserver-users] Label Displacement Question

Hi,

Java 8

GeoServer 2.8.3

Working through my issue to label my latitude lines at the “ends” of the line, I have this section of my label rule to tell me where it “is supposed to be”

sld:TextSymbolizer

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>

Expected Label Location<![CDATA[

]]>

<ogc:Function name=“Concatenate”>

ogc:LiteralPOINT(</ogc:Literal>

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

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>

Blah blah other labels, font etc

</sld:Label>

</sld:TextSymbolizer>

</sld:Rule>

sld:Rule

sld:Namelabel 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=“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>

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>°0’0"

</sld:Label>

sld:Font

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

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

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

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

</sld:Font>

0.0

0.0

40

0

0

sld:Fill

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

</sld:Fill>

</sld:TextSymbolizer>

</sld:Rule>

However, I get the label ~96 pixels from the LEFT of the output image instead of the expected 40 pixels from the RIGHT of the output (see image with → Expect Point)

I added another rule (first one above) to print at standard location where it is expected to be before moving with the displacement. (Image not to full size)

Is there something I am missing in my rules, or mistaking what the displacement is supposed to do? My understanding is it should be XX pixels from the geometry point.

Thanks,

Chris Snider

Senior Software Engineer

Intelligent Software Solutions, Inc.

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

Chris,

I don’t know if this will help or hinder you, but this is where I got to, for some reason it only works for the Western (left hand) edge in general, and will display the other edges only at the extremes

Ian

<?xml version="1.0" encoding="ISO-8859-1"?>

grid A teal line style teal line #00cc33 the_geom wms_bbox

</ogc:Function>
</ogc:Function>


<ogc:Function name=“endPoint”>
<ogc:Function name=“intersection”>
ogc:PropertyNamethe_geom</ogc:PropertyName>
<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>
</ogc:Function>

</ogc:Function>
</ogc:Function>

0.0 0.0 -120 40 0 the_geom wms_bbox

</ogc:Function>
</ogc:Function>


<ogc:Function name=“startPoint”>
<ogc:Function name=“intersection”>
ogc:PropertyNamethe_geom</ogc:PropertyName>
<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>
</ogc:Function>

</ogc:Function>
</ogc:Function>

0.0 0.0 0 -20 0

image003.png

image001.png

···

On 7 November 2016 at 23:37, Chris Snider <chris.snider@…3225…> wrote:

Hi,

Java 8

GeoServer 2.8.3

Working through my issue to label my latitude lines at the “ends” of the line, I have this section of my label rule to tell me where it “is supposed to be”

sld:TextSymbolizer

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>

Expected Label Location<![CDATA[

]]>

<ogc:Function name=“Concatenate”>

ogc:LiteralPOINT(</ogc:Literal>

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

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>

Blah blah other labels, font etc

</sld:Label>

</sld:TextSymbolizer>

</sld:Rule>

sld:Rule

sld:Namelabel 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=“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>

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>°0’0"

</sld:Label>

sld:Font

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

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

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

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

</sld:Font>

0.0

0.0

40

0

0

sld:Fill

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

</sld:Fill>

</sld:TextSymbolizer>

</sld:Rule>

However, I get the label ~96 pixels from the LEFT of the output image instead of the expected 40 pixels from the RIGHT of the output (see image with → Expect Point)

I added another rule (first one above) to print at standard location where it is expected to be before moving with the displacement. (Image not to full size)

Is there something I am missing in my rules, or mistaking what the displacement is supposed to do? My understanding is it should be XX pixels from the geometry point.

Thanks,

Chris Snider

Senior Software Engineer

Intelligent Software Solutions, Inc.

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


Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi


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

Ian Turton

Ian,

Great pointer to the right direction. I took what you said about the extreme edge and realized I needed to invert my logic. Instead of trying to place the label on the right edge and backing it up by the expected pixel size, I start at the left edge and add the displacement as the env:wms_width, subtracting my expected label pixel size. No ratio algorithm, but it is easy enough to generate my label with a new font size, display it, then capture a portion to determine the width in pixels from Paint.NET or some such, and use that in the calculation of the env:wms_width – PIXEL_SIZE.

For those that are interested, here is the complete SLD for my latitude set

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

<sld:StyledLayerDescriptor xmlns=“http://www.opengis.net/sld” xmlns:sld=“http://www.opengis.net/sld” xmlns:gml=“http://www.opengis.net/gml” xmlns:ogc=“http://www.opengis.net/ogc” version=“1.0.0”>

sld:UserLayer

sld:LayerFeatureConstraints

sld:FeatureTypeConstraint/

</sld:LayerFeatureConstraints>

sld:UserStyle

sld:Namegridshape lon 10.0 deg</sld:Name>

sld:FeatureTypeStyle

sld:Namegroup 0</sld:Name>

sld:FeatureTypeNameFeature</sld:FeatureTypeName>

sld:SemanticTypeIdentifiergeneric:geometry</sld:SemanticTypeIdentifier>

sld:SemanticTypeIdentifiersimple</sld:SemanticTypeIdentifier>

sld:Rule

sld:Namelabel rule</sld:Name>

sld:LineSymbolizer

sld:Stroke

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

<sld:CssParameter name=“stroke-width”>.1</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=“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:Literal1</ogc:Literal>

</ogc:Add>

ogc:Sub

<ogc:Function name=“strIndexOf”>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

ogc:Literal:</ogc:Literal>

</ogc:Function>

ogc:Literal1</ogc:Literal>

</ogc:Sub>

</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>°0’0"

</sld:Label>

sld:Font

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

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

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

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

</sld:Font>

0.0

0.0

ogc:Sub

<ogc:Function name=“env”>

ogc:Literalwms_width</ogc:Literal>

</ogc:Function>

ogc:Literal33</ogc:Literal>

</ogc:Sub>

0

0

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:TextSymbolizer>

</sld:Rule>

</sld:FeatureTypeStyle>

</sld:UserStyle>

</sld:UserLayer>

</sld:StyledLayerDescriptor>

Chris Snider

Senior Software Engineer

Intelligent Software Solutions, Inc.

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

image001.png

image003.png

image002.png

···

Chris,

I don’t know if this will help or hinder you, but this is where I got to, for some reason it only works for the Western (left hand) edge in general, and will display the other edges only at the extremes

Ian

<?xml version="1.0" encoding="ISO-8859-1"?>

<StyledLayerDescriptor version=“1.0.0”

xsi:schemaLocation=“http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/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”>

grid

A teal line style teal line

#00cc33

<ogc:Function name=“endPoint”>

<ogc:Function name=“intersection”>

ogc:PropertyNamethe_geom</ogc:PropertyName>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

</ogc:Function>

</ogc:Function>

<ogc:Function name=“endPoint”>

<ogc:Function name=“intersection”>

ogc:PropertyNamethe_geom</ogc:PropertyName>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

</ogc:Function>

</ogc:Function>

0.0

0.0

-120

40

0

<ogc:Function name=“startPoint”>

<ogc:Function name=“intersection”>

ogc:PropertyNamethe_geom</ogc:PropertyName>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

</ogc:Function>

</ogc:Function>

<ogc:Function name=“startPoint”>

<ogc:Function name=“intersection”>

ogc:PropertyNamethe_geom</ogc:PropertyName>

<ogc:Function name=“env”>

ogc:Literalwms_bbox</ogc:Literal>

</ogc:Function>

</ogc:Function>

</ogc:Function>

0.0

0.0

0

-20

0

On 7 November 2016 at 23:37, Chris Snider <chris.snider@…3225…> wrote:

Hi,

Java 8

GeoServer 2.8.3

Working through my issue to label my latitude lines at the “ends” of the line, I have this section of my label rule to tell me where it “is supposed to be”

sld:TextSymbolizer

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>

Expected Label Location<![CDATA[

]]>

<ogc:Function name=“Concatenate”>

ogc:LiteralPOINT(</ogc:Literal>

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

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>

Blah blah other labels, font etc

</sld:Label>

</sld:TextSymbolizer>

</sld:Rule>

sld:Rule

sld:Namelabel 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=“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>

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>°0’0"

</sld:Label>

sld:Font

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

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

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

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

</sld:Font>

0.0

0.0

40

0

0

sld:Fill

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

</sld:Fill>

</sld:TextSymbolizer>

</sld:Rule>

However, I get the label ~96 pixels from the LEFT of the output image instead of the expected 40 pixels from the RIGHT of the output (see image with → Expect Point)

I added another rule (first one above) to print at standard location where it is expected to be before moving with the displacement. (Image not to full size)

Is there something I am missing in my rules, or mistaking what the displacement is supposed to do? My understanding is it should be XX pixels from the geometry point.

Thanks,

Chris Snider

Senior Software Engineer

Intelligent Software Solutions, Inc.

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


Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi


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

Ian Turton

Sent again with some prior code trimming

image001.png