[Geoserver-devel] JSON output - total number of features for paging

Hello GeoServer-Developers,

thanks for GeoServer, it’s a great product!

I needed the possibility to display GeoServer-WFS data in an Ext-JS grid, which uses paging. In order to fulfill this requirement, the GeoServer output had to show the total number of features in a layer, because the client needs to know how many pages there are (see geoserver_wfs_json_output_total_features.png).

I’ve extended the JSONoutputformat to return the total number of features, when doing a wfs-request.

Example:

Request: http://localhost/geoserver/wfs?service=wfs&REQUEST=GetFeature&version=1.1.0&outputformat=json&TYPENAME=v_tunnel_oss_daten&maxFeatures=20&sortBy=streckennummer%20A&startIndex=20

Response:

See geoserver_wfs_json_output_total_features_response.png

Do you think that we should implement this extension into the main trunk? Because I think that it’s a small enhancement with a big benefit.

Best regards

Paul

(attachments)

geoserver_wfs_json_output_total_features.png
geoserver_wfs_json_output_total_features_response.png

On Tue, Feb 19, 2013 at 10:32 AM, Biskup, Paul <Paul.Biskup@anonymised.com.> wrote:

Hello GeoServer-Developers,

thanks for GeoServer, it’s a great product!

I needed the possibility to display GeoServer-WFS data in an Ext-JS grid, which uses paging. In order to fulfill this requirement, the GeoServer output had to show the total number of features in a layer, because the client needs to know how many pages there are (see geoserver_wfs_json_output_total_features.png).

I’ve extended the JSONoutputformat to return the total number of features, when doing a wfs-request.

Example:

Request: http://localhost/geoserver/wfs?service=wfs&REQUEST=GetFeature&version=1.1.0&outputformat=json&TYPENAME=v_tunnel_oss_daten&maxFeatures=20&sortBy=streckennummer%20A&startIndex=20

Response:

See geoserver_wfs_json_output_total_features_response.png

Do you think that we should implement this extension into the main trunk? Because I think that it’s a small enhancement with a big benefit.

Yep, seems something useful and would put geojson on par with the GML output in this respect.
I’m wondering, does the GeoJSON format has a concept of a feature count, or would it be some GeoServer specific extension?

The other thing that we’d need along the patch is a test (or a modification of some existing tests) checking the
feature count works as expected (both today, and in the future as other people modify the code).

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Tue, Feb 19, 2013 at 2:52 AM, Andrea Aime
<andrea.aime@anonymised.com>wrote:

On Tue, Feb 19, 2013 at 10:32 AM, Biskup, Paul <
Paul.Biskup@anonymised.com> wrote:

Hello GeoServer-Developers,****

** **

thanks for GeoServer, it’s a great product!****

** **

I needed the possibility to display GeoServer-WFS data in an Ext-JS grid,
which uses paging. In order to fulfill this requirement, the GeoServer
output had to show the total number of features in a layer, because the
client needs to know how many pages there are (see
geoserver_wfs_json_output_total_features.png).****

** **

I’ve extended the JSONoutputformat to return the total number of
features, when doing a wfs-request. ****

** **

Example:****

** **

Request:
http://localhost/geoserver/wfs?service=wfs&REQUEST=GetFeature&version=1.1.0&outputformat=json&TYPENAME=v_tunnel_oss_daten&maxFeatures=20&sortBy=streckennummer%20A&startIndex=20
****

** **

Response: ****

See geoserver_wfs_json_output_total_features_response.png****

** **

Do you think that we should implement this extension into the main trunk?
Because I think that it’s a small enhancement with a big benefit.****

**

Yep, seems something useful and would put geojson on par with the GML
output in this respect.
I'm wondering, does the GeoJSON format has a concept of a feature count,
or would it be some GeoServer specific extension?

As I understand it there is no such notion but at the same time there is
nothing that prevents us from adding extra attributes to a feature
collection. Oh the joy of schemaless data structures :slight_smile:

