Skip to content

Commit

Permalink
Merge 3560917 into 7f49cc9
Browse files Browse the repository at this point in the history
  • Loading branch information
1chandu committed Nov 1, 2019
2 parents 7f49cc9 + 3560917 commit 8dae042
Show file tree
Hide file tree
Showing 26 changed files with 749 additions and 593 deletions.
58 changes: 0 additions & 58 deletions examples/layer-browser/src/examples/additional-layers.js
Expand Up @@ -7,7 +7,6 @@ import {
// KMLLayer
} from '@deck.gl/geo-layers';

import {GPUGridLayer, GridLayer, HeatmapLayer} from '@deck.gl/aggregation-layers';
import * as h3 from 'h3-js';

import {registerLoaders} from '@loaders.gl/core';
Expand All @@ -17,56 +16,6 @@ import * as dataSamples from '../data-samples';

registerLoaders([PLYLoader]);

const GRID_LAYER_PROPS_OBJECT = {
id: 'grid-layer',
cellSize: 200,
opacity: 1,
extruded: true,
pickable: false,
getPosition: d => d.COORDINATES
};

const GPU_GRID_LAYER_PROPS_OBJECT = Object.assign({}, GRID_LAYER_PROPS_OBJECT, {
id: 'gpu-grid-layer'
});

const GRID_LAYER_PROPS = {
getData: () => dataSamples.points,
props: GRID_LAYER_PROPS_OBJECT
};

const GPU_GRID_LAYER_PROPS = {
getData: () => dataSamples.points,
props: GPU_GRID_LAYER_PROPS_OBJECT
};

const HEAT_LAYER_PROPS = {
getData: () => dataSamples.points,
props: {
id: 'heatmp-layer',
opacity: 1,
pickable: false,
getPosition: d => d.COORDINATES
}
};

const GPUGridLayerExample = Object.assign({}, {layer: GPUGridLayer}, GPU_GRID_LAYER_PROPS);
const GridLayerExample = Object.assign({}, {layer: GridLayer}, GRID_LAYER_PROPS);
const HeatmapLayerExample = Object.assign({}, {layer: HeatmapLayer}, HEAT_LAYER_PROPS);

const GPUGridLayerPerfExample = (id, getData) => ({
layer: GPUGridLayer,
getData,
props: {
id: `gpuGridLayerPerf-${id}`,
cellSize: 200,
opacity: 1,
extruded: true,
pickable: false,
getPosition: d => d
}
});

const GreatCircleLayerExample = {
layer: GreatCircleLayer,
getData: () => dataSamples.greatCircles,
Expand Down Expand Up @@ -154,12 +103,5 @@ export default {
H3HexagonLayer: H3HexagonLayerExample,
GreatCircleLayer: GreatCircleLayerExample,
TripsLayer: TripsLayerExample
},
'Experimental Core Layers': {
GPUGridLayer: GPUGridLayerExample,
GridLayer: GridLayerExample,
HeatmapLayer: HeatmapLayerExample,
'GPUGridLayer (1M)': GPUGridLayerPerfExample('1M', dataSamples.getPoints1M),
'GPUGridLayer (5M)': GPUGridLayerPerfExample('5M', dataSamples.getPoints5M)
}
};
170 changes: 170 additions & 0 deletions examples/layer-browser/src/examples/aggregation-layers.js
@@ -0,0 +1,170 @@
import {
GridLayer,
GPUGridLayer,
CPUGridLayer,
HexagonLayer,
ContourLayer,
ScreenGridLayer,
HeatmapLayer
} from '@deck.gl/aggregation-layers';

// Demonstrate immutable support
import * as dataSamples from '../data-samples';

const ScreenGridLayerExample = {
layer: ScreenGridLayer,
getData: () => dataSamples.points,
props: {
id: 'screenGridLayer',
getPosition: d => d.COORDINATES,
cellSizePixels: 40,
pickable: false
}
};

const ContourLayerExample = {
layer: ContourLayer,
getData: () => dataSamples.points,
props: {
id: 'contourLayer',
cellSize: 200,
getPosition: d => d.COORDINATES,
gpuAggregation: true,
contours: [
{threshold: 1, color: [255, 0, 0], strokeWidth: 4},
{threshold: 5, color: [0, 255, 0], strokeWidth: 2},
{threshold: 15, color: [0, 0, 255]}
]
}
};

