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

[Feat] support GeoArrow format #2385

Merged
merged 43 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
57ecca0
[Feat] Support WKB geometry column in CSV
lixun910 Sep 15, 2023
910692b
support wkb in csv
lixun910 Sep 6, 2023
68caef7
update package.json
lixun910 Sep 7, 2023
c8f8478
clean up
lixun910 Sep 7, 2023
e173eaf
init impl
lixun910 Sep 12, 2023
c3edd32
wip
lixun910 Sep 13, 2023
aae3990
wip
lixun910 Sep 15, 2023
186113a
add test cases
lixun910 Sep 16, 2023
a412478
wip
lixun910 Sep 18, 2023
676da91
add arrow wkb/wkt
lixun910 Sep 18, 2023
47d5a60
clean up
lixun910 Sep 18, 2023
b85511d
reorg test files
lixun910 Sep 18, 2023
6e4007e
clean up
lixun910 Sep 18, 2023
8796c14
wip
lixun910 Sep 18, 2023
7948e16
try binary format in GeoJsonLayer
lixun910 Oct 16, 2023
7b99a39
wip
lixun910 Oct 17, 2023
8c6c673
add hover on arrowlayer
lixun910 Oct 18, 2023
becfff8
fix table for geoarrow
lixun910 Oct 18, 2023
8e4c1ae
support filtering
lixun910 Oct 19, 2023
fe5a2f7
fix polygon with hole
lixun910 Oct 19, 2023
5ffce6e
support point arrow
lixun910 Oct 19, 2023
c68c2c1
support linestring
lixun910 Oct 19, 2023
0430f2d
add gpu filter
lixun910 Oct 19, 2023
aa1029e
clean up
lixun910 Oct 19, 2023
15faaa8
clean after rebase
lixun910 Oct 19, 2023
4ec9b70
wip
lixun910 Oct 19, 2023
b185d8f
wip
lixun910 Oct 19, 2023
a938152
wip
lixun910 Oct 19, 2023
63aa253
wip
lixun910 Oct 20, 2023
52a4f09
bump to loaders.gl 4.0.1
lixun910 Nov 1, 2023
6150d79
support Arrow using loaders.gl
lixun910 Nov 1, 2023
f0c572a
comments
lixun910 Nov 1, 2023
a4ae70a
clean up
lixun910 Nov 1, 2023
27d0043
address comments
lixun910 Nov 2, 2023
b76ae9b
modify file names
lixun910 Nov 2, 2023
2631251
clean
lixun910 Nov 2, 2023
f924e80
improv perf
lixun910 Nov 2, 2023
282b822
consolidate GeoJsonLayer and GeoArrowLayer
lixun910 Nov 8, 2023
836ebe5
wip
lixun910 Nov 8, 2023
2d2fdd4
update to loaders.gl 4.0.2
lixun910 Nov 8, 2023
000d758
fix lint;fix test cases
lixun910 Nov 9, 2023
3de6a88
comments
lixun910 Nov 9, 2023
54c5db6
bump loaders.gl to 4.0.3
lixun910 Nov 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/webpack.config.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ function makeLocalDevConfig(env, EXAMPLE_DIR = LIB_DIR, externals = {}) {
use: ['source-map-loader'],
enforce: 'pre',
exclude: [/node_modules\/react-palm/, /node_modules\/react-data-grid/]
},
// for compiling apache-arrow ESM module
{
lixun910 marked this conversation as resolved.
Show resolved Hide resolved
test: /\.mjs$/,
include: /node_modules\/apache-arrow/,
type: 'javascript/auto'
}
]
},
Expand Down
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import '@testing-library/jest-dom';
import * as Utils from '@kepler.gl/utils';
require('@loaders.gl/polyfills');

