fix(lint): lint warning

This commit is contained in:
thinkinggis 2019-08-07 19:18:36 +08:00
parent 74332619ce
commit 34df410b1c
24 changed files with 36 additions and 116 deletions

View File

@ -44,6 +44,7 @@
"error",
"never"
],
"jsdoc/require-param": 0,
"linebreak-style": [
0
]

View File

@ -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"

View File

@ -14,8 +14,8 @@ const production = BUILD === 'production';
const outputFile = !production
? 'build/L7.js'
: minified
? 'build/L7-min.js'
: 'build/L7-unminified.js';
? 'build/L7-min.js'
: 'build/L7-unminified.js';
const config = [
{

View File

@ -156,7 +156,7 @@ class AttributeBase {
/**
* 映射数据
* @param {*} param1...paramn 多个数值
* @param {*} params 多个数值
* @return {Array} 映射的值组成的数组
*/
mapping(...params) {

View File

@ -37,7 +37,7 @@ export default class Popup extends Base {
this._container.appendChild(this._content);
if (this.get('className')) {
this.get('className').split(' ').forEach(name =>
this._container.classList.add(name));
this._container.classList.add(name));
}
}
if (this.get('maxWidth') && this._container.style.maxWidth !== this.get('maxWidth')) {

View File

@ -3,7 +3,7 @@ import Global from '../../global';
import ScaleController from './scale';
import Attr from '../../attr/index';
export default class Mapping {
/** mapping
/** mapping
* 初始化mapping
* @param {*} cfg 配置
* @param {*} cfg.layer layer对象
@ -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');

View File

@ -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');

View File

@ -182,7 +182,7 @@ export default class Scene extends Base {
this.map.off('mapmove', this._updateRender);
this.map.off('camerachange', this._updateRender);
}
// control
// control
addControl(ctr) {
this.get('controlController').addControl(ctr);

View File

@ -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;

View File

@ -112,7 +112,7 @@ export default class BufferBase extends Base {
prePoint[0], prePoint[1], 0,
nextPoint[0], nextPoint[1], 0
],
positionOffset * 3);
positionOffset * 3);
const indexArray = [ 1, 2, 0, 3, 2, 1 ].map(v => { return v + positionOffset; });
if (this.get('uv')) {
this.attributes.uv.set([ 0.1, 0, 0, 0, 0.1, size / 2000, 0, size / 2000 ], positionOffset * 2);

View File

@ -41,7 +41,7 @@ export default class Grid3D extends BufferBase {
this._encodeArray(feature, 4);
this.attributes.positions.set([ x, y, size, x, y, size, x, y, size, x, y, size ], this._offset * 3);
this.attributes.miters.set([ -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1 ], this._offset * 3);
this.attributes.normals.set([ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ], this._offset * 3); // top normal
this.attributes.normals.set([ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ], this._offset * 3); // top normal
const indexArray = [ 0, 2, 1, 2, 3, 1 ].map(v => { return v + this._offset; });
this.indexArray.set(indexArray, this._offset * 1.5);
this._offset += 4;
@ -60,7 +60,7 @@ export default class Grid3D extends BufferBase {
-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // left
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, // top
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 // right
], this._offset * 3); // top normal
], this._offset * 3); // top normal
for (let i = 0; i < 4; i++) {
this.attributes.positions.set([ x, y, 1, x, y, 1, x, y, 1, x, y, 1 ], this._offset * 3);
@ -77,7 +77,7 @@ export default class Grid3D extends BufferBase {
prePoint[0], prePoint[1], 0,
nextPoint[0], nextPoint[1], 0
],
positionOffset * 3);
positionOffset * 3);
const indexArray = [ 0, 1, 2, 1, 3, 2 ].map(v => { return v + positionOffset; });
if (this.get('uv')) {
// temp 点亮城市demo

View File

@ -16,7 +16,7 @@ export function LineMaterial(options) {
vertexShader: vs,
fragmentShader: fs,
transparent: true
// blending: THREE.AdditiveBlending
// blending: THREE.AdditiveBlending
});
return material;
}

View File

@ -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) {

View File

@ -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) {

View File

@ -7,7 +7,7 @@ export default class ImageTile extends Tile {
// Making this asynchronous really speeds up the LOD framerate
setTimeout(() => {
if (!this._mesh) {
// this._mesh = this._createMesh();
// this._mesh = this._createMesh();
this._requestTile();
}
}, 0);

View File

@ -80,7 +80,7 @@ export default class Tile extends Base {
return urlParams[key];
});
}
// 经纬度范围转瓦片范围
// 经纬度范围转瓦片范围
_tileBounds(lnglatBound) {
const ne = this.layer.scene.project([ lnglatBound.getNorthEast().lng, lnglatBound.getNorthEast().lat ]);
const sw = this.layer.scene.project([ lnglatBound.getSouthWest().lng, lnglatBound.getSouthWest().lat ]);

View File

@ -116,7 +116,7 @@ export default class TileLayer extends Layer {
const tileRange = this._pxBoundsToTileRange(pixelBounds);
const margin = this.get('keepBuffer');
this.noPruneRange = new Bounds(tileRange.getBottomLeft().subtract([ margin, -margin ]),
tileRange.getTopRight().add([ margin, -margin ]));
tileRange.getTopRight().add([ margin, -margin ]));
if (!(isFinite(tileRange.min.x) &&
isFinite(tileRange.min.y) &&
isFinite(tileRange.max.x) &&
@ -424,7 +424,7 @@ export default class TileLayer extends Layer {
if (!this._tiles.children.length > 0 || !this._object3D.visible) {
return;
}
// 更新数据颜色 过滤 filter
// 更新数据颜色 过滤 filter
if (!Util.isEqual(preAttrs.color, nextAttrs.color) || !Util.isEqual(preAttrs.filter, nextAttrs.filter)) {
this._tileCache.setNeedUpdate();
this._tiles.children.forEach(tile => {

View File

@ -58,9 +58,9 @@ export default class VectorTile extends Tile {
context.depthMask(false);
renderer.clearDepth();
// only render where stencil is set to 1
// only render where stencil is set to 1
context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1
context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1
context.stencilOp(context.KEEP, context.KEEP, context.KEEP);
}
_tileMaskMesh() {

View File

@ -79,9 +79,9 @@ export default class VectorTileMesh {
context.depthMask(false);
renderer.clearDepth();
// only render where stencil is set to 1
// only render where stencil is set to 1
context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1
context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1
context.stencilOp(context.KEEP, context.KEEP, context.KEEP);
}
_tileMaskMesh() {

View File

@ -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) {

View File

@ -3,7 +3,7 @@ import { getCoords } from '@turf/invariant';
import { djb2hash } from '../../util/bkdr-hash';
import rewind from '@mapbox/geojson-rewind';
export default function geoJSON(data, cfg) {
// 矢量瓦片图层不做 rewind
// 矢量瓦片图层不做 rewind
rewind(data, true);
const resultData = [];

View File

@ -122,7 +122,7 @@ export default class SouceCache extends Base {
_calculateTileIDs() {
this._tileMap = {};
this.updateTileList = [];
const zoom = Math.floor(this.scene.getZoom()); // - window.window.devicePixelRatio + 1; // zoom - 1
const zoom = Math.floor(this.scene.getZoom()); // - window.window.devicePixelRatio + 1; // zoom - 1
const minSourceZoom = this.get('minZoom');
const maxSourceZoom = this.get('maxZoom');
this.tileZoom = zoom > maxSourceZoom ? maxSourceZoom : zoom;
@ -300,7 +300,7 @@ export default class SouceCache extends Base {
}
}
}
// 地图拾取
// 地图拾取
_addPickMesh(layer, meshObj) {
if (this.type === 'image') {
return;

View File

@ -69,9 +69,9 @@ export default function(points, closed, indexOffset) {
attrIndex.push([ index + 0, index + 2, index + 1 ]);
// no miter, simple segment
// no miter, simple segment
if (!next) {
// reset normal
// reset normal
normal(_normal, lineA);
extrusions(attrPos, out, cur, _normal, 1);
attrDistance.push(d, d);
@ -97,7 +97,7 @@ export default function(points, closed, indexOffset) {
attrDistance.push(d, d);
attrIndex.push(
_lastFlip === 1 ? [ index + 1, index + 3, index + 2 ]
: [ index, index + 2, index + 3 ]
: [ index, index + 2, index + 3 ]
);
// 避免在 Material 中使用 THREE.DoubleSide

View File

@ -71,9 +71,9 @@ export default function(points, closed, indexOffset) {
attrIndex.push(index + 0, index + 2, index + 1);
// no miter, simple segment
// no miter, simple segment
if (!next) {
// reset normal
// reset normal
normal(_normal, lineA);
extrusions(attrPos, out, miters, cur, _normal, 1);
attrDistance.push(d, d);
@ -98,7 +98,7 @@ export default function(points, closed, indexOffset) {
extrusions(attrPos, out, miters, cur, _normal, 1);
attrDistance.push(d, d);
const indexData = _lastFlip === 1 ? [ index + 1, index + 3, index + 2 ]
: [ index, index + 2, index + 3 ];
: [ index, index + 2, index + 3 ];
attrIndex.push(...indexData);
// 避免在 Material 中使用 THREE.DoubleSide