|
From: <svn...@os...> - 2011-12-13 09:40:08
|
Author: aaime
Date: 2011-12-13 01:39:58 -0800 (Tue, 13 Dec 2011)
New Revision: 38416
Added:
branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileQueryCapabilities.java
Modified:
branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureLocking.java
branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureSource.java
branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureStore.java
Log:
[GEOT-3977] Have shapefile declare support for natural order sorting
Modified: branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureLocking.java
===================================================================
--- branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureLocking.java 2011-12-13 09:39:43 UTC (rev 38415)
+++ branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureLocking.java 2011-12-13 09:39:58 UTC (rev 38416)
@@ -37,6 +37,7 @@
super(hints);
shapefile = shapefileDataStore;
this.featureType = featureType;
+ this.queryCapabilities = new ShapefileQueryCapabilities();
}
public DataStore getDataStore() {
return shapefile;
Modified: branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureSource.java
===================================================================
--- branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureSource.java 2011-12-13 09:39:43 UTC (rev 38415)
+++ branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureSource.java 2011-12-13 09:39:58 UTC (rev 38416)
@@ -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.
@@ -40,6 +42,7 @@
super(hints);
shapefile = shapefileDataStore;
this.featureType = featureType;
+ this.queryCapabilities = new ShapefileQueryCapabilities();
}
public DataStore getDataStore() {
return shapefile;
Modified: branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureStore.java
===================================================================
--- branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureStore.java 2011-12-13 09:39:43 UTC (rev 38415)
+++ branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureStore.java 2011-12-13 09:39:58 UTC (rev 38416)
@@ -42,6 +42,7 @@
super(hints);
shapefile = shapefileDataStore;
this.featureType = featureType;
+ this.queryCapabilities = new ShapefileQueryCapabilities();
}
public DataStore getDataStore() {
return shapefile;
Added: branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileQueryCapabilities.java
===================================================================
--- branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileQueryCapabilities.java (rev 0)
+++ branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileQueryCapabilities.java 2011-12-13 09:39:58 UTC (rev 38416)
@@ -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);
+ }
+ }
+}
|