From 9c6ac20f89e4529e9f0b422c21502170db5165c9 Mon Sep 17 00:00:00 2001 From: David Levinsky Date: Mon, 1 May 2017 19:11:38 +0200 Subject: [PATCH] code cleanup for uglifyjs --- src/core/inspector/graphs.js | 2 +- src/core/map/config.js | 2 +- src/core/map/draw-tiles.js | 2 +- src/core/map/draw.js | 4 ++-- src/core/map/geodata-processor/processor.js | 6 +++--- .../map/geodata-processor/worker-linestring.js | 4 ++-- .../map/geodata-processor/worker-pointarray.js | 14 +++++++------- src/core/map/geodata-processor/worker-style.js | 10 ++++------ src/core/map/geodata.js | 2 +- src/core/map/map.js | 2 +- src/core/map/mesh.js | 2 +- src/core/map/stylesheet.js | 2 +- src/core/map/surface-tile.js | 16 ++++++++-------- src/core/map/surface-tree.js | 8 ++++---- src/core/renderer/camera.js | 2 +- src/core/renderer/draw.js | 2 +- src/core/renderer/gpu/program.js | 2 +- src/core/renderer/gpu/text.js | 2 +- src/core/renderer/renderer.js | 2 +- 19 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/core/inspector/graphs.js b/src/core/inspector/graphs.js index 721f7a41..ba030013 100755 --- a/src/core/inspector/graphs.js +++ b/src/core/inspector/graphs.js @@ -436,7 +436,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { ctx.fillRect(i*factorX, height -(value)*factorY, 1, 1); } - if (this.showCursor == true) { + if (this.showCursor) { index = (this.cursorIndex + samplesIndex) % samples; str = ' Total: ' + Math.ceil((valuesMetatiles[index] + valuesResources[index] + valuesTextures[index] + valuesMeshes[index])/(1024*1024)) + 'MB' + '   CPU: ' + Math.ceil(valuesResources[index]/(1024*1024)) + 'MB' + diff --git a/src/core/map/config.js b/src/core/map/config.js index b5c8380c..6831db6e 100755 --- a/src/core/map/config.js +++ b/src/core/map/config.js @@ -78,7 +78,7 @@ MapConfig.prototype.parseReferenceFrame = function() { this.map.referenceFrame = new MapRefFrame(this.map, rf); - if (this.map.referenceFrame.valid == false) { + if (!this.map.referenceFrame.valid) { return false; } diff --git a/src/core/map/draw-tiles.js b/src/core/map/draw-tiles.js index b69dc40b..7d85b527 100755 --- a/src/core/map/draw-tiles.js +++ b/src/core/map/draw-tiles.js @@ -509,7 +509,7 @@ MapDrawTiles.prototype.drawGeodataTile = function(tile, node, cameraPos, pixelSi /* else if (tile.lastRenderState){ - if (tile.surfaceGeodata.isReady(true, priority) == true) { + if (tile.surfaceGeodata.isReady(true, priority) { if (tile.drawCommands[channel].length > 0) { if (!preventRedener) { this.draw.processDrawCommands(cameraPos, tile.lastRenderState.drawCommands[channel], priority, true); diff --git a/src/core/map/draw.js b/src/core/map/draw.js index 478895cb..cc71948e 100755 --- a/src/core/map/draw.js +++ b/src/core/map/draw.js @@ -140,10 +140,10 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { var projected = this.isProjected; - if (!projected) { + //if (!projected) { //why calling this function distorts camera? why I have call it before update camera< //var camInfo = this.measure.getPositionCameraInfo(this.position, this.getNavigationSrs().isProjected(), true); // - } + //} var drawTiles = this.drawTiles; var camInfo = camera.update(); diff --git a/src/core/map/geodata-processor/processor.js b/src/core/map/geodata-processor/processor.js index 5460cc2a..c4e70ac6 100755 --- a/src/core/map/geodata-processor/processor.js +++ b/src/core/map/geodata-processor/processor.js @@ -8,7 +8,7 @@ var MapGeodataProcessor = function(surface, listener) { // eslint-disable-next-line var worker = require('worker-loader?inline&fallback=false!./worker-main'); - //var worker = require("worker-loader?inline!./worker-main"); + //var worker = require('worker-loader?!./worker-main'); //debug worker this.processWorker = new worker; @@ -22,7 +22,7 @@ var MapGeodataProcessor = function(surface, listener) { MapGeodataProcessor.prototype.kill = function() { - if (this.killed == true) { + if (this.killed) { return; } @@ -68,7 +68,7 @@ MapGeodataProcessor.prototype.setListener = function(listener) { MapGeodataProcessor.prototype.sendCommand = function(command, data, tile) { - if (this.killed == true) { + if (this.killed) { return; } diff --git a/src/core/map/geodata-processor/worker-linestring.js b/src/core/map/geodata-processor/worker-linestring.js index 02607b76..62cc2490 100755 --- a/src/core/map/geodata-processor/worker-linestring.js +++ b/src/core/map/geodata-processor/worker-linestring.js @@ -20,12 +20,13 @@ var postGroupMessage = postGroupMessage_; var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) { - var lines = lineString['lines'] || []; + var lines = (lineString['lines'] || lineString['d-lines']) || []; if (lines.length == 0) { return; } + var dlines = (lineString['lines']) ? true : false; var line = getLayerPropertyValue(style, 'line', lineString, lod); var lineLabel = getLayerPropertyValue(style, 'line-label', lineString, lod); @@ -140,7 +141,6 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) var texturedLine = (lineStyle != 'solid'); - var dlines = false; var distance = 0.001; var distance2 = 0.001; diff --git a/src/core/map/geodata-processor/worker-pointarray.js b/src/core/map/geodata-processor/worker-pointarray.js index 1affe83e..944a1b9c 100755 --- a/src/core/map/geodata-processor/worker-pointarray.js +++ b/src/core/map/geodata-processor/worker-pointarray.js @@ -15,13 +15,15 @@ var postGroupMessage = postGroupMessage_; var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) { var pointsGroups = []; - var i, li; + var i, li, dpoints = false; - if (pointArray['lines']) { //use lines as points - pointsGroups = pointArray['lines'] || []; + if (pointArray['lines'] || pointArray['d-lines']) { //use lines as points + pointsGroups = pointArray['lines'] || pointArray['d-lines']; + dpoints = (pointArray['d-lines']) ? true : false; } else { - if (pointArray['points']) { - pointsGroups = [pointArray['points']]; + if (pointArray['points'] || pointArray['d-points']) { + pointsGroups = [(pointArray['points'] || pointArray['d-points'])]; + dpoints = (pointArray['d-points']) ? true : false; } } @@ -159,8 +161,6 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) vertexBuffer = new Array(points.length * pointsVertices); } - var dpoints = false; - //add ponints for (i = 0, li = points.length; i < li; i++) { diff --git a/src/core/map/geodata-processor/worker-style.js b/src/core/map/geodata-processor/worker-style.js index c26c1022..b1ab538f 100755 --- a/src/core/map/geodata-processor/worker-style.js +++ b/src/core/map/geodata-processor/worker-style.js @@ -769,9 +769,7 @@ var processLayer = function(layerId, layerData, stylesheetLayersData) { var processStylesheet = function(stylesheetLayersData) { - var key; - globals.stylesheetBitmaps = {}; globals.stylesheetConstants = stylesheetLayersData['constants'] || {}; @@ -781,7 +779,7 @@ var processStylesheet = function(stylesheetLayersData) { //build map for (key in bitmaps) { var bitmap = bitmaps[key]; - var skip = false; + //var skip = false; if ((typeof bitmap) == 'string') { bitmap = {'url':bitmap}; @@ -793,9 +791,9 @@ var processStylesheet = function(stylesheetLayersData) { logError('wrong-bitmap', key); } - if (!skip) { - globals.stylesheetBitmaps[key] = bitmap; - } + //if (!skip) { + globals.stylesheetBitmaps[key] = bitmap; + //} } //load bitmaps diff --git a/src/core/map/geodata.js b/src/core/map/geodata.js index 2be24d04..ab83f72c 100755 --- a/src/core/map/geodata.js +++ b/src/core/map/geodata.js @@ -39,7 +39,7 @@ MapGeodata.prototype.killGeodata = function(killedByCache) { this.geodata = null; } - if (killedByCache != true && this.cacheItem != null) { + if (killedByCache !== true && this.cacheItem != null) { this.map.resourcesCache.remove(this.cacheItem); } diff --git a/src/core/map/map.js b/src/core/map/map.js index 5b4b2b3e..9d964d77 100755 --- a/src/core/map/map.js +++ b/src/core/map/map.js @@ -937,7 +937,7 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { this.dirty = true; } - if (this.hoverFeature != null && this.hoverFeature[3] == true) { + if (this.hoverFeature != null && this.hoverFeature[3]) { return [this.hoverFeature, true, relatedEvents]; } else { return [null, false, relatedEvents]; diff --git a/src/core/map/mesh.js b/src/core/map/mesh.js index 1cb6cba5..94e4da6e 100755 --- a/src/core/map/mesh.js +++ b/src/core/map/mesh.js @@ -203,7 +203,7 @@ MapMesh.prototype.onLoadError = function() { MapMesh.prototype.onLoaded = function(data, task) { - if (this.map.killed == true){ + if (this.map.killed){ return; } diff --git a/src/core/map/stylesheet.js b/src/core/map/stylesheet.js index e195c466..36ce7503 100755 --- a/src/core/map/stylesheet.js +++ b/src/core/map/stylesheet.js @@ -85,7 +85,7 @@ MapStylesheet.prototype.onLoadError = function() { MapStylesheet.prototype.onLoaded = function(data) { - if (this.map.killed == true){ + if (this.map.killed){ return; } diff --git a/src/core/map/surface-tile.js b/src/core/map/surface-tile.js index ce157cad..ee0d2d89 100755 --- a/src/core/map/surface-tile.js +++ b/src/core/map/surface-tile.js @@ -515,7 +515,7 @@ MapSurfaceTile.prototype.createVirtualMetanode = function(tree, priority) { var alien = surfaces[i][1]; metatile = this.metaresources.getMetatile(surface, null, this); - if (metatile.isReady(priority) == true) { + if (metatile.isReady(priority)) { metanode = metatile.getNode(this.id); if (metanode != null) { @@ -762,7 +762,7 @@ MapSurfaceTile.prototype.getPixelSize = function(bbox, screenPixelSize, cameraPo //console.log("new: " + (factor * screenPixelSize) + " old:" + this.tilePixelSize2(node) ); - if (returnDistance == true) { + if (returnDistance) { return [(factor[0] * screenPixelSize), factor[1]]; } @@ -1039,24 +1039,24 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { [ur[0], middle[1]] ]; - var flatGrid = true, h, coordsRes, factor, prog; + var h, coordsRes, factor, prog; if (fastGrid) { if (!this.metanode) { return; } - if (flatGrid) { + /*if (flatGrid) {*/ //var h = this.metanode.minZ; - h = this.metanode.surrogatez; + h = this.metanode.surrogatez; //if (this.map.drawLods) { h = this.metanode.minZ; } - coordsRes = [[h],[h],[h],[h],[h],[h],[h],[h]]; + coordsRes = [[h],[h],[h],[h],[h],[h],[h],[h]]; //middle[2] = h; //middle = node.getPhysicalCoords(middle, true); - } else { + /*} else { var mnode = this.metanode; @@ -1151,7 +1151,7 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { coordsRes[7] = [(border[5] + border[4]) * 0.5]; } - } + }*/ diff --git a/src/core/map/surface-tree.js b/src/core/map/surface-tree.js index 9493f3fb..e5f43972 100755 --- a/src/core/map/surface-tree.js +++ b/src/core/map/surface-tree.js @@ -17,10 +17,10 @@ var MapSurfaceTree = function(map, freeLayer, freeLayerSurface) { this.surfaceTree = new MapSurfaceTile(this.map, null, this.rootId); - if (freeLayer !== true) { + //if (freeLayer !== true) { //this.heightTracer = new MapMetanodeTracer(this, null, this.traceTileHeight.bind(this), this.traceHeightChild.bind(this)); //this.heightTracerNodeOnly = new MapMetanodeTracer(this, null, this.traceTileHeightNodeOnly.bind(this), this.traceHeightChild.bind(this)); - } + //} this.surfaceSequence = []; this.surfaceOnlySequence = []; @@ -776,7 +776,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function() { var lastProcessBufferIndex = newProcessBufferIndex; var lastDrawBufferIndex = drawBufferIndex; - if (node.hasChildren() == false || tile.texelSize <= texelSizeFit) { + if (!node.hasChildren() || tile.texelSize <= texelSizeFit) { priority = ((tile.id[0] + lodShift) * typeFactor) * tile.distance; @@ -1122,7 +1122,7 @@ MapSurfaceTree.prototype.traceHeightTileByMap = function(tile, params) { tile.heightMap = tile.resources.getTexture(path, true); //} } else { - if (tile.heightMap.isReady() == true) { + if (tile.heightMap.isReady()) { params.parent = { metanode : params.metanode, heightMap : params.heightMap, diff --git a/src/core/renderer/camera.js b/src/core/renderer/camera.js index 05579f38..dba1f872 100755 --- a/src/core/renderer/camera.js +++ b/src/core/renderer/camera.js @@ -157,7 +157,7 @@ Camera.prototype.scaleFactor = function(worldPos, returnDist) { // ('dist' is used instead of camera depth (camPos(2)) to make the tile // resolution independent of camera rotation) - if (returnDist == true) { + if (returnDist) { if (dist < this.near) return [Number.POSITIVEINFINITY, dist]; return [this.projection[0] / dist, dist]; //return [(this.projection[5]*0.5) / dist, dist]; //projection by sy diff --git a/src/core/renderer/draw.js b/src/core/renderer/draw.js index 35af3b26..efa9f71a 100755 --- a/src/core/renderer/draw.js +++ b/src/core/renderer/draw.js @@ -303,7 +303,7 @@ RendererDraw.prototype.drawImage = function(x, y, lx, ly, texture, color, depth, } if (useState !== true) { - if (depthTest != true) { + if (depthTest !== true) { gl.disable(gl.DEPTH_TEST); } diff --git a/src/core/renderer/gpu/program.js b/src/core/renderer/gpu/program.js index 83ef159d..ff681119 100755 --- a/src/core/renderer/gpu/program.js +++ b/src/core/renderer/gpu/program.js @@ -21,7 +21,7 @@ GpuProgram.prototype.createShader = function(source, vertexShader) { var shader; - if (vertexShader != true) { + if (vertexShader !== true) { shader = gl.createShader(gl.FRAGMENT_SHADER); } else { shader = gl.createShader(gl.VERTEX_SHADER); diff --git a/src/core/renderer/gpu/text.js b/src/core/renderer/gpu/text.js index 2feae73d..1e1c3e9d 100755 --- a/src/core/renderer/gpu/text.js +++ b/src/core/renderer/gpu/text.js @@ -400,7 +400,7 @@ GpuText.prototype.compile = function() { //this.core.renderer.statsFluxMesh[0][1] += this.size; } - if (this.withNormals == true) { + if (this.withNormals) { this.normals = []; } }; diff --git a/src/core/renderer/renderer.js b/src/core/renderer/renderer.js index d23d72ba..c0519d50 100755 --- a/src/core/renderer/renderer.js +++ b/src/core/renderer/renderer.js @@ -122,7 +122,7 @@ var Renderer = function(core, div, onUpdate, onResize, config) { //intit resources // eslint-disable-next-line - var init = new RenderInit(this); + this.init = new RenderInit(this); this.draw = new RenderDraw(this); //if (window["MelMobile"] && this.gpu.canvas != null) {