Better code indentation

This commit is contained in:
Frederic Junod
2018-02-16 13:39:16 +01:00
parent 7747f4f40d
commit 4cad77089a
12 changed files with 29 additions and 56 deletions

View File

@@ -222,8 +222,7 @@ Collection.prototype.removeAt = function(index) {
const prev = this.array_[index]; const prev = this.array_[index];
this.array_.splice(index, 1); this.array_.splice(index, 1);
this.updateLength_(); this.updateLength_();
this.dispatchEvent( this.dispatchEvent(new Collection.Event(CollectionEventType.REMOVE, prev));
new Collection.Event(CollectionEventType.REMOVE, prev));
return prev; return prev;
}; };

View File

@@ -385,14 +385,12 @@ GeoJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */
let features = null; let features = null;
if (geoJSONObject.type === 'FeatureCollection') { if (geoJSONObject.type === 'FeatureCollection') {
const geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */ const geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */ (object);
(object);
features = []; features = [];
const geoJSONFeatures = geoJSONFeatureCollection.features; const geoJSONFeatures = geoJSONFeatureCollection.features;
let i, ii; let i, ii;
for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) { for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
features.push(this.readFeatureFromObject(geoJSONFeatures[i], features.push(this.readFeatureFromObject(geoJSONFeatures[i], opt_options));
opt_options));
} }
} else { } else {
features = [this.readFeatureFromObject(object, opt_options)]; features = [this.readFeatureFromObject(object, opt_options)];

View File

@@ -55,8 +55,7 @@ DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
const anchor = mapBrowserEvent.coordinate; const anchor = mapBrowserEvent.coordinate;
const delta = browserEvent.shiftKey ? -this.delta_ : this.delta_; const delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
const view = map.getView(); const view = map.getView();
Interaction.zoomByDelta( Interaction.zoomByDelta(view, delta, anchor, this.duration_);
view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault(); mapBrowserEvent.preventDefault();
stopEvent = true; stopEvent = true;
} }

View File

