From 7ccfded86837d87ca7426b289a52e2f400c74ff7 Mon Sep 17 00:00:00 2001 From: Benjamin Webb <40066515+webb-ben@users.noreply.github.com> Date: Tue, 6 Jun 2023 17:42:58 -0400 Subject: [PATCH] Return numberMatched if in STA response (#1259) Attempt to return `@iot.count` in included in response. Including the query param `'$count' = 'true'` is costly on the SensorThings API endpoint when accessing the Observations entity. Some STA endpoints are including the count as a default. --- pygeoapi/provider/sensorthings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pygeoapi/provider/sensorthings.py b/pygeoapi/provider/sensorthings.py index 1aa75e3..6b497b4 100644 --- a/pygeoapi/provider/sensorthings.py +++ b/pygeoapi/provider/sensorthings.py @@ -249,9 +249,13 @@ class SensorThingsProvider(BaseProvider): # Make features response = self._get_response(url=self._url, params=params) - v = response.get('value') + + matched = response.get('@iot.count') + if matched: + fc['numberMatched'] = matched # Query if values are less than expected + v = response.get('value') while len(v) < limit: try: LOGGER.debug('Fetching next set of values')