The other thing that we'd need along the patch is a test (or a
modification of some existing tests) checking the
feature count works as expected (both today, and in the future as other
people modify the code).

Cheers
Andrea

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

I'd +1 this. I also use ExtJs paging grid but havent been able to paging
for WFS. Works great with SOLR.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

Yup, works for me. I tried to see if anybody else already tried to add a feature count attribute (just to avoid
reinventing the wheel) in the output but found none. I guess any pick is good :slight_smile:

Cheers
Andrea

···

I’m wondering, does the GeoJSON format has a concept of a feature count, or would it be some GeoServer specific extension?

As I understand it there is no such notion but at the same time there is nothing that prevents us from adding extra attributes to a feature collection. Oh the joy of schemaless data structures :slight_smile:

I’m glad to hear, that you want to integrate this extra attribute in JSON-output!

Since I have no experience in the contribution of source code, maybe I’ll just send you my patched „GeoJSONOutputFormat.java“-file.

I’ve added the function „getNumberOfFeaturesFromRequest“, which gets called before the JSON-object gets written.

This function also respects filters. So if a filter gets passed, only the count of the filtered features gets returned.

The positions I have edited are marked with PBI-comment.

I hope that this is sufficient.

This patch was written for GeoServer 2.1.4.

Best regards

Paul

Von: andrea.aime@anonymised.com [mailto:andrea.aime@anonymised.com] Im Auftrag von Andrea Aime
Gesendet: Mittwoch, 20. Februar 2013 09:27
An: Justin Deoliveira
Cc: Biskup, Paul; geoserver-devel@lists.sourceforge.net
Betreff: Re: [Geoserver-devel] JSON output - total number of features for paging

On Tue, Feb 19, 2013 at 3:19 PM, Justin Deoliveira <jdeolive@anonymised.com.> wrote:

Yep, seems something useful and would put geojson on par with the GML output in this respect.

I’m wondering, does the GeoJSON format has a concept of a feature count, or would it be some GeoServer specific extension?

As I understand it there is no such notion but at the same time there is nothing that prevents us from adding extra attributes to a feature collection. Oh the joy of schemaless data structures :slight_smile:

Yup, works for me. I tried to see if anybody else already tried to add a feature count attribute (just to avoid

reinventing the wheel) in the output but found none. I guess any pick is good :slight_smile:

Cheers

Andrea

==

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

==

Ing. Andrea Aime

@geowolf

Technical Lead

GeoSolutions S.A.S.

Via Poggio alle Viti 1187

55054 Massarosa (LU)

Italy

phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

http://www.geo-solutions.it

http://twitter.com/geosolutions_it


(attachments)

GeoJSONOutputFormat.java (14.2 KB)

On Wed, Feb 20, 2013 at 9:50 AM, Biskup, Paul <Paul.Biskup@anonymised.com> wrote:

I’m glad to hear, that you want to integrate this extra attribute in JSON-output!

Since I have no experience in the contribution of source code, maybe I’ll just send you my patched „GeoJSONOutputFormat.java“-file.

I’ve added the function „getNumberOfFeaturesFromRequest“, which gets called before the JSON-object gets written.

This function also respects filters. So if a filter gets passed, only the count of the filtered features gets returned.

The positions I have edited are marked with PBI-comment.

I hope that this is sufficient.

Generally speaking we don’t accept changes unless they are accompained by a test.
The bare minimum is a patch (not the full files) against the current GeoServer master that contains both the change to the code, and the test
showing it works.

If that’s too hard you can open an improvement request on jira.codehaus.org, attach the file above, and wait
for a good soul that completes the minimum requirements for you.

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Thanks for the information about the official way for contributing.

I’ll try to submit my patch regarding the minimum requirements.

Regards

Paul

Von: andrea.aime@anonymised.com403… [mailto:andrea.aime@anonymised.com] Im Auftrag von Andrea Aime
Gesendet: Mittwoch, 20. Februar 2013 12:59
An: Biskup, Paul
Cc: Justin Deoliveira; geoserver-devel@lists.sourceforge.net
Betreff: Re: [Geoserver-devel] JSON output - total number of features for paging