@@ -67,8 +67,7 @@ inherits(DragPan, PointerInteraction);
*/ */
function handleDragEvent(mapBrowserEvent) { function handleDragEvent(mapBrowserEvent) {
const targetPointers = this.targetPointers; const targetPointers = this.targetPointers;
const centroid = const centroid = PointerInteraction.centroid(targetPointers);
PointerInteraction.centroid(targetPointers);
if (targetPointers.length == this.lastPointersCount_) { if (targetPointers.length == this.lastPointersCount_) {
if (this.kinetic_) { if (this.kinetic_) {
this.kinetic_.update(centroid[0], centroid[1]); this.kinetic_.update(centroid[0], centroid[1]);

View File

@@ -298,8 +298,8 @@ Modify.prototype.removeFeatureSegmentData_ = function(feature) {
const /** @type {Array.<ol.ModifySegmentDataType>} */ nodesToRemove = []; const /** @type {Array.<ol.ModifySegmentDataType>} */ nodesToRemove = [];
rBush.forEach( rBush.forEach(
/** /**
* @param {ol.ModifySegmentDataType} node RTree node. * @param {ol.ModifySegmentDataType} node RTree node.
*/ */
function(node) { function(node) {
if (feature === node.feature) { if (feature === node.feature) {
nodesToRemove.push(node); nodesToRemove.push(node);
@@ -563,8 +563,7 @@ Modify.prototype.writeCircleGeometry_ = function(feature, geometry) {
Modify.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) { Modify.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) {
const geometries = geometry.getGeometriesArray(); const geometries = geometry.getGeometriesArray();
for (let i = 0; i < geometries.length; ++i) { for (let i = 0; i < geometries.length; ++i) {
this.SEGMENT_WRITERS_[geometries[i].getType()].call( this.SEGMENT_WRITERS_[geometries[i].getType()].call(this, feature, geometries[i]);
this, feature, geometries[i]);
} }
}; };
@@ -805,8 +804,7 @@ Modify.handleEvent = function(mapBrowserEvent) {
this.handlePointerMove_(mapBrowserEvent); this.handlePointerMove_(mapBrowserEvent);
} }
if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) { if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) {
if (mapBrowserEvent.type != MapBrowserEventType.SINGLECLICK || if (mapBrowserEvent.type != MapBrowserEventType.SINGLECLICK || !this.ignoreNextSingleClick_) {
!this.ignoreNextSingleClick_) {
handled = this.removePoint(); handled = this.removePoint();
} else { } else {
handled = true; handled = true;
@@ -817,8 +815,7 @@ Modify.handleEvent = function(mapBrowserEvent) {
this.ignoreNextSingleClick_ = false; this.ignoreNextSingleClick_ = false;
} }
return PointerInteraction.handleEvent.call(this, mapBrowserEvent) && return PointerInteraction.handleEvent.call(this, mapBrowserEvent) && !handled;
!handled;
}; };
@@ -872,8 +869,7 @@ Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
dist = Math.sqrt(Math.min(squaredDist1, squaredDist2)); dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
this.snappedToVertex_ = dist <= this.pixelTolerance_; this.snappedToVertex_ = dist <= this.pixelTolerance_;
if (this.snappedToVertex_) { if (this.snappedToVertex_) {
vertex = squaredDist1 > squaredDist2 ? vertex = squaredDist1 > squaredDist2 ? closestSegment[1] : closestSegment[0];
closestSegment[1] : closestSegment[0];
} }
this.createOrUpdateVertexFeature_(vertex); this.createOrUpdateVertexFeature_(vertex);
let segment; let segment;
@@ -1008,8 +1004,7 @@ Modify.prototype.insertVertex_ = function(segmentData, vertex) {
depth: depth, depth: depth,
index: index + 1 index: index + 1
}); });
rTree.insert(boundingExtent(newSegmentData2.segment), rTree.insert(boundingExtent(newSegmentData2.segment), newSegmentData2);
newSegmentData2);
this.dragSegments_.push([newSegmentData2, 0]); this.dragSegments_.push([newSegmentData2, 0]);
this.ignoreNextSingleClick_ = true; this.ignoreNextSingleClick_ = true;
}; };
@@ -1024,8 +1019,7 @@ Modify.prototype.removePoint = function() {
const evt = this.lastPointerEvent_; const evt = this.lastPointerEvent_;
this.willModifyFeatures_(evt); this.willModifyFeatures_(evt);
this.removeVertex_(); this.removeVertex_();
this.dispatchEvent(new Modify.Event( this.dispatchEvent(new Modify.Event(ModifyEventType.MODIFYEND, this.features_, evt));
ModifyEventType.MODIFYEND, this.features_, evt));
this.modified_ = false; this.modified_ = false;
return true; return true;
} }

View File

@@ -377,8 +377,7 @@ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
snappedToVertex = dist <= this.pixelTolerance_; snappedToVertex = dist <= this.pixelTolerance_;
if (snappedToVertex) { if (snappedToVertex) {
snapped = true; snapped = true;
vertex = squaredDist1 > squaredDist2 ? vertex = squaredDist1 > squaredDist2 ? closestSegment[1] : closestSegment[0];
closestSegment[1] : closestSegment[0];
vertexPixel = map.getPixelFromCoordinate(vertex); vertexPixel = map.getPixelFromCoordinate(vertex);
} }
} else if (this.edge_) { } else if (this.edge_) {
@@ -386,8 +385,7 @@ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
vertex = closestOnCircle(pixelCoordinate, vertex = closestOnCircle(pixelCoordinate,
/** @type {ol.geom.Circle} */ (segments[0].feature.getGeometry())); /** @type {ol.geom.Circle} */ (segments[0].feature.getGeometry()));
} else { } else {
vertex = (closestOnSegment(pixelCoordinate, vertex = closestOnSegment(pixelCoordinate, closestSegment);
closestSegment));
} }
vertexPixel = map.getPixelFromCoordinate(vertex); vertexPixel = map.getPixelFromCoordinate(vertex);
if (coordinateDistance(pixel, vertexPixel) <= this.pixelTolerance_) { if (coordinateDistance(pixel, vertexPixel) <= this.pixelTolerance_) {
@@ -400,8 +398,7 @@ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
dist = Math.sqrt(Math.min(squaredDist1, squaredDist2)); dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
snappedToVertex = dist <= this.pixelTolerance_; snappedToVertex = dist <= this.pixelTolerance_;
if (snappedToVertex) { if (snappedToVertex) {
vertex = squaredDist1 > squaredDist2 ? vertex = squaredDist1 > squaredDist2 ? closestSegment[1] : closestSegment[0];
closestSegment[1] : closestSegment[0];
vertexPixel = map.getPixelFromCoordinate(vertex); vertexPixel = map.getPixelFromCoordinate(vertex);
} }
} }

View File

@@ -119,8 +119,7 @@ inherits(CanvasImageReplay, CanvasReplay);
* @return {number} My end. * @return {number} My end.
*/ */
CanvasImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) { CanvasImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
return this.appendFlatCoordinates( return this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false);
flatCoordinates, offset, end, stride, false, false);
}; };
@@ -135,8 +134,7 @@ CanvasImageReplay.prototype.drawPoint = function(pointGeometry, feature) {
const flatCoordinates = pointGeometry.getFlatCoordinates(); const flatCoordinates = pointGeometry.getFlatCoordinates();
const stride = pointGeometry.getStride(); const stride = pointGeometry.getStride();
const myBegin = this.coordinates.length; const myBegin = this.coordinates.length;
const myEnd = this.drawCoordinates_( const myEnd = this.drawCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride);
flatCoordinates, 0, flatCoordinates.length, stride);
this.instructions.push([ this.instructions.push([
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_, CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
// Remaining arguments to DRAW_IMAGE are in alphabetical order // 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.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
]); ]);
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_,
this.hitDetectionImage_,
// Remaining arguments to DRAW_IMAGE are in alphabetical order // Remaining arguments to DRAW_IMAGE are in alphabetical order
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_, this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
this.originX_, this.originY_, this.rotateWithView_, this.rotation_, 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.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
]); ]);
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_,
this.hitDetectionImage_,
// Remaining arguments to DRAW_IMAGE are in alphabetical order // Remaining arguments to DRAW_IMAGE are in alphabetical order
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_, this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
this.originX_, this.originY_, this.rotateWithView_, this.rotation_, this.originX_, this.originY_, this.rotateWithView_, this.rotation_,

