From: Levasseur, B. <br...@ll...> - 2009-03-03 15:02:30
|
Hello, I am new to GeoTools and I have a question about the use of the gml:Envelope tag. I have a project where I am going to have to take in xml documents that will include OGC Filter statements. I downloaded a source copy of GeoTools version 2.5.1 and started to look at the code. I wanted to see how the xml version of the filter was handled in GeoTools, after some looking I found the test class modules/library/xml/src/test/java/org/geotools/xml/ogc/XMLEncoderTest.java. This test class apparently takes in filter statements in xml and tries to parse them into an org.opengis.filter.Filter object. I ran the JUnit test and of course everything passed. I then decided that I wanted to try some filter statements other than the ones used in the test. So I went to the file modules/library/xml/src/test/resources/org/geotools/xml/ogc/test-data/test3b.xml. This is one of the xml files that gets read in and parsed from xml to the Filter object, I decided to change it into a different filter statement to see how the filter object would look when using a gml:Envelope tag. I changed this xml file to the following: <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> I then ran the JUnit test again. The test that uses the file test3b.xml does not make any assertion statements to check and see what the outcome of the Filter is, so I thought that my test would still pass. Instead I got the following error while parsing the xml into the Filter object: java.lang.NullPointerException at org.geotools.filter.FilterFactoryImpl.bbox(FilterFactoryImpl.java:261) at org.geotools.filter.FilterDOMParser.parseFilter(FilterDOMParser.java:453) at org.geotools.xml.ogc.XMLEncoderTest.parseDocument(XMLEncoderTest.java:238) at org.geotools.xml.ogc.XMLEncoderTest.test3b(XMLEncoderTest.java:139) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) I tried to debug the error and found that in the method org.geotools.filterFilterDOMParser.parseFilter the code cannot parse the gml:Envelope tag to determine what the values for the bounding box are. Does GeoTools not support all of the gml language such as gml:Envelope tags, or is my filter statement written incorrectly for using the gml:Envelope tag, or is it that the class modules/library/xml/src/test/java/org/geotools/xml/ogc/XMLEncoderTest.java is not the correct JUnit class to handle parsing xml messages with gml:Envelope tags to Filter objects, or is there something else I am missing? Thank you. Brett |