Discussion:
[Geoserver-users] How can I to sort one property like "order by" via WFS?
Kevin Yang
2009-08-17 09:05:20 UTC
Permalink
Hello dear sir,
In SQL,the "order by" is one of the most common command. So in WFS, it is not an exception. How can I to sort one property like "order by" via WFS? Thank you very much!
Best regards,
Yang
Andrea Aime
2009-08-17 09:27:23 UTC
Permalink
Post by Kevin Yang
Hello dear sir,
In SQL,the "order by" is one of the most common command. So in WFS,
it is not an exception. How can I to sort one property like "order by"
via WFS? Thank you very much!
WFS 1.0 does not allow for result sorting.
WFS 1.1 has it, but support is optional.

GeoServer in practice supports sorting on both protocols (in WFS 1.0 as
an extension, and only for GET requests), provided the underlying
storage has native sorting capabilities (databases do, shapefiles don't).
Add &sortBy=property1 A,property2 D to sort on property1 ascending,
propert2 descending.

Hope this helps
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
connil
2009-10-01 14:04:33 UTC
Permalink
How about ArcSDE as underlying storage?

I am trying to sort a WFS getFeature request but the response is not sorted.
I am using GeoServer 1.7.5.

Below are the log entries for the request. Sorry for the long text, I don't
want to miss anything important.

A bit down you can see that ArcSDE query have OrderBy=null.

2009-10-01 15:50:09,306 DEBUG [geoserver.ows] - Raw XML request starts with:
<wfs:GetFeature service="WFS" version="1.1.0" maxFeatures="10"
xmlns:topp="http://www.openplans.org/topp"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<wfs:Query typeName="KOMMUNER">
<ogc:SortBy>
<ogc:SortProperty>
<ogc:PropertyName>KOD</ogc:PropertyName>
<ogc:SortOrder>ASC</ogc:SortOrder>
</ogc:SortProperty>
</ogc:SortBy>
</wfs:Query>
</wfs:GetFeature>
2009-10-01 15:50:09,306 INFO [geoserver.wfs] -
Request: getServiceInfo
2009-10-01 15:50:09,540 DEBUG [geotools.xml] - schemaLocation found:
http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd
2009-10-01 15:50:09,540 DEBUG [geotools.xml] - Found override for
http://www.opengis.net/wfs: http://schemas.opengis.net/wfs/1.1.0/wfs.xsd ==>
jar:file:/D:/.../lib/wfs-1.7.5.jar!/org/geoserver/wfs/xml/v1_1_0/wfs.xsd
2009-10-01 15:50:09,587 DEBUG [geoserver.requests] - Query is
***@13d9906 (group: [], propertyName: [],
function: null, filter: null, sortBy:
[***@1097438], featureVersion: null, handle:
null, srsName: null, typeName: [{http://www.opengis.net/wfs}KOMMUNER])
To gt2: Query:
feature type: KOMMUNER
filter: Filter.INCLUDE
[properties: ALL ]
[sort by: KOD ASCENDING]
2009-10-01 15:50:09,587 TRACE [arcsde.pool] - activating connection
Session[4]
2009-10-01 15:50:09,587 DEBUG [arcsde.pool] - -->Session[4] out of
connection pool. Active: 1, idle: 1
2009-10-01 15:50:09,587 DEBUG [data.ArcSDEQuery] - Creating new ArcSDEQuery
2009-10-01 15:50:09,587 DEBUG [data.ArcSDEQuery] - SQL portion of SDE Query:
'Filter.INCLUDE'
2009-10-01 15:50:09,587 DEBUG [data.ArcSDEQuery] - Spatial-Filter portion of
SDE Query: 'Filter.INCLUDE'
2009-10-01 15:50:09,587 DEBUG [data.ArcSDEQuery] - Unsupported (and
therefore ignored) portion of SDE Query: 'Filter.INCLUDE'
2009-10-01 15:50:09,587 TRACE [arcsde.pool] - passivating connection
Session[4]
2009-10-01 15:50:09,587 DEBUG [arcsde.pool] - <-- Session[4] retured to
pool. Active: 0, idle: 2
2009-10-01 15:50:09,587 INFO [geoserver.wfs] -
Request: getFeature
handle = null
service = WFS
version = 1.1.0
baseUrl = http://utv.metainfo.se:80/geoserver2/
providedVersion = 1.1.0
query = [***@13d9906 (group: null,
propertyName: null, function: null, filter: null, sortBy:
[***@1097438], featureVersion: null, handle:
null, srsName: null, typeName: [{http://www.opengis.net/wfs}KOMMUNER])]
maxFeatures = 10
outputFormat = text/xml; subtype=gml/3.1.1
resultType = results
traverseXlinkDepth = null
traverseXlinkExpiry = null
formatOptions = {}
2009-10-01 15:50:09,790 DEBUG [geotools.xml] - [ class
org.geoserver.security.decorators.ReadOnlyFeatureCollection ] is not of type
class [Lorg.opengis.feature.simple.SimpleFeature;
2009-10-01 15:50:09,790 WARN [geotools.xml] -
***@1f75468
(org.geoserver.security.decorators.ReadOnlyFeatureCollection) is not of
type [Lorg.opengis.feature.simple.SimpleFeature;
2009-10-01 15:50:09,790 DEBUG [geotools.xml] - Could not convert
***@1f75468 to
[Lorg.opengis.feature.simple.SimpleFeature;
2009-10-01 15:50:09,790 TRACE [arcsde.pool] - activating connection
Session[3]
2009-10-01 15:50:10,149 DEBUG [arcsde.pool] - -->Session[3] out of
connection pool. Active: 1, idle: 1
2009-10-01 15:50:10,149 DEBUG [data.ArcSDEQuery] - Creating new ArcSDEQuery
2009-10-01 15:50:10,149 DEBUG [data.ArcSDEQuery] - SQL portion of SDE Query:
'Filter.INCLUDE'
2009-10-01 15:50:10,149 DEBUG [data.ArcSDEQuery] - Spatial-Filter portion of
SDE Query: 'Filter.INCLUDE'
2009-10-01 15:50:10,149 DEBUG [data.ArcSDEQuery] - Unsupported (and
therefore ignored) portion of SDE Query: 'Filter.INCLUDE'
2009-10-01 15:50:10,149 DEBUG [data.ArcSDEQuery] - ArcSDE query is:
SeQueryInfo[
columns=MDBK_ADM.KOMMUNER_SORT.KOMMUNNAMN, MDBK_ADM.KOMMUNER_SORT.LANSNAMN,
MDBK_ADM.KOMMUNER_SORT.KOMMUNKOD, MDBK_ADM.KOMMUNER_SORT.LANSKOD,
MDBK_ADM.KOMMUNER_SORT.NAMN, MDBK_ADM.KOMMUNER_SORT.KOD,
MDBK_ADM.KOMMUNER_SORT.XMIN, MDBK_ADM.KOMMUNER_SORT.YMIN,
MDBK_ADM.KOMMUNER_SORT.XMAX, MDBK_ADM.KOMMUNER_SORT.YMAX,
MDBK_ADM.KOMMUNER_SORT.XIN, MDBK_ADM.KOMMUNER_SORT.YIN,
MDBK_ADM.KOMMUNER_SORT.SHAPE, MDBK_ADM.KOMMUNER_SORT.OBJECTID
Tables=MDBK_ADM.KOMMUNER_SORT
Where=null
OrderBy=null]
2009-10-01 15:50:10,165 DEBUG [data.ArcSDEQuery] - SQL portion of SDE Query:
'Filter.INCLUDE'
2009-10-01 15:50:10,165 DEBUG [data.ArcSDEQuery] - Spatial-Filter portion of
SDE Query: 'Filter.INCLUDE'
2009-10-01 15:50:10,165 DEBUG [data.ArcSDEQuery] - Unsupported (and
therefore ignored) portion of SDE Query: 'Filter.INCLUDE'
2009-10-01 15:50:10,165 DEBUG [arcsde.data] - Supported filters:
Filter.INCLUDE --- Filter.INCLUDE
2009-10-01 15:50:10,165 DEBUG [arcsde.data] - Unsupported filter:
Filter.INCLUDE
Post by Andrea Aime
Post by Kevin Yang
Hello dear sir,
In SQL,the "order by" is one of the most common command. So in WFS,
it is not an exception. How can I to sort one property like "order by"
via WFS? Thank you very much!
WFS 1.0 does not allow for result sorting.
WFS 1.1 has it, but support is optional.
GeoServer in practice supports sorting on both protocols (in WFS 1.0 as
an extension, and only for GET requests), provided the underlying
storage has native sorting capabilities (databases do, shapefiles don't).
Add &sortBy=property1 A,property2 D to sort on property1 ascending,
propert2 descending.
Hope this helps
Cheers
Andrea
--
View this message in context: http://www.nabble.com/How-can-I-to-sort-one-property-like-%22order-by%22-via-WFS--tp25003466p25696895.html
Sent from the GeoServer - User mailing list archive at Nabble.com.
Andrea Aime
2009-10-02 10:33:50 UTC
Permalink
Post by connil
How about ArcSDE as underlying storage?
I am trying to sort a WFS getFeature request but the response is not sorted.
I am using GeoServer 1.7.5.
Below are the log entries for the request. Sorry for the long text, I don't
want to miss anything important.
A bit down you can see that ArcSDE query have OrderBy=null.
I see... curious, the current code in the SDE code claims to support
sorting over properties, but I've never used SDE so far so I don't know
if it actually works on not. CC'ed Gabriel, the store maintainer.

Maybe this capability is available only in the latest GeoServer builds,
1.7.5 is months old

Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Gabriel Roldan
2009-10-02 13:17:13 UTC
Permalink
Hi Connil,

I'm pretty sure I fixed this for arcsde on 1.7.6, problem was the
datastore had a bug reporting always sort by was not supported while it was.

If you're on 1.7.5 you may want to try a newer geoserver version.

If problem persists do not hesitate in contacting us again and I'll take
a look at it asap.

Best regards,
Gabriel
Post by Andrea Aime
Post by connil
How about ArcSDE as underlying storage?
I am trying to sort a WFS getFeature request but the response is not sorted.
I am using GeoServer 1.7.5.
Below are the log entries for the request. Sorry for the long text, I don't
want to miss anything important.
A bit down you can see that ArcSDE query have OrderBy=null.
I see... curious, the current code in the SDE code claims to support
sorting over properties, but I've never used SDE so far so I don't know
if it actually works on not. CC'ed Gabriel, the store maintainer.
Maybe this capability is available only in the latest GeoServer builds,
1.7.5 is months old
Cheers
Andrea
--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Loading...