View File

@@ -384,8 +384,7 @@ CanvasImmediateRenderer.prototype.moveToLineTo_ = function(flatCoordinates, offs
*/ */
CanvasImmediateRenderer.prototype.drawRings_ = function(flatCoordinates, offset, ends, stride) { CanvasImmediateRenderer.prototype.drawRings_ = function(flatCoordinates, offset, ends, stride) {
for (let i = 0, ii = ends.length; i < ii; ++i) { for (let i = 0, ii = ends.length; i < ii; ++i) {
offset = this.moveToLineTo_( offset = this.moveToLineTo_(flatCoordinates, offset, ends[i], stride, true);
flatCoordinates, offset, ends[i], stride, true);
} }
return offset; return offset;
}; };
@@ -610,8 +609,7 @@ CanvasImmediateRenderer.prototype.drawMultiLineString = function(geometry) {
const stride = geometry.getStride(); const stride = geometry.getStride();
context.beginPath(); context.beginPath();
for (let i = 0, ii = ends.length; i < ii; ++i) { for (let i = 0, ii = ends.length; i < ii; ++i) {
offset = this.moveToLineTo_( offset = this.moveToLineTo_(flatCoordinates, offset, ends[i], stride, false);
flatCoordinates, offset, ends[i], stride, false);
} }
context.stroke(); context.stroke();
} }

View File