jest.mock('mapbox-gl/dist/mapbox-gl', () => ({
Map: () => ({})
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"@hubble.gl/core": "1.2.0-alpha.6",
"@hubble.gl/react": "1.2.0-alpha.6",
"@kepler.gl/components": "3.0.0-alpha.1",
"@loaders.gl/polyfills": "^4.0.0",
"@loaders.gl/polyfills": "^4.0.1",
"@types/mapbox__geo-viewport": "^0.4.1",
"@typescript-eslint/parser": "^5.27.0",
"eslint-config-developit": "^1.2.0",
Expand Down Expand Up @@ -140,7 +140,7 @@
"@babel/traverse": "^7.12.1",
"@cfaester/enzyme-adapter-react-18": "^0.7.0",
"@deck.gl/test-utils": "^8.9.12",
"@loaders.gl/polyfills": "^4.0.0",
"@loaders.gl/polyfills": "^4.0.1",
"@luma.gl/test-utils": "^8.5.19",
"@nebula.gl/layers": "1.0.2-alpha.1",
"@probe.gl/env": "^3.5.0",
Expand Down Expand Up @@ -214,12 +214,12 @@
"webpack-stats-plugin": "^0.2.1"
},
"resolutions": {
"@loaders.gl/core": "^4.0.0",
"@loaders.gl/csv": "^4.0.0",
"@loaders.gl/gltf": "^4.0.0",
"@loaders.gl/json": "^4.0.0",
"@loaders.gl/loader-utils": "^4.0.0",
"@loaders.gl/polyfills": "^4.0.0",
"@loaders.gl/core": "^4.0.1",
"@loaders.gl/csv": "^4.0.1",
"@loaders.gl/gltf": "^4.0.1",
"@loaders.gl/json": "^4.0.1",
"@loaders.gl/loader-utils": "^4.0.1",
"@loaders.gl/polyfills": "^4.0.1",
"@luma.gl/constants": "8.5.19",
"@luma.gl/core": "8.5.19",
"@luma.gl/experimental": "8.5.19",
Expand Down
13 changes: 13 additions & 0 deletions src/components/src/side-panel/layer-panel/layer-configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,19 @@ export default function LayerConfiguratorFactory(
);
}

/**
* Render layer configurator for GeoArrow layer (reuse the Geojson layer configurator)
* @param props - LayerConfiguratorProps
* @param props.layer - Layer
* @param props.visConfiguratorProps - VisConfiguratorProps
* @param props.layerConfiguratorProps - LayerConfiguratorProps
* @param props.layerChannelConfigProps - LayerChannelConfigProps
* @returns {JSX.Element} - Layer configurator for GeoArrow layer
*/
_renderGeoarrowLayerConfig(props) {
lixun910 marked this conversation as resolved.
Show resolved Hide resolved
return this._renderGeojsonLayerConfig(props);
}

_render3DLayerConfig({layer, visConfiguratorProps}) {
return (
<Fragment>
Expand Down
21 changes: 19 additions & 2 deletions src/constants/src/default-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ export const ALL_FIELD_TYPES = keyMirror({
timestamp: null,
point: null,
array: null,
object: null
object: null,
geoarrow: null
});

// Data Table
Expand Down Expand Up @@ -509,6 +510,10 @@ export const FIELD_TYPE_DISPLAY = {
label: 'geo',
color: BLUE2
},
[ALL_FIELD_TYPES.geoarrow]: {
label: 'geo',
color: BLUE2
},
[ALL_FIELD_TYPES.integer]: {
label: 'int',
color: YELLOW
Expand Down Expand Up @@ -757,6 +762,17 @@ export const FIELD_OPTS = {
tooltip: []
}
},
[ALL_FIELD_TYPES.geoarrow]: {
type: 'geometry',
scale: {
...notSupportedScaleOpts,
...notSupportAggrOpts
},
format: {
legend: d => '...',
tooltip: []
}
},
[ALL_FIELD_TYPES.object]: {
type: 'numerical',
scale: {},
Expand Down Expand Up @@ -1122,7 +1138,8 @@ export const DATASET_FORMATS = keyMirror({
row: null,
geojson: null,
csv: null,
keplergl: null
keplergl: null,
arrow: null
});

export const MAP_CONTROLS = keyMirror({
Expand Down
1 change: 1 addition & 0 deletions src/constants/src/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ export const LAYER_TYPES = keyMirror({
grid: null,
hexagon: null,
geojson: null,
geoarrow: null,
cluster: null,
icon: null,
heatmap: null,
Expand Down
1 change: 1 addition & 0 deletions src/deckgl-layers/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const PRESETS = ['@babel/preset-env', '@babel/preset-react', '@babel/preset-type
const PLUGINS = [
['@babel/plugin-transform-typescript', {isTSX: true, allowDeclareFields: true}],
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-proposal-class-properties', // for static class properties
'@babel/plugin-proposal-optional-chaining',
[
'@babel/transform-runtime',
Expand Down
57 changes: 57 additions & 0 deletions src/deckgl-layers/src/deckgl-extensions/filter-arrow-layer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {Layer, LayerExtension} from '@deck.gl/core';
import {LayerContext} from '@deck.gl/core/lib/layer';
import GL from '@luma.gl/constants';

import shaderModule from './filter-shader-module';

const VALUE_FILTERED = 1;

const defaultProps = {
getFiltered: {type: 'accessor', value: VALUE_FILTERED}
};

export type FilterArrowExtensionProps = {
getFiltered?: () => number;
};

/**
* FilterArrowExtension - a deck.gl extension to filter arrow layer
*
* A simple extension to filter arrow layer based on the result of CPU filteredIndex,
* so we can avoid filtering on the raw Arrow table and recreating geometry attributes.
* Specifically, an attribute `filtered` is added to the layer to indicate whether the feature has been Filtered
* the shader module is modified to discard the feature if filtered value is 0
* the accessor getFiltered is used to get the value of `filtered` based on the value `filteredIndex` in Arrowlayer
*/
export default class FilterArrowExtension extends LayerExtension {
static defaultProps = defaultProps;
static extensionName = 'FilterArrowExtension';

getShaders(extension: any) {
return {
modules: [shaderModule],
defines: {}
};
}

initializeState(this: Layer<FilterArrowExtensionProps>, context: LayerContext, extension: this) {
const attributeManager = this.getAttributeManager();
if (attributeManager) {
attributeManager.add({
filtered: {
size: 1,
type: GL.FLOAT,
accessor: 'getFiltered',
shaderAttributes: {
filtered: {
divisor: 0
},
instanceFiltered: {
divisor: 1
}
}
}
});
}
}
}
39 changes: 39 additions & 0 deletions src/deckgl-layers/src/deckgl-extensions/filter-shader-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {project} from '@deck.gl/core';

const vs = `
#ifdef NON_INSTANCED_MODEL
#define FILTER_ARROW_ATTRIB filtered
#else
#define FILTER_ARROW_ATTRIB instanceFiltered
#endif
attribute float FILTER_ARROW_ATTRIB;
`;

const fs = ``;

const inject = {
'vs:#decl': `
varying float is_filtered;
`,
'vs:#main-end': `
is_filtered = FILTER_ARROW_ATTRIB;
`,
'fs:#decl': `
varying float is_filtered;
`,
'fs:DECKGL_FILTER_COLOR': `
// abandon the fragments if it is not filtered
if (is_filtered == 0.) {
discard;
}
`
};

export default {
name: 'filter-arrow',
dependencies: [project],
vs: vs,
fs: fs,
inject: inject,
getUniforms: () => {}
};
1 change: 1 addition & 0 deletions src/deckgl-layers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {default as EnhancedGridLayer} from './grid-layer/enhanced-cpu-grid-layer
export {default as EnhancedHexagonLayer} from './hexagon-layer/enhanced-hexagon-layer';
export {default as EnhancedLineLayer} from './line-layer/line-layer';
export {default as SvgIconLayer} from './svg-icon-layer/svg-icon-layer';
export {default as FilterArrowExtension} from './deckgl-extensions/filter-arrow-layer';

export * from './layer-utils/shader-utils';

Expand Down
11 changes: 6 additions & 5 deletions src/layers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
"@kepler.gl/table": "3.0.0-alpha.1",
"@kepler.gl/types": "3.0.0-alpha.1",
"@kepler.gl/utils": "3.0.0-alpha.1",
"@loaders.gl/core": "^4.0.0",
"@loaders.gl/gis": "^4.0.0",
"@loaders.gl/gltf": "^4.0.0",
"@loaders.gl/wkt": "^4.0.0",
"@loaders.gl/arrow": "^4.0.1",
"@loaders.gl/core": "^4.0.1",
"@loaders.gl/gis": "^4.0.1",
"@loaders.gl/gltf": "^4.0.1",
"@loaders.gl/wkt": "^4.0.1",
"@luma.gl/constants": "^8.5.19",
"@mapbox/geojson-normalize": "0.0.1",
"@nebula.gl/layers": "1.0.2-alpha.1",
"@nebula.gl/edit-modes": "1.0.2-alpha.1",
"@nebula.gl/layers": "1.0.2-alpha.1",
"@turf/bbox": "^6.0.1",
"@turf/helpers": "^6.1.4",
"@types/geojson": "^7946.0.7",
Expand Down
5 changes: 4 additions & 1 deletion src/layers/src/base-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,10 @@ class Layer {
const dataUpdateTriggers = this.getDataUpdateTriggers(layerDataset);
const triggerChanged = this.getChangedTriggers(dataUpdateTriggers);

if (triggerChanged && triggerChanged.getMeta) {
// NOTES:
// 1) add checker `oldLayerData`: undefined oldLayerData means this is the first time layer is rendered
// and the updateLayerMeta() has already been called in setInitialLayerConfig
if (triggerChanged && triggerChanged.getMeta && Boolean(oldLayerData)) {
this.updateLayerMeta(dataContainer, getPosition);
}

Expand Down