Skip to content

Don't generate paging links if provider created them #1982

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

Open
wants to merge 2 commits into
base: master
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
23 changes: 15 additions & 8 deletions pygeoapi/api/itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,21 @@ def get_collection_items(
'href': f'{uri}?f={F_HTML}{serialized_query_params}'
}])

if offset > 0:
next_link = False
prev_link = False

if 'next' in [link['rel'] for link in content['links']]:
LOGGER.debug('Using next link from provider')
else:
if content.get('numberMatched', -1) > (limit + offset):
next_link = True
elif len(content['features']) == limit:
next_link = True

if offset > 0:
prev_link = True

if prev_link:
prev = max(0, offset - limit)
content['links'].append(
{
Expand All @@ -555,13 +569,6 @@ def get_collection_items(
'href': f'{uri}?offset={prev}{serialized_query_params}'
})

next_link = False

if content.get('numberMatched', -1) > (limit + offset):
next_link = True
elif len(content['features']) == limit:
next_link = True

if next_link:
next_ = offset + limit
next_href = f'{uri}?offset={next_}{serialized_query_params}'
Expand Down