@@ -91,8 +91,7 @@ CanvasLineStringReplay.prototype.drawMultiLineString = function(multiLineStringG
const stride = multiLineStringGeometry.getStride(); const stride = multiLineStringGeometry.getStride();
let offset = 0; let offset = 0;
for (let i = 0, ii = ends.length; i < ii; ++i) { for (let i = 0, ii = ends.length; i < ii; ++i) {
offset = this.drawFlatCoordinates_( offset = this.drawFlatCoordinates_(flatCoordinates, offset, ends[i], stride);
flatCoordinates, offset, ends[i], stride);
} }
this.hitDetectionInstructions.push(strokeInstruction); this.hitDetectionInstructions.push(strokeInstruction);
this.endGeometry(multiLineStringGeometry, feature); this.endGeometry(multiLineStringGeometry, feature);

View File

@@ -49,8 +49,7 @@ CanvasPolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCoordinates,
for (let i = 0; i < numEnds; ++i) { for (let i = 0; i < numEnds; ++i) {
const end = ends[i]; const end = ends[i];
const myBegin = this.coordinates.length; const myBegin = this.coordinates.length;
const myEnd = this.appendFlatCoordinates( const myEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, true, !stroke);
flatCoordinates, offset, end, stride, true, !stroke);
const moveToLineToInstruction = [CanvasInstruction.MOVE_TO_LINE_TO, myBegin, myEnd]; const moveToLineToInstruction = [CanvasInstruction.MOVE_TO_LINE_TO, myBegin, myEnd];
this.instructions.push(moveToLineToInstruction); this.instructions.push(moveToLineToInstruction);
this.hitDetectionInstructions.push(moveToLineToInstruction); this.hitDetectionInstructions.push(moveToLineToInstruction);
@@ -174,8 +173,7 @@ CanvasPolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry,
const stride = multiPolygonGeometry.getStride(); const stride = multiPolygonGeometry.getStride();
let offset = 0; let offset = 0;
for (let i = 0, ii = endss.length; i < ii; ++i) { for (let i = 0, ii = endss.length; i < ii; ++i) {
offset = this.drawFlatCoordinatess_( offset = this.drawFlatCoordinatess_(flatCoordinates, offset, endss[i], stride);
flatCoordinates, offset, endss[i], stride);
} }
this.endGeometry(multiPolygonGeometry, feature); this.endGeometry(multiPolygonGeometry, feature);
}; };

View File

@@ -201,8 +201,7 @@ CanvasTextReplay.prototype.drawText = function(geometry, feature) {
let flatEnd; let flatEnd;
for (let o = 0, oo = ends.length; o < oo; ++o) { for (let o = 0, oo = ends.length; o < oo; ++o) {
if (textAlign == undefined) { if (textAlign == undefined) {
const range = matchingChunk( const range = matchingChunk(textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
flatOffset = range[0]; flatOffset = range[0];
flatEnd = range[1]; flatEnd = range[1];
} else { } else {

View File

@@ -154,14 +154,12 @@ CanvasVectorTileLayerRenderer.prototype.prepareFrame = function(frameState, laye
* @param {olx.FrameState} frameState Frame state. * @param {olx.FrameState} frameState Frame state.
* @private * @private
*/ */
CanvasVectorTileLayerRenderer.prototype.createReplayGroup_ = function( CanvasVectorTileLayerRenderer.prototype.createReplayGroup_ = function(tile, frameState) {
tile, frameState) {
const layer = this.getLayer(); const layer = this.getLayer();
const pixelRatio = frameState.pixelRatio; const pixelRatio = frameState.pixelRatio;
const projection = frameState.viewState.projection; const projection = frameState.viewState.projection;
const revision = layer.getRevision(); const revision = layer.getRevision();
const renderOrder = /** @type {ol.RenderOrderFunction} */ const renderOrder = /** @type {ol.RenderOrderFunction} */ (layer.getRenderOrder()) || null;
(layer.getRenderOrder()) || null;
const replayState = tile.getReplayState(layer); const replayState = tile.getReplayState(layer);
if (!replayState.dirty && replayState.renderedRevision == revision && if (!replayState.dirty && replayState.renderedRevision == revision &&
@@ -196,8 +194,7 @@ CanvasVectorTileLayerRenderer.prototype.createReplayGroup_ = function(
replayState.dirty = false; replayState.dirty = false;
const replayGroup = new CanvasReplayGroup(0, sharedExtent, resolution, const replayGroup = new CanvasReplayGroup(0, sharedExtent, resolution,
pixelRatio, source.getOverlaps(), this.declutterTree_, layer.getRenderBuffer()); pixelRatio, source.getOverlaps(), this.declutterTree_, layer.getRenderBuffer());
const squaredTolerance = getSquaredRenderTolerance( const squaredTolerance = getSquaredRenderTolerance(resolution, pixelRatio);
resolution, pixelRatio);
/** /**
* @param {ol.Feature|ol.render.Feature} feature Feature. * @param {ol.Feature|ol.render.Feature} feature Feature.