Hi,
Mapserver does just that with GeoJSON. It streams data out and writes the number of features last into JSON. I have checked the result with jsonlint and geojsonlint and both validates it.
-Jukka Rahkonen-
Sampo Savolainen wrote:
···
Hi,
I’ve finally got my head around Andrea’s objections and you are absolutely right. Refactoring the number of features returned as a lazily populated number, similar to the total count, seems a sane way to achieve this. But I’m a bit worried that if the feature count is added to the JSON output, then the performance benefits of this would be lost also for that format. I did some rudimentary tests in the environment I’m working with (oracle backed feature, features derived from views) and doing the extra select count() adds ~50% to the response time of the queries.
Do you have any idea what is the use case for having the count in the GML / JSON response? In GML, having the count as an attribute in the root element kills any possibility of fully streaming the results. Only a streaming parser could take advantage of the count before the full response is read. For GML, there is a guarantee that the consumer will receive the root element before the features. But I don’t think GeoJSON defines any order in which fields in JSON objects need to be presented in, so there would be no guarantee for the consumer that they would receive the number of features before actually streaming the features themselves. And when you have the features, you have the count.
Sampo
On Thu, Nov 26, 2015 at 9:21 AM, Andrea Aime <andrea.aime@…1268…> wrote:
On Thu, Nov 26, 2015 at 4:58 AM, Jody Garnett <jody.garnett@…403…> wrote:
I am catching up on email, and kind of wish we had an example to point to.
Is it worth writing up a proposal page so you can clearly describe “places you mentioned” where counting is still required?
My take on Andrea’s response is that the GML format is forcing us to count features for WFS 2.0 GetFeature. I do not think he was rejecting your approach, just pointing out a limitation of the specification.
Yes. It means whatever implementation we do has either lazy count, similar to number matched, or we have a way to reach to the output
format and check its specific needs (something that would be useful for the other need we’d might have, checking if the output
format has axis order assumptions… e.g., don’t think anybody is happy with us producing lat/lon ordered data in anything
but GML).
Can I confirm that this feature counting is specific to GML output? Like if you were outputting geojson you would not need to count features?
Yes and no, we have a sequence of pull requests that introduced counts in GeoJson output format, so someone definitely
needs it (to the point they contributed code for it). Generally speaking, counting is useful for anyone in need of doing paging.
But I guess it could be made optional with a new config flag, of course, only for the formats where it can be made optional.
Cheers
Andrea
–
==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V 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://twitter.com/geosolutions_it
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.
–
Sampo Savolainen
Managing Director, Spatineo Oy
+358-407555649
Linnankoskenkatu 16 A 17, 00250 Helsinki, Finland
www.spatineo.com, twitter.com/#!/spatineo
www.linkedin.com/company/spatineo-inc
This message may contain privileged and/or confidential information. If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate, or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender
promptly by e-mail that you have done so.