Hi,

I am using the ShapefileRenderer to render a shapefile based on an SLD
that uses two rules (one is the complement of the other) which use an
attribute expression. 

The ShapefileRenderer code seems to be incorrectly interpreting this. In
createFeature() it reads the values, but uses the first attribute in the
schema (the attribute I care about is second). It also mixes up the
attribute and the geometry and throws an exception. I can't quite figure
out where it is going wrong. Here is the code I was looking at:

>From ShapefileRenderer.createFeature():

            Object[] all = dbfreader.readEntry();
            Object[] values = new Object[type.getAttributeCount()];

            for( int i = 0; i < (values.length - 1); i++ ) {
                values[i] = all[attributeIndexing[i]];

                if
(header.getFieldName(attributeIndexing[i]).equals(type.getAttributeType(i))) {
                    System.out.println("ok");
                }
            }

            values[values.length - 1] = getGeom(record.shape(),
type.getDefaultGeometry());

            return type.create(values, id);

'type' is a schema that is generated by the processSymbolizer method,
containing only the attribute that is used in the expression and the
geometry (so type only has two attributes where the original schema has
seven).

'all' is an array holding the attribute values, with the value we care
about in index position 1. 

'attributeIndexing' is a direct mapping here, so it can be ignored
(perhaps that is the bug?)

Note that the System.out.println doesn't actually occur, but it looks
like it should during proper execution.

Right before the return statement, values[] contains the attribute value
in all[0] and the geometry. The return statement throws an exception (it
is trying to convert value[0] to a geometry, but value[1] is the actual
geometry.

Any suggestions? Is my SLD insane?

Richard


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to