Skip to content

Commit

Permalink
[GEOT-3977] Have shapefile declare support for natural order sorting
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/geotools/branches/2.7.x@38416 e5c1c795-43da-0310-a71f-fac65c449510
  • Loading branch information
aaime committed Dec 13, 2011
1 parent dfd100c commit b7f1145
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
Expand Up @@ -37,6 +37,7 @@ public ShapefileFeatureLocking( ShapefileDataStore shapefileDataStore, Set hints
super(hints);
shapefile = shapefileDataStore;
this.featureType = featureType;
this.queryCapabilities = new ShapefileQueryCapabilities();
}
public DataStore getDataStore() {
return shapefile;
Expand Down
Expand Up @@ -23,9 +23,11 @@
import org.geotools.data.DataStore;
import org.geotools.data.FeatureListener;
import org.geotools.data.Query;
import org.geotools.data.QueryCapabilities;
import org.geotools.data.ResourceInfo;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.filter.sort.SortBy;

/**
* Allows transaction control when editing a shapefile.
Expand All @@ -40,6 +42,7 @@ class ShapefileFeatureSource extends AbstractFeatureSource {
super(hints);
shapefile = shapefileDataStore;
this.featureType = featureType;
this.queryCapabilities = new ShapefileQueryCapabilities();
}
public DataStore getDataStore() {
return shapefile;
Expand Down
Expand Up @@ -42,6 +42,7 @@ public ShapefileFeatureStore( ShapefileDataStore shapefileDataStore, Set hints,
super(hints);
shapefile = shapefileDataStore;
this.featureType = featureType;
this.queryCapabilities = new ShapefileQueryCapabilities();
}
public DataStore getDataStore() {
return shapefile;
Expand Down
@@ -0,0 +1,39 @@
/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2008, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotools.data.shapefile;

import org.geotools.data.QueryCapabilities;
import org.opengis.filter.sort.SortBy;

/**
* The usual capabilities, plug a twist: we always return features sorted according to the
* feature id
*
* @author Andrea Aime - GeoSolutions
*/
class ShapefileQueryCapabilities extends QueryCapabilities {

@Override
public boolean supportsSorting(SortBy[] sortAttributes) {
// we always return features in the pk increasing order
if(sortAttributes != null && sortAttributes.length == 1 && sortAttributes[0] == SortBy.NATURAL_ORDER) {
return true;
} else {
return super.supportsSorting(sortAttributes);
}
}
}

0 comments on commit b7f1145

Please sign in to comment.