On Wed, Feb 20, 2013 at 9:50 AM, Biskup, Paul <Paul.Biskup@anonymised.com> wrote:

I’m glad to hear, that you want to integrate this extra attribute in JSON-output!

Since I have no experience in the contribution of source code, maybe I’ll just send you my patched „GeoJSONOutputFormat.java“-file.

I’ve added the function „getNumberOfFeaturesFromRequest“, which gets called before the JSON-object gets written.

This function also respects filters. So if a filter gets passed, only the count of the filtered features gets returned.

The positions I have edited are marked with PBI-comment.

I hope that this is sufficient.

Generally speaking we don’t accept changes unless they are accompained by a test.

The bare minimum is a patch (not the full files) against the current GeoServer master that contains both the change to the code, and the test

showing it works.

If that’s too hard you can open an improvement request on jira.codehaus.org, attach the file above, and wait

for a good soul that completes the minimum requirements for you.

Cheers

Andrea

==

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

==

Ing. Andrea Aime

@geowolf

Technical Lead

GeoSolutions S.A.S.

Via Poggio alle Viti 1187

55054 Massarosa (LU)

Italy

phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

http://www.geo-solutions.it

http://twitter.com/geosolutions_it


Hi there,

I have just created a patch following the tutorial on how to submit a patch using github pull-requests from the GeoServer-documentation page. (http://docs.geoserver.org/latest/en/developer/policies/patches.html). A new test ‚testGetFeatureCount() was created in the ‚GeoJSONTest.java‘, which shows the featureCount for a request without a filter and a request with a filter.

I have created a branch named ‚json_featurecount‘ on my github-page https://github.com/PaulBiskup/geoserver/tree/json_featurecount

I have already sent a pull request to the master branch.

Is there anything else I have to do to get the patch integrated into the master branch?

Regards
Paul

Von: Biskup, Paul
Gesendet: Mittwoch, 20. Februar 2013 15:10
An: ‘Andrea Aime’
Cc: geoserver-devel@anonymised.com.sourceforge.net
Betreff: AW: [Geoserver-devel] JSON output - total number of features for paging

Thanks for the information about the official way for contributing.

I’ll try to submit my patch regarding the minimum requirements.

Regards

Paul

Von: andrea.aime@anonymised.com [mailto:andrea.aime@anonymised.com] Im Auftrag von Andrea Aime
Gesendet: Mittwoch, 20. Februar 2013 12:59
An: Biskup, Paul
Cc: Justin Deoliveira; geoserver-devel@lists.sourceforge.net
Betreff: Re: [Geoserver-devel] JSON output - total number of features for paging

On Wed, Feb 20, 2013 at 9:50 AM, Biskup, Paul <Paul.Biskup@anonymised.com…3654…> wrote:

I’m glad to hear, that you want to integrate this extra attribute in JSON-output!

Since I have no experience in the contribution of source code, maybe I’ll just send you my patched „GeoJSONOutputFormat.java“-file.

I’ve added the function „getNumberOfFeaturesFromRequest“, which gets called before the JSON-object gets written.

This function also respects filters. So if a filter gets passed, only the count of the filtered features gets returned.

The positions I have edited are marked with PBI-comment.

I hope that this is sufficient.

Generally speaking we don’t accept changes unless they are accompained by a test.

The bare minimum is a patch (not the full files) against the current GeoServer master that contains both the change to the code, and the test

showing it works.

If that’s too hard you can open an improvement request on jira.codehaus.org, attach the file above, and wait

for a good soul that completes the minimum requirements for you.

Cheers

Andrea

==

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

==

Ing. Andrea Aime

@geowolf

Technical Lead

GeoSolutions S.A.S.

Via Poggio alle Viti 1187

55054 Massarosa (LU)

Italy

phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

http://www.geo-solutions.it

http://twitter.com/geosolutions_it