Home > geotools > GeoTools WFS Query sortBy not working for GeoServer WFS

GeoTools WFS Query sortBy not working for GeoServer WFS

February 17Hits:11
Advertisement

I am using GeoTools to query a GeoServer WFS using the following code:

    Map connectionParameters = new HashMap();     connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", String.format("%s&request=GetCapabilities", wfsUrl));     connectionParameters.put("WFSDataStoreFactory:TIMEOUT", connectionTimeout*1000);     DataStore data = DataStoreFinder.getDataStore(connectionParameters);     SimpleFeatureType schema = data.getSchema("airports");     FeatureSource<SimpleFeatureType, SimpleFeature> source = data.getFeatureSource( typeName );     String geomName = schema.getGeometryDescriptor().getLocalName();     Envelope bbox = new Envelope( -100.0, -70, 25, 40 );      FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());     Object polygon = JTS.toGeometry(bbox);     Intersects filter = ff.intersects( ff.property( geomName ), ff.literal( polygon ) );      Query query = new DefaultQuery( typeName, filter, new String[]{ geomName } );     query.setSortBy(new SortBy[]{ff.sort("country", SortOrder.ASCENDING)});     FeatureCollection<SimpleFeatureType, SimpleFeature> features = source.getFeatures( query ); 

The query returns features, but sorting never works. A toString() on the query returns something like:

feature type: airports filter: [[ geom intersects POLYGON ((-117.8395870053188 31.58066038426718, -115.5957867039628 31.58066038426718, -115.5957867039628 33.27328332002949, -117.8395870053188 33.27328332002949, -117.8395870053188 31.58066038426718)) ]] [properties: ALL ] [sort by: country ASCENDING]

which indicates that sorting is part of the query.

The following direct WFS query works:

http://thing:8080/geoserver/ix/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=airports&srsName=epsg:4326&bbox=-117.8395870053188,31.58066038426718,-115.5957867039628,33.27328332002949&sortBy=country 

Any suggestions?

Answers

I figured out the problem. If you use WFS version 1.0.0 sortBy does not work. Using version 1.1.0 works.

Tags:geotools

