@@ -12,7 +12,7 @@ import {
12
12
PathLayer ,
13
13
ScatterplotLayer ,
14
14
} from "@deck.gl/layers"
15
- import useStartTask from "./log"
15
+ import useStartTaskLog from "./log"
16
16
import { bboxPolygon } from "@turf/turf"
17
17
18
18
export function useFitBoundsOnChange ( bbox ?: GeoBbox2D ) {
@@ -85,7 +85,7 @@ export function useBitmapTileLayer(osm?: Osm | null) {
85
85
}
86
86
87
87
export function usePickableOsmTileLayer ( osm ?: Osm | null ) {
88
- const startTask = useStartTask ( )
88
+ const startTaskLog = useStartTaskLog ( )
89
89
const osmWorker = useOsmWorker ( )
90
90
91
91
const [ selectedEntity , setSelectedEntity ] = useAtom ( selectedEntityAtom )
@@ -102,7 +102,7 @@ export function usePickableOsmTileLayer(osm?: Osm | null) {
102
102
extent : bbox ,
103
103
getTileData : async ( tile ) => {
104
104
if ( tile . index . z < MIN_PICKABLE_ZOOM ) {
105
- const task = startTask (
105
+ const taskLog = startTaskLog (
106
106
`generating bitmap for tile ${ tile . index . z } /${ tile . index . x } /${ tile . index . y } ` ,
107
107
"debug" ,
108
108
)
@@ -113,7 +113,7 @@ export function usePickableOsmTileLayer(osm?: Osm | null) {
113
113
tile . index ,
114
114
BITMAP_TILE_SIZE ,
115
115
)
116
- task . end (
116
+ taskLog . end (
117
117
`bitmap for tile ${ tile . index . z } /${ tile . index . x } /${ tile . index . y } generated` ,
118
118
"debug" ,
119
119
)
@@ -122,7 +122,7 @@ export function usePickableOsmTileLayer(osm?: Osm | null) {
122
122
123
123
// Show pickable data
124
124
const bbox = tile . bbox as GeoBoundingBox
125
- const task = startTask (
125
+ const taskLog = startTaskLog (
126
126
`generating data for tile ${ tile . index . z } /${ tile . index . x } /${ tile . index . y } ` ,
127
127
"debug" ,
128
128
)
@@ -132,7 +132,7 @@ export function usePickableOsmTileLayer(osm?: Osm | null) {
132
132
bbox . east ,
133
133
bbox . north ,
134
134
] )
135
- task . end (
135
+ taskLog . end (
136
136
`tile data for ${ tile . index . z } /${ tile . index . x } /${ tile . index . y } generated` ,
137
137
"debug" ,
138
138
)
@@ -174,38 +174,6 @@ export function usePickableOsmTileLayer(osm?: Osm | null) {
174
174
)
175
175
}
176
176
177
- if ( "nodes" in data ) {
178
- layers . push (
179
- new ScatterplotLayer ( {
180
- id : `${ tilePrefix } :nodes` ,
181
- data : {
182
- length : data . nodes . positions . length / 2 ,
183
- attributes : {
184
- getPosition : { value : data . nodes . positions , size : 2 } ,
185
- ids : data . nodes . ids ,
186
- } ,
187
- } ,
188
- pickable : true ,
189
- autoHighlight : true ,
190
- radiusUnits : "meters" ,
191
- getRadius : 3 ,
192
- radiusMinPixels : 1 ,
193
- radiusMaxPixels : 10 ,
194
- getFillColor : [ 255 , 255 , 255 , 255 ] ,
195
- highlightColor : [ 255 , 0 , 0 , 255 * 0.5 ] ,
196
- onClick : ( info ) => {
197
- console . log ( "ScatterplotLayer.onClick" , info )
198
- if ( info . picked ) {
199
- const nodeId = data . nodes . ids . at ( info . index )
200
- if ( nodeId ) {
201
- setSelectedEntity ( osm . nodes . getById ( nodeId ) )
202
- }
203
- return true
204
- }
205
- } ,
206
- } ) ,
207
- )
208
- }
209
177
if ( "ways" in data ) {
210
178
layers . push (
211
179
new PathLayer ( {
@@ -239,6 +207,40 @@ export function usePickableOsmTileLayer(osm?: Osm | null) {
239
207
)
240
208
}
241
209
210
+ if ( "nodes" in data ) {
211
+ layers . push (
212
+ new ScatterplotLayer ( {
213
+ id : `${ tilePrefix } :nodes` ,
214
+ data : {
215
+ length : data . nodes . positions . length / 2 ,
216
+ attributes : {
217
+ getPosition : { value : data . nodes . positions , size : 2 } ,
218
+ } ,
219
+ } ,
220
+ pickable : true ,
221
+ autoHighlight : true ,
222
+ radiusUnits : "meters" ,
223
+ getRadius : 3 ,
224
+ radiusMinPixels : 1 ,
225
+ radiusMaxPixels : 10 ,
226
+ getFillColor : [ 255 , 255 , 255 , 255 ] ,
227
+ highlightColor : [ 255 , 0 , 0 , 255 * 0.5 ] ,
228
+ onClick : ( info ) => {
229
+ if ( info . picked ) {
230
+ const nodeId = data . nodes . ids . at ( info . index )
231
+ console . log ( "ScatterplotLayer.onClick" , nodeId , info )
232
+ if ( nodeId ) {
233
+ setSelectedEntity ( osm . nodes . getById ( nodeId ) )
234
+ } else {
235
+ setSelectedEntity ( null )
236
+ }
237
+ return true
238
+ }
239
+ } ,
240
+ } ) ,
241
+ )
242
+ }
243
+
242
244
if (
243
245
process . env . NODE_ENV === "development" &&
244
246
tile . bbox &&
@@ -263,7 +265,7 @@ export function usePickableOsmTileLayer(osm?: Osm | null) {
263
265
return layers
264
266
} ,
265
267
} )
266
- } , [ osm , osmWorker , setSelectedEntity , startTask ] )
268
+ } , [ osm , osmWorker , setSelectedEntity , startTaskLog ] )
267
269
268
270
return {
269
271
layer,
0 commit comments