const ContourLayerBandsExample = {
layer: ContourLayer,
getData: () => dataSamples.points,
props: {
id: 'contourLayer',
cellSize: 200,
getPosition: d => d.COORDINATES,
gpuAggregation: true,
contours: [
{threshold: [1, 5], color: [255, 0, 0]},
{threshold: [5, 15], color: [0, 255, 0]},
{threshold: [15, 1000], color: [0, 0, 255]}
]
}
};

function getMean(pts, key) {
const filtered = pts.filter(pt => Number.isFinite(pt[key]));

return filtered.length
? filtered.reduce((accu, curr) => accu + curr[key], 0) / filtered.length
: null;
}

function getMax(pts, key) {
const filtered = pts.filter(pt => Number.isFinite(pt[key]));

return filtered.length
? filtered.reduce((accu, curr) => (curr[key] > accu ? curr[key] : accu), -Infinity)
: null;
}

const CPUGridLayerExample = {
layer: CPUGridLayer,
props: {
id: 'gridLayer',
data: dataSamples.points,
cellSize: 200,
opacity: 1,
extruded: true,
pickable: true,
getPosition: d => d.COORDINATES,
getColorValue: points => getMean(points, 'SPACES'),
getElevationValue: points => getMax(points, 'SPACES')
}
};

const HexagonLayerExample = {
layer: HexagonLayer,
props: {
id: 'HexagonLayer',
data: dataSamples.points,
extruded: true,
pickable: true,
radius: 1000,
opacity: 1,
elevationScale: 1,
elevationRange: [0, 3000],
coverage: 1,
getPosition: d => d.COORDINATES,
getColorValue: points => getMean(points, 'SPACES'),
getElevationValue: points => getMax(points, 'SPACES')
}
};

const GRID_LAYER_PROPS_OBJECT = {
id: 'grid-layer',
cellSize: 200,
opacity: 1,
extruded: true,
pickable: false,
getPosition: d => d.COORDINATES
};

const GPU_GRID_LAYER_PROPS_OBJECT = Object.assign({}, GRID_LAYER_PROPS_OBJECT, {
id: 'gpu-grid-layer'
});

const GRID_LAYER_PROPS = {
getData: () => dataSamples.points,
props: GRID_LAYER_PROPS_OBJECT
};

const GPU_GRID_LAYER_PROPS = {
getData: () => dataSamples.points,
props: GPU_GRID_LAYER_PROPS_OBJECT
};

const HEAT_LAYER_PROPS = {
getData: () => dataSamples.points,
props: {
id: 'heatmp-layer',
opacity: 1,
pickable: false,
getPosition: d => d.COORDINATES
}
};

const GPUGridLayerExample = Object.assign({}, {layer: GPUGridLayer}, GPU_GRID_LAYER_PROPS);
const GridLayerExample = Object.assign({}, {layer: GridLayer}, GRID_LAYER_PROPS);
const HeatmapLayerExample = Object.assign({}, {layer: HeatmapLayer}, HEAT_LAYER_PROPS);

const GPUGridLayerPerfExample = (id, getData) => ({
layer: GPUGridLayer,
getData,
props: {
id: `gpuGridLayerPerf-${id}`,
cellSize: 200,
opacity: 1,
extruded: true,
pickable: false,
getPosition: d => d
}
});

/* eslint-disable quote-props */
export default {
'Aggregation Layers': {
CPUGridLayer: CPUGridLayerExample,
ScreenGridLayer: ScreenGridLayerExample,
HexagonLayer: HexagonLayerExample,
ContourLayer: ContourLayerExample,
'ContourLayer (Bands)': ContourLayerBandsExample,
GPUGridLayer: GPUGridLayerExample,
GridLayer: GridLayerExample,
HeatmapLayer: HeatmapLayerExample,
'GPUGridLayer (1M)': GPUGridLayerPerfExample('1M', dataSamples.getPoints1M),
'GPUGridLayer (5M)': GPUGridLayerPerfExample('5M', dataSamples.getPoints5M)
}
};
106 changes: 1 addition & 105 deletions examples/layer-browser/src/examples/core-layers.js
Expand Up @@ -14,13 +14,6 @@ import {
TextLayer
} from '@deck.gl/layers';

