Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix raster webgl1 #2213

Merged
merged 2 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dev-demos/webgpu/device/demos/texture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export default () => {
`
},
fragment: {
wgsl: `
wgsl:
`

[[location(0)]] var<in> v_uv : vec2<f32>;
[[location(0)]] var<out> outputColor : vec4<f32>;
Expand Down
62 changes: 62 additions & 0 deletions examples/demos/raster/dem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Scene, RasterLayer } from '@antv/l7';
import * as allMap from '@antv/l7-maps';
import * as GeoTIFF from 'geotiff';

export function MapRender(option: {
map: string
renderer: string
}) {

const scene = new Scene({
id: 'map',
// renderer: option.renderer,
map: new allMap[option.map || 'Map']({
style: 'light',
center: [121.434765, 31.256735],
zoom: 3
})
});
async function getTiffData() {
const response = await fetch(
'https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat',
);
const arrayBuffer = await response.arrayBuffer();
return arrayBuffer;
}
scene.on('loaded', async () => {
const tiffdata = await getTiffData();
const tiff = await GeoTIFF.fromArrayBuffer(tiffdata);
const image = await tiff.getImage();
const width = image.getWidth();
const height = image.getHeight();
const values = await image.readRasters();
console.log(values);

const layer = new RasterLayer();
layer
.source(values[0], {
parser: {
type: 'raster',
width,
height,
extent: [73.482190241, 3.82501784112, 135.106618732, 57.6300459963],
},
})
.style({
opacity: 1,
// clampLow: false,
// clampHigh: false,
domain: [0, 10000],
rampColors: {
type:'custom',
colors: ['#b2182b','#d6604d','#f4a582','#fddbc7','#f7f7f7','#d1e5f0','#92c5de','#4393c3','#2166ac'],
positions: [0, 50, 200, 500, 2000, 3000, 4000, 5000, 8000,10000],
},

});

scene.addLayer(layer);
scene.startAnimate()
});

}
3 changes: 2 additions & 1 deletion examples/demos/raster/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { MapRender as image } from './image';
export { MapRender as tiff } from './tiff';
export { MapRender as tiff } from './tiff';
export { MapRender as dem } from './dem';
3 changes: 2 additions & 1 deletion examples/demos/raster/tiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function MapRender(option:{
}) {
const scene = new Scene({
id: 'map',
renderer:option.renderer,
// renderer:option.renderer,
map: new allMap[option.map || 'Map']({
center: [105, 37.5],
zoom: 2.5,
Expand All @@ -45,6 +45,7 @@ export function MapRender(option:{
zIndex: 2,
visible: true,
});
console.log(tiffdata)
layer
.source(tiffdata.data, {
parser: {
Expand Down
Loading
Loading