Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed count limit for response paging in two situations #1118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ public void doGetFeatureResults( GetFeature request, HttpResponseBuffer response
if ( count != null && ( options.getQueryMaxFeatures() < 1 || count.intValue() < options.getQueryMaxFeatures() ) ) {
returnMaxFeatures = count.intValue();
}
else if ( count != null && returnMaxFeatures > 0 ) {
// limit count to max features
count = BigInteger.valueOf( returnMaxFeatures );
}

int startIndex = 0;
if ( request.getPresentationParams().getStartIndex() != null ) {
Expand Down Expand Up @@ -312,6 +316,11 @@ private ResponsePagingUris createResponsePagingUrisHits( GetFeature request )
OWSException {
StandardPresentationParams requestPresentationParams = request.getPresentationParams();
BigInteger count = requestPresentationParams.getCount();
if (count != null && options.getQueryMaxFeatures() > 0) {
// limit count to max features
// (only has the effect that the hits request limits the count for the next query)
count = BigInteger.valueOf( Math.min( count.longValue(), options.getQueryMaxFeatures() ) );
}
int startIndex = 0;
if ( requestPresentationParams.getStartIndex() != null ) {
startIndex = requestPresentationParams.getStartIndex().intValue();
Expand All @@ -338,6 +347,12 @@ private ResponsePagingUris createResponsePagingUris( GetFeature request, BigInte
OWSException {
if ( count != null ) {
Map<String, String> kvpGetFeature = GetFeature200KVPEncoder.export( request );

// override count with the given value (e.g. if the original exceeds the max features)
if ( count != null ) {
kvpGetFeature.put( "COUNT", count.toString() );
}

String nextUri = createNextUri( count, startIndex, kvpGetFeature, request );
String previousUri = createPreviousUri( count, startIndex, kvpGetFeature );
return new ResponsePagingUris( nextUri, previousUri );
Expand All @@ -359,8 +374,13 @@ private String createNextUri( BigInteger count, int startIndex, Map<String, Stri

private String createPreviousUri( BigInteger count, int startIndex, Map<String, String> kvpGetFeature ) {
int previousStartIndex = ResponsePagingUtils.calculatePreviousStartIndex( startIndex, count.intValue() );
if ( previousStartIndex >= 0 )
if ( previousStartIndex >= 0 ) {
// adapt count to actual previous start index
int realCount = startIndex - previousStartIndex;
kvpGetFeature.put( "COUNT", String.valueOf( realCount ) );

return createUrlWithStartindex( kvpGetFeature, previousStartIndex );
}
return null;
}

Expand Down