From 431f0d752dbca0b5d059ba9a228e8943ddaca74d Mon Sep 17 00:00:00 2001 From: Daniel Bolin Date: Wed, 23 Oct 2024 16:48:57 -0400 Subject: [PATCH] fix(node-dist-vis): Fix edge filtering bug --- libs/node-dist-vis/src/lib/deckgl/edges.ts | 3 ++- libs/node-dist-vis/src/lib/deckgl/nodes.ts | 8 ++++++-- libs/node-dist-vis/src/lib/deckgl/utils/filters.ts | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libs/node-dist-vis/src/lib/deckgl/edges.ts b/libs/node-dist-vis/src/lib/deckgl/edges.ts index 65bd835ff..3b3522a4f 100644 --- a/libs/node-dist-vis/src/lib/deckgl/edges.ts +++ b/libs/node-dist-vis/src/lib/deckgl/edges.ts @@ -39,8 +39,9 @@ export function createEdgesLayer( return createColorAccessor(cellTypeAccessor(), map); }); const filterValueAccessor = computed(() => { + const nodeIndex = edges().getCellIDFor; const filterFn = nodeFilter().includes; - return createNodeFilterAccessor(cellTypeAccessor(), filterFn); + return createNodeFilterAccessor(cellTypeAccessor(), nodeIndex, filterFn); }); return computed(() => { diff --git a/libs/node-dist-vis/src/lib/deckgl/nodes.ts b/libs/node-dist-vis/src/lib/deckgl/nodes.ts index 848ce01d1..d01a5358a 100644 --- a/libs/node-dist-vis/src/lib/deckgl/nodes.ts +++ b/libs/node-dist-vis/src/lib/deckgl/nodes.ts @@ -1,5 +1,5 @@ import { computed, Signal } from '@angular/core'; -import { COORDINATE_SYSTEM } from '@deck.gl/core/typed'; +import { AccessorContext, COORDINATE_SYSTEM } from '@deck.gl/core/typed'; import { DataFilterExtension, DataFilterExtensionProps } from '@deck.gl/extensions/typed'; import { PointCloudLayer } from '@deck.gl/layers/typed'; import { ColorMapView } from '../models/color-map'; @@ -20,6 +20,10 @@ function getNodeSize(mode: ViewMode): number { return mode === 'inspect' ? INSPECT_NODE_SIZE : DEFAULT_NODE_SIZE; } +function getIndex(_obj: unknown, info: AccessorContext): number { + return info.index; +} + export function createNodesLayer( mode: Signal, nodes: Signal, @@ -39,7 +43,7 @@ export function createNodesLayer( const filterValueAccessor = computed(() => { const accessor = nodes().getCellTypeFor; const filterFn = nodeFilter().includes; - return createNodeFilterAccessor(accessor, filterFn); + return createNodeFilterAccessor(accessor, getIndex, filterFn); }); return computed(() => { diff --git a/libs/node-dist-vis/src/lib/deckgl/utils/filters.ts b/libs/node-dist-vis/src/lib/deckgl/utils/filters.ts index 0ae9a469e..e989d4797 100644 --- a/libs/node-dist-vis/src/lib/deckgl/utils/filters.ts +++ b/libs/node-dist-vis/src/lib/deckgl/utils/filters.ts @@ -7,11 +7,13 @@ export const FILTER_RANGE: [number, number] = [0, 2]; export function createNodeFilterAccessor( accessor: AccessorFunction, + indexAccessor: AccessorFunction, filterFn: NodeFilterPredFn, ): AccessorFunction { return (obj, info) => { const type = accessor(obj, info); - const result = filterFn(type, info.index); + const index = indexAccessor(obj, info); + const result = filterFn(type, index); return result ? FILTER_INCLUDE_VALUE : FILTER_EXCLUDE_VALUE; }; }