Skip to content

Commit 5d2d8d8

Browse files
Don't generate paging links if provider created them (#1982)
* Don't generate paging links if provider created them * Update itemtypes.py --------- Co-authored-by: Benjamin Webb <benjamin.miller.webb@gmail.com>
1 parent 451f1f0 commit 5d2d8d8

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

pygeoapi/api/itemtypes.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,21 @@ def get_collection_items(
580580
'href': f'{uri}?f={F_HTML}{serialized_query_params}'
581581
}])
582582

583-
if offset > 0:
583+
next_link = False
584+
prev_link = False
585+
586+
if 'next' in [link['rel'] for link in content['links']]:
587+
LOGGER.debug('Using next link from provider')
588+
else:
589+
if content.get('numberMatched', -1) > (limit + offset):
590+
next_link = True
591+
elif len(content['features']) == limit:
592+
next_link = True
593+
594+
if offset > 0:
595+
prev_link = True
596+
597+
if prev_link:
584598
prev = max(0, offset - limit)
585599
content['links'].append(
586600
{
@@ -590,13 +604,6 @@ def get_collection_items(
590604
'href': f'{uri}?offset={prev}{serialized_query_params}'
591605
})
592606

593-
next_link = False
594-
595-
if content.get('numberMatched', -1) > (limit + offset):
596-
next_link = True
597-
elif len(content['features']) == limit:
598-
next_link = True
599-
600607
if next_link:
601608
next_ = offset + limit
602609
next_href = f'{uri}?offset={next_}{serialized_query_params}'

0 commit comments

Comments
 (0)