Hi everybody,
Could please someone explain me somthing about that strange behavion
found during Filter converision?

I convert an xml (ogc:filter) in a Filter object (org.opengis.filter.Filter)
and then
when I try to convert in back to xml it is completely different.

Could please someone explain me where is the point?
Because if I pass that filter to GeoServer it returns me
an exception because it is not respecting the OpenGis Filter Schema:

<ows:ExceptionText>
  java.lang.RuntimeException: Parsing failed for BBOX:
java.lang.NullPointerException Parsing failed for BBOX:
java.lang.NullPointerException null
</ows:ExceptionText>

rgds

  Milan A.

--

*Here the test code:*


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.opengis.filter.*;
import org.xml.sax.SAXException;

public class TestFilter2 {

    public static void main(String[] args) {

        org.geotools.xml.Configuration configuration =
                new org.geotools.filter.v1_1.OGCConfiguration();
        org.geotools.xml.Parser parser =
                new org.geotools.xml.Parser(configuration);

        String xml =
                "<Filter xmlns:gml=\"http://www.opengis.net/gml\";>"
                + "<BBOX>"
                + "<PropertyName>Geometry</PropertyName>"
                + "<gml:Envelope>"
                + "<gml:lowerCorner>0 0</gml:lowerCorner>"
                + "<gml:upperCorner>10 10</gml:upperCorner>"
                + "</gml:Envelope>"
                + "</BBOX>"
                + "</Filter>";
        Filter f;
        try {
            f = (Filter) parser.parse(new ByteArrayInputStream(
                    xml.getBytes()));
            System.out.println(f);

            org.geotools.filter.FilterTransformer ft = new
org.geotools.filter.FilterTransformer();
            ft.setOmitXMLDeclaration(true);
            ft.setNamespaceDeclarationEnabled(true);
            ft.setIndentation(0);
            try {
                ft.setIndentation(2);
                System.out.println(ft.transform(f));
            } catch (TransformerException ex) {
                System.err.println("TransformerException: " +
ex.getMessageAndLocation());
            }

        } catch (IOException ex) {
            Logger.getLogger(TestFilter2.class.getName()).log(Level.SEVERE,
null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(TestFilter2.class.getName()).log(Level.SEVERE,
null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(TestFilter2.class.getName()).log(Level.SEVERE,
null, ex);
        }
    }
}
***

Output:

[ Geometry bbox POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0)) ]
<ogc:Filter xmlns="http://www.opengis.net/ogc"; xmlns:ogc="
http://www.opengis.net/ogc"; xmlns:gml="http://www.opengis.net/gml";>
  <ogc:BBOX>
    <ogc:PropertyName>Geometry</ogc:PropertyName>
    <gml:Polygon>
      <gml:outerBoundaryIs>
        <gml:LinearRing>
          <gml:coordinates xmlns:gml="http://www.opengis.net/gml";
decimal="." cs="," ts=" ">0,0 0,10 10,10 10,0 0,0</gml:coordinates>
        </gml:LinearRing>
      </gml:outerBoundaryIs>
    </gml:Polygon>
  </ogc:BBOX>
</ogc:Filter>


Why?? [?]

<<361.gif>>

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to