From 4cad77089a53445b9c26c6a80d6344e1e3809617 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 16 Feb 2018 13:39:16 +0100 Subject: [PATCH] Better code indentation --- src/ol/Collection.js | 3 +-- src/ol/format/GeoJSON.js | 6 ++---- src/ol/interaction/DoubleClickZoom.js | 3 +-- src/ol/interaction/DragPan.js | 3 +-- src/ol/interaction/Modify.js | 22 ++++++++-------------- src/ol/interaction/Snap.js | 9 +++------ src/ol/render/canvas/ImageReplay.js | 12 ++++-------- src/ol/render/canvas/Immediate.js | 6 ++---- src/ol/render/canvas/LineStringReplay.js | 3 +-- src/ol/render/canvas/PolygonReplay.js | 6 ++---- src/ol/render/canvas/TextReplay.js | 3 +-- src/ol/renderer/canvas/VectorTileLayer.js | 9 +++------ 12 files changed, 29 insertions(+), 56 deletions(-) diff --git a/src/ol/Collection.js b/src/ol/Collection.js index fee753d3c1..a4c97d06b3 100644 --- a/src/ol/Collection.js +++ b/src/ol/Collection.js @@ -222,8 +222,7 @@ Collection.prototype.removeAt = function(index) { const prev = this.array_[index]; this.array_.splice(index, 1); this.updateLength_(); - this.dispatchEvent( - new Collection.Event(CollectionEventType.REMOVE, prev)); + this.dispatchEvent(new Collection.Event(CollectionEventType.REMOVE, prev)); return prev; }; diff --git a/src/ol/format/GeoJSON.js b/src/ol/format/GeoJSON.js index 3e6cabc00d..ce46e9f7ad 100644 --- a/src/ol/format/GeoJSON.js +++ b/src/ol/format/GeoJSON.js @@ -385,14 +385,12 @@ GeoJSON.prototype.readFeaturesFromObject = function(object, opt_options) { /** @type {Array.} */ let features = null; if (geoJSONObject.type === 'FeatureCollection') { - const geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */ - (object); + const geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */ (object); features = []; const geoJSONFeatures = geoJSONFeatureCollection.features; let i, ii; for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) { - features.push(this.readFeatureFromObject(geoJSONFeatures[i], - opt_options)); + features.push(this.readFeatureFromObject(geoJSONFeatures[i], opt_options)); } } else { features = [this.readFeatureFromObject(object, opt_options)]; diff --git a/src/ol/interaction/DoubleClickZoom.js b/src/ol/interaction/DoubleClickZoom.js index 76c1179b46..bc00ada46b 100644 --- a/src/ol/interaction/DoubleClickZoom.js +++ b/src/ol/interaction/DoubleClickZoom.js @@ -55,8 +55,7 @@ DoubleClickZoom.handleEvent = function(mapBrowserEvent) { const anchor = mapBrowserEvent.coordinate; const delta = browserEvent.shiftKey ? -this.delta_ : this.delta_; const view = map.getView(); - Interaction.zoomByDelta( - view, delta, anchor, this.duration_); + Interaction.zoomByDelta(view, delta, anchor, this.duration_); mapBrowserEvent.preventDefault(); stopEvent = true; } diff --git a/src/ol/interaction/DragPan.js b/src/ol/interaction/DragPan.js index d3c07aede9..455d6229f4 100644 --- a/src/ol/interaction/DragPan.js +++ b/src/ol/interaction/DragPan.js @@ -67,8 +67,7 @@ inherits(DragPan, PointerInteraction); */ function handleDragEvent(mapBrowserEvent) { const targetPointers = this.targetPointers; - const centroid = - PointerInteraction.centroid(targetPointers); + const centroid = PointerInteraction.centroid(targetPointers); if (targetPointers.length == this.lastPointersCount_) { if (this.kinetic_) { this.kinetic_.update(centroid[0], centroid[1]); diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index 6ec3224024..d58c416b8c 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -298,8 +298,8 @@ Modify.prototype.removeFeatureSegmentData_ = function(feature) { const /** @type {Array.} */ nodesToRemove = []; rBush.forEach( /** - * @param {ol.ModifySegmentDataType} node RTree node. - */ + * @param {ol.ModifySegmentDataType} node RTree node. + */ function(node) { if (feature === node.feature) { nodesToRemove.push(node); @@ -563,8 +563,7 @@ Modify.prototype.writeCircleGeometry_ = function(feature, geometry) { Modify.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) { const geometries = geometry.getGeometriesArray(); for (let i = 0; i < geometries.length; ++i) { - this.SEGMENT_WRITERS_[geometries[i].getType()].call( - this, feature, geometries[i]); + this.SEGMENT_WRITERS_[geometries[i].getType()].call(this, feature, geometries[i]); } }; @@ -805,8 +804,7 @@ Modify.handleEvent = function(mapBrowserEvent) { this.handlePointerMove_(mapBrowserEvent); } if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) { - if (mapBrowserEvent.type != MapBrowserEventType.SINGLECLICK || - !this.ignoreNextSingleClick_) { + if (mapBrowserEvent.type != MapBrowserEventType.SINGLECLICK || !this.ignoreNextSingleClick_) { handled = this.removePoint(); } else { handled = true; @@ -817,8 +815,7 @@ Modify.handleEvent = function(mapBrowserEvent) { this.ignoreNextSingleClick_ = false; } - return PointerInteraction.handleEvent.call(this, mapBrowserEvent) && - !handled; + return PointerInteraction.handleEvent.call(this, mapBrowserEvent) && !handled; }; @@ -872,8 +869,7 @@ Modify.prototype.handlePointerAtPixel_ = function(pixel, map) { dist = Math.sqrt(Math.min(squaredDist1, squaredDist2)); this.snappedToVertex_ = dist <= this.pixelTolerance_; if (this.snappedToVertex_) { - vertex = squaredDist1 > squaredDist2 ? - closestSegment[1] : closestSegment[0]; + vertex = squaredDist1 > squaredDist2 ? closestSegment[1] : closestSegment[0]; } this.createOrUpdateVertexFeature_(vertex); let segment; @@ -1008,8 +1004,7 @@ Modify.prototype.insertVertex_ = function(segmentData, vertex) { depth: depth, index: index + 1 }); - rTree.insert(boundingExtent(newSegmentData2.segment), - newSegmentData2); + rTree.insert(boundingExtent(newSegmentData2.segment), newSegmentData2); this.dragSegments_.push([newSegmentData2, 0]); this.ignoreNextSingleClick_ = true; }; @@ -1024,8 +1019,7 @@ Modify.prototype.removePoint = function() { const evt = this.lastPointerEvent_; this.willModifyFeatures_(evt); this.removeVertex_(); - this.dispatchEvent(new Modify.Event( - ModifyEventType.MODIFYEND, this.features_, evt)); + this.dispatchEvent(new Modify.Event(ModifyEventType.MODIFYEND, this.features_, evt)); this.modified_ = false; return true; } diff --git a/src/ol/interaction/Snap.js b/src/ol/interaction/Snap.js index 7f9a9ac8e0..6c5fdf6663 100644 --- a/src/ol/interaction/Snap.js +++ b/src/ol/interaction/Snap.js @@ -377,8 +377,7 @@ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { snappedToVertex = dist <= this.pixelTolerance_; if (snappedToVertex) { snapped = true; - vertex = squaredDist1 > squaredDist2 ? - closestSegment[1] : closestSegment[0]; + vertex = squaredDist1 > squaredDist2 ? closestSegment[1] : closestSegment[0]; vertexPixel = map.getPixelFromCoordinate(vertex); } } else if (this.edge_) { @@ -386,8 +385,7 @@ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { vertex = closestOnCircle(pixelCoordinate, /** @type {ol.geom.Circle} */ (segments[0].feature.getGeometry())); } else { - vertex = (closestOnSegment(pixelCoordinate, - closestSegment)); + vertex = closestOnSegment(pixelCoordinate, closestSegment); } vertexPixel = map.getPixelFromCoordinate(vertex); if (coordinateDistance(pixel, vertexPixel) <= this.pixelTolerance_) { @@ -400,8 +398,7 @@ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { dist = Math.sqrt(Math.min(squaredDist1, squaredDist2)); snappedToVertex = dist <= this.pixelTolerance_; if (snappedToVertex) { - vertex = squaredDist1 > squaredDist2 ? - closestSegment[1] : closestSegment[0]; + vertex = squaredDist1 > squaredDist2 ? closestSegment[1] : closestSegment[0]; vertexPixel = map.getPixelFromCoordinate(vertex); } } diff --git a/src/ol/render/canvas/ImageReplay.js b/src/ol/render/canvas/ImageReplay.js index 23310d4190..70872cf1b8 100644 --- a/src/ol/render/canvas/ImageReplay.js +++ b/src/ol/render/canvas/ImageReplay.js @@ -119,8 +119,7 @@ inherits(CanvasImageReplay, CanvasReplay); * @return {number} My end. */ CanvasImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) { - return this.appendFlatCoordinates( - flatCoordinates, offset, end, stride, false, false); + return this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false); }; @@ -135,8 +134,7 @@ CanvasImageReplay.prototype.drawPoint = function(pointGeometry, feature) { const flatCoordinates = pointGeometry.getFlatCoordinates(); const stride = pointGeometry.getStride(); const myBegin = this.coordinates.length; - const myEnd = this.drawCoordinates_( - flatCoordinates, 0, flatCoordinates.length, stride); + const myEnd = this.drawCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride); this.instructions.push([ CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_, // Remaining arguments to DRAW_IMAGE are in alphabetical order @@ -145,8 +143,7 @@ CanvasImageReplay.prototype.drawPoint = function(pointGeometry, feature) { this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_ ]); this.hitDetectionInstructions.push([ - CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, - this.hitDetectionImage_, + CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_, // Remaining arguments to DRAW_IMAGE are in alphabetical order this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_, this.originX_, this.originY_, this.rotateWithView_, this.rotation_, @@ -177,8 +174,7 @@ CanvasImageReplay.prototype.drawMultiPoint = function(multiPointGeometry, featur this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_ ]); this.hitDetectionInstructions.push([ - CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, - this.hitDetectionImage_, + CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_, // Remaining arguments to DRAW_IMAGE are in alphabetical order this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_, this.originX_, this.originY_, this.rotateWithView_, this.rotation_, diff --git a/src/ol/render/canvas/Immediate.js b/src/ol/render/canvas/Immediate.js index b31eb31e54..78146ef023 100644 --- a/src/ol/render/canvas/Immediate.js +++ b/src/ol/render/canvas/Immediate.js @@ -384,8 +384,7 @@ CanvasImmediateRenderer.prototype.moveToLineTo_ = function(flatCoordinates, offs */ CanvasImmediateRenderer.prototype.drawRings_ = function(flatCoordinates, offset, ends, stride) { for (let i = 0, ii = ends.length; i < ii; ++i) { - offset = this.moveToLineTo_( - flatCoordinates, offset, ends[i], stride, true); + offset = this.moveToLineTo_(flatCoordinates, offset, ends[i], stride, true); } return offset; }; @@ -610,8 +609,7 @@ CanvasImmediateRenderer.prototype.drawMultiLineString = function(geometry) { const stride = geometry.getStride(); context.beginPath(); for (let i = 0, ii = ends.length; i < ii; ++i) { - offset = this.moveToLineTo_( - flatCoordinates, offset, ends[i], stride, false); + offset = this.moveToLineTo_(flatCoordinates, offset, ends[i], stride, false); } context.stroke(); } diff --git a/src/ol/render/canvas/LineStringReplay.js b/src/ol/render/canvas/LineStringReplay.js index 6c45b158cb..78db8cad92 100644 --- a/src/ol/render/canvas/LineStringReplay.js +++ b/src/ol/render/canvas/LineStringReplay.js @@ -91,8 +91,7 @@ CanvasLineStringReplay.prototype.drawMultiLineString = function(multiLineStringG const stride = multiLineStringGeometry.getStride(); let offset = 0; for (let i = 0, ii = ends.length; i < ii; ++i) { - offset = this.drawFlatCoordinates_( - flatCoordinates, offset, ends[i], stride); + offset = this.drawFlatCoordinates_(flatCoordinates, offset, ends[i], stride); } this.hitDetectionInstructions.push(strokeInstruction); this.endGeometry(multiLineStringGeometry, feature); diff --git a/src/ol/render/canvas/PolygonReplay.js b/src/ol/render/canvas/PolygonReplay.js index fa1929bb80..879ebff636 100644 --- a/src/ol/render/canvas/PolygonReplay.js +++ b/src/ol/render/canvas/PolygonReplay.js @@ -49,8 +49,7 @@ CanvasPolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCoordinates, for (let i = 0; i < numEnds; ++i) { const end = ends[i]; const myBegin = this.coordinates.length; - const myEnd = this.appendFlatCoordinates( - flatCoordinates, offset, end, stride, true, !stroke); + const myEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, true, !stroke); const moveToLineToInstruction = [CanvasInstruction.MOVE_TO_LINE_TO, myBegin, myEnd]; this.instructions.push(moveToLineToInstruction); this.hitDetectionInstructions.push(moveToLineToInstruction); @@ -174,8 +173,7 @@ CanvasPolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, const stride = multiPolygonGeometry.getStride(); let offset = 0; for (let i = 0, ii = endss.length; i < ii; ++i) { - offset = this.drawFlatCoordinatess_( - flatCoordinates, offset, endss[i], stride); + offset = this.drawFlatCoordinatess_(flatCoordinates, offset, endss[i], stride); } this.endGeometry(multiPolygonGeometry, feature); }; diff --git a/src/ol/render/canvas/TextReplay.js b/src/ol/render/canvas/TextReplay.js index c06a4003ee..1c3321056c 100644 --- a/src/ol/render/canvas/TextReplay.js +++ b/src/ol/render/canvas/TextReplay.js @@ -201,8 +201,7 @@ CanvasTextReplay.prototype.drawText = function(geometry, feature) { let flatEnd; for (let o = 0, oo = ends.length; o < oo; ++o) { if (textAlign == undefined) { - const range = matchingChunk( - textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride); + const range = matchingChunk(textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride); flatOffset = range[0]; flatEnd = range[1]; } else { diff --git a/src/ol/renderer/canvas/VectorTileLayer.js b/src/ol/renderer/canvas/VectorTileLayer.js index eb7139a7cf..761a13f2de 100644 --- a/src/ol/renderer/canvas/VectorTileLayer.js +++ b/src/ol/renderer/canvas/VectorTileLayer.js @@ -154,14 +154,12 @@ CanvasVectorTileLayerRenderer.prototype.prepareFrame = function(frameState, laye * @param {olx.FrameState} frameState Frame state. * @private */ -CanvasVectorTileLayerRenderer.prototype.createReplayGroup_ = function( - tile, frameState) { +CanvasVectorTileLayerRenderer.prototype.createReplayGroup_ = function(tile, frameState) { const layer = this.getLayer(); const pixelRatio = frameState.pixelRatio; const projection = frameState.viewState.projection; const revision = layer.getRevision(); - const renderOrder = /** @type {ol.RenderOrderFunction} */ - (layer.getRenderOrder()) || null; + const renderOrder = /** @type {ol.RenderOrderFunction} */ (layer.getRenderOrder()) || null; const replayState = tile.getReplayState(layer); if (!replayState.dirty && replayState.renderedRevision == revision && @@ -196,8 +194,7 @@ CanvasVectorTileLayerRenderer.prototype.createReplayGroup_ = function( replayState.dirty = false; const replayGroup = new CanvasReplayGroup(0, sharedExtent, resolution, pixelRatio, source.getOverlaps(), this.declutterTree_, layer.getRenderBuffer()); - const squaredTolerance = getSquaredRenderTolerance( - resolution, pixelRatio); + const squaredTolerance = getSquaredRenderTolerance(resolution, pixelRatio); /** * @param {ol.Feature|ol.render.Feature} feature Feature.