0

I am trying to style an GeometryCollection geometry data type from PotGIS table in Geoserver. I have not found any examples on the Internet how to do it nor is it supported in Geoserver or not. When I try to style it using standard PolygonSymbolizer, LineSymbolizer and PointSymbolizer I get strange behaviours. For example, filled non-closed linestrings, non-exitsting points appear on linestring etc. This is one example of my SLD file and rendered WMS request.

Am I doing something wrong in my SLD?

Is GeometryCollection supported in Geoserver?

Example of SLD:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0"
 xsi:schemaLocation="http://www.opengis.net/sld 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">
  <NamedLayer>
    <UserStyle>
      <FeatureTypeStyle>
       <Rule>
        <ogc:Filter>
         <ogc:PropertyIsEqualTo>
            <ogc:Function name="geometryType">
               <ogc:PropertyName>the_geom</ogc:PropertyName>
            </ogc:Function>
            <ogc:Literal>GeometryCollection</ogc:Literal>
         </ogc:PropertyIsEqualTo>
       </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#FF0000</CssParameter>
            </Fill>
            <Stroke>
              <CssParameter name="stroke">#FFFFFF</CssParameter>
              <CssParameter name="stroke-width">6</CssParameter>
            </Stroke>
          </PolygonSymbolizer>
          <LineSymbolizer>
            <Stroke>
              <CssParameter name="fill">#00FF00</CssParameter>
              <CssParameter name="stroke-width">2</CssParameter>
              <CssParameter name="stroke-linejoin">round</CssParameter>
              <CssParameter name="stroke-linecap">round</CssParameter>
            </Stroke>
          </LineSymbolizer>
         <PointSymbolizer>
              <Graphic>
                <Mark>
                  <WellKnownName>circle</WellKnownName>
                  <Fill>
                    <CssParameter name="fill">#0000FF</CssParameter>
                  </Fill>
                </Mark>
              <Size>9</Size>
            </Graphic>
          </PointSymbolizer>
      </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Rendered WMS request with provided SLD file:

Rendered WMS request with provided SLD file

2

What you are seeing is the correct behaviour as described by the SLD Spec. If you want to only apply one symbolizer to a feature then you need to provide a filter that selects one (or more) of the symbolizers for each feature.

The GeoServer documentation covers how to handle multiple geometries in one column quite clearly here.

  • Yes, I understand this, but I have geometrycollection which has points, lines and poligons, how can I select particular type from that geometrycollection object? – Mario Miler Dec 9 '14 at 12:05
  • I might go to making views into PostGIS or SQL View layer in GeoServer for splitting GeometryCollections to point/multipoint, linestring/multilinestring, and polygon/multipolygon layers. Then the layers could be styled in a reasonable way and combined back together by making a WMS layer group. Very few software can style geometrycollections well. OpenJUMP is one that can but it does not help you with your web service. – user30184 Dec 9 '14 at 12:21
  • easiest way is the filter on geometry type – Ian Turton Dec 9 '14 at 12:58
  • @user30184 I am aware of this approach, but I wanted to avoid it :) .. thank you for the suggestion – Mario Miler Dec 9 '14 at 19:59
  • @iant if I filler by geometry type, I get geometry type geometrycollection ... what to with it then? With filtering by geometry type I do not get point, linestring and polygon. – Mario Miler Dec 9 '14 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.