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

(WIP) [feat] emulate geoarrow.wkb and geoarrow.linestring support in trip layer #2940

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
39 changes: 22 additions & 17 deletions src/layers/src/geojson-layer/geojson-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
ProtoDatasetField,
LayerColumn
} from '@kepler.gl/types';
import {KeplerTable} from '@kepler.gl/table';
import {KeplerTable, Datasets} from '@kepler.gl/table';
import {DataContainerInterface, ArrowDataContainer} from '@kepler.gl/utils';
import {FilterArrowExtension} from '@kepler.gl/deckgl-layers';
import GeojsonInfoModalFactory from './geojson-info-modal';
Expand Down Expand Up @@ -182,7 +182,7 @@ type ObjectInfo = {
export const featureAccessor =
({geojson}: GeoJsonLayerColumnsConfig) =>
(dc: DataContainerInterface) =>
d =>
(d: {index: number}) =>
dc.valueAt(d.index, geojson.fieldIdx);

const geoColumnAccessor =
Expand Down Expand Up @@ -232,15 +232,17 @@ const SUPPORTED_COLUMN_MODES = [
const DEFAULT_COLUMN_MODE = COLUMN_MODE_GEOJSON;

export default class GeoJsonLayer extends Layer {
declare config: GeoJsonLayerConfig;
declare visConfigSettings: GeoJsonVisConfigSettings;
declare config: GeoJsonLayerConfig;
declare meta: GeoJsonLayerMeta;
declare geoArrowMode: boolean;

dataToFeature: GeojsonDataMaps = [];
dataContainer: DataContainerInterface | null = null;

filteredIndex: Uint8ClampedArray | null = null;
filteredIndexTrigger: number[] | null = null;

centroids: Array<number[] | null> = [];

_layerInfoModal: {
Expand All @@ -250,23 +252,28 @@ export default class GeoJsonLayer extends Layer {

constructor(props) {
super(props);

this.registerVisConfig(geojsonVisConfigs);
this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
featureAccessor(this.config.columns)(dataContainer);
this._layerInfoModal = {
[COLUMN_MODE_TABLE]: GeojsonInfoModalFactory(COLUMN_MODE_TABLE),
[COLUMN_MODE_GEOJSON]: GeojsonInfoModalFactory(COLUMN_MODE_GEOJSON)
};

this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
featureAccessor(this.config.columns)(dataContainer);
}

get type() {
return GeoJsonLayer.type;
get supportedColumnModes() {
return SUPPORTED_COLUMN_MODES;
}

static get type(): 'geojson' {
return 'geojson';
}

get type() {
return GeoJsonLayer.type;
}

get name(): 'Polygon' {
return 'Polygon';
}
Expand All @@ -279,10 +286,6 @@ export default class GeoJsonLayer extends Layer {
return this.defaultPointColumnPairs;
}

get supportedColumnModes() {
return SUPPORTED_COLUMN_MODES;
}

get layerInfoModal() {
return {
[COLUMN_MODE_GEOJSON]: {
Expand Down Expand Up @@ -501,7 +504,7 @@ export default class GeoJsonLayer extends Layer {
}
}

formatLayerData(datasets, oldLayerData) {
formatLayerData(datasets: Datasets, oldLayerData) {
if (this.config.dataId === null) {
return {};
}
Expand All @@ -525,12 +528,14 @@ export default class GeoJsonLayer extends Layer {
return this.filteredIndex ? this.filteredIndex[d.properties.index] : 1;
};

const getFilterValue = gpuFilter.filterValueAccessor(dataContainer)(
indexAccessor,
filterValueAccessor
);

return {
data,
getFilterValue: gpuFilter.filterValueAccessor(dataContainer)(
indexAccessor,
filterValueAccessor
),
getFilterValue,
getFiltered: isFilteredAccessor,
...accessors
};
Expand Down
6 changes: 4 additions & 2 deletions src/layers/src/geojson-layer/geojson-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,19 @@ export function parseGeoJsonRawFeature(rawFeature: unknown): Feature | null {
export function getGeojsonLayerMeta({
dataContainer,
getFeature,
config
config,
sortByColumn
}: {
dataContainer: DataContainerInterface;
getFeature: GetFeature;
config: LayerBaseConfig;
sortByColumn?: string;
}): GeojsonLayerMetaProps {
const dataToFeature =
config.columnMode === COLUMN_MODE_GEOJSON
? getGeojsonDataMaps(dataContainer, getFeature)
: // COLUMN_MODE_TABLE
groupColumnsAsGeoJson(dataContainer, config.columns, 'sortBy');
groupColumnsAsGeoJson(dataContainer, config.columns, sortByColumn || 'sortBy');

// get bounds from features
const bounds = getGeojsonBounds(dataToFeature);
Expand Down
Loading
Loading