mirror of https://gitee.com/antv-l7/antv-l7
fix(lint): lint warning
This commit is contained in:
parent
74332619ce
commit
34df410b1c
|
@ -44,6 +44,7 @@
|
|||
"error",
|
||||
"never"
|
||||
],
|
||||
"jsdoc/require-param": 0,
|
||||
"linebreak-style": [
|
||||
0
|
||||
]
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
"shelljs": "~0.7.8",
|
||||
"string-replace-loader": "~1.3.0",
|
||||
"torchjs": "~2.1.0",
|
||||
"uglify-js": "~3.1.10",
|
||||
"uglify-js": "~3.1.10"
|
||||
},
|
||||
"scripts": {
|
||||
"build-dev": "rollup -c --environment BUILD:dev",
|
||||
|
@ -130,7 +130,6 @@
|
|||
"simple-statistics": "^7.0.1",
|
||||
"supercluster": "^6.0.1",
|
||||
"three": "^0.101.1",
|
||||
"venn.js": "^0.2.20",
|
||||
"viewport-mercator-project": "^5.2.0",
|
||||
"webworkify-webpack": "^2.1.3",
|
||||
"wolfy87-eventemitter": "~5.2.4"
|
||||
|
|
|
@ -156,7 +156,7 @@ class AttributeBase {
|
|||
|
||||
/**
|
||||
* 映射数据
|
||||
* @param {*} param1...paramn 多个数值
|
||||
* @param {*} params 多个数值
|
||||
* @return {Array} 映射的值组成的数组
|
||||
*/
|
||||
mapping(...params) {
|
||||
|
|
|
@ -14,16 +14,19 @@ export default class Mapping {
|
|||
if (!this.mesh) this.mesh = this.layer;
|
||||
this._init();
|
||||
}
|
||||
|
||||
_init() {
|
||||
this._initControllers();
|
||||
this._initTileAttrs();
|
||||
this._mapping();
|
||||
}
|
||||
|
||||
update() {
|
||||
this.mesh.set('scales', {});
|
||||
this._initTileAttrs();
|
||||
this._updateMaping();
|
||||
}
|
||||
|
||||
_initControllers() {
|
||||
const scalesOption = this.layer.get('scaleOptions');
|
||||
const scaleController = new ScaleController({
|
||||
|
@ -33,6 +36,7 @@ export default class Mapping {
|
|||
});
|
||||
this.mesh.set('scaleController', scaleController);
|
||||
}
|
||||
|
||||
_createScale(field) {
|
||||
const scales = this.mesh.get('scales');
|
||||
this._initControllers(); // scale更新
|
||||
|
@ -43,6 +47,7 @@ export default class Mapping {
|
|||
}
|
||||
return scale;
|
||||
}
|
||||
|
||||
createScale(field) {
|
||||
const data = this.mesh.layerSource.data.dataArray;
|
||||
const scales = this.mesh.get('scales');
|
||||
|
@ -72,6 +77,7 @@ export default class Mapping {
|
|||
const values = attr.mapping(...params);
|
||||
return values;
|
||||
}
|
||||
|
||||
_mapping() {
|
||||
const attrs = this.mesh.get('attrs');
|
||||
const mappedData = [];
|
||||
|
@ -112,11 +118,6 @@ export default class Mapping {
|
|||
this.mesh.layerData = mappedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据maping
|
||||
* @param {*} layerSource 数据源
|
||||
* @param {*} layer map
|
||||
*/
|
||||
_updateMaping() {
|
||||
const attrs = this.mesh.get('attrs');
|
||||
|
||||
|
|
|
@ -107,11 +107,6 @@ export default class TileMapping extends Base {
|
|||
this.layerData = mappedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据maping
|
||||
* @param {*} layerSource 数据源
|
||||
* @param {*} layer map
|
||||
*/
|
||||
_updateMaping() {
|
||||
const attrs = this.get('attrs');
|
||||
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
class WorkerPool {
|
||||
constructor(workerCount) {
|
||||
this.workerCount = workerCount || Math.max(Math.floor(window.navigator.hardwareConcurrency / 2), 1);
|
||||
this.workers = []; // worker线程池
|
||||
this.workerQueue = []; // 任务队列
|
||||
this._initWorker(); // 初始化线程池
|
||||
}
|
||||
_initWorker() {
|
||||
while (this.workers.length < this.workerCount) {
|
||||
this.workers.push(new Worker());
|
||||
}
|
||||
}
|
||||
runTask(payload) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.workers.length > 0) {
|
||||
const worker = this.workers.shift(); // 从线程池取出一个worker
|
||||
worker.postMessage(payload); // 向线程发送数据
|
||||
const workerCallback = e => {
|
||||
resolve(e.data); // 成功则返回数据
|
||||
// 移除事件监听
|
||||
worker.removeEventListener('message', workerCallback);
|
||||
// 重新放回线程池
|
||||
this.workers.push(worker);
|
||||
// 如果任务队列的数据还有则从任务队列继续取数据执行任务
|
||||
if (this.workerQueue.length > 0) {
|
||||
const queueData = this.workerQueue.shift();
|
||||
this.runTask(queueData.payload).then(data => {
|
||||
queueData.resolve(data);
|
||||
});
|
||||
}
|
||||
};
|
||||
// 监听worker事件
|
||||
worker.addEventListener('message', workerCallback);
|
||||
worker.addEventListener('error', e => {
|
||||
reject('filename:' + e.filename + '\nmessage:' + e.message + '\nlineno:' + e.lineno);
|
||||
});
|
||||
} else {
|
||||
// 如果线程池都被占用,则将数据丢入任务队列,并保存对应的resolve和reject
|
||||
this.workerQueue.push({
|
||||
payload,
|
||||
resolve,
|
||||
reject
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
release() {
|
||||
this.workers.forEach(worker => {
|
||||
worker.terminate();
|
||||
});
|
||||
}
|
||||
}
|
||||
export default WorkerPool;
|
|
@ -11,7 +11,6 @@ export function circle(type) {
|
|||
}
|
||||
/**
|
||||
* @param {enum} type 渲染类型
|
||||
* @param {boolean} extrude 是否进行高度拉伸
|
||||
* @return {object} 顶点坐标和索引坐标
|
||||
*/
|
||||
export function triangle(type) {
|
||||
|
@ -21,7 +20,6 @@ export function triangle(type) {
|
|||
|
||||
/**
|
||||
* @param {enum} type 渲染类型
|
||||
* @param {boolean} extrude 是否进行高度拉伸
|
||||
* @return {object} 顶点坐标和索引坐标
|
||||
*/
|
||||
export function diamond(type) {
|
||||
|
@ -35,7 +33,6 @@ export function square(type) {
|
|||
|
||||
/**
|
||||
* @param {enum} type 渲染类型
|
||||
* @param {boolean} extrude 是否进行高度拉伸
|
||||
* @return {object} 顶点坐标和索引坐标
|
||||
*/
|
||||
export function hexagon(type) {
|
||||
|
|
|
@ -2,7 +2,6 @@ import extrudePolygon from '../extrude';
|
|||
/**
|
||||
* 计算平面的 polygon的顶点坐标和索引
|
||||
* @param {Array} points 顶点坐标
|
||||
* @param {*} extrude 是否拉伸
|
||||
* @return {object} 顶点坐标和顶点索引
|
||||
*/
|
||||
export function fill(points) {
|
||||
|
@ -12,7 +11,6 @@ export function fill(points) {
|
|||
/**
|
||||
* 计算 extrude 的 polygon的顶点坐标和索引
|
||||
* @param {Array} points 顶点坐标
|
||||
* @param {*} extrude 是否拉伸
|
||||
* @return {object} 顶点坐标和顶点索引
|
||||
*/
|
||||
export function extrude(points) {
|
||||
|
|
|
@ -64,23 +64,6 @@ class Base {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取该度量的ticks,返回的是多个对象,
|
||||
* - text: tick 的文本
|
||||
* - value: 对应的度量转换后的值
|
||||
* <code>
|
||||
* [
|
||||
* {text: 0,value:0}
|
||||
* {text: 1,value:0.2}
|
||||
* {text: 2,value:0.4}
|
||||
* {text: 3,value:0.6}
|
||||
* {text: 4,value:0.8}
|
||||
* {text: 5,value:1}
|
||||
* ]
|
||||
* </code>
|
||||
* @param {Number} count 输出tick的个数的近似值,默认是 10
|
||||
* @return {Array} 返回 ticks 数组
|
||||
*/
|
||||
getTicks() {
|
||||
const self = this;
|
||||
const ticks = self.ticks;
|
||||
|
@ -172,7 +155,6 @@ class Base {
|
|||
/**
|
||||
* 更改度量的属性信息
|
||||
* @param {Object} info 属性信息
|
||||
* @chainable
|
||||
* @return {Scale} 返回自身的引用
|
||||
*/
|
||||
change(info) {
|
||||
|
|
Loading…
Reference in New Issue