@@ -9,14 +9,14 @@ import {GeoJsonLayer} from '@deck.gl/layers';
9
9
import type { TilejsonResult } from '@carto/api-client' ;
10
10
import VectorTileLayer from './vector-tile-layer' ;
11
11
import { transformTrajectoryData , type TileBounds , normalizeTimestamp } from './trajectory-utils' ;
12
- import { applyTrajectoryColors } from './trajectory-speed-utils' ;
12
+ import { autocomputeSpeed } from './trajectory-speed-utils' ;
13
13
import { createBinaryProxy , createEmptyBinary } from '../utils' ;
14
14
15
15
const defaultProps : DefaultProps < TrajectoryTileLayerProps > = {
16
16
...TripsLayer . defaultProps ,
17
17
data : VectorTileLayer . defaultProps . data ,
18
+ autocomputeSpeed : false ,
18
19
renderMode : 'trips' ,
19
- palette : 'Sunset' ,
20
20
fadeTrail : true ,
21
21
currentTime : 0 ,
22
22
trailLength : 1000
@@ -30,31 +30,17 @@ export type TrajectoryTileLayerProps<FeaturePropertiesT = unknown> = _Trajectory
30
30
type _TrajectoryTileLayerProps = {
31
31
data : null | TilejsonResult | Promise < TilejsonResult > ;
32
32
33
+ /**
34
+ * Set to true to automatically compute speed for each vertex and store in properties.speed
35
+ */
36
+ autocomputeSpeed ?: boolean ;
37
+
33
38
/**
34
39
* Rendering mode for trajectories.
35
40
* - 'paths': Static path rendering
36
41
* - 'trips': Animated trip rendering with time controls
37
42
*/
38
43
renderMode ?: 'paths' | 'trips' ;
39
-
40
- /**
41
- * Color palette for trajectory visualization (deprecated - use getVertexColor instead)
42
- */
43
- palette ?: string ;
44
-
45
- /**
46
- * Accessor function to get color for each vertex based on calculated attributes
47
- * Receives an object with calculated properties (e.g., speed) and should return RGBA color array
48
- * @param vertexData - Object containing calculated attributes like {speed: number}
49
- * @param info - Additional info object with index, data, target properties
50
- * @returns RGBA color array [r, g, b, a] where values are 0-255
51
- */
52
- getVertexColor ?: ( vertexData : { speed : number } , info : { index : number ; data : any [ ] ; target : any [ ] } ) => [ number , number , number , number ] ;
53
-
54
- /**
55
- * Outline color for the trajectory
56
- */
57
- outline ?: 'white' | 'black' | 'none' ;
58
44
} ;
59
45
60
46
// @ts -ignore
@@ -120,10 +106,9 @@ export default class TrajectoryTileLayer<
120
106
121
107
if ( ! lines ) return null ;
122
108
123
- // Optionally apply vertex colors
124
- //if (this.props.getVertexColor) {
125
- applyTrajectoryColors ( lines , this . props . getVertexColor ) ;
126
- //}
109
+ if ( this . props . autocomputeSpeed ) {
110
+ autocomputeSpeed ( lines ) ;
111
+ }
127
112
128
113
return { ...createEmptyBinary ( ) , lines }
129
114
}
@@ -157,7 +142,6 @@ export default class TrajectoryTileLayer<
157
142
lineJointRounded : props . jointRounded !== undefined ? props . jointRounded : true ,
158
143
capRounded : props . capRounded !== undefined ? props . capRounded : true ,
159
144
_pathType : props . _pathType || 'open' ,
160
- outline : props . outline || 'none'
161
145
} ;
162
146
163
147
const { minTime, maxTime} = this . state ;
0 commit comments