import {
CPUGridLayer,
HexagonLayer,
ContourLayer,
ScreenGridLayer
} from '@deck.gl/aggregation-layers';

const {flattenVertices} = experimental;

// Demonstrate immutable support
Expand Down Expand Up @@ -239,17 +232,6 @@ const PathLayerBinaryExample = {
}
};

const ScreenGridLayerExample = {
layer: ScreenGridLayer,
getData: () => dataSamples.points,
props: {
id: 'screenGridLayer',
getPosition: d => d.COORDINATES,
cellSizePixels: 40,
pickable: false
}
};

const LineLayerExample = {
layer: LineLayer,
getData: () => dataSamples.routes,
Expand Down Expand Up @@ -293,69 +275,6 @@ const ColumnLayerExample = {
}
};

const ContourLayerExample = {
layer: ContourLayer,
getData: () => dataSamples.points,
props: {
id: 'contourLayer',
cellSize: 200,
getPosition: d => d.COORDINATES,
gpuAggregation: true,
contours: [
{threshold: 1, color: [255, 0, 0], strokeWidth: 4},
{threshold: 5, color: [0, 255, 0], strokeWidth: 2},
{threshold: 15, color: [0, 0, 255]}
]
}
};

const ContourLayerBandsExample = {
layer: ContourLayer,
getData: () => dataSamples.points,
props: {
id: 'contourLayer',
cellSize: 200,
getPosition: d => d.COORDINATES,
gpuAggregation: true,
contours: [
{threshold: [1, 5], color: [255, 0, 0]},
{threshold: [5, 15], color: [0, 255, 0]},
{threshold: [15, 1000], color: [0, 0, 255]}
]
}
};

function getMean(pts, key) {
const filtered = pts.filter(pt => Number.isFinite(pt[key]));

return filtered.length
? filtered.reduce((accu, curr) => accu + curr[key], 0) / filtered.length
: null;
}

function getMax(pts, key) {
const filtered = pts.filter(pt => Number.isFinite(pt[key]));

return filtered.length
? filtered.reduce((accu, curr) => (curr[key] > accu ? curr[key] : accu), -Infinity)
: null;
}

const CPUGridLayerExample = {
layer: CPUGridLayer,
props: {
id: 'gridLayer',
data: dataSamples.points,
cellSize: 200,
opacity: 1,
extruded: true,
pickable: true,
getPosition: d => d.COORDINATES,
getColorValue: points => getMean(points, 'SPACES'),
getElevationValue: points => getMax(points, 'SPACES')
}
};

/*
const ColumnLayerExample = {
layer: ColumnLayer,
Expand All @@ -375,24 +294,6 @@ const ColumnLayerExample = {
};
*/

const HexagonLayerExample = {
layer: HexagonLayer,
props: {
id: 'HexagonLayer',
data: dataSamples.points,
extruded: true,
pickable: true,
radius: 1000,
opacity: 1,
elevationScale: 1,
elevationRange: [0, 3000],
coverage: 1,
getPosition: d => d.COORDINATES,
getColorValue: points => getMean(points, 'SPACES'),
getElevationValue: points => getMax(points, 'SPACES')
}
};

const TextLayerExample = {
layer: TextLayer,
getData: () => dataSamples.texts,
Expand Down Expand Up @@ -520,11 +421,6 @@ export default {
'IconLayer (auto packing)': IconLayerAutoPackingExample,
TextLayer: TextLayerExample,
BitmapLayer: BitmapLayerExample,
ColumnLayer: ColumnLayerExample,
CPUGridLayer: CPUGridLayerExample,
ScreenGridLayer: ScreenGridLayerExample,
HexagonLayer: HexagonLayerExample,
ContourLayer: ContourLayerExample,
'ContourLayer (Bands)': ContourLayerBandsExample
ColumnLayer: ColumnLayerExample
}
};

0 comments on commit 8dae042

Please sign in to comment.