[Geoserver-devel] Another bug in GetLegendGraphic

Hi,
I found another problem in GetLegendGraphic, when I ask for a legend for a layer with a generic geometry type (GEOMETRY) I have the following exception:

java.lang.IllegalArgumentException: class com.vividsolutions.jts.geom.Geometry is not supported by this method
at org.geotools.data.DataUtilities.defaultValue(DataUtilities.java:997)
at org.geotools.feature.simple.SimpleFeatureBuilder.convert(SimpleFeatureBuilder.java:316)
at org.geotools.feature.simple.SimpleFeatureBuilder.set(SimpleFeatureBuilder.java:297)
at org.geotools.feature.simple.SimpleFeatureBuilder.add(SimpleFeatureBuilder.java:220)
at org.geotools.feature.simple.SimpleFeatureBuilder.template(SimpleFeatureBuilder.java:502)
at org.geoserver.wms.legendgraphic.BufferedImageLegendGraphicBuilder.createSampleFeature(BufferedImageLegendGraphicBuilder.java:534

To solve that I’d follow the following approach:

  • for each Rule, scan all the Symbolizers to find the one with the greatest “dimension” (Point = 0, Line = 1, Polygon =2, …)
  • choose a Geometry type to match the max dimension found at the previous step and create a sample for that geometry type
  • draw the icon as usual for the sample

Obviously this would be done only if I have a generic GEOMETRY, for all the other types the rendering process would be unchanged.

Can I proceed to craft a patch for master to solve this issue?

Thanks.

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it