Related Articles

  • GeoTools WFS Query sortBy not working for GeoServer WFSFebruary 17

    I am using GeoTools to query a GeoServer WFS using the following code: Map connectionParameters = new HashMap(); connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", String.format("%s&request=GetCapabilities", wfsUr

  • How to add GeoServer wfs layer on OpenLayers?

    How to add GeoServer wfs layer on OpenLayers?March 4

    I can't seem to add a WFS layer like this. It works when i copy all this code locally but as soon as i change the values to point to my own layer within my own GeoServer this is the response viewed in firebug: Could not locate {http://www.mydomain.co

  • Accessing GeoServer WFS services in ArcGIS Online map viewer?September 9

    Has anyone was able to add GeoServer WFS service into ArcGIS Online map viewer? By this I mean having an ArcGIS Online account (either free or for Organizations), logging in and adding layers from the web. I have no problems adding a WMS service such

  • How to query multiple features from Geoserver WFS?September 22

    Are there any methods to query several features by id other than one entry by a single url request? The scenario is I store around 200 point layers in PostgreGIS. Each maintains 100k entries GPS points. My boss wants to let them "move" in the br

  • Receiving -infinity in geoserver wfs GetFeature resultOctober 16

    I'm currently using: - Geoserver 2.7.2 - PostgreSQL 9.4.4 - PostGIS 2.1.9 When I submit the following wfs GetFeature request: http://localhost:8080/geoserver/wfs?service=wfs&version=2.0.0&request=GetFeature&typeNames=gis:roads&propertyName

  • WFS Query Failing when using Logical ORJanuary 5

    I'm having some difficulty when using a Logical OR in a WFS query to get multiple postcodes. This code works fine when it's only 1 PropertyIsEqualTo filter, but when I wrap the OR around more than one PropertyIsEqualTo filter I get an exception. POST

  • Allow GeoServer WFS request by featureIDApril 6

    I'm not able to use the featureID parameter in a WFS URL request for my dataset on GeoServer. Example: http://demo.opengeo.org/geoserver/wfs?version=1.1.0&service=wfs&request=GetFeature&typeName=topp:tasmania_roads&maxFeatures=10&featu

  • Only return the NumberOfFeatures in a WFS queryJanuary 3

    I'm running a GetFeature WFS query in Geoserver (looking for features within a polygon) but all I actually want is the total number of features. Is there a way of just returning this info (in the hope that the query will run a little faster) rather t

  • Add features to vector layer from WFS queryOctober 8

    I am trying to add the resulting WFS features (xml format) to my selected items vector layer but can't get it to work. I am querying my WFS layer with the following: showFeatureLink.on('click', function() { OpenLayers.Request.GET({ url: 'http://1.2.3

  • Geoserver WFS POST and format_options=PRJFILEFORMATMay 9

    I'm using geoserver (2.4.4) to provide users with shapefile downloads. Some of the software the shapefiles are going to be used in requires .prj-files that follows the "ESRI-standard". A bit of searching lead me to a Geoserver ticket (GEOS-4503)

  • QGIS does not update data in Geoserver WFS-TNovember 14

    I am trying to edit a WFS from geoserver (using PostGIS data) within QGIS. This is the request as recorded by Fiddler <Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version=&quo

  • Geoserver WFS 2.0 CSV Output Multiple Features/typeNamesJanuary 27

    I'm setting up an export function so that users may download data from a Geoserver WFS 2.0 service in a variety of the supported formats. The service has multiple FeatureTypes which should be available for export in a single query (along with BBOX an

  • WFS query against SQL Server - Returned results not restricted by queryOctober 6

    I have an SQL Server 2012 table, which contains a DbGeometry column with a spatial index. Then a Geoserver 2.7 using it. The problem is that when I do a WFS query it doesn't restrict the results to the coordinates I pass in by BBOX, it always returns

  • Geoserver WFS-T "Feature type 'Workspace:Layer' is not available" Error on update / deleteDecember 1

    I am using the following code for insert / update (changed from this source: http://wordpress-dbauszus.rhcloud.com/?p=71): var formatWFS = new ol.format.WFS(); // GML Format zur Interaktion mit WFS var formatGML = new ol.format.GML({ featureNS: 'http

  • Drupal-Geoserver WFS error September 24

    I am having trouble getting a WFS layer working using Geoserver, OpenLayers and GeoExt. I get the following error: XMLHttpRequest cannot load http://10.0.0.155/geoserver/wfs. Origin http://10.0.0.155:8080 is not allowed by Access-Control-Allow-Origin

  • geoserver wfs insert errorApril 27

    I keep getting an insert error from geoserver when trying to save a point, poly etc etc to my postgis table. any ideas, my code is below var Projection = new OpenLayers.Projection("EPSG:4326"); var map = new OpenLayers.Map("Map", { //p

  • Releasing GeoServer WFS-T Feature LockMay 24

    For some reason I'm having trouble finding any documentation about releasing feature locks in a GeoServer WFS (or any WFS for that matter). I can easily request a FeatureLock with a request like this http://localhost:8080/geoserver/wfs?service=WFS&ve

  • GeoServer WFS OpenLayers EditingPanel ProblemJune 13

    I'm trying to use OpenLayers to edit features of vector data served from a local geoserver. So far, I'm able to pull WMS and WFS layers using OpenLayers from the same geoserver. But now, I'd like enable editing of features of the vector layers. The r

  • WFS layer seems not work with Geoserver 2.2 RC1 and openlayers - updatedJuly 18

    I have a Openlayers+Geoserver application. Now I'm trying to move the application on a new server with the new GEOSERVER 2.2 RC1. With the Geoserver ver. 2.1.0 i was able to show the WFS-T layer, while now, there is something different and with GeoSe

  • Cant see WFS-T layer with OpenLayers and GeoServer (Windows)

    Cant see WFS-T layer with OpenLayers and GeoServer (Windows)October 1

    I am trying to implement a simple test of a OpenLayers + WFS-T + GeoServer -setup. I have followed the instructions by populating PostGIS and configuring GeoServer, and can see the WFS-T layer data in GeoServer's preview fine. I am following these st

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 1.148 s.