@@ -4,8 +4,10 @@ import {
44 CompositeLayer ,
55 CompositeLayerProps ,
66 DefaultProps ,
7+ GetPickingInfoParams ,
78 Layer ,
89 LayersList ,
10+ PickingInfo ,
911 Unit ,
1012} from "@deck.gl/core/typed" ;
1113import { PathLayer } from "@deck.gl/layers/typed" ;
@@ -18,6 +20,7 @@ import {
1820 getMultiLineStringChild ,
1921 getMultiLineStringResolvedOffsets ,
2022 getPointChild ,
23+ invertOffsets ,
2124 isLineStringVector ,
2225 isMultiLineStringVector ,
2326 validateColorVector ,
@@ -138,6 +141,37 @@ export class GeoArrowPathLayer<
138141 static defaultProps = defaultProps ;
139142 static layerName = "GeoArrowPathLayer" ;
140143
144+ getPickingInfo ( { info, sourceLayer } : GetPickingInfoParams ) : PickingInfo {
145+ const { data : table } = this . props ;
146+
147+ // Geometry index as rendered
148+ let index = info . index ;
149+
150+ // if a MultiLineString dataset, map from the rendered index back to the
151+ // feature index
152+ // @ts -expect-error `invertedGeomOffsets` is manually set on layer props
153+ if ( sourceLayer . props . invertedGeomOffsets ) {
154+ // @ts -expect-error `invertedGeomOffsets` is manually set on layer props
155+ index = sourceLayer . props . invertedGeomOffsets [ index ] ;
156+ }
157+
158+ // @ts -expect-error `recordBatchIdx` is manually set on layer props
159+ const recordBatchIdx : number = sourceLayer . props . recordBatchIdx ;
160+ const batch = table . batches [ recordBatchIdx ] ;
161+ const row = batch . get ( index ) ;
162+
163+ // @ts -expect-error hack: using private method to avoid recomputing via
164+ // batch lengths on each iteration
165+ const offsets : number [ ] = table . _offsets ;
166+ const currentBatchOffset = offsets [ recordBatchIdx ] ;
167+
168+ info . object = row ;
169+ // Update index to be _global_ index, not within the specific record batch
170+ index += currentBatchOffset ;
171+ info . index = index ;
172+ return info ;
173+ }
174+
141175 renderLayers ( ) : Layer < { } > | LayersList | null {
142176 const { data : table } = this . props ;
143177
@@ -206,6 +240,9 @@ export class GeoArrowPathLayer<
206240 const flatCoordinateArray = coordData . values ;
207241
208242 const props : PathLayerProps = {
243+ // used for picking purposes
244+ recordBatchIdx,
245+
209246 id : `${ this . props . id } -geoarrow-path-${ recordBatchIdx } ` ,
210247 widthUnits : this . props . widthUnits ,
211248 widthScale : this . props . widthScale ,
@@ -282,6 +319,7 @@ export class GeoArrowPathLayer<
282319 const pointData = getLineStringChild ( lineStringData ) ;
283320 const coordData = getPointChild ( pointData ) ;
284321
322+ const geomOffsets = multiLineStringData . valueOffsets ;
285323 const ringOffsets = lineStringData . valueOffsets ;
286324
287325 const nDim = pointData . type . listSize ;
@@ -290,6 +328,10 @@ export class GeoArrowPathLayer<
290328 getMultiLineStringResolvedOffsets ( multiLineStringData ) ;
291329
292330 const props : PathLayerProps = {
331+ // used for picking purposes
332+ recordBatchIdx,
333+ invertedGeomOffsets : invertOffsets ( geomOffsets ) ,
334+
293335 id : `${ this . props . id } -geoarrow-path-${ recordBatchIdx } ` ,
294336 widthUnits : this . props . widthUnits ,
295337 widthScale : this . props . widthScale ,
0 commit comments