@@ -6,6 +6,7 @@ import GL from "@luma.gl/constants";
6
6
import { Texture2D } from "@luma.gl/core" ;
7
7
import { DeckGLLayerContext } from "../../components/Map" ;
8
8
import { colorTablesArray , rgbValues } from "@emerson-eps/color-tables/" ;
9
+ import { createPropertyData , PropertyDataType } from "../utils/layerTools" ;
9
10
10
11
const DEFAULT_TEXTURE_PARAMETERS = {
11
12
[ GL . TEXTURE_MIN_FILTER ] : GL . LINEAR_MIPMAP_LINEAR ,
@@ -177,27 +178,41 @@ export default class TerrainMapLayer extends SimpleMeshLayer<
177
178
const r = info . color [ 0 ] * DECODER . rScaler ;
178
179
const g = info . color [ 1 ] * DECODER . gScaler ;
179
180
const b = info . color [ 2 ] * DECODER . bScaler ;
181
+ const value = r + g + b ;
180
182
181
- const floatScaler = 1.0 / ( 256.0 * 256.0 * 256.0 - 1.0 ) ;
183
+ let depth = undefined ;
184
+ const layer_properties : PropertyDataType [ ] = [ ] ;
182
185
183
- const isPropertyReadout = ! this . props . isReadoutDepth ; // Either map properties or map depths are encoded here.
184
- let value = ( r + g + b ) * ( isPropertyReadout ? floatScaler : 1.0 ) ;
185
-
186
- if ( isPropertyReadout ) {
187
- // Remap the [0, 1] decoded value to property value range.
188
- const [ min , max ] = this . props . propertyValueRange ;
189
- value = value * ( max - min ) + min ;
190
- }
191
-
192
- const valueString =
193
- ( isPropertyReadout ? "Property: " : "Depth: " ) + value . toFixed ( 1 ) ;
186
+ // Either map properties or map depths are encoded here.
187
+ if ( this . props . isReadoutDepth ) depth = value . toFixed ( 2 ) ;
188
+ else
189
+ layer_properties . push (
190
+ getMapProperty ( value , this . props . propertyValueRange )
191
+ ) ;
194
192
195
193
return {
196
194
...info ,
197
- propertyValue : valueString ,
195
+ properties : layer_properties ,
196
+ propertyValue : depth ,
198
197
} ;
199
198
}
200
199
}
201
200
202
201
TerrainMapLayer . layerName = "TerrainMapLayer" ;
203
202
TerrainMapLayer . defaultProps = defaultProps ;
203
+
204
+ //================= Local help functions. ==================
205
+
206
+ function getMapProperty (
207
+ value : number ,
208
+ value_range : [ number , number ]
209
+ ) : PropertyDataType {
210
+ // Remap the [0, 1] decoded value to property value range.
211
+ const [ min , max ] = value_range ;
212
+
213
+ const floatScaler = 1.0 / ( 256.0 * 256.0 * 256.0 - 1.0 ) ;
214
+ const scaled_value = value * floatScaler ;
215
+
216
+ value = scaled_value * ( max - min ) + min ;
217
+ return createPropertyData ( "Property" , value ) ;
218
+ }
0 commit comments