乘以 2 个源,WebGlLayer (openlayers)

问题描述 投票:0回答:1

我整个晚上都在挣扎。我想做的就是将两个栅格相乘。我知道我可以使用 RasterSource 做到这一点,但我需要更好的性能。当我为每个单独的源创建一个图层(webgl)时,提取数据工作正常:[“band”,1],... [“band”,4],其中前3个带是相同的(存储字节) ,第四个是不透明度。但是,如果我有 2 个或更多源,我无法从多个源中提取数据(有趣的是,它始终是数组中的最后一个)。

import WebGLTileLayer, { Style as WebGLStyle } from 'ol/layer/WebGLTile';
const src1 = createXYZ(url1)
const src2 = createXYZ(url2)


const product = ["*", ["band", 1], ["band", 5]] // 5 since 4 + 1, this should be the red channel of src2, right?

const style: WebGLStyle = {
    color: [
        'case',
        ['<', product, 0.5],
        [0, 0, 0, 0],
        [255, 0, 0, 1]]
}
const layer = new WebGLTileLayer({
    sources: [src1, src2],
    style,

})

我想做的是从每个来源提取数据。我尝试了 ["band", 5],但什么也没有。我尝试过其他波段索引,但要么什么也没有得到,要么只是 src2 中的数据。我做错了什么?

javascript webgl openlayers openlayers-3
1个回答
0
投票

您的代码所做的类似于https://openlayers.org/en/latest/examples/multiple-cogs.html,其中每个源都使用相同的频段。

要使用 8 个频段进行样式设置,您需要一个具有 8 个频段的 DataTile 源 - OpenLayers 有一项提案允许在 https://github.com/openlayers/openlayers/pull/16090 中实现这一点,但它还不是API。

如果不使用它,您将需要一个自定义加载器将来自 2 个源的 4 个频段合并到一个 8 频段 DataTile 中,例如 https://stackblitz.com/edit/js-npm2wk?file=index.html,package.json,索引.js

© www.soinside.com 2019 - 2024. All rights reserved.