Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions
+19 -19
View File
@@ -16,10 +16,10 @@ import _ol_render_canvas_Replay_ from '../canvas/Replay.js';
* @param {?} declutterTree Declutter tree.
* @struct
*/
var _ol_render_canvas_ImageReplay_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
const _ol_render_canvas_ImageReplay_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
_ol_render_canvas_Replay_.call(this,
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
/**
* @private
@@ -120,7 +120,7 @@ inherits(_ol_render_canvas_ImageReplay_, _ol_render_canvas_Replay_);
*/
_ol_render_canvas_ImageReplay_.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
return this.appendFlatCoordinates(
flatCoordinates, offset, end, stride, false, false);
flatCoordinates, offset, end, stride, false, false);
};
@@ -132,11 +132,11 @@ _ol_render_canvas_ImageReplay_.prototype.drawPoint = function(pointGeometry, fea
return;
}
this.beginGeometry(pointGeometry, feature);
var flatCoordinates = pointGeometry.getFlatCoordinates();
var stride = pointGeometry.getStride();
var myBegin = this.coordinates.length;
var myEnd = this.drawCoordinates_(
flatCoordinates, 0, flatCoordinates.length, stride);
const flatCoordinates = pointGeometry.getFlatCoordinates();
const stride = pointGeometry.getStride();
const myBegin = this.coordinates.length;
const myEnd = this.drawCoordinates_(
flatCoordinates, 0, flatCoordinates.length, stride);
this.instructions.push([
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.image_,
// Remaining arguments to DRAW_IMAGE are in alphabetical order
@@ -164,11 +164,11 @@ _ol_render_canvas_ImageReplay_.prototype.drawMultiPoint = function(multiPointGeo
return;
}
this.beginGeometry(multiPointGeometry, feature);
var flatCoordinates = multiPointGeometry.getFlatCoordinates();
var stride = multiPointGeometry.getStride();
var myBegin = this.coordinates.length;
var myEnd = this.drawCoordinates_(
flatCoordinates, 0, flatCoordinates.length, stride);
const flatCoordinates = multiPointGeometry.getFlatCoordinates();
const stride = multiPointGeometry.getStride();
const myBegin = this.coordinates.length;
const myEnd = this.drawCoordinates_(
flatCoordinates, 0, flatCoordinates.length, stride);
this.instructions.push([
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.image_,
// Remaining arguments to DRAW_IMAGE are in alphabetical order
@@ -214,11 +214,11 @@ _ol_render_canvas_ImageReplay_.prototype.finish = function() {
* @inheritDoc
*/
_ol_render_canvas_ImageReplay_.prototype.setImageStyle = function(imageStyle, declutterGroup) {
var anchor = imageStyle.getAnchor();
var size = imageStyle.getSize();
var hitDetectionImage = imageStyle.getHitDetectionImage(1);
var image = imageStyle.getImage(1);
var origin = imageStyle.getOrigin();
const anchor = imageStyle.getAnchor();
const size = imageStyle.getSize();
const hitDetectionImage = imageStyle.getHitDetectionImage(1);
const image = imageStyle.getImage(1);
const origin = imageStyle.getOrigin();
this.anchorX_ = anchor[0];
this.anchorY_ = anchor[1];
this.declutterGroup_ = /** @type {ol.DeclutterGroup} */ (declutterGroup);
+116 -116
View File
@@ -35,7 +35,7 @@ import _ol_transform_ from '../../transform.js';
* @param {number} viewRotation View rotation.
* @struct
*/
var CanvasImmediateRenderer = function(context, pixelRatio, extent, transform, viewRotation) {
const CanvasImmediateRenderer = function(context, pixelRatio, extent, transform, viewRotation) {
VectorContext.call(this);
/**
@@ -252,40 +252,40 @@ CanvasImmediateRenderer.prototype.drawImages_ = function(flatCoordinates, offset
if (!this.image_) {
return;
}
var pixelCoordinates = _ol_geom_flat_transform_.transform2D(
flatCoordinates, offset, end, 2, this.transform_,
this.pixelCoordinates_);
var context = this.context_;
var localTransform = this.tmpLocalTransform_;
var alpha = context.globalAlpha;
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
flatCoordinates, offset, end, 2, this.transform_,
this.pixelCoordinates_);
const context = this.context_;
const localTransform = this.tmpLocalTransform_;
const alpha = context.globalAlpha;
if (this.imageOpacity_ != 1) {
context.globalAlpha = alpha * this.imageOpacity_;
}
var rotation = this.imageRotation_;
let rotation = this.imageRotation_;
if (this.imageRotateWithView_) {
rotation += this.viewRotation_;
}
var i, ii;
let i, ii;
for (i = 0, ii = pixelCoordinates.length; i < ii; i += 2) {
var x = pixelCoordinates[i] - this.imageAnchorX_;
var y = pixelCoordinates[i + 1] - this.imageAnchorY_;
let x = pixelCoordinates[i] - this.imageAnchorX_;
let y = pixelCoordinates[i + 1] - this.imageAnchorY_;
if (this.imageSnapToPixel_) {
x = Math.round(x);
y = Math.round(y);
}
if (rotation !== 0 || this.imageScale_ != 1) {
var centerX = x + this.imageAnchorX_;
var centerY = y + this.imageAnchorY_;
const centerX = x + this.imageAnchorX_;
const centerY = y + this.imageAnchorY_;
_ol_transform_.compose(localTransform,
centerX, centerY,
this.imageScale_, this.imageScale_,
rotation,
-centerX, -centerY);
centerX, centerY,
this.imageScale_, this.imageScale_,
rotation,
-centerX, -centerY);
context.setTransform.apply(context, localTransform);
}
context.drawImage(this.image_, this.imageOriginX_, this.imageOriginY_,
this.imageWidth_, this.imageHeight_, x, y,
this.imageWidth_, this.imageHeight_);
this.imageWidth_, this.imageHeight_, x, y,
this.imageWidth_, this.imageHeight_);
}
if (rotation !== 0 || this.imageScale_ != 1) {
context.setTransform(1, 0, 0, 1, 0, 0);
@@ -314,23 +314,23 @@ CanvasImmediateRenderer.prototype.drawText_ = function(flatCoordinates, offset,
this.setContextStrokeState_(this.textStrokeState_);
}
this.setContextTextState_(this.textState_);
var pixelCoordinates = _ol_geom_flat_transform_.transform2D(
flatCoordinates, offset, end, stride, this.transform_,
this.pixelCoordinates_);
var context = this.context_;
var rotation = this.textRotation_;
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
flatCoordinates, offset, end, stride, this.transform_,
this.pixelCoordinates_);
const context = this.context_;
let rotation = this.textRotation_;
if (this.textRotateWithView_) {
rotation += this.viewRotation_;
}
for (; offset < end; offset += stride) {
var x = pixelCoordinates[offset] + this.textOffsetX_;
var y = pixelCoordinates[offset + 1] + this.textOffsetY_;
const x = pixelCoordinates[offset] + this.textOffsetX_;
const y = pixelCoordinates[offset + 1] + this.textOffsetY_;
if (rotation !== 0 || this.textScale_ != 1) {
var localTransform = _ol_transform_.compose(this.tmpLocalTransform_,
x, y,
this.textScale_, this.textScale_,
rotation,
-x, -y);
const localTransform = _ol_transform_.compose(this.tmpLocalTransform_,
x, y,
this.textScale_, this.textScale_,
rotation,
-x, -y);
context.setTransform.apply(context, localTransform);
}
if (this.textStrokeState_) {
@@ -356,16 +356,16 @@ CanvasImmediateRenderer.prototype.drawText_ = function(flatCoordinates, offset,
* @return {number} end End.
*/
CanvasImmediateRenderer.prototype.moveToLineTo_ = function(flatCoordinates, offset, end, stride, close) {
var context = this.context_;
var pixelCoordinates = _ol_geom_flat_transform_.transform2D(
flatCoordinates, offset, end, stride, this.transform_,
this.pixelCoordinates_);
const context = this.context_;
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
flatCoordinates, offset, end, stride, this.transform_,
this.pixelCoordinates_);
context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);
var length = pixelCoordinates.length;
let length = pixelCoordinates.length;
if (close) {
length -= 2;
}
for (var i = 2; i < length; i += 2) {
for (let i = 2; i < length; i += 2) {
context.lineTo(pixelCoordinates[i], pixelCoordinates[i + 1]);
}
if (close) {
@@ -384,10 +384,10 @@ CanvasImmediateRenderer.prototype.moveToLineTo_ = function(flatCoordinates, offs
* @return {number} End.
*/
CanvasImmediateRenderer.prototype.drawRings_ = function(flatCoordinates, offset, ends, stride) {
var i, ii;
let i, ii;
for (i = 0, ii = ends.length; i < ii; ++i) {
offset = this.moveToLineTo_(
flatCoordinates, offset, ends[i], stride, true);
flatCoordinates, offset, ends[i], stride, true);
}
return offset;
};
@@ -412,15 +412,15 @@ CanvasImmediateRenderer.prototype.drawCircle = function(geometry) {
if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_);
}
var pixelCoordinates = SimpleGeometry.transform2D(
geometry, this.transform_, this.pixelCoordinates_);
var dx = pixelCoordinates[2] - pixelCoordinates[0];
var dy = pixelCoordinates[3] - pixelCoordinates[1];
var radius = Math.sqrt(dx * dx + dy * dy);
var context = this.context_;
const pixelCoordinates = SimpleGeometry.transform2D(
geometry, this.transform_, this.pixelCoordinates_);
const dx = pixelCoordinates[2] - pixelCoordinates[0];
const dy = pixelCoordinates[3] - pixelCoordinates[1];
const radius = Math.sqrt(dx * dx + dy * dy);
const context = this.context_;
context.beginPath();
context.arc(
pixelCoordinates[0], pixelCoordinates[1], radius, 0, 2 * Math.PI);
pixelCoordinates[0], pixelCoordinates[1], radius, 0, 2 * Math.PI);
if (this.fillState_) {
context.fill();
}
@@ -458,7 +458,7 @@ CanvasImmediateRenderer.prototype.setStyle = function(style) {
* @api
*/
CanvasImmediateRenderer.prototype.drawGeometry = function(geometry) {
var type = geometry.getType();
const type = geometry.getType();
switch (type) {
case GeometryType.POINT:
this.drawPoint(/** @type {ol.geom.Point} */ (geometry));
@@ -501,7 +501,7 @@ CanvasImmediateRenderer.prototype.drawGeometry = function(geometry) {
* @api
*/
CanvasImmediateRenderer.prototype.drawFeature = function(feature, style) {
var geometry = style.getGeometryFunction()(feature);
const geometry = style.getGeometryFunction()(feature);
if (!geometry || !intersects(this.extent_, geometry.getExtent())) {
return;
}
@@ -518,8 +518,8 @@ CanvasImmediateRenderer.prototype.drawFeature = function(feature, style) {
* @override
*/
CanvasImmediateRenderer.prototype.drawGeometryCollection = function(geometry) {
var geometries = geometry.getGeometriesArray();
var i, ii;
const geometries = geometry.getGeometriesArray();
let i, ii;
for (i = 0, ii = geometries.length; i < ii; ++i) {
this.drawGeometry(geometries[i]);
}
@@ -534,8 +534,8 @@ CanvasImmediateRenderer.prototype.drawGeometryCollection = function(geometry) {
* @override
*/
CanvasImmediateRenderer.prototype.drawPoint = function(geometry) {
var flatCoordinates = geometry.getFlatCoordinates();
var stride = geometry.getStride();
const flatCoordinates = geometry.getFlatCoordinates();
const stride = geometry.getStride();
if (this.image_) {
this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);
}
@@ -553,8 +553,8 @@ CanvasImmediateRenderer.prototype.drawPoint = function(geometry) {
* @override
*/
CanvasImmediateRenderer.prototype.drawMultiPoint = function(geometry) {
var flatCoordinates = geometry.getFlatCoordinates();
var stride = geometry.getStride();
const flatCoordinates = geometry.getFlatCoordinates();
const stride = geometry.getStride();
if (this.image_) {
this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);
}
@@ -577,15 +577,15 @@ CanvasImmediateRenderer.prototype.drawLineString = function(geometry) {
}
if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_);
var context = this.context_;
var flatCoordinates = geometry.getFlatCoordinates();
const context = this.context_;
const flatCoordinates = geometry.getFlatCoordinates();
context.beginPath();
this.moveToLineTo_(flatCoordinates, 0, flatCoordinates.length,
geometry.getStride(), false);
geometry.getStride(), false);
context.stroke();
}
if (this.text_ !== '') {
var flatMidpoint = geometry.getFlatMidpoint();
const flatMidpoint = geometry.getFlatMidpoint();
this.drawText_(flatMidpoint, 0, 2, 2);
}
};
@@ -600,27 +600,27 @@ CanvasImmediateRenderer.prototype.drawLineString = function(geometry) {
* @override
*/
CanvasImmediateRenderer.prototype.drawMultiLineString = function(geometry) {
var geometryExtent = geometry.getExtent();
const geometryExtent = geometry.getExtent();
if (!intersects(this.extent_, geometryExtent)) {
return;
}
if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_);
var context = this.context_;
var flatCoordinates = geometry.getFlatCoordinates();
var offset = 0;
var ends = geometry.getEnds();
var stride = geometry.getStride();
const context = this.context_;
const flatCoordinates = geometry.getFlatCoordinates();
let offset = 0;
const ends = geometry.getEnds();
const stride = geometry.getStride();
context.beginPath();
var i, ii;
let i, ii;
for (i = 0, ii = ends.length; i < ii; ++i) {
offset = this.moveToLineTo_(
flatCoordinates, offset, ends[i], stride, false);
flatCoordinates, offset, ends[i], stride, false);
}
context.stroke();
}
if (this.text_ !== '') {
var flatMidpoints = geometry.getFlatMidpoints();
const flatMidpoints = geometry.getFlatMidpoints();
this.drawText_(flatMidpoints, 0, flatMidpoints.length, 2);
}
};
@@ -644,10 +644,10 @@ CanvasImmediateRenderer.prototype.drawPolygon = function(geometry) {
if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_);
}
var context = this.context_;
const context = this.context_;
context.beginPath();
this.drawRings_(geometry.getOrientedFlatCoordinates(),
0, geometry.getEnds(), geometry.getStride());
0, geometry.getEnds(), geometry.getStride());
if (this.fillState_) {
context.fill();
}
@@ -656,7 +656,7 @@ CanvasImmediateRenderer.prototype.drawPolygon = function(geometry) {
}
}
if (this.text_ !== '') {
var flatInteriorPoint = geometry.getFlatInteriorPoint();
const flatInteriorPoint = geometry.getFlatInteriorPoint();
this.drawText_(flatInteriorPoint, 0, 2, 2);
}
};
@@ -679,15 +679,15 @@ CanvasImmediateRenderer.prototype.drawMultiPolygon = function(geometry) {
if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_);
}
var context = this.context_;
var flatCoordinates = geometry.getOrientedFlatCoordinates();
var offset = 0;
var endss = geometry.getEndss();
var stride = geometry.getStride();
var i, ii;
const context = this.context_;
const flatCoordinates = geometry.getOrientedFlatCoordinates();
let offset = 0;
const endss = geometry.getEndss();
const stride = geometry.getStride();
let i, ii;
context.beginPath();
for (i = 0, ii = endss.length; i < ii; ++i) {
var ends = endss[i];
const ends = endss[i];
offset = this.drawRings_(flatCoordinates, offset, ends, stride);
}
if (this.fillState_) {
@@ -698,7 +698,7 @@ CanvasImmediateRenderer.prototype.drawMultiPolygon = function(geometry) {
}
}
if (this.text_ !== '') {
var flatInteriorPoints = geometry.getFlatInteriorPoints();
const flatInteriorPoints = geometry.getFlatInteriorPoints();
this.drawText_(flatInteriorPoints, 0, flatInteriorPoints.length, 2);
}
};
@@ -709,8 +709,8 @@ CanvasImmediateRenderer.prototype.drawMultiPolygon = function(geometry) {
* @private
*/
CanvasImmediateRenderer.prototype.setContextFillState_ = function(fillState) {
var context = this.context_;
var contextFillState = this.contextFillState_;
const context = this.context_;
const contextFillState = this.contextFillState_;
if (!contextFillState) {
context.fillStyle = fillState.fillStyle;
this.contextFillState_ = {
@@ -729,8 +729,8 @@ CanvasImmediateRenderer.prototype.setContextFillState_ = function(fillState) {
* @private
*/
CanvasImmediateRenderer.prototype.setContextStrokeState_ = function(strokeState) {
var context = this.context_;
var contextStrokeState = this.contextStrokeState_;
const context = this.context_;
const contextStrokeState = this.contextStrokeState_;
if (!contextStrokeState) {
context.lineCap = strokeState.lineCap;
if (_ol_has_.CANVAS_LINE_DASH) {
@@ -786,9 +786,9 @@ CanvasImmediateRenderer.prototype.setContextStrokeState_ = function(strokeState)
* @private
*/
CanvasImmediateRenderer.prototype.setContextTextState_ = function(textState) {
var context = this.context_;
var contextTextState = this.contextTextState_;
var textAlign = textState.textAlign ?
const context = this.context_;
const contextTextState = this.contextTextState_;
const textAlign = textState.textAlign ?
textState.textAlign : _ol_render_canvas_.defaultTextAlign;
if (!contextTextState) {
context.font = textState.font;
@@ -826,7 +826,7 @@ CanvasImmediateRenderer.prototype.setFillStrokeStyle = function(fillStyle, strok
if (!fillStyle) {
this.fillState_ = null;
} else {
var fillStyleColor = fillStyle.getColor();
const fillStyleColor = fillStyle.getColor();
this.fillState_ = {
fillStyle: asColorLike(fillStyleColor ?
fillStyleColor : _ol_render_canvas_.defaultFillStyle)
@@ -835,13 +835,13 @@ CanvasImmediateRenderer.prototype.setFillStrokeStyle = function(fillStyle, strok
if (!strokeStyle) {
this.strokeState_ = null;
} else {
var strokeStyleColor = strokeStyle.getColor();
var strokeStyleLineCap = strokeStyle.getLineCap();
var strokeStyleLineDash = strokeStyle.getLineDash();
var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
var strokeStyleLineJoin = strokeStyle.getLineJoin();
var strokeStyleWidth = strokeStyle.getWidth();
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
const strokeStyleColor = strokeStyle.getColor();
const strokeStyleLineCap = strokeStyle.getLineCap();
const strokeStyleLineDash = strokeStyle.getLineDash();
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
const strokeStyleLineJoin = strokeStyle.getLineJoin();
const strokeStyleWidth = strokeStyle.getWidth();
const strokeStyleMiterLimit = strokeStyle.getMiterLimit();
this.strokeState_ = {
lineCap: strokeStyleLineCap !== undefined ?
strokeStyleLineCap : _ol_render_canvas_.defaultLineCap,
@@ -873,11 +873,11 @@ CanvasImmediateRenderer.prototype.setImageStyle = function(imageStyle) {
if (!imageStyle) {
this.image_ = null;
} else {
var imageAnchor = imageStyle.getAnchor();
const imageAnchor = imageStyle.getAnchor();
// FIXME pixel ratio
var imageImage = imageStyle.getImage(1);
var imageOrigin = imageStyle.getOrigin();
var imageSize = imageStyle.getSize();
const imageImage = imageStyle.getImage(1);
const imageOrigin = imageStyle.getOrigin();
const imageSize = imageStyle.getSize();
this.imageAnchorX_ = imageAnchor[0];
this.imageAnchorY_ = imageAnchor[1];
this.imageHeight_ = imageSize[1];
@@ -905,27 +905,27 @@ CanvasImmediateRenderer.prototype.setTextStyle = function(textStyle) {
if (!textStyle) {
this.text_ = '';
} else {
var textFillStyle = textStyle.getFill();
const textFillStyle = textStyle.getFill();
if (!textFillStyle) {
this.textFillState_ = null;
} else {
var textFillStyleColor = textFillStyle.getColor();
const textFillStyleColor = textFillStyle.getColor();
this.textFillState_ = {
fillStyle: asColorLike(textFillStyleColor ?
textFillStyleColor : _ol_render_canvas_.defaultFillStyle)
};
}
var textStrokeStyle = textStyle.getStroke();
const textStrokeStyle = textStyle.getStroke();
if (!textStrokeStyle) {
this.textStrokeState_ = null;
} else {
var textStrokeStyleColor = textStrokeStyle.getColor();
var textStrokeStyleLineCap = textStrokeStyle.getLineCap();
var textStrokeStyleLineDash = textStrokeStyle.getLineDash();
var textStrokeStyleLineDashOffset = textStrokeStyle.getLineDashOffset();
var textStrokeStyleLineJoin = textStrokeStyle.getLineJoin();
var textStrokeStyleWidth = textStrokeStyle.getWidth();
var textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit();
const textStrokeStyleColor = textStrokeStyle.getColor();
const textStrokeStyleLineCap = textStrokeStyle.getLineCap();
const textStrokeStyleLineDash = textStrokeStyle.getLineDash();
const textStrokeStyleLineDashOffset = textStrokeStyle.getLineDashOffset();
const textStrokeStyleLineJoin = textStrokeStyle.getLineJoin();
const textStrokeStyleWidth = textStrokeStyle.getWidth();
const textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit();
this.textStrokeState_ = {
lineCap: textStrokeStyleLineCap !== undefined ?
textStrokeStyleLineCap : _ol_render_canvas_.defaultLineCap,
@@ -943,15 +943,15 @@ CanvasImmediateRenderer.prototype.setTextStyle = function(textStyle) {
textStrokeStyleColor : _ol_render_canvas_.defaultStrokeStyle)
};
}
var textFont = textStyle.getFont();
var textOffsetX = textStyle.getOffsetX();
var textOffsetY = textStyle.getOffsetY();
var textRotateWithView = textStyle.getRotateWithView();
var textRotation = textStyle.getRotation();
var textScale = textStyle.getScale();
var textText = textStyle.getText();
var textTextAlign = textStyle.getTextAlign();
var textTextBaseline = textStyle.getTextBaseline();
const textFont = textStyle.getFont();
const textOffsetX = textStyle.getOffsetX();
const textOffsetY = textStyle.getOffsetY();
const textRotateWithView = textStyle.getRotateWithView();
const textRotation = textStyle.getRotation();
const textScale = textStyle.getScale();
const textText = textStyle.getText();
const textTextAlign = textStyle.getTextAlign();
const textTextBaseline = textStyle.getTextBaseline();
this.textState_ = {
font: textFont !== undefined ?
textFont : _ol_render_canvas_.defaultFont,
+22 -22
View File
@@ -16,10 +16,10 @@ import _ol_render_canvas_Replay_ from '../canvas/Replay.js';
* @param {?} declutterTree Declutter tree.
* @struct
*/
var _ol_render_canvas_LineStringReplay_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
const _ol_render_canvas_LineStringReplay_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
_ol_render_canvas_Replay_.call(this,
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
};
inherits(_ol_render_canvas_LineStringReplay_, _ol_render_canvas_Replay_);
@@ -34,10 +34,10 @@ inherits(_ol_render_canvas_LineStringReplay_, _ol_render_canvas_Replay_);
* @return {number} end.
*/
_ol_render_canvas_LineStringReplay_.prototype.drawFlatCoordinates_ = function(flatCoordinates, offset, end, stride) {
var myBegin = this.coordinates.length;
var myEnd = this.appendFlatCoordinates(
flatCoordinates, offset, end, stride, false, false);
var moveToLineToInstruction =
const myBegin = this.coordinates.length;
const myEnd = this.appendFlatCoordinates(
flatCoordinates, offset, end, stride, false, false);
const moveToLineToInstruction =
[_ol_render_canvas_Instruction_.MOVE_TO_LINE_TO, myBegin, myEnd];
this.instructions.push(moveToLineToInstruction);
this.hitDetectionInstructions.push(moveToLineToInstruction);
@@ -49,9 +49,9 @@ _ol_render_canvas_LineStringReplay_.prototype.drawFlatCoordinates_ = function(fl
* @inheritDoc
*/
_ol_render_canvas_LineStringReplay_.prototype.drawLineString = function(lineStringGeometry, feature) {
var state = this.state;
var strokeStyle = state.strokeStyle;
var lineWidth = state.lineWidth;
const state = this.state;
const strokeStyle = state.strokeStyle;
const lineWidth = state.lineWidth;
if (strokeStyle === undefined || lineWidth === undefined) {
return;
}
@@ -64,8 +64,8 @@ _ol_render_canvas_LineStringReplay_.prototype.drawLineString = function(lineStri
], [
_ol_render_canvas_Instruction_.BEGIN_PATH
]);
var flatCoordinates = lineStringGeometry.getFlatCoordinates();
var stride = lineStringGeometry.getStride();
const flatCoordinates = lineStringGeometry.getFlatCoordinates();
const stride = lineStringGeometry.getStride();
this.drawFlatCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride);
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.STROKE]);
this.endGeometry(lineStringGeometry, feature);
@@ -76,9 +76,9 @@ _ol_render_canvas_LineStringReplay_.prototype.drawLineString = function(lineStri
* @inheritDoc
*/
_ol_render_canvas_LineStringReplay_.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
var state = this.state;
var strokeStyle = state.strokeStyle;
var lineWidth = state.lineWidth;
const state = this.state;
const strokeStyle = state.strokeStyle;
const lineWidth = state.lineWidth;
if (strokeStyle === undefined || lineWidth === undefined) {
return;
}
@@ -91,14 +91,14 @@ _ol_render_canvas_LineStringReplay_.prototype.drawMultiLineString = function(mul
], [
_ol_render_canvas_Instruction_.BEGIN_PATH
]);
var ends = multiLineStringGeometry.getEnds();
var flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
var stride = multiLineStringGeometry.getStride();
var offset = 0;
var i, ii;
const ends = multiLineStringGeometry.getEnds();
const flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
const stride = multiLineStringGeometry.getStride();
let offset = 0;
let i, ii;
for (i = 0, ii = ends.length; i < ii; ++i) {
offset = this.drawFlatCoordinates_(
flatCoordinates, offset, ends[i], stride);
flatCoordinates, offset, ends[i], stride);
}
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.STROKE]);
this.endGeometry(multiLineStringGeometry, feature);
@@ -109,7 +109,7 @@ _ol_render_canvas_LineStringReplay_.prototype.drawMultiLineString = function(mul
* @inheritDoc
*/
_ol_render_canvas_LineStringReplay_.prototype.finish = function() {
var state = this.state;
const state = this.state;
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) {
this.instructions.push([_ol_render_canvas_Instruction_.STROKE]);
}
+46 -46
View File
@@ -19,10 +19,10 @@ import _ol_render_canvas_Replay_ from '../canvas/Replay.js';
* @param {?} declutterTree Declutter tree.
* @struct
*/
var _ol_render_canvas_PolygonReplay_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
const _ol_render_canvas_PolygonReplay_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
_ol_render_canvas_Replay_.call(this,
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
};
inherits(_ol_render_canvas_PolygonReplay_, _ol_render_canvas_Replay_);
@@ -37,38 +37,38 @@ inherits(_ol_render_canvas_PolygonReplay_, _ol_render_canvas_Replay_);
* @return {number} End.
*/
_ol_render_canvas_PolygonReplay_.prototype.drawFlatCoordinatess_ = function(flatCoordinates, offset, ends, stride) {
var state = this.state;
var fill = state.fillStyle !== undefined;
var stroke = state.strokeStyle != undefined;
var numEnds = ends.length;
var beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH];
const state = this.state;
const fill = state.fillStyle !== undefined;
const stroke = state.strokeStyle != undefined;
const numEnds = ends.length;
const beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH];
this.instructions.push(beginPathInstruction);
this.hitDetectionInstructions.push(beginPathInstruction);
for (var i = 0; i < numEnds; ++i) {
var end = ends[i];
var myBegin = this.coordinates.length;
var myEnd = this.appendFlatCoordinates(
flatCoordinates, offset, end, stride, true, !stroke);
var moveToLineToInstruction =
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 moveToLineToInstruction =
[_ol_render_canvas_Instruction_.MOVE_TO_LINE_TO, myBegin, myEnd];
this.instructions.push(moveToLineToInstruction);
this.hitDetectionInstructions.push(moveToLineToInstruction);
if (stroke) {
// Performance optimization: only call closePath() when we have a stroke.
// Otherwise the ring is closed already (see appendFlatCoordinates above).
var closePathInstruction = [_ol_render_canvas_Instruction_.CLOSE_PATH];
const closePathInstruction = [_ol_render_canvas_Instruction_.CLOSE_PATH];
this.instructions.push(closePathInstruction);
this.hitDetectionInstructions.push(closePathInstruction);
}
offset = end;
}
var fillInstruction = [_ol_render_canvas_Instruction_.FILL];
const fillInstruction = [_ol_render_canvas_Instruction_.FILL];
this.hitDetectionInstructions.push(fillInstruction);
if (fill) {
this.instructions.push(fillInstruction);
}
if (stroke) {
var strokeInstruction = [_ol_render_canvas_Instruction_.STROKE];
const strokeInstruction = [_ol_render_canvas_Instruction_.STROKE];
this.instructions.push(strokeInstruction);
this.hitDetectionInstructions.push(strokeInstruction);
}
@@ -80,9 +80,9 @@ _ol_render_canvas_PolygonReplay_.prototype.drawFlatCoordinatess_ = function(flat
* @inheritDoc
*/
_ol_render_canvas_PolygonReplay_.prototype.drawCircle = function(circleGeometry, feature) {
var state = this.state;
var fillStyle = state.fillStyle;
var strokeStyle = state.strokeStyle;
const state = this.state;
const fillStyle = state.fillStyle;
const strokeStyle = state.strokeStyle;
if (fillStyle === undefined && strokeStyle === undefined) {
return;
}
@@ -100,22 +100,22 @@ _ol_render_canvas_PolygonReplay_.prototype.drawCircle = function(circleGeometry,
state.miterLimit, state.lineDash, state.lineDashOffset
]);
}
var flatCoordinates = circleGeometry.getFlatCoordinates();
var stride = circleGeometry.getStride();
var myBegin = this.coordinates.length;
const flatCoordinates = circleGeometry.getFlatCoordinates();
const stride = circleGeometry.getStride();
const myBegin = this.coordinates.length;
this.appendFlatCoordinates(
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
var beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH];
var circleInstruction = [_ol_render_canvas_Instruction_.CIRCLE, myBegin];
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
const beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH];
const circleInstruction = [_ol_render_canvas_Instruction_.CIRCLE, myBegin];
this.instructions.push(beginPathInstruction, circleInstruction);
this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction);
var fillInstruction = [_ol_render_canvas_Instruction_.FILL];
const fillInstruction = [_ol_render_canvas_Instruction_.FILL];
this.hitDetectionInstructions.push(fillInstruction);
if (state.fillStyle !== undefined) {
this.instructions.push(fillInstruction);
}
if (state.strokeStyle !== undefined) {
var strokeInstruction = [_ol_render_canvas_Instruction_.STROKE];
const strokeInstruction = [_ol_render_canvas_Instruction_.STROKE];
this.instructions.push(strokeInstruction);
this.hitDetectionInstructions.push(strokeInstruction);
}
@@ -127,7 +127,7 @@ _ol_render_canvas_PolygonReplay_.prototype.drawCircle = function(circleGeometry,
* @inheritDoc
*/
_ol_render_canvas_PolygonReplay_.prototype.drawPolygon = function(polygonGeometry, feature) {
var state = this.state;
const state = this.state;
this.setFillStrokeStyles_(polygonGeometry);
this.beginGeometry(polygonGeometry, feature);
// always fill the polygon for hit detection
@@ -142,9 +142,9 @@ _ol_render_canvas_PolygonReplay_.prototype.drawPolygon = function(polygonGeometr
state.miterLimit, state.lineDash, state.lineDashOffset
]);
}
var ends = polygonGeometry.getEnds();
var flatCoordinates = polygonGeometry.getOrientedFlatCoordinates();
var stride = polygonGeometry.getStride();
const ends = polygonGeometry.getEnds();
const flatCoordinates = polygonGeometry.getOrientedFlatCoordinates();
const stride = polygonGeometry.getStride();
this.drawFlatCoordinatess_(flatCoordinates, 0, ends, stride);
this.endGeometry(polygonGeometry, feature);
};
@@ -154,9 +154,9 @@ _ol_render_canvas_PolygonReplay_.prototype.drawPolygon = function(polygonGeometr
* @inheritDoc
*/
_ol_render_canvas_PolygonReplay_.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
var state = this.state;
var fillStyle = state.fillStyle;
var strokeStyle = state.strokeStyle;
const state = this.state;
const fillStyle = state.fillStyle;
const strokeStyle = state.strokeStyle;
if (fillStyle === undefined && strokeStyle === undefined) {
return;
}
@@ -174,14 +174,14 @@ _ol_render_canvas_PolygonReplay_.prototype.drawMultiPolygon = function(multiPoly
state.miterLimit, state.lineDash, state.lineDashOffset
]);
}
var endss = multiPolygonGeometry.getEndss();
var flatCoordinates = multiPolygonGeometry.getOrientedFlatCoordinates();
var stride = multiPolygonGeometry.getStride();
var offset = 0;
var i, ii;
const endss = multiPolygonGeometry.getEndss();
const flatCoordinates = multiPolygonGeometry.getOrientedFlatCoordinates();
const stride = multiPolygonGeometry.getStride();
let offset = 0;
let i, ii;
for (i = 0, ii = endss.length; i < ii; ++i) {
offset = this.drawFlatCoordinatess_(
flatCoordinates, offset, endss[i], stride);
flatCoordinates, offset, endss[i], stride);
}
this.endGeometry(multiPolygonGeometry, feature);
};
@@ -197,10 +197,10 @@ _ol_render_canvas_PolygonReplay_.prototype.finish = function() {
// simplified using quantization and point elimination. However, we might
// have received a mix of quantized and non-quantized geometries, so ensure
// that all are quantized by quantizing all coordinates in the batch.
var tolerance = this.tolerance;
const tolerance = this.tolerance;
if (tolerance !== 0) {
var coordinates = this.coordinates;
var i, ii;
const coordinates = this.coordinates;
let i, ii;
for (i = 0, ii = coordinates.length; i < ii; ++i) {
coordinates[i] = _ol_geom_flat_simplify_.snap(coordinates[i], tolerance);
}
@@ -213,8 +213,8 @@ _ol_render_canvas_PolygonReplay_.prototype.finish = function() {
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
*/
_ol_render_canvas_PolygonReplay_.prototype.setFillStrokeStyles_ = function(geometry) {
var state = this.state;
var fillStyle = state.fillStyle;
const state = this.state;
const fillStyle = state.fillStyle;
if (fillStyle !== undefined) {
this.updateFillStyle(state, this.createFill, geometry);
}
+167 -167
View File
@@ -31,7 +31,7 @@ import _ol_transform_ from '../../transform.js';
* @param {?} declutterTree Declutter tree.
* @struct
*/
var _ol_render_canvas_Replay_ = function(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
const _ol_render_canvas_Replay_ = function(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
VectorContext.call(this);
/**
@@ -181,7 +181,7 @@ inherits(_ol_render_canvas_Replay_, VectorContext);
* @param {Array.<*>} strokeInstruction Stroke instruction.
*/
_ol_render_canvas_Replay_.prototype.replayTextBackground_ = function(context, p1, p2, p3, p4,
fillInstruction, strokeInstruction) {
fillInstruction, strokeInstruction) {
context.beginPath();
context.moveTo.apply(context, p1);
context.lineTo.apply(context, p2);
@@ -220,31 +220,31 @@ _ol_render_canvas_Replay_.prototype.replayTextBackground_ = function(context, p1
* @param {Array.<*>} strokeInstruction Stroke instruction.
*/
_ol_render_canvas_Replay_.prototype.replayImage_ = function(context, x, y, image,
anchorX, anchorY, declutterGroup, height, opacity, originX, originY,
rotation, scale, snapToPixel, width, padding, fillInstruction, strokeInstruction) {
var fillStroke = fillInstruction || strokeInstruction;
var localTransform = this.tmpLocalTransform_;
anchorX, anchorY, declutterGroup, height, opacity, originX, originY,
rotation, scale, snapToPixel, width, padding, fillInstruction, strokeInstruction) {
const fillStroke = fillInstruction || strokeInstruction;
const localTransform = this.tmpLocalTransform_;
anchorX *= scale;
anchorY *= scale;
x -= anchorX;
y -= anchorY;
var w = (width + originX > image.width) ? image.width - originX : width;
var h = (height + originY > image.height) ? image.height - originY : height;
var box = this.tmpExtent_;
var boxW = padding[3] + w * scale + padding[1];
var boxH = padding[0] + h * scale + padding[2];
var boxX = x - padding[3];
var boxY = y - padding[0];
const w = (width + originX > image.width) ? image.width - originX : width;
const h = (height + originY > image.height) ? image.height - originY : height;
const box = this.tmpExtent_;
const boxW = padding[3] + w * scale + padding[1];
const boxH = padding[0] + h * scale + padding[2];
const boxX = x - padding[3];
const boxY = y - padding[0];
/** @type {ol.Coordinate} */
var p1;
let p1;
/** @type {ol.Coordinate} */
var p2;
let p2;
/** @type {ol.Coordinate} */
var p3;
let p3;
/** @type {ol.Coordinate} */
var p4;
let p4;
if (fillStroke || rotation !== 0) {
p1 = [boxX, boxY];
p2 = [boxX + boxW, boxY];
@@ -252,12 +252,12 @@ _ol_render_canvas_Replay_.prototype.replayImage_ = function(context, x, y, image
p4 = [boxX, boxY + boxH];
}
var transform = null;
let transform = null;
if (rotation !== 0) {
var centerX = x + anchorX;
var centerY = y + anchorY;
const centerX = x + anchorX;
const centerY = y + anchorY;
transform = _ol_transform_.compose(localTransform,
centerX, centerY, 1, 1, rotation, -centerX, -centerY);
centerX, centerY, 1, 1, rotation, -centerX, -centerY);
createOrUpdateEmpty(box);
extendCoordinate(box, _ol_transform_.apply(localTransform, p1));
@@ -267,9 +267,9 @@ _ol_render_canvas_Replay_.prototype.replayImage_ = function(context, x, y, image
} else {
createOrUpdate(boxX, boxY, boxX + boxW, boxY + boxH, box);
}
var canvas = context.canvas;
var strokePadding = strokeInstruction ? (strokeInstruction[2] * scale / 2) : 0;
var intersects =
const canvas = context.canvas;
const strokePadding = strokeInstruction ? (strokeInstruction[2] * scale / 2) : 0;
const intersects =
box[0] - strokePadding <= canvas.width && box[2] + strokePadding >= 0 &&
box[1] - strokePadding <= canvas.height && box[3] + strokePadding >= 0;
@@ -283,7 +283,7 @@ _ol_render_canvas_Replay_.prototype.replayImage_ = function(context, x, y, image
return;
}
extend(declutterGroup, box);
var declutterArgs = intersects ?
const declutterArgs = intersects ?
[context, transform ? transform.slice(0) : null, opacity, image, originX, originY, w, h, x, y, scale] :
null;
if (declutterArgs && fillStroke) {
@@ -293,8 +293,8 @@ _ol_render_canvas_Replay_.prototype.replayImage_ = function(context, x, y, image
} else if (intersects) {
if (fillStroke) {
this.replayTextBackground_(context, p1, p2, p3, p4,
/** @type {Array.<*>} */ (fillInstruction),
/** @type {Array.<*>} */ (strokeInstruction));
/** @type {Array.<*>} */ (fillInstruction),
/** @type {Array.<*>} */ (strokeInstruction));
}
_ol_render_canvas_.drawImage(context, transform, opacity, image, originX, originY, w, h, x, y, scale);
}
@@ -307,7 +307,7 @@ _ol_render_canvas_Replay_.prototype.replayImage_ = function(context, x, y, image
* @return {Array.<number>} Dash array with pixel ratio applied
*/
_ol_render_canvas_Replay_.prototype.applyPixelRatio = function(dashArray) {
var pixelRatio = this.pixelRatio;
const pixelRatio = this.pixelRatio;
return pixelRatio == 1 ? dashArray : dashArray.map(function(dash) {
return dash * pixelRatio;
});
@@ -326,16 +326,16 @@ _ol_render_canvas_Replay_.prototype.applyPixelRatio = function(dashArray) {
*/
_ol_render_canvas_Replay_.prototype.appendFlatCoordinates = function(flatCoordinates, offset, end, stride, closed, skipFirst) {
var myEnd = this.coordinates.length;
var extent = this.getBufferedMaxExtent();
let myEnd = this.coordinates.length;
const extent = this.getBufferedMaxExtent();
if (skipFirst) {
offset += stride;
}
var lastCoord = [flatCoordinates[offset], flatCoordinates[offset + 1]];
var nextCoord = [NaN, NaN];
var skipped = true;
const lastCoord = [flatCoordinates[offset], flatCoordinates[offset + 1]];
const nextCoord = [NaN, NaN];
let skipped = true;
var i, lastRel, nextRel;
let i, lastRel, nextRel;
for (i = offset + stride; i < end; i += stride) {
nextCoord[0] = flatCoordinates[i];
nextCoord[1] = flatCoordinates[i + 1];
@@ -378,9 +378,9 @@ _ol_render_canvas_Replay_.prototype.appendFlatCoordinates = function(flatCoordin
* @return {number} Offset.
*/
_ol_render_canvas_Replay_.prototype.drawCustomCoordinates_ = function(flatCoordinates, offset, ends, stride, replayEnds) {
for (var i = 0, ii = ends.length; i < ii; ++i) {
var end = ends[i];
var replayEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false);
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
const replayEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false);
replayEnds.push(replayEnd);
offset = end;
}
@@ -393,19 +393,19 @@ _ol_render_canvas_Replay_.prototype.drawCustomCoordinates_ = function(flatCoordi
*/
_ol_render_canvas_Replay_.prototype.drawCustom = function(geometry, feature, renderer) {
this.beginGeometry(geometry, feature);
var type = geometry.getType();
var stride = geometry.getStride();
var replayBegin = this.coordinates.length;
var flatCoordinates, replayEnd, replayEnds, replayEndss;
var offset;
const type = geometry.getType();
const stride = geometry.getStride();
const replayBegin = this.coordinates.length;
let flatCoordinates, replayEnd, replayEnds, replayEndss;
let offset;
if (type == GeometryType.MULTI_POLYGON) {
geometry = /** @type {ol.geom.MultiPolygon} */ (geometry);
flatCoordinates = geometry.getOrientedFlatCoordinates();
replayEndss = [];
var endss = geometry.getEndss();
const endss = geometry.getEndss();
offset = 0;
for (var i = 0, ii = endss.length; i < ii; ++i) {
var myEnds = [];
for (let i = 0, ii = endss.length; i < ii; ++i) {
const myEnds = [];
offset = this.drawCustomCoordinates_(flatCoordinates, offset, endss[i], stride, myEnds);
replayEndss.push(myEnds);
}
@@ -417,14 +417,14 @@ _ol_render_canvas_Replay_.prototype.drawCustom = function(geometry, feature, ren
/** @type {ol.geom.Polygon} */ (geometry).getOrientedFlatCoordinates() :
geometry.getFlatCoordinates();
offset = this.drawCustomCoordinates_(flatCoordinates, 0,
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
stride, replayEnds);
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
stride, replayEnds);
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
replayBegin, replayEnds, geometry, renderer, _ol_geom_flat_inflate_.coordinatess]);
} else if (type == GeometryType.LINE_STRING || type == GeometryType.MULTI_POINT) {
flatCoordinates = geometry.getFlatCoordinates();
replayEnd = this.appendFlatCoordinates(
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
replayBegin, replayEnd, geometry, renderer, _ol_geom_flat_inflate_.coordinates]);
} else if (type == GeometryType.POINT) {
@@ -459,7 +459,7 @@ _ol_render_canvas_Replay_.prototype.beginGeometry = function(geometry, feature)
*/
_ol_render_canvas_Replay_.prototype.fill_ = function(context) {
if (this.fillOrigin_) {
var origin = _ol_transform_.apply(this.renderedTransform_, this.fillOrigin_.slice());
const origin = _ol_transform_.apply(this.renderedTransform_, this.fillOrigin_.slice());
context.translate(origin[0], origin[1]);
context.rotate(this.viewRotation_);
}
@@ -494,10 +494,10 @@ _ol_render_canvas_Replay_.prototype.setStrokeStyle_ = function(context, instruct
*/
_ol_render_canvas_Replay_.prototype.renderDeclutter_ = function(declutterGroup, feature) {
if (declutterGroup && declutterGroup.length > 5) {
var groupCount = declutterGroup[4];
const groupCount = declutterGroup[4];
if (groupCount == 1 || groupCount == declutterGroup.length - 5) {
/** @type {ol.RBushEntry} */
var box = {
const box = {
minX: /** @type {number} */ (declutterGroup[0]),
minY: /** @type {number} */ (declutterGroup[1]),
maxX: /** @type {number} */ (declutterGroup[2]),
@@ -506,14 +506,14 @@ _ol_render_canvas_Replay_.prototype.renderDeclutter_ = function(declutterGroup,
};
if (!this.declutterTree.collides(box)) {
this.declutterTree.insert(box);
var drawImage = _ol_render_canvas_.drawImage;
for (var j = 5, jj = declutterGroup.length; j < jj; ++j) {
var declutterData = /** @type {Array} */ (declutterGroup[j]);
const drawImage = _ol_render_canvas_.drawImage;
for (let j = 5, jj = declutterGroup.length; j < jj; ++j) {
const declutterData = /** @type {Array} */ (declutterGroup[j]);
if (declutterData) {
if (declutterData.length > 11) {
this.replayTextBackground_(declutterData[0],
declutterData[13], declutterData[14], declutterData[15], declutterData[16],
declutterData[11], declutterData[12]);
declutterData[13], declutterData[14], declutterData[15], declutterData[16],
declutterData[11], declutterData[12]);
}
drawImage.apply(undefined, declutterData);
}
@@ -541,10 +541,10 @@ _ol_render_canvas_Replay_.prototype.renderDeclutter_ = function(declutterGroup,
* @template T
*/
_ol_render_canvas_Replay_.prototype.replay_ = function(
context, transform, skippedFeaturesHash,
instructions, featureCallback, opt_hitExtent) {
context, transform, skippedFeaturesHash,
instructions, featureCallback, opt_hitExtent) {
/** @type {Array.<number>} */
var pixelCoordinates;
let pixelCoordinates;
if (this.pixelCoordinates_ && equals(transform, this.renderedTransform_)) {
pixelCoordinates = this.pixelCoordinates_;
} else {
@@ -552,24 +552,24 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
this.pixelCoordinates_ = [];
}
pixelCoordinates = _ol_geom_flat_transform_.transform2D(
this.coordinates, 0, this.coordinates.length, 2,
transform, this.pixelCoordinates_);
this.coordinates, 0, this.coordinates.length, 2,
transform, this.pixelCoordinates_);
_ol_transform_.setFromArray(this.renderedTransform_, transform);
}
var skipFeatures = !_ol_obj_.isEmpty(skippedFeaturesHash);
var i = 0; // instruction index
var ii = instructions.length; // end of instructions
var d = 0; // data index
var dd; // end of per-instruction data
var anchorX, anchorY, prevX, prevY, roundX, roundY, declutterGroup, image;
var pendingFill = 0;
var pendingStroke = 0;
var lastFillInstruction = null;
var lastStrokeInstruction = null;
var coordinateCache = this.coordinateCache_;
var viewRotation = this.viewRotation_;
const skipFeatures = !_ol_obj_.isEmpty(skippedFeaturesHash);
let i = 0; // instruction index
const ii = instructions.length; // end of instructions
let d = 0; // data index
let dd; // end of per-instruction data
let anchorX, anchorY, prevX, prevY, roundX, roundY, declutterGroup, image;
let pendingFill = 0;
let pendingStroke = 0;
let lastFillInstruction = null;
let lastStrokeInstruction = null;
const coordinateCache = this.coordinateCache_;
const viewRotation = this.viewRotation_;
var state = /** @type {olx.render.State} */ ({
const state = /** @type {olx.render.State} */ ({
context: context,
pixelRatio: this.pixelRatio,
resolution: this.resolution,
@@ -578,12 +578,12 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
// When the batch size gets too big, performance decreases. 200 is a good
// balance between batch size and number of fill/stroke instructions.
var batchSize =
const batchSize =
this.instructions != instructions || this.overlaps ? 0 : 200;
while (i < ii) {
var instruction = instructions[i];
var type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
var /** @type {ol.Feature|ol.render.Feature} */ feature, x, y;
const instruction = instructions[i];
const type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
let /** @type {ol.Feature|ol.render.Feature} */ feature, x, y;
switch (type) {
case _ol_render_canvas_Instruction_.BEGIN_GEOMETRY:
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
@@ -592,7 +592,7 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
!feature.getGeometry()) {
i = /** @type {number} */ (instruction[2]);
} else if (opt_hitExtent !== undefined && !intersects(
opt_hitExtent, feature.getGeometry().getExtent())) {
opt_hitExtent, feature.getGeometry().getExtent())) {
i = /** @type {number} */ (instruction[2]) + 1;
} else {
++i;
@@ -615,13 +615,13 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
break;
case _ol_render_canvas_Instruction_.CIRCLE:
d = /** @type {number} */ (instruction[1]);
var x1 = pixelCoordinates[d];
var y1 = pixelCoordinates[d + 1];
var x2 = pixelCoordinates[d + 2];
var y2 = pixelCoordinates[d + 3];
var dx = x2 - x1;
var dy = y2 - y1;
var r = Math.sqrt(dx * dx + dy * dy);
const x1 = pixelCoordinates[d];
const y1 = pixelCoordinates[d + 1];
const x2 = pixelCoordinates[d + 2];
const y2 = pixelCoordinates[d + 3];
const dx = x2 - x1;
const dy = y2 - y1;
const r = Math.sqrt(dx * dx + dy * dy);
context.moveTo(x1 + r, y1);
context.arc(x1, y1, r, 0, 2 * Math.PI, true);
++i;
@@ -633,15 +633,15 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
case _ol_render_canvas_Instruction_.CUSTOM:
d = /** @type {number} */ (instruction[1]);
dd = instruction[2];
var geometry = /** @type {ol.geom.SimpleGeometry} */ (instruction[3]);
var renderer = instruction[4];
var fn = instruction.length == 6 ? instruction[5] : undefined;
const geometry = /** @type {ol.geom.SimpleGeometry} */ (instruction[3]);
const renderer = instruction[4];
const fn = instruction.length == 6 ? instruction[5] : undefined;
state.geometry = geometry;
state.feature = feature;
if (!(i in coordinateCache)) {
coordinateCache[i] = [];
}
var coords = coordinateCache[i];
const coords = coordinateCache[i];
if (fn) {
fn(pixelCoordinates, d, dd, 2, coords);
} else {
@@ -661,17 +661,17 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
anchorX = /** @type {number} */ (instruction[4]);
anchorY = /** @type {number} */ (instruction[5]);
declutterGroup = featureCallback ? null : /** @type {ol.DeclutterGroup} */ (instruction[6]);
var height = /** @type {number} */ (instruction[7]);
var opacity = /** @type {number} */ (instruction[8]);
var originX = /** @type {number} */ (instruction[9]);
var originY = /** @type {number} */ (instruction[10]);
var rotateWithView = /** @type {boolean} */ (instruction[11]);
var rotation = /** @type {number} */ (instruction[12]);
var scale = /** @type {number} */ (instruction[13]);
var snapToPixel = /** @type {boolean} */ (instruction[14]);
var width = /** @type {number} */ (instruction[15]);
const height = /** @type {number} */ (instruction[7]);
const opacity = /** @type {number} */ (instruction[8]);
const originX = /** @type {number} */ (instruction[9]);
const originY = /** @type {number} */ (instruction[10]);
const rotateWithView = /** @type {boolean} */ (instruction[11]);
let rotation = /** @type {number} */ (instruction[12]);
const scale = /** @type {number} */ (instruction[13]);
const snapToPixel = /** @type {boolean} */ (instruction[14]);
const width = /** @type {number} */ (instruction[15]);
var padding, backgroundFill, backgroundStroke;
let padding, backgroundFill, backgroundStroke;
if (instruction.length > 16) {
padding = /** @type {Array.<number>} */ (instruction[16]);
backgroundFill = /** @type {boolean} */ (instruction[17]);
@@ -686,40 +686,40 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
}
for (; d < dd; d += 2) {
this.replayImage_(context,
pixelCoordinates[d], pixelCoordinates[d + 1], image, anchorX, anchorY,
declutterGroup, height, opacity, originX, originY, rotation, scale,
snapToPixel, width, padding,
backgroundFill ? /** @type {Array.<*>} */ (lastFillInstruction) : null,
backgroundStroke ? /** @type {Array.<*>} */ (lastStrokeInstruction) : null);
pixelCoordinates[d], pixelCoordinates[d + 1], image, anchorX, anchorY,
declutterGroup, height, opacity, originX, originY, rotation, scale,
snapToPixel, width, padding,
backgroundFill ? /** @type {Array.<*>} */ (lastFillInstruction) : null,
backgroundStroke ? /** @type {Array.<*>} */ (lastStrokeInstruction) : null);
}
this.renderDeclutter_(declutterGroup, feature);
++i;
break;
case _ol_render_canvas_Instruction_.DRAW_CHARS:
var begin = /** @type {number} */ (instruction[1]);
var end = /** @type {number} */ (instruction[2]);
var baseline = /** @type {number} */ (instruction[3]);
const begin = /** @type {number} */ (instruction[1]);
const end = /** @type {number} */ (instruction[2]);
const baseline = /** @type {number} */ (instruction[3]);
declutterGroup = featureCallback ? null : /** @type {ol.DeclutterGroup} */ (instruction[4]);
var overflow = /** @type {number} */ (instruction[5]);
var fillKey = /** @type {string} */ (instruction[6]);
var maxAngle = /** @type {number} */ (instruction[7]);
var measure = /** @type {function(string):number} */ (instruction[8]);
var offsetY = /** @type {number} */ (instruction[9]);
var strokeKey = /** @type {string} */ (instruction[10]);
var strokeWidth = /** @type {number} */ (instruction[11]);
var text = /** @type {string} */ (instruction[12]);
var textKey = /** @type {string} */ (instruction[13]);
var textScale = /** @type {number} */ (instruction[14]);
const overflow = /** @type {number} */ (instruction[5]);
const fillKey = /** @type {string} */ (instruction[6]);
const maxAngle = /** @type {number} */ (instruction[7]);
const measure = /** @type {function(string):number} */ (instruction[8]);
const offsetY = /** @type {number} */ (instruction[9]);
const strokeKey = /** @type {string} */ (instruction[10]);
const strokeWidth = /** @type {number} */ (instruction[11]);
const text = /** @type {string} */ (instruction[12]);
const textKey = /** @type {string} */ (instruction[13]);
const textScale = /** @type {number} */ (instruction[14]);
var pathLength = _ol_geom_flat_length_.lineString(pixelCoordinates, begin, end, 2);
var textLength = measure(text);
const pathLength = _ol_geom_flat_length_.lineString(pixelCoordinates, begin, end, 2);
const textLength = measure(text);
if (overflow || textLength <= pathLength) {
var textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
var startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
var parts = _ol_geom_flat_textpath_.lineString(
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
const textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
const startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
const parts = _ol_geom_flat_textpath_.lineString(
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
if (parts) {
var c, cc, chars, label, part;
let c, cc, chars, label, part;
if (strokeKey) {
for (c = 0, cc = parts.length; c < cc; ++c) {
part = parts[c]; // x, y, anchorX, rotation, chunk
@@ -728,10 +728,10 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
anchorX = /** @type {number} */ (part[2]) + strokeWidth;
anchorY = baseline * label.height + (0.5 - baseline) * 2 * strokeWidth - offsetY;
this.replayImage_(context,
/** @type {number} */ (part[0]), /** @type {number} */ (part[1]), label,
anchorX, anchorY, declutterGroup, label.height, 1, 0, 0,
/** @type {number} */ (part[3]), textScale, false, label.width,
_ol_render_canvas_.defaultPadding, null, null);
/** @type {number} */ (part[0]), /** @type {number} */ (part[1]), label,
anchorX, anchorY, declutterGroup, label.height, 1, 0, 0,
/** @type {number} */ (part[3]), textScale, false, label.width,
_ol_render_canvas_.defaultPadding, null, null);
}
}
if (fillKey) {
@@ -742,10 +742,10 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
anchorX = /** @type {number} */ (part[2]);
anchorY = baseline * label.height - offsetY;
this.replayImage_(context,
/** @type {number} */ (part[0]), /** @type {number} */ (part[1]), label,
anchorX, anchorY, declutterGroup, label.height, 1, 0, 0,
/** @type {number} */ (part[3]), textScale, false, label.width,
_ol_render_canvas_.defaultPadding, null, null);
/** @type {number} */ (part[0]), /** @type {number} */ (part[1]), label,
anchorX, anchorY, declutterGroup, label.height, 1, 0, 0,
/** @type {number} */ (part[3]), textScale, false, label.width,
_ol_render_canvas_.defaultPadding, null, null);
}
}
}
@@ -756,7 +756,7 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
case _ol_render_canvas_Instruction_.END_GEOMETRY:
if (featureCallback !== undefined) {
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
var result = featureCallback(feature);
const result = featureCallback(feature);
if (result) {
return result;
}
@@ -852,10 +852,10 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
* to skip.
*/
_ol_render_canvas_Replay_.prototype.replay = function(
context, transform, viewRotation, skippedFeaturesHash) {
context, transform, viewRotation, skippedFeaturesHash) {
this.viewRotation_ = viewRotation;
this.replay_(context, transform,
skippedFeaturesHash, this.instructions, undefined, undefined);
skippedFeaturesHash, this.instructions, undefined, undefined);
};
@@ -873,11 +873,11 @@ _ol_render_canvas_Replay_.prototype.replay = function(
* @template T
*/
_ol_render_canvas_Replay_.prototype.replayHitDetection = function(
context, transform, viewRotation, skippedFeaturesHash,
opt_featureCallback, opt_hitExtent) {
context, transform, viewRotation, skippedFeaturesHash,
opt_featureCallback, opt_hitExtent) {
this.viewRotation_ = viewRotation;
return this.replay_(context, transform, skippedFeaturesHash,
this.hitDetectionInstructions, opt_featureCallback, opt_hitExtent);
this.hitDetectionInstructions, opt_featureCallback, opt_hitExtent);
};
@@ -885,15 +885,15 @@ _ol_render_canvas_Replay_.prototype.replayHitDetection = function(
* Reverse the hit detection instructions.
*/
_ol_render_canvas_Replay_.prototype.reverseHitDetectionInstructions = function() {
var hitDetectionInstructions = this.hitDetectionInstructions;
const hitDetectionInstructions = this.hitDetectionInstructions;
// step 1 - reverse array
hitDetectionInstructions.reverse();
// step 2 - reverse instructions within geometry blocks
var i;
var n = hitDetectionInstructions.length;
var instruction;
var type;
var begin = -1;
let i;
const n = hitDetectionInstructions.length;
let instruction;
let type;
let begin = -1;
for (i = 0; i < n; ++i) {
instruction = hitDetectionInstructions[i];
type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
@@ -912,34 +912,34 @@ _ol_render_canvas_Replay_.prototype.reverseHitDetectionInstructions = function()
* @inheritDoc
*/
_ol_render_canvas_Replay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
var state = this.state;
const state = this.state;
if (fillStyle) {
var fillStyleColor = fillStyle.getColor();
const fillStyleColor = fillStyle.getColor();
state.fillStyle = asColorLike(fillStyleColor ?
fillStyleColor : _ol_render_canvas_.defaultFillStyle);
} else {
state.fillStyle = undefined;
}
if (strokeStyle) {
var strokeStyleColor = strokeStyle.getColor();
const strokeStyleColor = strokeStyle.getColor();
state.strokeStyle = asColorLike(strokeStyleColor ?
strokeStyleColor : _ol_render_canvas_.defaultStrokeStyle);
var strokeStyleLineCap = strokeStyle.getLineCap();
const strokeStyleLineCap = strokeStyle.getLineCap();
state.lineCap = strokeStyleLineCap !== undefined ?
strokeStyleLineCap : _ol_render_canvas_.defaultLineCap;
var strokeStyleLineDash = strokeStyle.getLineDash();
const strokeStyleLineDash = strokeStyle.getLineDash();
state.lineDash = strokeStyleLineDash ?
strokeStyleLineDash.slice() : _ol_render_canvas_.defaultLineDash;
var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
state.lineDashOffset = strokeStyleLineDashOffset ?
strokeStyleLineDashOffset : _ol_render_canvas_.defaultLineDashOffset;
var strokeStyleLineJoin = strokeStyle.getLineJoin();
const strokeStyleLineJoin = strokeStyle.getLineJoin();
state.lineJoin = strokeStyleLineJoin !== undefined ?
strokeStyleLineJoin : _ol_render_canvas_.defaultLineJoin;
var strokeStyleWidth = strokeStyle.getWidth();
const strokeStyleWidth = strokeStyle.getWidth();
state.lineWidth = strokeStyleWidth !== undefined ?
strokeStyleWidth : _ol_render_canvas_.defaultLineWidth;
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
const strokeStyleMiterLimit = strokeStyle.getMiterLimit();
state.miterLimit = strokeStyleMiterLimit !== undefined ?
strokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit;
@@ -966,10 +966,10 @@ _ol_render_canvas_Replay_.prototype.setFillStrokeStyle = function(fillStyle, str
* @return {Array.<*>} Fill instruction.
*/
_ol_render_canvas_Replay_.prototype.createFill = function(state, geometry) {
var fillStyle = state.fillStyle;
var fillInstruction = [_ol_render_canvas_Instruction_.SET_FILL_STYLE, fillStyle];
const fillStyle = state.fillStyle;
const fillInstruction = [_ol_render_canvas_Instruction_.SET_FILL_STYLE, fillStyle];
if (typeof fillStyle !== 'string') {
var fillExtent = geometry.getExtent();
const fillExtent = geometry.getExtent();
fillInstruction.push([fillExtent[0], fillExtent[3]]);
}
return fillInstruction;
@@ -1004,7 +1004,7 @@ _ol_render_canvas_Replay_.prototype.createStroke = function(state) {
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
*/
_ol_render_canvas_Replay_.prototype.updateFillStyle = function(state, createFill, geometry) {
var fillStyle = state.fillStyle;
const fillStyle = state.fillStyle;
if (typeof fillStyle !== 'string' || state.currentFillStyle != fillStyle) {
if (fillStyle !== undefined) {
this.instructions.push(createFill.call(this, state, geometry));
@@ -1019,13 +1019,13 @@ _ol_render_canvas_Replay_.prototype.updateFillStyle = function(state, createFill
* @param {function(this:ol.render.canvas.Replay, ol.CanvasFillStrokeState)} applyStroke Apply stroke.
*/
_ol_render_canvas_Replay_.prototype.updateStrokeStyle = function(state, applyStroke) {
var strokeStyle = state.strokeStyle;
var lineCap = state.lineCap;
var lineDash = state.lineDash;
var lineDashOffset = state.lineDashOffset;
var lineJoin = state.lineJoin;
var lineWidth = state.lineWidth;
var miterLimit = state.miterLimit;
const strokeStyle = state.strokeStyle;
const lineCap = state.lineCap;
const lineDash = state.lineDash;
const lineDashOffset = state.lineDashOffset;
const lineJoin = state.lineJoin;
const lineWidth = state.lineWidth;
const miterLimit = state.miterLimit;
if (state.currentStrokeStyle != strokeStyle ||
state.currentLineCap != lineCap ||
(lineDash != state.currentLineDash && !equals(state.currentLineDash, lineDash)) ||
@@ -1056,7 +1056,7 @@ _ol_render_canvas_Replay_.prototype.endGeometry = function(geometry, feature) {
this.beginGeometryInstruction1_ = null;
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
this.beginGeometryInstruction2_ = null;
var endGeometryInstruction =
const endGeometryInstruction =
[_ol_render_canvas_Instruction_.END_GEOMETRY, feature];
this.instructions.push(endGeometryInstruction);
this.hitDetectionInstructions.push(endGeometryInstruction);
@@ -1080,7 +1080,7 @@ _ol_render_canvas_Replay_.prototype.getBufferedMaxExtent = function() {
if (!this.bufferedMaxExtent_) {
this.bufferedMaxExtent_ = clone(this.maxExtent);
if (this.maxLineWidth > 0) {
var width = this.resolution * (this.maxLineWidth + 1) / 2;
const width = this.resolution * (this.maxLineWidth + 1) / 2;
buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_);
}
}
+65 -66
View File
@@ -30,8 +30,8 @@ import _ol_transform_ from '../../transform.js';
* @param {number=} opt_renderBuffer Optional rendering buffer.
* @struct
*/
var _ol_render_canvas_ReplayGroup_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree, opt_renderBuffer) {
const _ol_render_canvas_ReplayGroup_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree, opt_renderBuffer) {
_ol_render_ReplayGroup_.call(this);
/**
@@ -125,8 +125,8 @@ _ol_render_canvas_ReplayGroup_.circleArrayCache_ = {
* @private
*/
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_ = function(array, x, y) {
var i;
var radius = Math.floor(array.length / 2);
let i;
const radius = Math.floor(array.length / 2);
if (x >= radius) {
for (i = radius; i < x; i++) {
array[i][y] = true;
@@ -153,15 +153,15 @@ _ol_render_canvas_ReplayGroup_.getCircleArray_ = function(radius) {
return _ol_render_canvas_ReplayGroup_.circleArrayCache_[radius];
}
var arraySize = radius * 2 + 1;
var arr = new Array(arraySize);
for (var i = 0; i < arraySize; i++) {
const arraySize = radius * 2 + 1;
const arr = new Array(arraySize);
for (let i = 0; i < arraySize; i++) {
arr[i] = new Array(arraySize);
}
var x = radius;
var y = 0;
var error = 0;
let x = radius;
let y = 0;
let error = 0;
while (x >= y) {
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + x, radius + y);
@@ -192,13 +192,13 @@ _ol_render_canvas_ReplayGroup_.getCircleArray_ = function(radius) {
* @param {number} rotation Rotation.
*/
_ol_render_canvas_ReplayGroup_.replayDeclutter = function(declutterReplays, context, rotation) {
var zs = Object.keys(declutterReplays).map(Number).sort(numberSafeCompareFunction);
var skippedFeatureUids = {};
for (var z = 0, zz = zs.length; z < zz; ++z) {
var replayData = declutterReplays[zs[z].toString()];
for (var i = 0, ii = replayData.length; i < ii;) {
var replay = replayData[i++];
var transform = replayData[i++];
const zs = Object.keys(declutterReplays).map(Number).sort(numberSafeCompareFunction);
const skippedFeatureUids = {};
for (let z = 0, zz = zs.length; z < zz; ++z) {
const replayData = declutterReplays[zs[z].toString()];
for (let i = 0, ii = replayData.length; i < ii;) {
const replay = replayData[i++];
const transform = replayData[i++];
replay.replay(context, transform, rotation, skippedFeatureUids);
}
}
@@ -210,7 +210,7 @@ _ol_render_canvas_ReplayGroup_.replayDeclutter = function(declutterReplays, cont
* @return {ol.DeclutterGroup} Declutter instruction group.
*/
_ol_render_canvas_ReplayGroup_.prototype.addDeclutter = function(group) {
var declutter = null;
let declutter = null;
if (this.declutterTree_) {
if (group) {
declutter = this.declutterGroup_;
@@ -229,7 +229,7 @@ _ol_render_canvas_ReplayGroup_.prototype.addDeclutter = function(group) {
* @param {ol.Transform} transform Transform.
*/
_ol_render_canvas_ReplayGroup_.prototype.clip = function(context, transform) {
var flatClipCoords = this.getClipCoords(transform);
const flatClipCoords = this.getClipCoords(transform);
context.beginPath();
context.moveTo(flatClipCoords[0], flatClipCoords[1]);
context.lineTo(flatClipCoords[2], flatClipCoords[3]);
@@ -244,9 +244,9 @@ _ol_render_canvas_ReplayGroup_.prototype.clip = function(context, transform) {
* @return {boolean} Has replays of the provided types.
*/
_ol_render_canvas_ReplayGroup_.prototype.hasReplays = function(replays) {
for (var zIndex in this.replaysByZIndex_) {
var candidates = this.replaysByZIndex_[zIndex];
for (var i = 0, ii = replays.length; i < ii; ++i) {
for (const zIndex in this.replaysByZIndex_) {
const candidates = this.replaysByZIndex_[zIndex];
for (let i = 0, ii = replays.length; i < ii; ++i) {
if (replays[i] in candidates) {
return true;
}
@@ -260,11 +260,10 @@ _ol_render_canvas_ReplayGroup_.prototype.hasReplays = function(replays) {
* FIXME empty description for jsdoc
*/
_ol_render_canvas_ReplayGroup_.prototype.finish = function() {
var zKey;
let zKey;
for (zKey in this.replaysByZIndex_) {
var replays = this.replaysByZIndex_[zKey];
var replayKey;
for (replayKey in replays) {
const replays = this.replaysByZIndex_[zKey];
for (const replayKey in replays) {
replays[replayKey].finish();
}
}
@@ -286,16 +285,16 @@ _ol_render_canvas_ReplayGroup_.prototype.finish = function() {
* @template T
*/
_ol_render_canvas_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function(
coordinate, resolution, rotation, hitTolerance, skippedFeaturesHash, callback, declutterReplays) {
coordinate, resolution, rotation, hitTolerance, skippedFeaturesHash, callback, declutterReplays) {
hitTolerance = Math.round(hitTolerance);
var contextSize = hitTolerance * 2 + 1;
var transform = _ol_transform_.compose(this.hitDetectionTransform_,
hitTolerance + 0.5, hitTolerance + 0.5,
1 / resolution, -1 / resolution,
-rotation,
-coordinate[0], -coordinate[1]);
var context = this.hitDetectionContext_;
const contextSize = hitTolerance * 2 + 1;
const transform = _ol_transform_.compose(this.hitDetectionTransform_,
hitTolerance + 0.5, hitTolerance + 0.5,
1 / resolution, -1 / resolution,
-rotation,
-coordinate[0], -coordinate[1]);
const context = this.hitDetectionContext_;
if (context.canvas.width !== contextSize || context.canvas.height !== contextSize) {
context.canvas.width = contextSize;
@@ -307,34 +306,34 @@ _ol_render_canvas_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function(
/**
* @type {ol.Extent}
*/
var hitExtent;
let hitExtent;
if (this.renderBuffer_ !== undefined) {
hitExtent = createEmpty();
extendCoordinate(hitExtent, coordinate);
buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent);
}
var mask = _ol_render_canvas_ReplayGroup_.getCircleArray_(hitTolerance);
var declutteredFeatures;
const mask = _ol_render_canvas_ReplayGroup_.getCircleArray_(hitTolerance);
let declutteredFeatures;
if (this.declutterTree_) {
declutteredFeatures = this.declutterTree_.all().map(function(entry) {
return entry.value;
});
}
var replayType;
let replayType;
/**
* @param {ol.Feature|ol.render.Feature} feature Feature.
* @return {?} Callback result.
*/
function featureCallback(feature) {
var imageData = context.getImageData(0, 0, contextSize, contextSize).data;
for (var i = 0; i < contextSize; i++) {
for (var j = 0; j < contextSize; j++) {
const imageData = context.getImageData(0, 0, contextSize, contextSize).data;
for (let i = 0; i < contextSize; i++) {
for (let j = 0; j < contextSize; j++) {
if (mask[i][j]) {
if (imageData[(j * contextSize + i) * 4 + 3] > 0) {
var result;
let result;
if (!(declutteredFeatures && (replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) ||
declutteredFeatures.indexOf(feature) !== -1) {
result = callback(feature);
@@ -352,12 +351,12 @@ _ol_render_canvas_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function(
}
/** @type {Array.<number>} */
var zs = Object.keys(this.replaysByZIndex_).map(Number);
const zs = Object.keys(this.replaysByZIndex_).map(Number);
zs.sort(numberSafeCompareFunction);
var i, j, replays, replay, result;
let i, j, replays, replay, result;
for (i = zs.length - 1; i >= 0; --i) {
var zIndexKey = zs[i].toString();
const zIndexKey = zs[i].toString();
replays = this.replaysByZIndex_[zIndexKey];
for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
replayType = _ol_render_replay_.ORDER[j];
@@ -365,7 +364,7 @@ _ol_render_canvas_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function(
if (replay !== undefined) {
if (declutterReplays &&
(replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) {
var declutter = declutterReplays[zIndexKey];
const declutter = declutterReplays[zIndexKey];
if (!declutter) {
declutterReplays[zIndexKey] = [replay, transform.slice(0)];
} else {
@@ -373,7 +372,7 @@ _ol_render_canvas_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function(
}
} else {
result = replay.replayHitDetection(context, transform, rotation,
skippedFeaturesHash, featureCallback, hitExtent);
skippedFeaturesHash, featureCallback, hitExtent);
if (result) {
return result;
}
@@ -390,14 +389,14 @@ _ol_render_canvas_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function(
* @return {Array.<number>} Clip coordinates.
*/
_ol_render_canvas_ReplayGroup_.prototype.getClipCoords = function(transform) {
var maxExtent = this.maxExtent_;
var minX = maxExtent[0];
var minY = maxExtent[1];
var maxX = maxExtent[2];
var maxY = maxExtent[3];
var flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
const maxExtent = this.maxExtent_;
const minX = maxExtent[0];
const minY = maxExtent[1];
const maxX = maxExtent[2];
const maxY = maxExtent[3];
const flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
_ol_geom_flat_transform_.transform2D(
flatClipCoords, 0, 8, 2, transform, flatClipCoords);
flatClipCoords, 0, 8, 2, transform, flatClipCoords);
return flatClipCoords;
};
@@ -406,17 +405,17 @@ _ol_render_canvas_ReplayGroup_.prototype.getClipCoords = function(transform) {
* @inheritDoc
*/
_ol_render_canvas_ReplayGroup_.prototype.getReplay = function(zIndex, replayType) {
var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
var replays = this.replaysByZIndex_[zIndexKey];
const zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
let replays = this.replaysByZIndex_[zIndexKey];
if (replays === undefined) {
replays = {};
this.replaysByZIndex_[zIndexKey] = replays;
}
var replay = replays[replayType];
let replay = replays[replayType];
if (replay === undefined) {
var Constructor = _ol_render_canvas_ReplayGroup_.BATCH_CONSTRUCTORS_[replayType];
const Constructor = _ol_render_canvas_ReplayGroup_.BATCH_CONSTRUCTORS_[replayType];
replay = new Constructor(this.tolerance_, this.maxExtent_,
this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_);
this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_);
replays[replayType] = replay;
}
return replay;
@@ -451,10 +450,10 @@ _ol_render_canvas_ReplayGroup_.prototype.isEmpty = function() {
* replays.
*/
_ol_render_canvas_ReplayGroup_.prototype.replay = function(context,
transform, viewRotation, skippedFeaturesHash, opt_replayTypes, opt_declutterReplays) {
transform, viewRotation, skippedFeaturesHash, opt_replayTypes, opt_declutterReplays) {
/** @type {Array.<number>} */
var zs = Object.keys(this.replaysByZIndex_).map(Number);
const zs = Object.keys(this.replaysByZIndex_).map(Number);
zs.sort(numberSafeCompareFunction);
// setup clipping so that the parts of over-simplified geometries are not
@@ -462,18 +461,18 @@ _ol_render_canvas_ReplayGroup_.prototype.replay = function(context,
context.save();
this.clip(context, transform);
var replayTypes = opt_replayTypes ? opt_replayTypes : _ol_render_replay_.ORDER;
var i, ii, j, jj, replays, replay;
const replayTypes = opt_replayTypes ? opt_replayTypes : _ol_render_replay_.ORDER;
let i, ii, j, jj, replays, replay;
for (i = 0, ii = zs.length; i < ii; ++i) {
var zIndexKey = zs[i].toString();
const zIndexKey = zs[i].toString();
replays = this.replaysByZIndex_[zIndexKey];
for (j = 0, jj = replayTypes.length; j < jj; ++j) {
var replayType = replayTypes[j];
const replayType = replayTypes[j];
replay = replays[replayType];
if (replay !== undefined) {
if (opt_declutterReplays &&
(replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) {
var declutter = opt_declutterReplays[zIndexKey];
const declutter = opt_declutterReplays[zIndexKey];
if (!declutter) {
opt_declutterReplays[zIndexKey] = [replay, transform.slice(0)];
} else {
+89 -89
View File
@@ -25,10 +25,10 @@ import TextPlacement from '../../style/TextPlacement.js';
* @param {?} declutterTree Declutter tree.
* @struct
*/
var _ol_render_canvas_TextReplay_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
const _ol_render_canvas_TextReplay_ = function(
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
_ol_render_canvas_Replay_.call(this,
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
/**
* @private
@@ -129,7 +129,7 @@ var _ol_render_canvas_TextReplay_ = function(
*/
this.widths_ = {};
var labelCache = _ol_render_canvas_.labelCache;
const labelCache = _ol_render_canvas_.labelCache;
labelCache.prune();
};
@@ -145,9 +145,9 @@ inherits(_ol_render_canvas_TextReplay_, _ol_render_canvas_Replay_);
* @return {number} Width of the whole text.
*/
_ol_render_canvas_TextReplay_.measureTextWidths = function(font, lines, widths) {
var numLines = lines.length;
var width = 0;
var currentWidth, i;
const numLines = lines.length;
let width = 0;
let currentWidth, i;
for (i = 0; i < numLines; ++i) {
currentWidth = _ol_render_canvas_.measureTextWidth(font, lines[i]);
width = Math.max(width, currentWidth);
@@ -161,26 +161,26 @@ _ol_render_canvas_TextReplay_.measureTextWidths = function(font, lines, widths)
* @inheritDoc
*/
_ol_render_canvas_TextReplay_.prototype.drawText = function(geometry, feature) {
var fillState = this.textFillState_;
var strokeState = this.textStrokeState_;
var textState = this.textState_;
const fillState = this.textFillState_;
const strokeState = this.textStrokeState_;
const textState = this.textState_;
if (this.text_ === '' || !textState || (!fillState && !strokeState)) {
return;
}
var begin = this.coordinates.length;
let begin = this.coordinates.length;
var geometryType = geometry.getType();
var flatCoordinates = null;
var end = 2;
var stride = 2;
var i, ii;
const geometryType = geometry.getType();
let flatCoordinates = null;
let end = 2;
let stride = 2;
let i, ii;
if (textState.placement === TextPlacement.LINE) {
if (!intersects(this.getBufferedMaxExtent(), geometry.getExtent())) {
return;
}
var ends;
let ends;
flatCoordinates = geometry.getFlatCoordinates();
stride = geometry.getStride();
if (geometryType == GeometryType.LINE_STRING) {
@@ -190,20 +190,20 @@ _ol_render_canvas_TextReplay_.prototype.drawText = function(geometry, feature) {
} else if (geometryType == GeometryType.POLYGON) {
ends = geometry.getEnds().slice(0, 1);
} else if (geometryType == GeometryType.MULTI_POLYGON) {
var endss = geometry.getEndss();
const endss = geometry.getEndss();
ends = [];
for (i = 0, ii = endss.length; i < ii; ++i) {
ends.push(endss[i][0]);
}
}
this.beginGeometry(geometry, feature);
var textAlign = textState.textAlign;
var flatOffset = 0;
var flatEnd;
for (var o = 0, oo = ends.length; o < oo; ++o) {
const textAlign = textState.textAlign;
let flatOffset = 0;
let flatEnd;
for (let o = 0, oo = ends.length; o < oo; ++o) {
if (textAlign == undefined) {
var range = _ol_geom_flat_straightchunk_.lineString(
textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
const range = _ol_geom_flat_straightchunk_.lineString(
textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
flatOffset = range[0];
flatEnd = range[1];
} else {
@@ -220,8 +220,8 @@ _ol_render_canvas_TextReplay_.prototype.drawText = function(geometry, feature) {
this.endGeometry(geometry, feature);
} else {
var label = this.getImage(this.text_, this.textKey_, this.fillKey_, this.strokeKey_);
var width = label.width / this.pixelRatio;
const label = this.getImage(this.text_, this.textKey_, this.fillKey_, this.strokeKey_);
const width = label.width / this.pixelRatio;
switch (geometryType) {
case GeometryType.POINT:
case GeometryType.MULTI_POINT:
@@ -246,7 +246,7 @@ _ol_render_canvas_TextReplay_.prototype.drawText = function(geometry, feature) {
stride = 3;
break;
case GeometryType.MULTI_POLYGON:
var interiorPoints = /** @type {ol.geom.MultiPolygon} */ (geometry).getFlatInteriorPoints();
const interiorPoints = /** @type {ol.geom.MultiPolygon} */ (geometry).getFlatInteriorPoints();
flatCoordinates = [];
for (i = 0, ii = interiorPoints.length; i < ii; i += 3) {
if (textState.overflow || interiorPoints[i + 2] / this.resolution >= width) {
@@ -283,29 +283,29 @@ _ol_render_canvas_TextReplay_.prototype.drawText = function(geometry, feature) {
* @return {HTMLCanvasElement} Image.
*/
_ol_render_canvas_TextReplay_.prototype.getImage = function(text, textKey, fillKey, strokeKey) {
var label;
var key = strokeKey + textKey + text + fillKey + this.pixelRatio;
let label;
const key = strokeKey + textKey + text + fillKey + this.pixelRatio;
var labelCache = _ol_render_canvas_.labelCache;
const labelCache = _ol_render_canvas_.labelCache;
if (!labelCache.containsKey(key)) {
var strokeState = strokeKey ? this.strokeStates[strokeKey] || this.textStrokeState_ : null;
var fillState = fillKey ? this.fillStates[fillKey] || this.textFillState_ : null;
var textState = this.textStates[textKey] || this.textState_;
var pixelRatio = this.pixelRatio;
var scale = textState.scale * pixelRatio;
var align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || _ol_render_canvas_.defaultTextAlign];
var strokeWidth = strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0;
const strokeState = strokeKey ? this.strokeStates[strokeKey] || this.textStrokeState_ : null;
const fillState = fillKey ? this.fillStates[fillKey] || this.textFillState_ : null;
const textState = this.textStates[textKey] || this.textState_;
const pixelRatio = this.pixelRatio;
const scale = textState.scale * pixelRatio;
const align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || _ol_render_canvas_.defaultTextAlign];
const strokeWidth = strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0;
var lines = text.split('\n');
var numLines = lines.length;
var widths = [];
var width = _ol_render_canvas_TextReplay_.measureTextWidths(textState.font, lines, widths);
var lineHeight = _ol_render_canvas_.measureTextHeight(textState.font);
var height = lineHeight * numLines;
var renderWidth = (width + strokeWidth);
var context = createCanvasContext2D(
Math.ceil(renderWidth * scale),
Math.ceil((height + strokeWidth) * scale));
const lines = text.split('\n');
const numLines = lines.length;
const widths = [];
const width = _ol_render_canvas_TextReplay_.measureTextWidths(textState.font, lines, widths);
const lineHeight = _ol_render_canvas_.measureTextHeight(textState.font);
const height = lineHeight * numLines;
const renderWidth = (width + strokeWidth);
const context = createCanvasContext2D(
Math.ceil(renderWidth * scale),
Math.ceil((height + strokeWidth) * scale));
label = context.canvas;
labelCache.set(key, label);
if (scale != 1) {
@@ -328,9 +328,9 @@ _ol_render_canvas_TextReplay_.prototype.getImage = function(text, textKey, fillK
}
context.textBaseline = 'middle';
context.textAlign = 'center';
var leftRight = (0.5 - align);
var x = align * label.width / scale + leftRight * strokeWidth;
var i;
const leftRight = (0.5 - align);
const x = align * label.width / scale + leftRight * strokeWidth;
let i;
if (strokeKey) {
for (i = 0; i < numLines; ++i) {
context.strokeText(lines[i], x + leftRight * widths[i], 0.5 * (strokeWidth + lineHeight) + i * lineHeight);
@@ -353,15 +353,15 @@ _ol_render_canvas_TextReplay_.prototype.getImage = function(text, textKey, fillK
* @param {number} end End.
*/
_ol_render_canvas_TextReplay_.prototype.drawTextImage_ = function(label, begin, end) {
var textState = this.textState_;
var strokeState = this.textStrokeState_;
var pixelRatio = this.pixelRatio;
var align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || _ol_render_canvas_.defaultTextAlign];
var baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
var strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
const textState = this.textState_;
const strokeState = this.textStrokeState_;
const pixelRatio = this.pixelRatio;
const align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || _ol_render_canvas_.defaultTextAlign];
const baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
const strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
var anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth;
var anchorY = baseline * label.height / pixelRatio + 2 * (0.5 - baseline) * strokeWidth;
const anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth;
const anchorY = baseline * label.height / pixelRatio + 2 * (0.5 - baseline) * strokeWidth;
this.instructions.push([_ol_render_canvas_Instruction_.DRAW_IMAGE, begin, end,
label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio,
this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_,
@@ -388,11 +388,11 @@ _ol_render_canvas_TextReplay_.prototype.drawTextImage_ = function(label, begin,
* @param {ol.DeclutterGroup} declutterGroup Declutter group.
*/
_ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declutterGroup) {
var strokeState = this.textStrokeState_;
var textState = this.textState_;
var fillState = this.textFillState_;
const strokeState = this.textStrokeState_;
const textState = this.textState_;
const fillState = this.textFillState_;
var strokeKey = this.strokeKey_;
const strokeKey = this.strokeKey_;
if (strokeState) {
if (!(strokeKey in this.strokeStates)) {
this.strokeStates[strokeKey] = /** @type {ol.CanvasStrokeState} */ ({
@@ -406,7 +406,7 @@ _ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declut
});
}
}
var textKey = this.textKey_;
const textKey = this.textKey_;
if (!(this.textKey_ in this.textStates)) {
this.textStates[this.textKey_] = /** @type {ol.CanvasTextState} */ ({
font: textState.font,
@@ -414,7 +414,7 @@ _ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declut
scale: textState.scale
});
}
var fillKey = this.fillKey_;
const fillKey = this.fillKey_;
if (fillState) {
if (!(fillKey in this.fillStates)) {
this.fillStates[fillKey] = /** @type {ol.CanvasFillState} */ ({
@@ -423,15 +423,15 @@ _ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declut
}
}
var pixelRatio = this.pixelRatio;
var baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
const pixelRatio = this.pixelRatio;
const baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
var offsetY = this.textOffsetY_ * pixelRatio;
var text = this.text_;
var font = textState.font;
var textScale = textState.scale;
var strokeWidth = strokeState ? strokeState.lineWidth * textScale / 2 : 0;
var widths = this.widths_[font];
const offsetY = this.textOffsetY_ * pixelRatio;
const text = this.text_;
const font = textState.font;
const textScale = textState.scale;
const strokeWidth = strokeState ? strokeState.lineWidth * textScale / 2 : 0;
let widths = this.widths_[font];
if (!widths) {
this.widths_[font] = widths = {};
}
@@ -439,7 +439,7 @@ _ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declut
begin, end, baseline, declutterGroup,
textState.overflow, fillKey, textState.maxAngle,
function(text) {
var width = widths[text];
let width = widths[text];
if (!width) {
width = widths[text] = _ol_render_canvas_.measureTextWidth(font, text);
}
@@ -451,7 +451,7 @@ _ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declut
begin, end, baseline, declutterGroup,
textState.overflow, fillKey, textState.maxAngle,
function(text) {
var width = widths[text];
let width = widths[text];
if (!width) {
width = widths[text] = _ol_render_canvas_.measureTextWidth(font, text);
}
@@ -466,13 +466,13 @@ _ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declut
* @inheritDoc
*/
_ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declutterGroup) {
var textState, fillState, strokeState;
let textState, fillState, strokeState;
if (!textStyle) {
this.text_ = '';
} else {
this.declutterGroup_ = /** @type {ol.DeclutterGroup} */ (declutterGroup);
var textFillStyle = textStyle.getFill();
const textFillStyle = textStyle.getFill();
if (!textFillStyle) {
fillState = this.textFillState_ = null;
} else {
@@ -481,10 +481,10 @@ _ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declu
fillState = this.textFillState_ = /** @type {ol.CanvasFillState} */ ({});
}
fillState.fillStyle = asColorLike(
textFillStyle.getColor() || _ol_render_canvas_.defaultFillStyle);
textFillStyle.getColor() || _ol_render_canvas_.defaultFillStyle);
}
var textStrokeStyle = textStyle.getStroke();
const textStrokeStyle = textStyle.getStroke();
if (!textStrokeStyle) {
strokeState = this.textStrokeState_ = null;
} else {
@@ -492,10 +492,10 @@ _ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declu
if (!strokeState) {
strokeState = this.textStrokeState_ = /** @type {ol.CanvasStrokeState} */ ({});
}
var lineDash = textStrokeStyle.getLineDash();
var lineDashOffset = textStrokeStyle.getLineDashOffset();
var lineWidth = textStrokeStyle.getWidth();
var miterLimit = textStrokeStyle.getMiterLimit();
const lineDash = textStrokeStyle.getLineDash();
const lineDashOffset = textStrokeStyle.getLineDashOffset();
const lineWidth = textStrokeStyle.getWidth();
const miterLimit = textStrokeStyle.getMiterLimit();
strokeState.lineCap = textStrokeStyle.getLineCap() || _ol_render_canvas_.defaultLineCap;
strokeState.lineDash = lineDash ? lineDash.slice() : _ol_render_canvas_.defaultLineDash;
strokeState.lineDashOffset =
@@ -506,13 +506,13 @@ _ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declu
strokeState.miterLimit =
miterLimit === undefined ? _ol_render_canvas_.defaultMiterLimit : miterLimit;
strokeState.strokeStyle = asColorLike(
textStrokeStyle.getColor() || _ol_render_canvas_.defaultStrokeStyle);
textStrokeStyle.getColor() || _ol_render_canvas_.defaultStrokeStyle);
}
textState = this.textState_;
var font = textStyle.getFont() || _ol_render_canvas_.defaultFont;
const font = textStyle.getFont() || _ol_render_canvas_.defaultFont;
_ol_render_canvas_.checkFont(font);
var textScale = textStyle.getScale();
const textScale = textStyle.getScale();
textState.overflow = textStyle.getOverflow();
textState.font = font;
textState.maxAngle = textStyle.getMaxAngle();
@@ -524,10 +524,10 @@ _ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declu
textState.padding = textStyle.getPadding() || _ol_render_canvas_.defaultPadding;
textState.scale = textScale === undefined ? 1 : textScale;
var textOffsetX = textStyle.getOffsetX();
var textOffsetY = textStyle.getOffsetY();
var textRotateWithView = textStyle.getRotateWithView();
var textRotation = textStyle.getRotation();
const textOffsetX = textStyle.getOffsetX();
const textOffsetY = textStyle.getOffsetY();
const textRotateWithView = textStyle.getRotateWithView();
const textRotation = textStyle.getRotation();
this.text_ = textStyle.getText() || '';
this.textOffsetX_ = textOffsetX === undefined ? 0 : textOffsetX;
this.textOffsetY_ = textOffsetY === undefined ? 0 : textOffsetY;