Hi Cory,

>-                atts.addAttribute("", "fid", "", "", fids[i]);
>+                atts.addAttribute("", "fid", "fid", "", fids[i]);
>
>So this problem was fixed on the 2.2.x branch: r15885 | jeichar | 2005-09-27
>
>Cory.


I have just downloaded Geotools 2.2.1 for testing. It seems that the new line of code does not solve all the problem. Now Geotools will not throw Exception anymore, but if my original FidFilter before the transformation has more than 1 ids in it, after the transformation we will only have 1.

This is the code I use to test:

[0] public static void main(String[] arg) {
[1]    List fiveFeatureId = new ArrayList();
[2]    for (int i = 0; i < 5; i++) {
[3]        fiveFeatureId.add("parcell."+ i );
[4]    }

[5]    FidFilter fidF = FilterFactoryFinder.createFilterFactory().createFidFilter();
[6]    fidF.addAllFids(fiveFeatureId);

[7]    Style styleBefore = new StyleBuilder().createStyle();
[8]    Symbolizer sym = new StyleBuilder().createPolygonSymbolizer();
[9]    Rule r = new StyleBuilder().createRule(sym);
[10]    r.setFilter(fidF);
[11]    FeatureTypeStyle featureTypeStyle = styleBefore.getFeatureTypeStyles()[0];
[12]    featureTypeStyle.addRule(r);
[13]    styleBefore.addFeatureTypeStyle(featureTypeStyle);

[14]    String filterName = fidF.getClass().getName();
[15]    try {
[16]        String sld = new SLDTransformer().transform(new Style[] { styleBefore });

[17]        InputStream is = new ByteArrayInputStream(sld.getBytes());
[18]        Style[] styles = new SLDParser(StyleFactoryFinder.createStyleFactory(), is).readXML();

[19]        System.out.println("Transformation with '" + filterName + "' Correctly: " +  styleBefore.equals(styles[0]));
[20]        //This would print something like "Transformation with 'org.geotools.filter.FidFilterImpl' Correctly: false"

[21]    } catch (TransformerException e) {
[22]        System.err.println("Tranformation Error When Transforming... ");
[23]    }
[24] }

---------------------------------------------------------------------
Using Eclipse's debugging tool, I can see that 'styleBefore' in line [16] has a FidFilter with a set of 5 ids, "[ parcell.2, parcell.0, parcell.3, parcell.1, parcell.4 ]", while styler[0] in line [19] has a filer with only 1 id, "[parcell.4]".

So it looks like between writing stuff into XML and reading it back, some ids got droped. I will not paste the XML string here, since my Yahoo Mail will make it something else. But I attached it as a text file for you.

Do you know if this bug has been reported/fixed?

Thanks,

Trung



<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor 
xmlns:sld="http://www.opengis.net/sld"; xmlns:ogc="http://www.opengis.net/ogc"; 
xmlns:gml="http://www.opengis.net/gml";><sld:NamedLayer><sld:UserStyle><sld:Name>Default
 Styler</sld:Name><sld:Title>Default 
Styler</sld:Title><sld:Abstract></sld:Abstract><sld:FeatureTypeStyle><sld:Name>name</sld:Name><sld:Title>title</sld:Title><sld:Abstract>abstract</sld:Abstract><sld:FeatureTypeName>Feature</sld:FeatureTypeName><sld:SemanticTypeIdentifier>generic:geometry</sld:SemanticTypeIdentifier><sld:Rule><sld:Name>name</sld:Name><sld:Title>title</sld:Title><sld:Abstract>Abstract</sld:Abstract><ogc:Filter><ogc:FeatureId
 fid="parcell.2"/><ogc:FeatureId fid="parcell.0"/><ogc:FeatureId 
fid="parcell.3"/><ogc:FeatureId fid="parcell.1"/><ogc:FeatureId 
fid="parcell.4"/></ogc:Filter><sld:MaxScaleDenominator>1.7976931348623157E308</sld:MaxScaleDenominator><sld:PolygonSymbolizer><sld:Fill><sld:CssParameter
 
name="fill"><ogc:Literal>#808080</ogc:Literal></sld:CssParameter><sld:CssParameter
 
name="fill-opacity"><ogc:Literal>1.0</ogc:Literal></sld:CssParameter></sld:Fill><sld:Stroke><sld:CssParameter
 
name="stroke"><ogc:Literal>#000000</ogc:Literal></sld:CssParameter><sld:CssParameter
 
name="stroke-linecap"><ogc:Literal>butt</ogc:Literal></sld:CssParameter><sld:CssParameter
 
name="stroke-linejoin"><ogc:Literal>miter</ogc:Literal></sld:CssParameter><sld:CssParameter
 
name="stroke-opacity"><ogc:Literal>1</ogc:Literal></sld:CssParameter><sld:CssParameter
 
name="stroke-width"><ogc:Literal>1</ogc:Literal></sld:CssParameter><sld:CssParameter
 
name="stroke-dashoffset"><ogc:Literal>0</ogc:Literal></sld:CssParameter></sld:Stroke></sld:PolygonSymbolizer></sld:Rule></sld:FeatureTypeStyle></sld:UserStyle></sld:NamedLayer></sld:StyledLayerDescriptor>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to