WFS GetFeature Query Order – Is MAXFEATURES Guaranteed to Work Based on TypeNames Order in WFS GetFeature Query?

geoservergetfeaturewfs

I perform a GetFeature query in multiple layers (typeNames according to spec), which is limited to a certain number of MAXFEATURES, let's say 500.

Let's say layer A has 10 features that match, and layer B has 600 features that match.

If I include typeNames: [B,A], only features from layer B are returned.
If I include typeNames: [A,B], I get 10 features from layer A and 490 from layer B.

This is working as I need it to, in the times I've tried it.

My question is: Can I count on it? Is this documented behavior?

The official documentation only mentions "Exactly which N features will be returned depends on the internal structure of the data", which isn't really telling me anything.

Best Answer

One might argue that the the official documentation is the WFS standard, not the GeoServer documentation.

In Web Feature Service Implementation Specification with Corrigendum (Version: 1.1.3) it states:

The optional maxFeatures attribute can be used to limit the number of explicitly requested features (i.e. features specified via the GetFeature/Query/@typeName attribute) that a GetFeature request presents in the response document. The maxFeatures value applies to whole result set and the constraint in applied to the features in the order in which they are presented. In addition, feature members contained in a requested feature collection do not count – the requested feature collection counts as one feature. Once the maxFeatures limit is reached, the result set is truncated at that point. There is no default value defined and the absense of the attribute means that all feature type instances in the result should should be returned to the client.

So if GeoServer follows the standard you should be able to count on it.

However...

You have used typenames which suggests you are using WFS 2. In WFS 2 maxfeatures is no longer supported, and you should instead use the COUNT parameter.

The count value applies to the entire result set (i.e. the result set generated by processing one or more Query actions) and the constraint shall be applied to the values in the order in which they are presented. Once the count limit is reached, request processing may terminate and the response document, containing at most count values, shall be presented to the client.