1

I have a layer in GeoServer which is stored in a PostGIS database. The geometrytype of the layer is GEOMETRY and now the table only contains LINESTRING. But I what to add points and polygons to the table, this is the reason I choose GEOMETRY as the geometrytype. My layer is working fine in the Layer Preview...

But when I do a GetLegendGraphic request I get the following ServiceException: java.lang.IllegalArgumentException: class com.vividsolutions.jts.geom.Geometry is not supported by this method class com.vividsolutions.jts.geom.Geometry is not supported by this method

My SLD is quite simple:


<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 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"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
    <Name></Name>
    <UserStyle>
      <Abstract></Abstract>
      <FeatureTypeStyle>
  <Rule>
  <Title>Test</Title>
  <ogc:Filter>
   <ogc:PropertyIsEqualTo>
    <ogc:PropertyName>feature_type</ogc:PropertyName>
    <ogc:Literal>Test</ogc:Literal>
   </ogc:PropertyIsEqualTo>
  </ogc:Filter>
          <LineSymbolizer>
      <Stroke>
     <CssParameter name="stroke">#FFA618</CssParameter>
     <CssParameter name="stroke-width">2</CssParameter>
     <CssParameter name="stroke-dasharray">5 2</CssParameter>
      </Stroke>
    </LineSymbolizer>
  </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

My GetLegendGraphic request is:
http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=16&HEIGHT=16&LAYER=namespace:layer

I have tried the request on a GeoServer 2.0.1 and a GeoServer 2.0.2 and in both cases I get ServiceException as above mentioned.

What can I do to get the request working?

2

I found out that my geometry column had a not-null constraint in PostGIS. When I removed the not-null constraint I got rid of the GetLegendGraphic request ServiceException.

Another solution to get rid of the GetLegendGraphic request ServiceException was to change the geometrytype in PostGIS from GEOMETRY TO LINESTRING (change the type in the table geometry_columns), but that is not a valid option in my case.

1

You need a filter something like:

<ogc:PropertyIsEqualsTo>
      <ogc:Function name="geometryType">
         <ogc:PropertyName>geom</ogc:PropertyName>
      </ogc:Function>
      <ogc:Literal>LineString</ogc:Literal>
   </ogc:PropertyIsEqualsTo>

in the rule you would like to style the lines.

See http://docs.geoserver.org/2.0.0/user/styling/sld-tipstricks/mixed-geometries.html for a fuller discussion of how to handle multiple geometry types in the same table.

  • 1
    My filter only selects the lines as the all have the value 'test'. But I have tried using geometryType filter and I still get the same ServiceException. I have another layer where I have points, lines and polygons.This layer are shown fine (all the geometrytypes are drawn) when I style the layer, but the GetLegendGraphic request still fails... – taudorf Oct 6 '10 at 14:23
  • could be a bug then. – Ian Turton Oct 6 '10 at 15:21

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.