Merge pull request #7843 from fredj/indent

Better code indentation
This commit is contained in:
Frédéric Junod
2018-02-16 14:59:09 +01:00
committed by GitHub
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];
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;
};

View File

@@ -385,14 +385,12 @@ GeoJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
/** @type {Array.<ol.Feature>} */
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)];

View File

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

View File

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

View File

@@ -298,8 +298,8 @@ Modify.prototype.removeFeatureSegmentData_ = function(feature) {
const /** @type {Array.<ol.ModifySegmentDataType>} */ 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;
}

View File

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

View File

@@ -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_,

View File

@@ -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();
}

View File

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

View File

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

View File

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

View File

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