2

I need to sort my output because I want to animate my output in Leaflet. I realize that I could sort the resulting GeoJSON in my JavaScript code but that is less efficient.

When I Googled it I got to the GeoServer 2.12.x documentation that suggested I use an addition to my query SortBy=&. So here is what my URL looks like:

http://localhost:8080/geoserver/wfs?service=WFS&version=2.11.2&request=GetFeature&typeNames=hurricane:hurricane_point&PROPERTYNAME=(point,strength,category)&CQL_FILTER=storm_id=%27al122017%27%20and%20is_prediction=false&sortBy=(occur_date)&outputFormat=JSON

So that didn't work, no error so I assume that GeoServer ignored the SortBy.

Any ideas?

EDIT: OK, I'm an idiot! It was working all along, I just didn't recognize it. I was judging whether it sorted correctly by the display order of the markers in Leaflet. As user30184 pointed out, without including the SortBy field(s) in the output it's hard to ascertain if the sort worked correctly. I did some experimentation with adding +Desc to the sort field to get it to sort backwards and did some key comparisons and see that all's well. Adding credit because user30184 helped with correct syntax, plus I learned a bit from the answer.

5

First thing, the version in the query means to version of the WFS standard, not the version of GeoServer as I suppose that you mean with your "2.11.2"

Here are some examples of syntax that seems to work. Firs examples are sorting by a selected feature so it is possible to check if the result is right.

http://demo.geo-solutions.it/geoserver/wfs?service=wfs&version=1.1.0&request=getfeature&typename=topp:states&propertyname=STATE_NAME&SORTBY=STATE_NAME%20ASC&CQL_FILTER=STATE_NAME%20LIKE%20%27I%25%27

http://demo.geo-solutions.it/geoserver/wfs?service=wfs&version=1.1.0&request=getfeature&typename=topp:states&propertyname=STATE_NAME&SORTBY=STATE_NAME%20DESC&CQL_FILTER=STATE_NAME%20LIKE%20%27I%25%27

These examples use attribute "PERSONS" for "sortby" which makes it hard to say if the result is right or not because "PERSONS" is not selected into output but that is similar case than the one you use in your question.

http://demo.geo-solutions.it/geoserver/wfs?service=wfs&version=1.1.0&request=getfeature&typename=topp:states&propertyname=STATE_NAME&SORTBY=PERSONS%20ASC&CQL_FILTER=STATE_NAME%20LIKE%20%27I%25%27

http://demo.geo-solutions.it/geoserver/wfs?service=wfs&version=1.1.0&request=getfeature&typename=topp:states&propertyname=STATE_NAME&SORTBY=PERSONS%20DESC&CQL_FILTER=STATE_NAME%20LIKE%20%27I%25%27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.