GeoTools

sort() method does not work on JDBCFeatureCollection

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 2.4-M4
  • Fix Version/s: 2.7-M0
  • Component/s: data, main
  • Labels:
    None

Description

If I try to sort a FeatureCollection, I get a null FeatureList. So I do:

final FeatureCollection fc = source.getFeatures(filter);

and this returns my feature collection (an instance of JDBCFeatureCollection to be precise). Good. But:

final SortBy rt = ff.sort(sortField, SortOrder.DESCENDING);
final FeatureList fl = fc.sort(sort);

this returns a null FeatureList (ff is the FilterFactory). Hmmm. To figure out why, I looked into these three classes (gt2-2.4-M4):

library/jdbc/src/main/java/org/geotools/data/jdbc/JDBCFeatureCollection.java
unsupported/h2/src/main/java/org/geotools/data/jdbc/collection/JDBCFeatureCollection.java
library/main/src/main/java/org/geotools/feature/DefaultFeatureCollection.java

Apparently, sorting is not properly implemented (yet).

As a work-around, sorting via the Query interface works:

final DefaultQuery query = new DefaultQuery( typeName, filter);
final SortBy rt = ff.sort(sortField, SortOrder.DESCENDING);
query.setSortBy(new SortBy[] { sort });
final FeatureCollection fc = source.getFeatures(query);

Activity

Hide
Andrea Aime added a comment -
Jody, this seems to be yours :)
Show
Andrea Aime added a comment - Jody, this seems to be yours :)
Hide
Jody Garnett added a comment -
FeatureCollection.sort was removed from the grand plan; the only option is to set up a Query; and hope the DataStore you are using supports it.
Show
Jody Garnett added a comment - FeatureCollection.sort was removed from the grand plan; the only option is to set up a Query; and hope the DataStore you are using supports it.
Hide
Jody Garnett added a comment -
Bleck; api was not deprecated in 2.4.x, so this is still open (just as a QA problem).
Show
Jody Garnett added a comment - Bleck; api was not deprecated in 2.4.x, so this is still open (just as a QA problem).
Hide
Jody Garnett added a comment -
changing this to 2.6.x ...this problem will not be fixed in the 2.4.x development stream.
Show
Jody Garnett added a comment - changing this to 2.6.x ...this problem will not be fixed in the 2.4.x development stream.
Hide
Jody Garnett added a comment -
This is fixed in the jdbcng implementation.
Show
Jody Garnett added a comment - This is fixed in the jdbcng implementation.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: