Skip to content

Commit

Permalink
select correct style for a layer from dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
zcernigoj committed Oct 4, 2024
1 parent 771c6a9 commit 1163d91
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/layer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,25 @@ export async function fetchLayerParamsFromConfigurationService(
...getAxiosReqParams(reqConfigWithMemoryCache, null),
};
const res = await axios.get(url, requestConfig);
const layersParams = res.data.map((l: any) => ({
layerId: l.id,
title: l.title,
description: l.description,
...l.datasourceDefaults,
//maxCloudCoverPercent vs maxCloudCoverage
...(l.datasourceDefaults?.maxCloudCoverage !== undefined && {
maxCloudCoverPercent: l.datasourceDefaults.maxCloudCoverage,
}),
evalscript: l.styles[0].evalScript,
dataProduct: l.styles[0].dataProductId
? `${configurationServiceHostName}api/v2/configuration/datasets/${l.collectionType}/dataproducts/${l.styles[0].dataProductId}`
: undefined,
legend: l.styles.find((s: any) => s.name === l.defaultStyleName)
? l.styles.find((s: any) => s.name === l.defaultStyleName).legend
: null,
}));
const layersParams = res.data.map((l: any) => {
const defaultStyle = l.styles.find((s: any) => s.name === l.defaultStyleName) ?? l.styles[0];

return {
layerId: l.id,
title: l.title,
description: l.description,
...l.datasourceDefaults,
//maxCloudCoverPercent vs maxCloudCoverage
...(l.datasourceDefaults?.maxCloudCoverage !== undefined && {
maxCloudCoverPercent: l.datasourceDefaults.maxCloudCoverage,
}),
evalscript: defaultStyle.evalScript,
dataProduct: defaultStyle.dataProductId
? `${configurationServiceHostName}api/v2/configuration/datasets/${l.collectionType}/dataproducts/${defaultStyle.dataProductId}`
: undefined,
legend: defaultStyle ? defaultStyle.legend : null,
};
});
return layersParams;
}

Expand Down

0 comments on commit 1163d91

Please sign in to comment.