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() { protected async addProvinceFill() {
const { depth } = this.options; 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); const fillData = await this.fetchData(countryConfig.fill);
this.addFillLayer(fillData); this.addFillLayer(fillData);
} }

View File

@ -1,10 +1,35 @@
import { sum } from '../src/statistics'; import { max, mean, min, sum, mode } from '../src/statistics';
describe('sum', () => { const a = ['1', '2', '3'];
it('sum string array', () => { const b = [1, 2, 3];
const a = ['1', '2', '3']; const c = [1, 2, 3, '1', 2, '3', 3];
const b = [1, 2, 3]; describe('statistic', () => {
it('sum', () => {
// @ts-ignore // @ts-ignore
expect(sum(a)).toEqual(6); expect(sum(a)).toEqual(6);
expect(sum(b)).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]; value = x[i];
} }
} }
return value; return value * 1;
} }
function min(x: number[]) { function min(x: number[]) {
@ -30,7 +30,7 @@ function min(x: number[]) {
value = x[i]; value = x[i];
} }
} }
return value; return value * 1;
} }
function sum(x: number[]) { function sum(x: number[]) {
@ -81,7 +81,7 @@ function mode(x: any[]) {
seenThis++; seenThis++;
} }
} }
return value; return value * 1;
} }
export { sum, max, min, mean, mode }; export { sum, max, min, mean, mode };

View File

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