fix(district): contry layer

This commit is contained in:
thinkinggis 2020-05-27 14:57:09 +08:00
parent 4dc0cfac3c
commit 3aa1c2ef19
4 changed files with 37 additions and 9 deletions

View File

@ -24,7 +24,9 @@ export default class CountryLayer extends BaseLayer {
}
protected async addProvinceFill() {
const { depth } = this.options;
const countryConfig = getDataConfig(this.options.geoDataLevel).CHN[depth];
const countryConfig = getDataConfig(this.options.geoDataLevel).country.CHN[
depth
];
const fillData = await this.fetchData(countryConfig.fill);
this.addFillLayer(fillData);
}

View File

@ -1,10 +1,35 @@
import { sum } from '../src/statistics';
describe('sum', () => {
it('sum string array', () => {
const a = ['1', '2', '3'];
const b = [1, 2, 3];
import { max, mean, min, sum, mode } from '../src/statistics';
const a = ['1', '2', '3'];
const b = [1, 2, 3];
const c = [1, 2, 3, '1', 2, '3', 3];
describe('statistic', () => {
it('sum', () => {
// @ts-ignore
expect(sum(a)).toEqual(6);
expect(sum(b)).toEqual(6);
});
it('max', () => {
// @ts-ignore
expect(max(a)).toEqual(3);
expect(max(b)).toEqual(3);
});
it('min', () => {
// @ts-ignore
expect(min(a)).toEqual(1);
expect(min(b)).toEqual(1);
});
it('mean', () => {
// @ts-ignore
expect(mean(a)).toEqual(2);
// @ts-ignore
expect(mean(b)).toEqual(2);
});
it('mode', () => {
// @ts-ignore
expect(mode(a)).toEqual(1);
expect(mode(c)).toEqual(2);
});
});

View File

@ -14,7 +14,7 @@ function max(x: number[]) {
value = x[i];
}
}
return value;
return value * 1;
}
function min(x: number[]) {
@ -30,7 +30,7 @@ function min(x: number[]) {
value = x[i];
}
}
return value;
return value * 1;
}
function sum(x: number[]) {
@ -81,7 +81,7 @@ function mode(x: any[]) {
seenThis++;
}
}
return value;
return value * 1;
}
export { sum, max, min, mean, mode };

View File

@ -21,6 +21,7 @@ export default class Circle extends React.Component {
}),
});
this.scene = scene;
const line =
scene.on('loaded', () => {
const drawLine = new DrawLine(scene);