GeoTools
  1. GeoTools
  2. GEOT-1499

WFSFeatureSource.getFeatures() always returns empty set with ALL query

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.4-RC0, 2.5-M0
    • Fix Version/s: 2.7.6
    • Component/s: wfs plugin
    • Labels:
      None
    • Environment:
      Fedora 7 (kernel 2.6.22.5-76.fc7)
      Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)

      Description

      The getFeatures(Query query) method from WFSFeatureSource doesn't work with the Query.ALL filter. This is because Query.ALL doesn't specify a typeName, and this triggers the execution of the if (query.getTypeName() == null) branch. This creates an ad-hoc ALL inclusive query for the source type name, but it doesn't actually use it.

      Proposed fix is attached.

      1. wfs-patch-1.patch
        0.7 kB
        Gustavo Giráldez

        Activity

        Hide
        Fabio Da Soghe added a comment -
        I encountered this problem with latest "stable" geotools, 2.5.1.

        This is my code:

        String getCapabilities = "http://myserver:8080/ws/dasoghe?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetCapabilities";

        Map<Object, Object> connectionParameters = new HashMap<Object, Object>();
        connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL",
        getCapabilities);

        DataStore data = DataStoreFinder.getDataStore(connectionParameters);

        String typeNames[] = data.getTypeNames();
        String typeName = typeNames[0];

        FeatureSource<SimpleFeatureType, SimpleFeature> source = data.getFeatureSource(typeName);

        FeatureCollection<SimpleFeatureType, SimpleFeature> features = source.getFeatures();

        assertEquals(3, features.size());


        I know in the first feature type there are 3 features, but the last assertion fails: the FeatureCollection is empty (size == 0). I double checked that the feature type queried is the right one (I removed some debug logging from the code above).

        I have to use this code in order to read the features:

        String geomName = schema.getGeometryDescriptor().getLocalName();
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2( GeoTools.getDefaultHints() );
        Object polygon = JTS.toGeometry( (com.vividsolutions.jts.geom.Envelope)source.getBounds() );
        Intersects filter = ff.intersects( ff.property( geomName ), ff.literal( polygon ) );
        Query query = new DefaultQuery( typeName, filter, new String[]{ geomName } );
        features = source.getFeatures( query );

        That is, a spatial filter with a bbox equals to the bounds envelope. Very very bad: I have to do a spatial query in order to read my feature?

        I just updated from geotools 2.4 and that test (source.getFeatures()) was working fine. It seems to me a very bad regression.

        Regards,

        Fabio
        Show
        Fabio Da Soghe added a comment - I encountered this problem with latest "stable" geotools, 2.5.1. This is my code: String getCapabilities = " http://myserver:8080/ws/dasoghe?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetCapabilities "; Map<Object, Object> connectionParameters = new HashMap<Object, Object>(); connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", getCapabilities); DataStore data = DataStoreFinder.getDataStore(connectionParameters); String typeNames[] = data.getTypeNames(); String typeName = typeNames[0]; FeatureSource<SimpleFeatureType, SimpleFeature> source = data.getFeatureSource(typeName); FeatureCollection<SimpleFeatureType, SimpleFeature> features = source.getFeatures(); assertEquals(3, features.size()); I know in the first feature type there are 3 features, but the last assertion fails: the FeatureCollection is empty (size == 0). I double checked that the feature type queried is the right one (I removed some debug logging from the code above). I have to use this code in order to read the features: String geomName = schema.getGeometryDescriptor().getLocalName(); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2( GeoTools.getDefaultHints() ); Object polygon = JTS.toGeometry( (com.vividsolutions.jts.geom.Envelope)source.getBounds() ); Intersects filter = ff.intersects( ff.property( geomName ), ff.literal( polygon ) ); Query query = new DefaultQuery( typeName, filter, new String[]{ geomName } ); features = source.getFeatures( query ); That is, a spatial filter with a bbox equals to the bounds envelope. Very very bad: I have to do a spatial query in order to read my feature? I just updated from geotools 2.4 and that test (source.getFeatures()) was working fine. It seems to me a very bad regression. Regards, Fabio
        Hide
        Fabio Da Soghe added a comment -
        I forgot: I get this exception:

        4-dic-2008 19.45.18 org.geotools.xml.XMLSAXHandler processException
        GRAVE: msQueryByRect(): Search returned no results. No matching record(s) found.
        msQueryByRect(): Search returned no results. No matching record(s) found. org.geotools.xml.filter.FilterComplexTypes$ServiceExceptionType.getValue(FilterComplexTypes.java:1669)
            org.geotools.xml.handlers.ComplexElementHandler.endElement(ComplexElementHandler.java:157)
            org.geotools.xml.XMLSAXHandler.endElement(XMLSAXHandler.java:266)
            com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
            com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
            com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
            com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
            com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
            com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
            com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
            com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
            javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
            javax.xml.parsers.SAXParser.parse(SAXParser.java:176)
            org.geotools.xml.DocumentFactory.getInstance(DocumentFactory.java:140)
            org.geotools.wfs.v_1_0_0.data.WFSFeatureReader.run(WFSFeatureReader.java:125)
        Show
        Fabio Da Soghe added a comment - I forgot: I get this exception: 4-dic-2008 19.45.18 org.geotools.xml.XMLSAXHandler processException GRAVE: msQueryByRect(): Search returned no results. No matching record(s) found. msQueryByRect(): Search returned no results. No matching record(s) found. org.geotools.xml.filter.FilterComplexTypes$ServiceExceptionType.getValue(FilterComplexTypes.java:1669)     org.geotools.xml.handlers.ComplexElementHandler.endElement(ComplexElementHandler.java:157)     org.geotools.xml.XMLSAXHandler.endElement(XMLSAXHandler.java:266)     com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)     com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)     com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)     com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)     com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)     com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)     com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)     com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)     javax.xml.parsers.SAXParser.parse(SAXParser.java:375)     javax.xml.parsers.SAXParser.parse(SAXParser.java:176)     org.geotools.xml.DocumentFactory.getInstance(DocumentFactory.java:140)     org.geotools.wfs.v_1_0_0.data.WFSFeatureReader.run(WFSFeatureReader.java:125)
        Hide
        Francis added a comment - - edited
        I have the same problem, but I use geotools 2.5.3. This is my pom.xml:

        <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-geometry</artifactId>
        <version>2.5-RC1</version>
        </dependency>
        <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-data</artifactId>
        <version>2.5.3</version>
        </dependency>
        <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-hsql</artifactId>
        <version>2.5.3</version>
        </dependency>
        <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-metadata</artifactId>
        <version>2.5.3</version>
        </dependency>
        <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-oracle-spatial</artifactId>
        <version>2.5-RC1</version>
        </dependency>

        I have a lot of code in this geotools version, and I don't want change it. In addition to this when I update to 2.4 it does not work!. Any idea about an alternative way code?
        Show
        Francis added a comment - - edited I have the same problem, but I use geotools 2.5.3. This is my pom.xml: <dependency> <groupId>org.geotools</groupId> <artifactId>gt-geometry</artifactId> <version>2.5-RC1</version> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-data</artifactId> <version>2.5.3</version> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-epsg-hsql</artifactId> <version>2.5.3</version> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-metadata</artifactId> <version>2.5.3</version> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-oracle-spatial</artifactId> <version>2.5-RC1</version> </dependency> I have a lot of code in this geotools version, and I don't want change it. In addition to this when I update to 2.4 it does not work!. Any idea about an alternative way code?
        Hide
        Andrea Aime added a comment -
        The WFS module has been unmaintained for a long time so far. If anyone has the skills and time to become a maintainer please just say so on the GeoTools developers mailing list.
        Show
        Andrea Aime added a comment - The WFS module has been unmaintained for a long time so far. If anyone has the skills and time to become a maintainer please just say so on the GeoTools developers mailing list.

          People

          • Assignee:
            Unassigned
            Reporter:
            Gustavo Giráldez
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: