I have a PostGIS table that holds polygon, polyline, and point geometry types. I added this table to Geoserver as a FeatureType and would like to be able to, in a single SLD, style each type of geometry differently for use in WMS. I've looked around and can't find any examples of this being done. I tried using the SLD generated in uDig, which looked fine in uDig, but that only rendered all the features as points in Geoserver. Is this possible in Geoserver?
Thank you,
Aaron
Hi Aaron,
For each geometry you want to render you need a separate symbolizer for it. And the each symbolizer needs to explicitly reference the geometry to be used with the "sld:Geometry" element.
Example:
<Rule>
...
<PolygonSymbolizer>
<Geometry>myPolygonGeometry</Geometry>
<PolygonSymbolizer>
<PointSymbolizer>
<Geometry>myPointGeometry</Geometry>
<PointSymbolizer>
...
</Rule>
-Justin
Aaron Sutula wrote:
I have a PostGIS table that holds polygon, polyline, and point geometry types. I added this table to Geoserver as a FeatureType and would like to be able to, in a single SLD, style each type of geometry differently for use in WMS. I've looked around and can't find any examples of this being done. I tried using the SLD generated in uDig, which looked fine in uDig, but that only rendered all the features as points in Geoserver. Is this possible in Geoserver?
Thank you,
Aaron
------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
Thanks for the reply, Justin. It may help me, but let me clarify one thing first…
Is your example assuming that my polygon geometries are stored in a different column than my point geometries? From what I gather from your example "myPolygonGeometry"and “myPointGeometry” are column names. That is not my case. In my table, polygons, points and lines are stored in the same column. Is your example valid in that case?
Thanks again for your help.
Aaron
Justin Deoliveira wrote:
Aaron Sutula ha scritto:
Thanks for the reply, Justin. It may help me, but let me clarify one thing first...
Is your example assuming that my polygon geometries are stored in a different column than my point geometries? From what I gather from your example "myPolygonGeometry"and "myPointGeometry" are column names. That is not my case. In my table, polygons, points and lines are stored in the same column. Is your example valid in that case?
It's not. SLD does not provide any cross-server interperable way
to recognize the geometry type. But GeoServer has filter functions
that can extract that information, and you case use them in
your filters:
<Rule>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="geometryType">
<ogc:Literal>myGeomColumnName</ogc:Literal>
<ogc:Function>
<ogc:Literal>Point</ogc:Literal>
</ogc:PropertyIsEqualTo>
...
</Rule>
should work only against geometries of point type.
Other values returned will be LineString, LinearRing,
Polygon and the MultiXXX variants.
Ah mind, that filter will be executed in memory, no
datastore is able to encode it into a native check, thought
it's of course possible to do for spatial databases
(patches/funding welcomed)
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Andrea Aime ha scritto:
Hmmm... it should actually be:
<Rule>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="geometryType">
<ogc:PropertyName>myGeomColumnName</ogc:PropertyName>
<ogc:Function>
<ogc:Literal>Point</ogc:Literal>
</ogc:PropertyIsEqualTo>
...
</Rule>
(hopefully, don't have time to try it out).
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Thank you Andrea and Justin. This works perfectly!
Aaron
Andrea Aime wrote:
Andrea Aime ha scritto:
Hmmm... it should actually be:
<Rule>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="geometryType">
<ogc:PropertyName>myGeomColumnName</ogc:PropertyName>
<ogc:Function>
<ogc:Literal>Point</ogc:Literal>
</ogc:PropertyIsEqualTo>
...
</Rule>
(hopefully, don't have time to try it out).
Cheers
Andrea