in analysis/webservice/algorithms/doms/StacCatalog.py [0:0]
def calc(self, request, **args):
page_size = request.get_int_arg('pageSize', default=1000)
url_path_regex = '^\/cdmscatalog\/?(?P<id>[a-zA-Z0-9-]*)\/?(?P<format>[a-zA-Z0-9]*)'
match = re.search(url_path_regex, request.requestHandler.request.path)
execution_id = match.group('id')
output_format = match.group('format')
self.host = request.requestHandler.request.host
if not execution_id:
raise NexusProcessingException(
reason=f'Execution ID path param must be provided.',
code=400
)
if execution_id:
try:
execution_id = uuid.UUID(execution_id)
except ValueError:
raise NexusProcessingException(
reason=f'"{execution_id}" is not a valid uuid',
code=400
)
if output_format and output_format.upper() not in ['CSV', 'JSON', 'NETCDF']:
raise NexusProcessingException(
reason=f'"{output_format}" is not a valid format. Should be CSV, JSON, or NETCDF.',
code=400
)
if execution_id and not output_format:
# Route to STAC catalog for execution
stac_output = self.construct_catalog(execution_id)
elif execution_id and output_format:
# Route to STAC collection for execution+format
with ResultsRetrieval(self.config) as retrieval:
try:
execution_stats = retrieval.retrieveStats(execution_id)
execution_params = retrieval.retrieveParams(execution_id)
except NexusProcessingException:
execution_stats = {}
num_primary_matched = execution_stats.get('numPrimaryMatched', 0)
start_time = execution_params['startTime'].isoformat()
end_time = execution_params['endTime'].isoformat()
bbox = list(map(float, execution_params['bbox'].split(',')))
stac_output = self.construct_collection(
execution_id, output_format, num_primary_matched, page_size,
start_time, end_time, bbox
)
else:
raise NexusProcessingException(
reason=f'Invalid path parameters were provided',
code=400
)
return StacResults(stac_output)