Skip to content

Commit 71899b3

Browse files
committed
create COG layer on the fly if none is provided (#9527)
1 parent 21da9ea commit 71899b3

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

web/client/api/catalog/COG.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ const fetchMetadata = (layer, url, controller) => {
132132

133133
export const getRecords = (_url, startPosition, maxRecords, text, info = {}) => {
134134
const service = get(info, 'options.service');
135+
const controller = get(info, 'options.controller');
135136
let layers = [];
136137
if (service.records) {
137138
// each record/url corresponds to a layer
@@ -144,7 +145,6 @@ export const getRecords = (_url, startPosition, maxRecords, text, info = {}) =>
144145
sources: [{url}],
145146
options: service.options || {}
146147
};
147-
const controller = get(info, 'options.controller');
148148
const isSave = get(info, 'options.save', false);
149149
// Fetch metadata only on saving the service (skip on search)
150150
if ((isNil(service.fetchMetadata) || service.fetchMetadata) && isSave) {
@@ -154,6 +154,23 @@ export const getRecords = (_url, startPosition, maxRecords, text, info = {}) =>
154154
});
155155
}
156156
return Promise.all([...layers]).then((_layers) => {
157+
if (!_layers.length) {
158+
return fetchMetadata({
159+
...service,
160+
title: text,
161+
identifier: _url,
162+
type: COG_LAYER_TYPE,
163+
sources: [{url: _url}],
164+
options: service.options || {}
165+
}, _url, controller).then(lyr => {
166+
const records = [lyr];
167+
return {
168+
numberOfRecordsMatched: 1,
169+
numberOfRecordsReturned: 1,
170+
records
171+
};
172+
});
173+
}
157174
return searchAndPaginate(_layers, startPosition, maxRecords, text);
158175
});
159176
};

0 commit comments

Comments
 (0)