1

I am working on a specific style for a geoserver layer

Im trying to get polygon from intersection between wms_bbox and geometry

              <ogc:Function name="intersection">
                <ogc:PropertyName>geom</ogc:PropertyName>
                <ogc:Function name="env">
                  <ogc:Literal>wms_bbox</ogc:Literal>
                </ogc:Function>
              </ogc:Function>

I use this piece of code but it doesn't work

Documentation: https://geoserver-pdf.readthedocs.io/en/latest/filter/function_reference.html#spatial-relationship-functions

Does anyone have an idea what I'm doing wrong?

GeoServer Version 2.10.3

I want to place a label in the lower left corner of the visible part of the polygon

    <Rule>
      <TextSymbolizer>


        <Geometry>
          <ogc:Function name="pointN">
            <ogc:Function name="boundary">


              <ogc:Function name="intersection">
                <ogc:PropertyName>geom</ogc:PropertyName>
                <ogc:Function name="env">
                  <ogc:Literal>wms_bbox</ogc:Literal>
                </ogc:Function>
              </ogc:Function>


            </ogc:Function>
            <ogc:Literal>0</ogc:Literal>
          </ogc:Function>
        </Geometry>

        <Label>
   ....

EDIT:

I updated the code with the function offset, works almost perfectly,but always only in the lower left part of the grid, label is not displayed

     <Geometry>
        <ogc:Function name="offset">
        
          <ogc:Function name="pointN">
            <ogc:Function name="boundary">
              <ogc:Function name="intersection">
                <ogc:PropertyName>geom</ogc:PropertyName>
                <ogc:Function name="env">
                  <ogc:Literal>wms_bbox</ogc:Literal>
                </ogc:Function>
              </ogc:Function>
            </ogc:Function>
            <ogc:Literal>0</ogc:Literal>
          </ogc:Function>
                  
          <ogc:Literal>20.0</ogc:Literal>
          <ogc:Literal>20.0</ogc:Literal>
          
          </ogc:Function>
        </Geometry>

        ...
        <LabelPlacement>
          <PointPlacement>
            <AnchorPoint>
              <AnchorPointX>0</AnchorPointX>
              <AnchorPointY>0.5</AnchorPointY>
            </AnchorPoint>
            <Displacement>
              <DisplacementX>0</DisplacementX>
              <DisplacementY>0</DisplacementY>
            </Displacement>
          </PointPlacement>

        </LabelPlacement>

enter image description here

enter image description here

2
  • What doesn't work? And why not use a recent version of GeoServer?
    – Ian Turton
    Jul 26, 2022 at 16:36
  • @IanTurton there are no errors in the GeoServer Logs. I edited my post with the expected result
    – ncica
    Jul 26, 2022 at 18:36

1 Answer 1

1

Because the point you generate is on the edge of the window and GeoServer won't draw a label that is partly off the screen.

If you use an X offset it might work.

Finally, for this sort of exact positioning you might be best turning off the labelling engine altogether using the ConflictResolution vendor option.

<VendorOption name="conflictResolution">false</VendorOption>
3
  • I updated the code with the function offset, works almost perfectly,but always only in the lower left part of the grid label is not displayed. The changes are in my post.
    – ncica
    Jul 26, 2022 at 20:01
  • Looking at your lower image it looks like there is room for one or the other of the left labels.
    – Ian Turton
    Jul 27, 2022 at 7:48
  • How you can see, the quadrant above and quadrant on the right have labels, that's why I expect label to be in this quadrant as well, especially considering image 1
    – ncica
    Jul 27, 2022 at 11:21

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.