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

支持 Point / Line / Polygon / Heatmap 在 WebGPU 下的渲染 #2225

Merged
merged 24 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
52 changes: 31 additions & 21 deletions __tests__/e2e/snapshot.spec.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import { chromium, devices } from 'playwright';
import { TestDemoList } from './tests';
import { sleep } from './utils/sleep';
import './utils/useSnapshotMatchers';
import { TestDemoList } from './tests'
describe('Snapshots', () => {
const demosFlatList: Array<{
type: string;
name: string;
sleepTime: number;
}> = [];
TestDemoList.filter(g=>g.snapshots!==false).forEach((groups) => {
TestDemoList.filter((g) => g.snapshots !== false).forEach((groups) => {
const { type, demos } = groups;

demos.filter(g=>g.snapshots!==false).map((demo) => {
const { name, sleepTime = 1.5 } = demo;
demosFlatList.push({
type,
name,
sleepTime
})

})
})

demos
.filter((g) => g.snapshots !== false)
.map((demo) => {
const { name, sleepTime = 1.5 } = demo;
demosFlatList.push({
type,
name,
sleepTime,
});
});
});
demosFlatList.map((demo) => {
const { name, sleepTime = 1.5,type } = demo;
const { name, sleepTime = 1.5, type } = demo;
const key = `${type}_${name}`;

it(key, async () => {
Expand All @@ -34,9 +35,21 @@ describe('Snapshots', () => {
const page = await context.newPage();
// Go to test page served by vite devServer.
const url = `http://localhost:8080/?type=${type}&name=${name}`;
await page.goto(url);

await sleep(sleepTime * 1000);
let resolveReadyPromise: () => void;
const readyPromise = new Promise((resolve) => {
resolveReadyPromise = () => {
resolve(this);
};
});

await context.exposeFunction('screenshot', async () => {
resolveReadyPromise();
});

await page.goto(url);
await readyPromise;
await sleep(2000);

// Chart already rendered, capture into buffer.
const buffer = await page.locator('canvas').screenshot();
Expand All @@ -51,8 +64,5 @@ describe('Snapshots', () => {
await browser.close();
}
});

})


})
});
});
Binary file added __tests__/e2e/snapshots/Point_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 65 additions & 65 deletions __tests__/e2e/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,37 @@ export const TestDemoList: Array<{
},
{
name: 'fill',
sleepTime: 1,
},
// {
// name: 'image',
// },
{
name: 'image',
snapshots: false,
sleepTime: 1,
name: 'text',
},
],
},
{
type: 'Line',
snapshots: false,
demos: [
{
name: 'arc',
},
{
name: 'arc_plane',
},
// {
// type: 'Line',
// snapshots: false,
// demos: [
// {
// name: 'arc',
// },
// {
// name: 'arc_plane',
// },

{
name: 'flow',
},
{
name: 'arc',
},
{
name: 'dash',
},
],
},
// {
// name: 'flow',
// },
// {
// name: 'arc',
// },
// {
// name: 'dash',
// },
// ],
// },
{
type: 'Polygon',
demos: [
Expand All @@ -75,37 +75,37 @@ export const TestDemoList: Array<{
},
],
},
{
type: 'HeatMap',
snapshots: false,
demos: [
{
name: 'grid',
sleepTime: 2,
},
{
name: 'hexagon',
sleepTime: 2,
},
{
name: 'normal',
sleepTime: 2,
},
],
},
{
type: 'Raster',
snapshots: false,
demos: [
{
name: 'tiff',
sleepTime: 2,
},
{
name: 'image',
},
],
},
// {
// type: 'HeatMap',
// snapshots: false,
// demos: [
// {
// name: 'grid',
// sleepTime: 2,
// },
// {
// name: 'hexagon',
// sleepTime: 2,
// },
// {
// name: 'normal',
// sleepTime: 2,
// },
// ],
// },
// {
// type: 'Raster',
// snapshots: false,
// demos: [
// {
// name: 'tiff',
// sleepTime: 2,
// },
// {
// name: 'image',
// },
// ],
// },
{
type: 'Mask',
demos: [
Expand All @@ -122,13 +122,13 @@ export const TestDemoList: Array<{
},
],
},
{
type: 'Gallery',
demos: [
{
name: 'fujian',
sleepTime: 2,
},
],
},
// {
// type: 'Gallery',
// demos: [
// {
// name: 'fujian',
// sleepTime: 2,
// },
// ],
// },
];
118 changes: 58 additions & 60 deletions examples/demos/heatmap/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,65 @@ import { HeatmapLayer, Scene } from '@antv/l7';
import * as allMap from '@antv/l7-maps';

export function MapRender(option: {
map: string
renderer: 'regl' | 'device'
map: string;
renderer: 'regl' | 'device';
}) {
const scene = new Scene({
id: 'map',
renderer: option.renderer,
map: new allMap[option.map || 'Map']({
style: 'light',
center: [121.434765, 31.256735],
zoom: 14.83,
}),
});

const scene = new Scene({
id: 'map',
renderer: option.renderer,
map: new allMap[option.map || 'Map']({
style: 'light',
center: [121.434765, 31.256735],
zoom: 14.83
})
});

scene.on('loaded', () => {
fetch(
'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json',
)
.then((res) => res.json())
.then((data) => {
const layer = new HeatmapLayer({autoFit:true})
.source(data, {
transforms: [
{
type: 'grid',
size: 150000,
field: 'mag',
method: 'sum',
},
],
})
.size('sum', sum => {
return sum * 2000;
})
.shape('hexagonColumn')
.style({
coverage: 0.8,
angle: 0,
})
.color(
'count',
[
'#0B0030',
'#100243',
'#100243',
'#1B048B',
'#051FB7',
'#0350C1',
'#0350C1',
'#0072C4',
'#0796D3',
'#2BA9DF',
'#30C7C4',
'#6BD5A0',
'#A7ECB2',
'#D0F4CA'
].reverse()
);
scene.addLayer(layer);

});
scene.on('loaded', () => {
fetch(
'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json',
)
.then((res) => res.json())
.then((data) => {
const layer = new HeatmapLayer({ autoFit: true })
.source(data, {
transforms: [
{
type: 'grid',
size: 150000,
field: 'mag',
method: 'sum',
},
],
})
.size('sum', (sum) => {
return sum * 2000;
})
.shape('hexagonColumn')
.style({
coverage: 0.8,
angle: 0,
})
.active(true)
.color(
'count',
[
'#0B0030',
'#100243',
'#100243',
'#1B048B',
'#051FB7',
'#0350C1',
'#0350C1',
'#0072C4',
'#0796D3',
'#2BA9DF',
'#30C7C4',
'#6BD5A0',
'#A7ECB2',
'#D0F4CA',
].reverse(),
);
scene.addLayer(layer);
});

});
}
Loading
Loading