Hi Jody,
want to try the attached patch?
This is the deal: I didn't want to touch anything but the wfs 1.0
datastore. Made a test case that uses a BBOX implementation that does
not implement the deprecated geotools' GeometryFilter and reproduced the
issue.
Then used DuplicatingFilterVisitor to make sure the the query filter is
of the expected types.
Sort of band aid solution, but as long as wfs 1.0 datastore is kind of
unmaintained, I would say it's good enough until porting it to the new
architecture.
Thoughts?
Cheers,
Gabriel
Jody Garnett wrote:
Gabriel / Mark - here is the results of testing GeoServer 1.7.7
against udig + geotools trunk.
Everything is looking okay; except for WFS Editing - looks like a
change on the geotools side to me? Or a change in what the renderer is
sending to the WFS DataStore?
Jody
net.refractions.udig.project.render.RenderException: Problem
rendering: Exception rendering layer DefaultMapLayer[ Test, VISIBLE,
UNSELECTED, style=StyleImpl[ name=Default Styler],
data=net.refractions.udig.project.internal.impl.udigfeaturest...@1b3409f,
query=Query: [Request All Features]
feature type: null
filter: Filter.INCLUDE
[properties: ALL ]]
at
net.refractions.udig.render.internal.feature.basic.BasicFeatureRenderer.render(BasicFeatureRenderer.java:368)
at
net.refractions.udig.render.internal.feature.basic.BasicFeatureRenderer.render(BasicFeatureRenderer.java:213)
at
net.refractions.udig.project.internal.render.impl.RenderJob.startRendering(RenderJob.java:108)
at
net.refractions.udig.project.internal.render.impl.RenderJob.run(RenderJob.java:213)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.Exception: Exception rendering layer
DefaultMapLayer[ Test, VISIBLE, UNSELECTED, style=StyleImpl[
name=Default Styler],
data=net.refractions.udig.project.internal.impl.udigfeaturest...@1b3409f,
query=Query: [Request All Features]
feature type: null
filter: Filter.INCLUDE
[properties: ALL ]]
at
org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:679)
at
org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:501)
at
net.refractions.udig.render.internal.feature.basic.BasicFeatureRenderer.render(BasicFeatureRenderer.java:340)
... 4 more
Caused by: java.lang.ClassCastException:
org.geotools.renderer.lite.FastBBOX cannot be cast to
org.geotools.filter.Filter
at org.geotools.filter.Filters.accept(Filters.java:262)
at
org.geotools.data.wfs.v1_0_0.NonStrictWFSStrategy.correctFilterForServer(NonStrictWFSStrategy.java:213)
at
org.geotools.data.wfs.v1_0_0.NonStrictWFSStrategy.getFeatureReader(NonStrictWFSStrategy.java:69)
at
org.geotools.data.wfs.v1_0_0.WFS_1_0_0_DataStore.getFeatureReader(WFS_1_0_0_DataStore.java:729)
at
org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:210)
at
org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:224)
at
org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:194)
at
org.geotools.renderer.lite.StreamingRenderer.drawOptimized(StreamingRenderer.java:1796)
at
org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1730)
at
org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:675)
... 6 more
--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Index: src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java
===================================================================
--- src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java
(revision 34115)
+++ src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java
(working copy)
@@ -72,6 +72,7 @@
import org.geotools.filter.Filters;
import org.geotools.filter.GeometryFilter;
import org.geotools.filter.LiteralExpression;
+import org.geotools.filter.visitor.DuplicatingFilterVisitor;
import org.geotools.filter.visitor.PostPreProcessFilterSplittingVisitor;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS;
@@ -472,6 +473,15 @@
}
if (request != null) {
+ if (request.getFilter() != null) {
+ // duplicate the filter so we're sure it uses the old and
deprecated interfaces.
+ // Weird? yes. WFS 1.0 support is still not ported to the
GeoAPI Filter interfaces
+ DefaultQuery q = new DefaultQuery(request);
+ DuplicatingFilterVisitor dfv = new DuplicatingFilterVisitor();
+ Filter duplicated = (Filter) request.getFilter().accept(dfv,
null);
+ q.setFilter(duplicated);
+ request = q;
+ }
if (request.getMaxFeatures() != Query.DEFAULT_MAX) {
url += ("&MAXFEATURES=" + request.getMaxFeatures());
}
@@ -661,6 +671,15 @@
hints.put(DocumentWriter.BASE_ELEMENT,
WFSSchema.getInstance().getElements()[2]); // GetFeature
hints.put(DocumentWriter.ENCODING, protocolHandler.getEncoding());
try {
+ if (query.getFilter() != null) {
+ // duplicate the filter so we're sure it uses the old and
deprecated interfaces.
+ // Weird? yes. WFS 1.0 support is still not ported to the
GeoAPI Filter interfaces
+ DefaultQuery q = new DefaultQuery(query);
+ DuplicatingFilterVisitor dfv = new DuplicatingFilterVisitor();
+ Filter duplicated = (Filter) query.getFilter().accept(dfv,
null);
+ q.setFilter(duplicated);
+ query = q;
+ }
DocumentWriter.writeDocument(query, WFSSchema.getInstance(), w,
hints);
} catch (OperationNotSupportedException e) {
LOGGER.warning(e.toString());
Index: src/test/java/org/geotools/data/wfs/v1_0_0/GeoServerOnlineTest.java
===================================================================
--- src/test/java/org/geotools/data/wfs/v1_0_0/GeoServerOnlineTest.java
(revision 34115)
+++ src/test/java/org/geotools/data/wfs/v1_0_0/GeoServerOnlineTest.java
(working copy)
@@ -54,16 +54,20 @@
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.filter.IllegalFilterException;
+import org.geotools.geometry.jts.ReferencedEnvelope;
import org.junit.Before;
import org.junit.Test;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.filter.Filter;
import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.FilterVisitor;
import org.opengis.filter.Id;
import org.opengis.filter.PropertyIsNull;
+import org.opengis.filter.expression.Expression;
import org.opengis.filter.expression.PropertyName;
import org.opengis.filter.identity.FeatureId;
+import org.opengis.filter.spatial.BBOX;
import org.xml.sax.SAXException;
import com.vividsolutions.jts.geom.Coordinate;
@@ -232,7 +236,77 @@
WFSDataStoreReadTest.doFeatureReaderWithQuery(url, true, false, 0);
}
+ /**
+ * {...@link BBOX} support?
+ */
@Test
+ public void testDataStoreSupportsPlainBBOXInterface() throws Exception {
+ final WFS_1_0_0_DataStore wfs = WFSDataStoreReadTest.getDataStore(url);
+ final SimpleFeatureType ft = wfs.getSchema(TO_EDIT_TYPE);
+ final ReferencedEnvelope bounds =
wfs.getFeatureSource(TO_EDIT_TYPE).getBounds();
+
+ final FilterFactory2 ff =
CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
+ final BBOX bbox = ff.bbox("the_geom", bounds.getMinX(),
bounds.getMinY(), bounds.getMaxX(), bounds.getMaxY(), null);
+
+ /**
+ * This one does not implement the deprecated geotools filter
interfaces
+ */
+ final BBOX strictBBox = new BBOX() {
+
+ public boolean evaluate(Object object) {
+ return bbox.evaluate(object);
+ }
+
+ public Object accept(FilterVisitor visitor, Object extraData) {
+ return bbox.accept(visitor, extraData);
+ }
+
+ public Expression getExpression2() {
+ return bbox.getExpression2();
+ }
+
+ public Expression getExpression1() {
+ return bbox.getExpression1();
+ }
+
+ public String getSRS() {
+ return bbox.getSRS();
+ }
+
+ public String getPropertyName() {
+ return bbox.getPropertyName();
+ }
+
+ public double getMinY() {
+ return bbox.getMinY();
+ }
+
+ public double getMinX() {
+ return bbox.getMinX();
+ }
+
+ public double getMaxY() {
+ return bbox.getMaxY();
+ }
+
+ public double getMaxX() {
+ return bbox.getMaxX();
+ }
+ };
+
+ final DefaultQuery query = new DefaultQuery(ft.getTypeName());
+ query.setFilter(strictBBox);
+
+ FeatureReader<SimpleFeatureType, SimpleFeature> reader;
+
+ reader = wfs.getFeatureReaderGet(query, Transaction.AUTO_COMMIT);
+ assertNotNull(reader);
+
+ reader = wfs.getFeatureReaderPost(query, Transaction.AUTO_COMMIT);
+ assertNotNull(reader);
+ }
+
+ @Test
public void testFeatureReaderWithFilterPOST() throws
NoSuchElementException,
IllegalAttributeException, IOException, SAXException {
WFSDataStoreReadTest.doFeatureReaderWithQuery(url, false, true, 0);
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel