antv-l7/stories/layerbuild/components/RasterLayer.tsx

93 lines
2.1 KiB
TypeScript
Raw Normal View History

feat: 渲染流程异步改造、部分支持 worker (#1224) * feat: 去处事件节流 * feat: 创建图层流程改造 + worker 功能验证 * style: lint style * feat: 修改 worker 引入 * feat: 调整 worker 的拼接 * style: lint style * feat: 修改 source 构建流程为异步 * style: lint style * feat: 在点图层中去除 global 的耦合 * style: lint style * fix: 修复更新 style 的同时更新了 option 带来的问题 * style: lint style * feat: 拆除 arc3d 地球模式和普通模式的耦合 * style: lint style * feat: 修改 worker * style: lint style * feat: 优化图层创建渲染流程 * style: lint style * Merge branch 'workspace' into tileDemo * style: style lint * feat: 改在点图层的创建流程 * style: lint style * style: lint style * chore: worker helper (#1241) * chore: worker helper * chore: 修改注册流程 * chore: 修改打包方式 * chore: 集成打包环境 * style: lint style * feat: add worker pool failed * style: lint style * style: lint style * feat: 更新 worker 的使用 * chore: 更新 scripts 标签 (#1242) * feat: remove utils triangulation * feat: 完成 pointLayer/earthLayer 的异步改造 * style: lint style * style: lint style * style: lint style * chore: 修改 worker 执行函数 (#1246) * chore: 修改 worker 执行函数 * chore: remove console * feat: 完成线图层和线图层的异步创建流程改造 * style: lint style * style: lint style * feat: 完成 polygon 创建流程的异步改造 * style: lint style * feat: 完成 heatmap 创建流程的异步改造 * style: lint style * feat: 完成 citybuildingLayer 图层创建的异步改造 * style: lint style * feat: 完成 imageLayer 创建异步改造 * style: lint style * feat: 完成 ImageLayer/RasterLayer 创建的异步改造 * style: lint style * feat: 完成 geometryLayer 创建的异步改造 * style: lint style * feat: 完成 WindLayer 创建的异步改造 * style: lint style * feat: 完成 tileLayer 瓦片图层创建图层的异步改造 * style: lint style * feat: 调整 worker 调用的参数和 worker 代码的位置 * style: lint style * chore: 调整 worker 代码结构 * style: lint style * feat: 梳理完善 layer 的 modelName * style: lint style * chore: 调整部分 modeName 的命名 * feat: 线图层的 lineModel 支持 worker 计算 * style: lint style * feat: 完善 source 异步改造,增加测试 * style: lint style * feat: 支持 polygonFill 的 worker 计算 * style: lint style * feat: tile point/line/polygon 支持 worker 计算 * style: lint style * chore: 调整 worker 目录结构 * style: lint style * chore: 修改 worker 打包路径 * feat: 增加 ISrource 时间的类型定义 * chore: change function getPureDescriptors -> getDescriptorsWithOutFunc * feat: 完善类型定义,去除额外 worker 代码 * chore: worker 注册放到 utils 里面 (#1253) * chore: 代码清理 * style: lint style * fix: 修复 encodeData 可能的空值 * feat: 地球模式的点、线图层兼容写法 * style: lint style * feat: 完成对 dataImage 的异步改造 * fix: 修复 demo 中对时序数据的使用 * style: lint style * fix: 修复点图层文字重新布局未重绘问题 * fix: 修复 pointLayer fillImage 失效 * style: lint style * chore: 在官网 demo 中去除 multipass * chore: 调整官网 demo 效果 * style: lint style * chore: 调整官网 demo * style: lint style * fix: 修复 layerModel 使用的报错 * chore: update l7plot version Co-authored-by: lvisei <yunji.me@outlook.com>
2022-08-02 19:05:27 +08:00
// @ts-nocheck
// @ts-ignore
import { Scene, Source } from '@antv/l7';
import { ImageLayer, RasterLayer } from '@antv/l7-layers';
import { GaodeMap } from '@antv/l7-maps';
import * as React from 'react';
import * as GeoTIFF from 'geotiff';
async function getTiffData() {
const response = await fetch(
'https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat',
);
const arrayBuffer = await response.arrayBuffer();
const tiff = await GeoTIFF.fromArrayBuffer(arrayBuffer);
const image = await tiff.getImage();
const width = image.getWidth();
const height = image.getHeight();
const values = await image.readRasters();
return {
data: values[0],
width,
height,
min: 0,
max: 8000,
};
}
export default class Demo extends React.Component {
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [121.268, 30.3628],
zoom: 3,
}),
});
async function addLayer() {
const tiffdata = await getTiffData();
const layer = new RasterLayer({});
layer
.source(tiffdata.data, {
parser: {
type: 'raster',
width: tiffdata.width,
height: tiffdata.height,
min: 0,
max: 80,
extent: [73.482190241, 3.82501784112, 135.106618732, 57.6300459963],
},
})
.style({
heightRatio: 100,
opacity: 0.8,
rampColors: {
colors: [
'#FF4818',
'#F7B74A',
'#FFF598',
'#91EABC',
'#2EA9A1',
'#206C7C',
].reverse(),
positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0],
},
});
return layer;
}
const layer = await addLayer();
scene.on('loaded', () => {
scene.addLayer(layer);
});
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
></div>
);
}
}