in src/layers/geojson-layer/geojson-layer.js [192:280]
formatLayerData(datasets, oldLayerData, opt = {}) {
const {
colorScale,
colorField,
colorDomain,
strokeColorField,
strokeColorScale,
strokeColorDomain,
color,
sizeScale,
sizeDomain,
sizeField,
heightField,
heightDomain,
heightScale,
radiusField,
radiusDomain,
radiusScale,
visConfig
} = this.config;
const {
enable3d,
stroked,
colorRange,
heightRange,
sizeRange,
radiusRange,
strokeColorRange,
strokeColor
} = visConfig;
const {allData, gpuFilter} = datasets[this.config.dataId];
const {data} = this.updateData(datasets, oldLayerData);
// fill color
const cScale =
colorField &&
this.getVisChannelScale(colorScale, colorDomain, colorRange.colors.map(hexToRgb));
// stroke color
const scScale =
strokeColorField &&
this.getVisChannelScale(
strokeColorScale,
strokeColorDomain,
strokeColorRange.colors.map(hexToRgb)
);
// calculate stroke scale - if stroked = true
const sScale =
sizeField && stroked && this.getVisChannelScale(sizeScale, sizeDomain, sizeRange);
// calculate elevation scale - if extruded = true
const eScale =
heightField && enable3d && this.getVisChannelScale(heightScale, heightDomain, heightRange);
// point radius
const rScale = radiusField && this.getVisChannelScale(radiusScale, radiusDomain, radiusRange);
// access feature properties from geojson sub layer
const getDataForGpuFilter = f => allData[f.properties.index];
const getIndexForGpuFilter = f => f.properties.index;
return {
data,
getFilterValue: gpuFilter.filterValueAccessor(getIndexForGpuFilter, getDataForGpuFilter),
getFillColor: d =>
cScale
? this.getEncodedChannelValue(cScale, allData[d.properties.index], colorField)
: d.properties.fillColor || color,
getLineColor: d =>
scScale
? this.getEncodedChannelValue(scScale, allData[d.properties.index], strokeColorField)
: d.properties.lineColor || strokeColor || color,
getLineWidth: d =>
sScale
? this.getEncodedChannelValue(sScale, allData[d.properties.index], sizeField, 0)
: d.properties.lineWidth || defaultLineWidth,
getElevation: d =>
eScale
? this.getEncodedChannelValue(eScale, allData[d.properties.index], heightField, 0)
: d.properties.elevation || defaultElevation,
getRadius: d =>
rScale
? this.getEncodedChannelValue(rScale, allData[d.properties.index], radiusField, 0)
: d.properties.radius || defaultRadius
};
}