From 32849e74ce106e03097e3cf408db4560c3364afb Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 24 Jul 2024 17:41:29 +0200 Subject: [PATCH] Debug --- .../src/formbuilder/objectform/coglayer.ts | 18 +++++++++++++----- packages/base/src/mainview/mainview.tsx | 15 +++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/base/src/formbuilder/objectform/coglayer.ts b/packages/base/src/formbuilder/objectform/coglayer.ts index 8fb3a4a6..e6a83bf1 100644 --- a/packages/base/src/formbuilder/objectform/coglayer.ts +++ b/packages/base/src/formbuilder/objectform/coglayer.ts @@ -32,12 +32,20 @@ export class COGLayerPropertiesForm extends LayerPropertiesForm { protected syncData(properties: IDict | undefined) { // TODO Compute this stupid bidx properly (indexing starts at 1 -_-) - const url = cogTile({ - url: this.props.currentLayerSourceFormData.url, - bidx: [1, 2, 3] - }); + const sourceBands = this.props.currentLayerSourceFormData.bands as string[]; - properties && (properties.url = url); + if (properties && properties.bands) { + const url = cogTile({ + url: this.props.currentLayerSourceFormData.url, + bidx: [ + sourceBands.indexOf(properties.bands[0]) + 1, + sourceBands.indexOf(properties.bands[1]) + 1, + sourceBands.indexOf(properties.bands[2]) + 1 + ] + }); + + properties.url = url; + } return super.syncData(properties); } diff --git a/packages/base/src/mainview/mainview.tsx b/packages/base/src/mainview/mainview.tsx index 28268569..a98af38c 100644 --- a/packages/base/src/mainview/mainview.tsx +++ b/packages/base/src/mainview/mainview.tsx @@ -530,22 +530,21 @@ export class MainView extends React.Component { // The COG Layer has something specific where it owns the URL to the tiles, not the source // So we'll create one source per-layer under the hood on Maplibre const parameters = layer.parameters as ICOGLayer; - const cogSource = source.parameters as ICOGSource; - const actualSourceId = `${sourceId}-${id}`; const mapSource = this._Map.getSource( actualSourceId ) as MapLibre.RasterTileSource; if (mapSource) { - mapSource.setUrl(cogSource.url); + mapSource.setUrl(parameters.url || ''); + // this._Map.redraw(); } - this._Map.setPaintProperty( - id, - 'raster-opacity', - parameters?.opacity !== undefined ? parameters.opacity : 1 - ); + // this._Map.setPaintProperty( + // id, + // 'raster-opacity', + // parameters?.opacity !== undefined ? parameters.opacity : 1 + // ); break; } }