In my GeoServer SLD I need to place a symbol (particularly a piechart) exactly on Centroid of the result of Intersection of 2 geometry:
- geom field from my PostGIS table AND
- environment variable WMS_BBOX
My aim is to place my Piechart on centroid of shown part of a polygon (an not on centroid of the whole polygon itself).
Ian Turton commented on my previous question with the following Geometry element in SLD, and to use it in
<Geometry> <ogc:Function name="intersection"> <ogc:PropertyName>the_geom</ogc:PropertyName> <ogc:Function name="env"> <ogc:Literal>wms_bbox</ogc:Literal> </ogc:Function> </ogc:Function> </Geometry>
The problem is, with the above Geometry (of intersection between geom field and WMS_BBOX) the piechart is shown in every geometry element of my multipolygon table. And this is surely not desirable.
This effect is similar to forcing a
<PointSymbolizer> Rule (below) to a multipolygon table.
<Rule> <PointSymbolizer> <Graphic> <Mark> <WellKnownName>square</WellKnownName> <Fill><CssParameter name="fill">#FF0000</CssParameter> </Fill> </Mark> <Size>6</Size> </Graphic> </PointSymbolizer> </Rule>
The above style enforcement gives the below layer (these islands belong to 1 row of a multipolygon table).
Again this is not desirable.
So then i tried the
<ogc:Function name="centroid">. Thinking that this is equivalent to a PostGIS command of
ST_CENTROID( ST_INTERSECTION( geometry_field, --of my multipolygon table WMS_BBOX ))
... then I wrote the following in my SLD:
<Geometry> <ogc:Function name="centroid"> <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> </Geometry>
However my WMS preview throws this error:
code:"internalError:Rendering process failed Filter Function problem for function centroid argument #0 - expected type Geometry
This is as if
Centroid argument expects a geometry type but
Intersection argument gives non-geometry type. The GeoServer Geometric functions reference however, while clearly states the type of arguments input, does not states clearly the type of the output.
- why does
centroidargument fail on my
- how to solve it?
- GeoServer 2.14.3 (with chart extension)
- Apache Tomcat 8.5.32 Server
- Windows 10 Pro 64-bit on Xeon E5-1660 3GHz, 32GB memory
- PostgreSQL 9.6.11, PostGIS 2.5