Skip to content

Commit

Permalink
[Bug] Fixed bug with fixed radius after remove size field in pointlay…
Browse files Browse the repository at this point in the history
…er (#1343)

Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
  • Loading branch information
heshan0131 committed Dec 7, 2020
1 parent 32d8018 commit 2ea853b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/layers/point-layer/point-layer.js
Expand Up @@ -228,7 +228,10 @@ export default class PointLayer extends Layer {

renderLayer(opts) {
const {data, gpuFilter, objectHovered, mapState, interactionConfig} = opts;
const radiusScale = this.getRadiusScaleByZoom(mapState);

// if no field size is defined we need to pass fixed radius = false
const fixedRadius = this.config.visConfig.fixedRadius && Boolean(this.config.sizeField);
const radiusScale = this.getRadiusScaleByZoom(mapState, fixedRadius);

const layerProps = {
stroked: this.config.visConfig.outline,
Expand Down
66 changes: 66 additions & 0 deletions test/browser/layer-tests/point-layer-specs.js
Expand Up @@ -395,6 +395,72 @@ test('#PointLayer -> formatLayerData', t => {
'getRadius should return corrent radius'
);
}
},
{
name: 'Test gps point.2 Data with fixed radius and null SizeField',
layer: {
type: 'point',
id: 'test_layer_2',
config: {
dataId,
label: 'some point file',
columns: {
lat: 'lat',
lng: 'lng'
},
color: [10, 10, 10],
visConfig: {
outline: true,
fixedRadius: true
},
// size by id(integer)
sizeField: null
}
},
datasets: {
[dataId]: {
...preparedDataset,
filteredIndex
}
},
assert: result => {
const {layerData, layer} = result;

const expectedLayerData = {
data: [
{
data: testRows[0],
index: 0,
position: [testRows[0][2], testRows[0][1], 0]
},
{
data: testRows[4],
index: 4,
position: [testRows[4][2], testRows[4][1], 0]
}
],
getFilterValue: () => {},
getLineColor: () => {},
getFillColor: () => {},
getRadius: () => {},
getPosition: () => {},
textLabels: []
};

t.deepEqual(
Object.keys(layerData).sort(),
Object.keys(expectedLayerData).sort(),
'layerData should have 6 keys'
);
t.deepEqual(
layerData.data,
expectedLayerData.data,
'should format correct point layerData data'
);
t.deepEqual(layer.config.sizeDomain, [0, 1], 'should update layer sizeDomain');
// getRadius should be a constant because sizeField is null
t.equal(layerData.getRadius, 1, 'getRadius should return current radius');
}
}
];

Expand Down

0 comments on commit 2ea853b

Please sign in to comment.