Search in sources :

Example 1 with SortedSimpleFeatureCollection

use of org.geotools.feature.collection.SortedSimpleFeatureCollection in project coastal-hazards by USGS-CIDA.

the class RibboningProcess method sortFeatures.

// if there's an attribute to sort by, sort by it
public SimpleFeatureCollection sortFeatures(String sortAttribute, SimpleFeatureCollection features) {
    SimpleFeatureCollection result = features;
    AttributeDescriptor sortAttr = features.getSchema().getDescriptor(sortAttribute);
    if (null != sortAttr) {
        SortBy sort = new SortByImpl(new AttributeExpressionImpl(sortAttr.getName()), SortOrder.ASCENDING);
        result = new SortedSimpleFeatureCollection(features, new SortBy[] { sort });
    } else {
        LOGGER.log(Level.WARNING, "Could not find sort attribute {0}", sortAttribute);
    }
    return result;
}
Also used : SortedSimpleFeatureCollection(org.geotools.feature.collection.SortedSimpleFeatureCollection) SortByImpl(org.geotools.filter.SortByImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) SortBy(org.opengis.filter.sort.SortBy) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) SortedSimpleFeatureCollection(org.geotools.feature.collection.SortedSimpleFeatureCollection) SimpleFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection)

Aggregations

SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)1 SortedSimpleFeatureCollection (org.geotools.feature.collection.SortedSimpleFeatureCollection)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 SortByImpl (org.geotools.filter.SortByImpl)1 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)1 SortBy (org.opengis.filter.sort.SortBy)1