Remove unused Builder/Executor functions and members
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
/**
|
||||
* @module ol/render/BuilderGroup
|
||||
*/
|
||||
import {abstract} from '../util.js';
|
||||
|
||||
/**
|
||||
* Base class for builder groups.
|
||||
*/
|
||||
class BuilderGroup {
|
||||
/**
|
||||
* @abstract
|
||||
* @param {number|undefined} zIndex Z index.
|
||||
* @param {import("./ReplayType.js").default} replayType Replay type.
|
||||
* @return {import("./VectorContext.js").default} Replay.
|
||||
*/
|
||||
getBuilder(zIndex, replayType) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
isEmpty() {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {boolean} group Group with previous builder
|
||||
* @return {Array<*>} The resulting instruction group
|
||||
*/
|
||||
addDeclutter(group) {
|
||||
return abstract();
|
||||
}
|
||||
}
|
||||
|
||||
export default BuilderGroup;
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* @module ol/render/ExecutorGroup
|
||||
*/
|
||||
import {abstract} from '../util.js';
|
||||
|
||||
/**
|
||||
* Base class for replay groups.
|
||||
*/
|
||||
class ExecutorGroup {
|
||||
/**
|
||||
* @abstract
|
||||
* @param {number|undefined} zIndex Z index.
|
||||
* @param {import("./ReplayType.js").default} replayType Replay type.
|
||||
* @return {import("./VectorContext.js").default} Executor.
|
||||
*/
|
||||
getExecutor(zIndex, replayType) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
isEmpty() {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {import("../extent.js").Extent} The extent of the group.
|
||||
*/
|
||||
getMaxExtent() {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {boolean} group Group with previous executor
|
||||
* @return {Array<*>} The resulting instruction group
|
||||
*/
|
||||
addDeclutter(group) {
|
||||
return abstract();
|
||||
}
|
||||
}
|
||||
|
||||
export default ExecutorGroup;
|
||||
@@ -7,16 +7,11 @@ import {buffer, clone, coordinateRelationship} from '../../extent.js';
|
||||
import Relationship from '../../extent/Relationship.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import {inflateCoordinates, inflateCoordinatesArray, inflateMultiCoordinatesArray} from '../../geom/flat/inflate.js';
|
||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||
import VectorContext from '../VectorContext.js';
|
||||
import {resetTransform, defaultFillStyle, defaultStrokeStyle,
|
||||
import {defaultFillStyle, defaultStrokeStyle,
|
||||
defaultMiterLimit, defaultLineWidth, defaultLineJoin, defaultLineDashOffset,
|
||||
defaultLineDash, defaultLineCap} from '../canvas.js';
|
||||
import CanvasInstruction from './Instruction.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
apply as applyTransform
|
||||
} from '../../transform.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,17 +31,10 @@ class CanvasBuilder extends VectorContext {
|
||||
* @param {import("../../extent.js").Extent} maxExtent Maximum extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {boolean} overlaps The builder can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
*/
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio) {
|
||||
super();
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
this.declutterTree = declutterTree;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
@@ -60,12 +48,6 @@ class CanvasBuilder extends VectorContext {
|
||||
*/
|
||||
this.maxExtent = maxExtent;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.overlaps = overlaps;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
@@ -85,12 +67,6 @@ class CanvasBuilder extends VectorContext {
|
||||
*/
|
||||
this.resolution = resolution;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.alignFill_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<*>}
|
||||
@@ -121,42 +97,18 @@ class CanvasBuilder extends VectorContext {
|
||||
*/
|
||||
this.coordinates = [];
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object<number,import("../../coordinate.js").Coordinate|Array<import("../../coordinate.js").Coordinate>|Array<Array<import("../../coordinate.js").Coordinate>>>}
|
||||
*/
|
||||
this.coordinateCache_ = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!import("../../transform.js").Transform}
|
||||
*/
|
||||
this.renderedTransform_ = createTransform();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {Array<*>}
|
||||
*/
|
||||
this.hitDetectionInstructions = [];
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<number>}
|
||||
*/
|
||||
this.pixelCoordinates_ = null;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {import("../canvas.js").FillStrokeState}
|
||||
*/
|
||||
this.state = /** @type {import("../canvas.js").FillStrokeState} */ ({});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.viewRotation_ = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,40 +267,6 @@ class CanvasBuilder extends VectorContext {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
*/
|
||||
fill_(context) {
|
||||
if (this.alignFill_) {
|
||||
const origin = applyTransform(this.renderedTransform_, [0, 0]);
|
||||
const repeatSize = 512 * this.pixelRatio;
|
||||
context.translate(origin[0] % repeatSize, origin[1] % repeatSize);
|
||||
context.rotate(this.viewRotation_);
|
||||
}
|
||||
context.fill();
|
||||
if (this.alignFill_) {
|
||||
context.setTransform.apply(context, resetTransform);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {Array<*>} instruction Instruction.
|
||||
*/
|
||||
setStrokeStyle_(context, instruction) {
|
||||
context.strokeStyle = /** @type {import("../../colorlike.js").ColorLike} */ (instruction[1]);
|
||||
context.lineWidth = /** @type {number} */ (instruction[2]);
|
||||
context.lineCap = /** @type {CanvasLineCap} */ (instruction[3]);
|
||||
context.lineJoin = /** @type {CanvasLineJoin} */ (instruction[4]);
|
||||
context.miterLimit = /** @type {number} */ (instruction[5]);
|
||||
if (CANVAS_LINE_DASH) {
|
||||
context.lineDashOffset = /** @type {number} */ (instruction[7]);
|
||||
context.setLineDash(/** @type {Array<number>} */ (instruction[6]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the hit detection instructions.
|
||||
*/
|
||||
|
||||
@@ -2,61 +2,42 @@
|
||||
* @module ol/render/canvas/BuilderGroup
|
||||
*/
|
||||
|
||||
import {numberSafeCompareFunction} from '../../array.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import {buffer, createEmpty, extendCoordinate} from '../../extent.js';
|
||||
import {transform2D} from '../../geom/flat/transform.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import BuilderGroup from '../BuilderGroup.js';
|
||||
import ReplayType from '../ReplayType.js';
|
||||
import CanvasBuilder from './Builder.js';
|
||||
import CanvasImageBuilder from './ImageBuilder.js';
|
||||
import CanvasLineStringBuilder from './LineStringBuilder.js';
|
||||
import CanvasPolygonBuilder from './PolygonBuilder.js';
|
||||
import CanvasTextBuilder from './TextBuilder.js';
|
||||
import {ORDER} from '../replay.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../../transform.js';
|
||||
import {createEmpty} from '../../extent.js';
|
||||
import Builder from './Builder.js';
|
||||
import ImageBuilder from './ImageBuilder.js';
|
||||
import LineStringBuilder from './LineStringBuilder.js';
|
||||
import PolygonBuilder from './PolygonBuilder.js';
|
||||
import TextBuilder from './TextBuilder.js';
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object<ReplayType, typeof CanvasBuilder>}
|
||||
* @type {Object<import("./BuilderType").default, typeof Builder>}
|
||||
*/
|
||||
const BATCH_CONSTRUCTORS = {
|
||||
'Circle': CanvasPolygonBuilder,
|
||||
'Default': CanvasBuilder,
|
||||
'Image': CanvasImageBuilder,
|
||||
'LineString': CanvasLineStringBuilder,
|
||||
'Polygon': CanvasPolygonBuilder,
|
||||
'Text': CanvasTextBuilder
|
||||
'Circle': PolygonBuilder,
|
||||
'Default': Builder,
|
||||
'Image': ImageBuilder,
|
||||
'LineString': LineStringBuilder,
|
||||
'Polygon': PolygonBuilder,
|
||||
'Text': TextBuilder
|
||||
};
|
||||
|
||||
|
||||
class CanvasBuilderGroup extends BuilderGroup {
|
||||
class BuilderGroup {
|
||||
/**
|
||||
* @param {number} tolerance Tolerance.
|
||||
* @param {import("../../extent.js").Extent} maxExtent Max extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {boolean} overlaps The builder group can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree for declutter processing in postrender.
|
||||
* @param {number=} opt_renderBuffer Optional rendering buffer.
|
||||
* @param {boolean} declutter Decluttering enabled.
|
||||
*/
|
||||
constructor(
|
||||
tolerance,
|
||||
maxExtent,
|
||||
resolution,
|
||||
pixelRatio,
|
||||
overlaps,
|
||||
declutterTree,
|
||||
opt_renderBuffer
|
||||
) {
|
||||
super();
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, declutter) {
|
||||
|
||||
/**
|
||||
* Declutter tree.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.declutterTree_ = declutterTree;
|
||||
this.declutter_ = declutter;
|
||||
|
||||
/**
|
||||
* @type {import("../canvas.js").DeclutterGroup}
|
||||
@@ -76,12 +57,6 @@ class CanvasBuilderGroup extends BuilderGroup {
|
||||
*/
|
||||
this.maxExtent_ = maxExtent;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.overlaps_ = overlaps;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -96,35 +71,18 @@ class CanvasBuilderGroup extends BuilderGroup {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.renderBuffer_ = opt_renderBuffer;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object<string, !Object<ReplayType, CanvasBuilder>>}
|
||||
* @type {!Object<string, !Object<import("./BuilderType").default, Builder>>}
|
||||
*/
|
||||
this.buildersByZIndex_ = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
this.hitDetectionContext_ = createCanvasContext2D(1, 1);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../../transform.js").Transform}
|
||||
*/
|
||||
this.hitDetectionTransform_ = createTransform();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {boolean} group Group with previous builder.
|
||||
* @return {Array<*>} The resulting instruction group.
|
||||
*/
|
||||
addDeclutter(group) {
|
||||
let declutter = null;
|
||||
if (this.declutterTree_) {
|
||||
if (this.declutter_) {
|
||||
if (group) {
|
||||
declutter = this.declutterGroup_;
|
||||
/** @type {number} */ (declutter[4])++;
|
||||
@@ -137,21 +95,7 @@ class CanvasBuilderGroup extends BuilderGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {import("../../transform.js").Transform} transform Transform.
|
||||
*/
|
||||
clip(context, transform) {
|
||||
const flatClipCoords = this.getClipCoords(transform);
|
||||
context.beginPath();
|
||||
context.moveTo(flatClipCoords[0], flatClipCoords[1]);
|
||||
context.lineTo(flatClipCoords[2], flatClipCoords[3]);
|
||||
context.lineTo(flatClipCoords[4], flatClipCoords[5]);
|
||||
context.lineTo(flatClipCoords[6], flatClipCoords[7]);
|
||||
context.clip();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {!Object<string, !Object<ReplayType, import("./Builder.js").SerializableInstructions>>} The serializable instructions
|
||||
* @return {!Object<string, !Object<import("./BuilderType").default, import("./Builder.js").SerializableInstructions>>} The serializable instructions
|
||||
*/
|
||||
finish() {
|
||||
const builderInstructions = {};
|
||||
@@ -167,243 +111,26 @@ class CanvasBuilderGroup extends BuilderGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} rotation Rotation.
|
||||
* @param {number} hitTolerance Hit tolerance in pixels.
|
||||
* @param {Object<string, boolean>} skippedFeaturesHash Ids of features to skip.
|
||||
* @param {function((import("../../Feature.js").default|import("../Feature.js").default)): T} callback Feature callback.
|
||||
* @param {Object<string, import("../canvas.js").DeclutterGroup>} declutterReplays Declutter replays.
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
* @param {number|undefined} zIndex Z index.
|
||||
* @param {import("./BuilderType.js").default} builderType Replay type.
|
||||
* @return {import("../VectorContext.js").default} Replay.
|
||||
*/
|
||||
forEachFeatureAtCoordinate(
|
||||
coordinate,
|
||||
resolution,
|
||||
rotation,
|
||||
hitTolerance,
|
||||
skippedFeaturesHash,
|
||||
callback,
|
||||
declutterReplays
|
||||
) {
|
||||
|
||||
hitTolerance = Math.round(hitTolerance);
|
||||
const contextSize = hitTolerance * 2 + 1;
|
||||
const transform = composeTransform(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;
|
||||
context.canvas.height = contextSize;
|
||||
} else {
|
||||
context.clearRect(0, 0, contextSize, contextSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import("../../extent.js").Extent}
|
||||
*/
|
||||
let hitExtent;
|
||||
if (this.renderBuffer_ !== undefined) {
|
||||
hitExtent = createEmpty();
|
||||
extendCoordinate(hitExtent, coordinate);
|
||||
buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent);
|
||||
}
|
||||
|
||||
const mask = getCircleArray(hitTolerance);
|
||||
let declutteredFeatures;
|
||||
if (this.declutterTree_) {
|
||||
declutteredFeatures = this.declutterTree_.all().map(function(entry) {
|
||||
return entry.value;
|
||||
});
|
||||
}
|
||||
|
||||
let replayType;
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature.js").default|import("../Feature.js").default} feature Feature.
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function featureCallback(feature) {
|
||||
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) {
|
||||
let result;
|
||||
if (!(declutteredFeatures && (replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) ||
|
||||
declutteredFeatures.indexOf(feature) !== -1) {
|
||||
result = callback(feature);
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
} else {
|
||||
context.clearRect(0, 0, contextSize, contextSize);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {Array<number>} */
|
||||
const zs = Object.keys(this.buildersByZIndex_).map(Number);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
|
||||
let i, j, builders, builder, result;
|
||||
for (i = zs.length - 1; i >= 0; --i) {
|
||||
const zIndexKey = zs[i].toString();
|
||||
builders = this.buildersByZIndex_[zIndexKey];
|
||||
for (j = ORDER.length - 1; j >= 0; --j) {
|
||||
replayType = ORDER[j];
|
||||
builder = builders[replayType];
|
||||
if (builder !== undefined) {
|
||||
if (declutterReplays &&
|
||||
(replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) {
|
||||
const declutter = declutterReplays[zIndexKey];
|
||||
if (!declutter) {
|
||||
declutterReplays[zIndexKey] = [builder, transform.slice(0)];
|
||||
} else {
|
||||
declutter.push(builder, transform.slice(0));
|
||||
}
|
||||
} else {
|
||||
result = builder.executeHitDetection(context, transform, rotation,
|
||||
skippedFeaturesHash, featureCallback, hitExtent);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../transform.js").Transform} transform Transform.
|
||||
* @return {Array<number>} Clip coordinates.
|
||||
*/
|
||||
getClipCoords(transform) {
|
||||
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];
|
||||
transform2D(
|
||||
flatClipCoords, 0, 8, 2, transform, flatClipCoords);
|
||||
return flatClipCoords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getBuilder(zIndex, replayType) {
|
||||
getBuilder(zIndex, builderType) {
|
||||
const zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
||||
let replays = this.buildersByZIndex_[zIndexKey];
|
||||
if (replays === undefined) {
|
||||
replays = {};
|
||||
this.buildersByZIndex_[zIndexKey] = replays;
|
||||
}
|
||||
let replay = replays[replayType];
|
||||
let replay = replays[builderType];
|
||||
if (replay === undefined) {
|
||||
const Constructor = BATCH_CONSTRUCTORS[replayType];
|
||||
const Constructor = BATCH_CONSTRUCTORS[builderType];
|
||||
replay = new Constructor(this.tolerance_, this.maxExtent_,
|
||||
this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_);
|
||||
replays[replayType] = replay;
|
||||
this.resolution_, this.pixelRatio_);
|
||||
replays[builderType] = replay;
|
||||
}
|
||||
return replay;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
isEmpty() {
|
||||
return isEmpty(this.buildersByZIndex_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This cache is used for storing calculated pixel circles for increasing performance.
|
||||
* It is a static property to allow each Replaygroup to access it.
|
||||
* @type {Object<number, Array<Array<(boolean|undefined)>>>}
|
||||
*/
|
||||
const circleArrayCache = {
|
||||
0: [[true]]
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This method fills a row in the array from the given coordinate to the
|
||||
* middle with `true`.
|
||||
* @param {Array<Array<(boolean|undefined)>>} array The array that will be altered.
|
||||
* @param {number} x X coordinate.
|
||||
* @param {number} y Y coordinate.
|
||||
*/
|
||||
function fillCircleArrayRowToMiddle(array, x, y) {
|
||||
let i;
|
||||
const radius = Math.floor(array.length / 2);
|
||||
if (x >= radius) {
|
||||
for (i = radius; i < x; i++) {
|
||||
array[i][y] = true;
|
||||
}
|
||||
} else if (x < radius) {
|
||||
for (i = x + 1; i < radius; i++) {
|
||||
array[i][y] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This methods creates a circle inside a fitting array. Points inside the
|
||||
* circle are marked by true, points on the outside are undefined.
|
||||
* It uses the midpoint circle algorithm.
|
||||
* A cache is used to increase performance.
|
||||
* @param {number} radius Radius.
|
||||
* @returns {Array<Array<(boolean|undefined)>>} An array with marked circle points.
|
||||
*/
|
||||
export function getCircleArray(radius) {
|
||||
if (circleArrayCache[radius] !== undefined) {
|
||||
return circleArrayCache[radius];
|
||||
}
|
||||
|
||||
const arraySize = radius * 2 + 1;
|
||||
const arr = new Array(arraySize);
|
||||
for (let i = 0; i < arraySize; i++) {
|
||||
arr[i] = new Array(arraySize);
|
||||
}
|
||||
|
||||
let x = radius;
|
||||
let y = 0;
|
||||
let error = 0;
|
||||
|
||||
while (x >= y) {
|
||||
fillCircleArrayRowToMiddle(arr, radius + x, radius + y);
|
||||
fillCircleArrayRowToMiddle(arr, radius + y, radius + x);
|
||||
fillCircleArrayRowToMiddle(arr, radius - y, radius + x);
|
||||
fillCircleArrayRowToMiddle(arr, radius - x, radius + y);
|
||||
fillCircleArrayRowToMiddle(arr, radius - x, radius - y);
|
||||
fillCircleArrayRowToMiddle(arr, radius - y, radius - x);
|
||||
fillCircleArrayRowToMiddle(arr, radius + y, radius - x);
|
||||
fillCircleArrayRowToMiddle(arr, radius + x, radius - y);
|
||||
|
||||
y++;
|
||||
error += 1 + 2 * y;
|
||||
if (2 * (error - x) + 1 > 0) {
|
||||
x -= 1;
|
||||
error += 1 - 2 * x;
|
||||
}
|
||||
}
|
||||
|
||||
circleArrayCache[radius] = arr;
|
||||
return arr;
|
||||
}
|
||||
|
||||
export default CanvasBuilderGroup;
|
||||
export default BuilderGroup;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @module ol/render/ReplayType
|
||||
* @module ol/render/BuilderType
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -2,8 +2,8 @@
|
||||
* @module ol/render/canvas/Executor
|
||||
*/
|
||||
import {getUid} from '../../util.js';
|
||||
import {equals, reverseSubArray} from '../../array.js';
|
||||
import {buffer, clone, createEmpty, createOrUpdate,
|
||||
import {equals} from '../../array.js';
|
||||
import {createEmpty, createOrUpdate,
|
||||
createOrUpdateEmpty, extend, extendCoordinate, intersects} from '../../extent.js';
|
||||
import {lineStringLength} from '../../geom/flat/length.js';
|
||||
import {drawTextOnPath} from '../../geom/flat/textpath.js';
|
||||
@@ -12,7 +12,7 @@ import {CANVAS_LINE_DASH} from '../../has.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import {drawImage, resetTransform, defaultPadding, defaultTextBaseline} from '../canvas.js';
|
||||
import CanvasInstruction from './Instruction.js';
|
||||
import {TEXT_ALIGN} from '../replay.js';
|
||||
import {TEXT_ALIGN} from './TextBuilder.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
compose as composeTransform,
|
||||
@@ -45,9 +45,8 @@ const tmpExtent = createEmpty();
|
||||
const tmpTransform = createTransform();
|
||||
|
||||
|
||||
class CanvasExecutor {
|
||||
class Executor {
|
||||
/**
|
||||
* @param {number} tolerance Tolerance.
|
||||
* @param {import("../../extent.js").Extent} maxExtent Maximum extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
@@ -55,18 +54,12 @@ class CanvasExecutor {
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
* @param {SerializableInstructions} instructions The serializable instructions
|
||||
*/
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree, instructions) {
|
||||
constructor(maxExtent, resolution, pixelRatio, overlaps, declutterTree, instructions) {
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
this.declutterTree = declutterTree;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
*/
|
||||
this.tolerance = tolerance;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @const
|
||||
@@ -86,12 +79,6 @@ class CanvasExecutor {
|
||||
*/
|
||||
this.pixelRatio = pixelRatio;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxLineWidth = 0;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @const
|
||||
@@ -105,24 +92,6 @@ class CanvasExecutor {
|
||||
*/
|
||||
this.alignFill_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<*>}
|
||||
*/
|
||||
this.beginGeometryInstruction1_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<*>}
|
||||
*/
|
||||
this.beginGeometryInstruction2_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../../extent.js").Extent}
|
||||
*/
|
||||
this.bufferedMaxExtent_ = null;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {Array<*>}
|
||||
@@ -159,12 +128,6 @@ class CanvasExecutor {
|
||||
*/
|
||||
this.pixelCoordinates_ = null;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {import("../canvas.js").FillStrokeState}
|
||||
*/
|
||||
this.state = /** @type {import("../canvas.js").FillStrokeState} */ ({});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -186,8 +149,6 @@ class CanvasExecutor {
|
||||
*/
|
||||
this.textStates = instructions.textStates || {};
|
||||
|
||||
// Adaptations
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Object<string, Object<string, number>>}
|
||||
@@ -406,18 +367,6 @@ class CanvasExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @param {Array<number>} dashArray Dash array.
|
||||
* @return {Array<number>} Dash array with pixel ratio applied
|
||||
*/
|
||||
applyPixelRatio(dashArray) {
|
||||
const pixelRatio = this.pixelRatio;
|
||||
return pixelRatio == 1 ? dashArray : dashArray.map(function(dash) {
|
||||
return dash * pixelRatio;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
@@ -914,83 +863,7 @@ class CanvasExecutor {
|
||||
return this.execute_(context, transform, skippedFeaturesHash,
|
||||
this.hitDetectionInstructions, true, opt_featureCallback, opt_hitExtent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the hit detection instructions.
|
||||
*/
|
||||
reverseHitDetectionInstructions() {
|
||||
const hitDetectionInstructions = this.hitDetectionInstructions;
|
||||
// step 1 - reverse array
|
||||
hitDetectionInstructions.reverse();
|
||||
// step 2 - reverse instructions within geometry blocks
|
||||
let i;
|
||||
const n = hitDetectionInstructions.length;
|
||||
let instruction;
|
||||
let type;
|
||||
let begin = -1;
|
||||
for (i = 0; i < n; ++i) {
|
||||
instruction = hitDetectionInstructions[i];
|
||||
type = /** @type {CanvasInstruction} */ (instruction[0]);
|
||||
if (type == CanvasInstruction.END_GEOMETRY) {
|
||||
begin = i;
|
||||
} else if (type == CanvasInstruction.BEGIN_GEOMETRY) {
|
||||
instruction[2] = i;
|
||||
reverseSubArray(this.hitDetectionInstructions, begin, i);
|
||||
begin = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../canvas.js").FillStrokeState} state State.
|
||||
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
|
||||
* @return {Array<*>} Fill instruction.
|
||||
*/
|
||||
createFill(state, geometry) {
|
||||
const fillStyle = state.fillStyle;
|
||||
/** @type {Array<*>} */
|
||||
const fillInstruction = [CanvasInstruction.SET_FILL_STYLE, fillStyle];
|
||||
if (typeof fillStyle !== 'string') {
|
||||
// Fill is a pattern or gradient - align it!
|
||||
fillInstruction.push(true);
|
||||
}
|
||||
return fillInstruction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../canvas.js").FillStrokeState} state State.
|
||||
* @return {Array<*>} Stroke instruction.
|
||||
*/
|
||||
createStroke(state) {
|
||||
return [
|
||||
CanvasInstruction.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth * this.pixelRatio, state.lineCap,
|
||||
state.lineJoin, state.miterLimit,
|
||||
this.applyPixelRatio(state.lineDash), state.lineDashOffset * this.pixelRatio
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the buffered rendering extent. Rendering will be clipped to the extent
|
||||
* provided to the constructor. To account for symbolizers that may intersect
|
||||
* this extent, we calculate a buffered extent (e.g. based on stroke width).
|
||||
* @return {import("../../extent.js").Extent} The buffered rendering extent.
|
||||
* @protected
|
||||
*/
|
||||
getBufferedMaxExtent() {
|
||||
if (!this.bufferedMaxExtent_) {
|
||||
this.bufferedMaxExtent_ = clone(this.maxExtent);
|
||||
if (this.maxLineWidth > 0) {
|
||||
const width = this.resolution * (this.maxLineWidth + 1) / 2;
|
||||
buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_);
|
||||
}
|
||||
}
|
||||
return this.bufferedMaxExtent_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default CanvasExecutor;
|
||||
export default Executor;
|
||||
|
||||
@@ -7,36 +7,37 @@ import {createCanvasContext2D} from '../../dom.js';
|
||||
import {buffer, createEmpty, extendCoordinate} from '../../extent.js';
|
||||
import {transform2D} from '../../geom/flat/transform.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import BaseExecutorGroup from '../ExecutorGroup.js';
|
||||
import ReplayType from '../ReplayType.js';
|
||||
import {ORDER} from '../replay.js';
|
||||
import BuilderType from './BuilderType.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../../transform.js';
|
||||
import CanvasExecutor from './Executor.js';
|
||||
import Executor from './Executor.js';
|
||||
|
||||
|
||||
class ExecutorGroup extends BaseExecutorGroup {
|
||||
/**
|
||||
* @param {number} tolerance Tolerance.
|
||||
* @const
|
||||
* @type {Array<BuilderType>}
|
||||
*/
|
||||
const ORDER = [
|
||||
BuilderType.POLYGON,
|
||||
BuilderType.CIRCLE,
|
||||
BuilderType.LINE_STRING,
|
||||
BuilderType.IMAGE,
|
||||
BuilderType.TEXT,
|
||||
BuilderType.DEFAULT
|
||||
];
|
||||
|
||||
|
||||
class ExecutorGroup {
|
||||
/**
|
||||
* @param {import("../../extent.js").Extent} maxExtent Max extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {boolean} overlaps The executor group can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree for declutter processing in postrender.
|
||||
* @param {!Object<string, !Object<ReplayType, import("./Builder.js").SerializableInstructions>>} allInstructions
|
||||
* @param {!Object<string, !Object<BuilderType, import("./Builder.js").SerializableInstructions>>} allInstructions
|
||||
* The serializable instructions.
|
||||
* @param {number=} opt_renderBuffer Optional rendering buffer.
|
||||
*/
|
||||
constructor(
|
||||
tolerance,
|
||||
maxExtent,
|
||||
resolution,
|
||||
pixelRatio,
|
||||
overlaps,
|
||||
declutterTree,
|
||||
allInstructions,
|
||||
opt_renderBuffer
|
||||
) {
|
||||
super();
|
||||
constructor(maxExtent, resolution, pixelRatio, overlaps, declutterTree,
|
||||
allInstructions, opt_renderBuffer) {
|
||||
|
||||
/**
|
||||
* Declutter tree.
|
||||
@@ -44,18 +45,6 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
*/
|
||||
this.declutterTree_ = declutterTree;
|
||||
|
||||
/**
|
||||
* @type {import("../canvas.js").DeclutterGroup}
|
||||
* @private
|
||||
*/
|
||||
this.declutterGroup_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.tolerance_ = tolerance;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../../extent.js").Extent}
|
||||
@@ -88,7 +77,7 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object<string, !Object<ReplayType, import("./Executor").default>>}
|
||||
* @type {!Object<string, !Object<BuilderType, import("./Executor").default>>}
|
||||
*/
|
||||
this.executorsByZIndex_ = {};
|
||||
|
||||
@@ -104,7 +93,7 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
*/
|
||||
this.hitDetectionTransform_ = createTransform();
|
||||
|
||||
this.createExectutors_(allInstructions);
|
||||
this.createExecutors_(allInstructions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,25 +113,25 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
/**
|
||||
* Create executors and populate them using the provided instructions.
|
||||
* @private
|
||||
* @param {!Object<string, !Object<ReplayType, import("./Builder.js").SerializableInstructions>>} allInstructions The serializable instructions
|
||||
* @param {!Object<string, !Object<BuilderType, import("./Builder.js").SerializableInstructions>>} allInstructions The serializable instructions
|
||||
*/
|
||||
createExectutors_(allInstructions) {
|
||||
createExecutors_(allInstructions) {
|
||||
for (const zIndex in allInstructions) {
|
||||
let executors = this.executorsByZIndex_[zIndex];
|
||||
if (executors === undefined) {
|
||||
this.executorsByZIndex_[zIndex] = executors = {};
|
||||
}
|
||||
const instructionByZindex = allInstructions[zIndex];
|
||||
for (const replayType in instructionByZindex) {
|
||||
const instructions = instructionByZindex[replayType];
|
||||
executors[replayType] = new CanvasExecutor(this.tolerance_, this.maxExtent_,
|
||||
for (const builderType in instructionByZindex) {
|
||||
const instructions = instructionByZindex[builderType];
|
||||
executors[builderType] = new Executor(this.maxExtent_,
|
||||
this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_, instructions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<ReplayType>} executors Executors.
|
||||
* @param {Array<BuilderType>} executors Executors.
|
||||
* @return {boolean} Has executors of the provided types.
|
||||
*/
|
||||
hasExecutors(executors) {
|
||||
@@ -213,7 +202,7 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
});
|
||||
}
|
||||
|
||||
let replayType;
|
||||
let builderType;
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature.js").default|import("../Feature.js").default} feature Feature.
|
||||
@@ -226,7 +215,7 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
if (mask[i][j]) {
|
||||
if (imageData[(j * contextSize + i) * 4 + 3] > 0) {
|
||||
let result;
|
||||
if (!(declutteredFeatures && (replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) ||
|
||||
if (!(declutteredFeatures && (builderType == BuilderType.IMAGE || builderType == BuilderType.TEXT)) ||
|
||||
declutteredFeatures.indexOf(feature) !== -1) {
|
||||
result = callback(feature);
|
||||
}
|
||||
@@ -251,11 +240,11 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
const zIndexKey = zs[i].toString();
|
||||
executors = this.executorsByZIndex_[zIndexKey];
|
||||
for (j = ORDER.length - 1; j >= 0; --j) {
|
||||
replayType = ORDER[j];
|
||||
executor = executors[replayType];
|
||||
builderType = ORDER[j];
|
||||
executor = executors[builderType];
|
||||
if (executor !== undefined) {
|
||||
if (declutterReplays &&
|
||||
(replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) {
|
||||
(builderType == BuilderType.IMAGE || builderType == BuilderType.TEXT)) {
|
||||
const declutter = declutterReplays[zIndexKey];
|
||||
if (!declutter) {
|
||||
declutterReplays[zIndexKey] = [executor, transform.slice(0)];
|
||||
@@ -299,39 +288,41 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {number|undefined} zIndex Z index.
|
||||
* @param {import("./BuilderType.js").default} builderType Builder type.
|
||||
* @return {import("../VectorContext.js").default} Executor.
|
||||
*/
|
||||
getExecutor(zIndex, replayType) {
|
||||
getExecutor(zIndex, builderType) {
|
||||
const zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
||||
let executors = this.executorsByZIndex_[zIndexKey];
|
||||
if (executors === undefined) {
|
||||
executors = {};
|
||||
this.executorsByZIndex_[zIndexKey] = executors;
|
||||
}
|
||||
let executor = executors[replayType];
|
||||
let executor = executors[builderType];
|
||||
if (executor === undefined) {
|
||||
// FIXME: it should not be possible to ask for an executor that does not exist
|
||||
executor = new CanvasExecutor(this.tolerance_, this.maxExtent_,
|
||||
executor = new Executor(this.maxExtent_,
|
||||
this.resolution_, this.pixelRatio_, this.overlaps_, {
|
||||
instructions: [],
|
||||
hitDetectionInstructions: [],
|
||||
coordinates: []
|
||||
},
|
||||
this.declutterTree_);
|
||||
executors[replayType] = executor;
|
||||
executors[builderType] = executor;
|
||||
}
|
||||
return executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Object<string, Object<ReplayType, CanvasReplay>>} Replays.
|
||||
* @return {Object<string, Object<BuilderType, CanvasReplay>>} Replays.
|
||||
*/
|
||||
getExecutors() {
|
||||
return this.executorsByZIndex_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
isEmpty() {
|
||||
return isEmpty(this.executorsByZIndex_);
|
||||
@@ -343,19 +334,12 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @param {Object<string, boolean>} skippedFeaturesHash Ids of features to skip.
|
||||
* @param {boolean} snapToPixel Snap point symbols and test to integer pixel.
|
||||
* @param {Array<ReplayType>=} opt_replayTypes Ordered replay types to replay.
|
||||
* @param {Array<BuilderType>=} opt_builderTypes Ordered replay types to replay.
|
||||
* Default is {@link module:ol/render/replay~ORDER}
|
||||
* @param {Object<string, import("../canvas.js").DeclutterGroup>=} opt_declutterReplays Declutter replays.
|
||||
*/
|
||||
execute(
|
||||
context,
|
||||
transform,
|
||||
viewRotation,
|
||||
skippedFeaturesHash,
|
||||
snapToPixel,
|
||||
opt_replayTypes,
|
||||
opt_declutterReplays
|
||||
) {
|
||||
execute(context, transform, viewRotation, skippedFeaturesHash, snapToPixel, opt_builderTypes,
|
||||
opt_declutterReplays) {
|
||||
|
||||
/** @type {Array<number>} */
|
||||
const zs = Object.keys(this.executorsByZIndex_).map(Number);
|
||||
@@ -366,17 +350,17 @@ class ExecutorGroup extends BaseExecutorGroup {
|
||||
context.save();
|
||||
this.clip(context, transform);
|
||||
|
||||
const replayTypes = opt_replayTypes ? opt_replayTypes : ORDER;
|
||||
const builderTypes = opt_builderTypes ? opt_builderTypes : ORDER;
|
||||
let i, ii, j, jj, replays, replay;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
const zIndexKey = zs[i].toString();
|
||||
replays = this.executorsByZIndex_[zIndexKey];
|
||||
for (j = 0, jj = replayTypes.length; j < jj; ++j) {
|
||||
const replayType = replayTypes[j];
|
||||
replay = replays[replayType];
|
||||
for (j = 0, jj = builderTypes.length; j < jj; ++j) {
|
||||
const builderType = builderTypes[j];
|
||||
replay = replays[builderType];
|
||||
if (replay !== undefined) {
|
||||
if (opt_declutterReplays &&
|
||||
(replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) {
|
||||
(builderType == BuilderType.IMAGE || builderType == BuilderType.TEXT)) {
|
||||
const declutter = opt_declutterReplays[zIndexKey];
|
||||
if (!declutter) {
|
||||
opt_declutterReplays[zIndexKey] = [replay, transform.slice(0)];
|
||||
|
||||
@@ -10,11 +10,9 @@ class CanvasImageBuilder extends CanvasBuilder {
|
||||
* @param {import("../../extent.js").Extent} maxExtent Maximum extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {boolean} overlaps The builder can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
*/
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
super(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio) {
|
||||
super(tolerance, maxExtent, resolution, pixelRatio);
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -10,11 +10,9 @@ class CanvasLineStringBuilder extends CanvasBuilder {
|
||||
* @param {import("../../extent.js").Extent} maxExtent Maximum extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {boolean} overlaps The replay can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
*/
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
super(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio) {
|
||||
super(tolerance, maxExtent, resolution, pixelRatio);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,11 +16,9 @@ class CanvasPolygonBuilder extends CanvasBuilder {
|
||||
* @param {import("../../extent.js").Extent} maxExtent Maximum extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {boolean} overlaps The replay can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
*/
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
super(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio) {
|
||||
super(tolerance, maxExtent, resolution, pixelRatio);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,8 +9,24 @@ import GeometryType from '../../geom/GeometryType.js';
|
||||
import {labelCache, defaultTextAlign, defaultPadding, defaultLineCap, defaultLineDashOffset, defaultLineDash, defaultLineJoin, defaultFillStyle, checkFont, defaultFont, defaultLineWidth, defaultMiterLimit, defaultStrokeStyle, defaultTextBaseline} from '../canvas.js';
|
||||
import CanvasInstruction from './Instruction.js';
|
||||
import CanvasBuilder from './Builder.js';
|
||||
import {TEXT_ALIGN} from '../replay.js';
|
||||
import TextPlacement from '../../style/TextPlacement.js';
|
||||
/**
|
||||
* @const
|
||||
* @enum {number}
|
||||
*/
|
||||
export const TEXT_ALIGN = {};
|
||||
TEXT_ALIGN['left'] = 0;
|
||||
TEXT_ALIGN['end'] = 0;
|
||||
TEXT_ALIGN['center'] = 0.5;
|
||||
TEXT_ALIGN['right'] = 1;
|
||||
TEXT_ALIGN['start'] = 1;
|
||||
TEXT_ALIGN['top'] = 0;
|
||||
TEXT_ALIGN['middle'] = 0.5;
|
||||
TEXT_ALIGN['hanging'] = 0.2;
|
||||
TEXT_ALIGN['alphabetic'] = 0.8;
|
||||
TEXT_ALIGN['ideographic'] = 0.8;
|
||||
TEXT_ALIGN['bottom'] = 1;
|
||||
|
||||
|
||||
class CanvasTextBuilder extends CanvasBuilder {
|
||||
/**
|
||||
@@ -18,11 +34,9 @@ class CanvasTextBuilder extends CanvasBuilder {
|
||||
* @param {import("../../extent.js").Extent} maxExtent Maximum extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {boolean} overlaps The replay can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
*/
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
super(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio) {
|
||||
super(tolerance, maxExtent, resolution, pixelRatio);
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* @module ol/render/replay
|
||||
*/
|
||||
import ReplayType from './ReplayType.js';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array<ReplayType>}
|
||||
*/
|
||||
export const ORDER = [
|
||||
ReplayType.POLYGON,
|
||||
ReplayType.CIRCLE,
|
||||
ReplayType.LINE_STRING,
|
||||
ReplayType.IMAGE,
|
||||
ReplayType.TEXT,
|
||||
ReplayType.DEFAULT
|
||||
];
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @enum {number}
|
||||
*/
|
||||
export const TEXT_ALIGN = {};
|
||||
TEXT_ALIGN['left'] = 0;
|
||||
TEXT_ALIGN['end'] = 0;
|
||||
TEXT_ALIGN['center'] = 0.5;
|
||||
TEXT_ALIGN['right'] = 1;
|
||||
TEXT_ALIGN['start'] = 1;
|
||||
TEXT_ALIGN['top'] = 0;
|
||||
TEXT_ALIGN['middle'] = 0.5;
|
||||
TEXT_ALIGN['hanging'] = 0.2;
|
||||
TEXT_ALIGN['alphabetic'] = 0.8;
|
||||
TEXT_ALIGN['ideographic'] = 0.8;
|
||||
TEXT_ALIGN['bottom'] = 1;
|
||||
@@ -296,7 +296,7 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
|
||||
|
||||
const replayGroup = new CanvasBuilderGroup(
|
||||
getRenderTolerance(resolution, pixelRatio), extent, resolution,
|
||||
pixelRatio, vectorSource.getOverlaps(), this.declutterTree_, vectorLayer.getRenderBuffer());
|
||||
pixelRatio, !!this.declutterTree_);
|
||||
|
||||
vectorSource.loadFeatures(extent, resolution, projection);
|
||||
|
||||
@@ -335,8 +335,7 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
|
||||
}
|
||||
|
||||
const replayGroupInstructions = replayGroup.finish();
|
||||
const renderingExecutorGroup = new InstructionsGroupExecutor(
|
||||
getRenderTolerance(resolution, pixelRatio), extent, resolution,
|
||||
const renderingExecutorGroup = new InstructionsGroupExecutor(extent, resolution,
|
||||
pixelRatio, vectorSource.getOverlaps(), this.declutterTree_,
|
||||
replayGroupInstructions, vectorLayer.getRenderBuffer());
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {buffer, containsCoordinate, equals, getIntersection, getTopLeft, interse
|
||||
import VectorTileRenderType from '../../layer/VectorTileRenderType.js';
|
||||
import {equivalent as equivalentProjection} from '../../proj.js';
|
||||
import Units from '../../proj/Units.js';
|
||||
import ReplayType from '../../render/ReplayType.js';
|
||||
import ReplayType from '../../render/canvas/BuilderType.js';
|
||||
import {labelCache} from '../../render/canvas.js';
|
||||
import CanvasBuilderGroup from '../../render/canvas/BuilderGroup.js';
|
||||
import CanvasTileLayerRenderer from './TileLayer.js';
|
||||
@@ -32,7 +32,7 @@ import CanvasExecutorGroup, {replayDeclutter} from '../../render/canvas/Executor
|
||||
|
||||
|
||||
/**
|
||||
* @type {!Object<string, Array<import("../../render/ReplayType.js").default>>}
|
||||
* @type {!Object<string, Array<import("../../render/canvas/BuilderType.js").default>>}
|
||||
*/
|
||||
const IMAGE_REPLAYS = {
|
||||
'image': [ReplayType.POLYGON, ReplayType.CIRCLE,
|
||||
@@ -42,7 +42,7 @@ const IMAGE_REPLAYS = {
|
||||
|
||||
|
||||
/**
|
||||
* @type {!Object<string, Array<import("../../render/ReplayType.js").default>>}
|
||||
* @type {!Object<string, Array<import("../../render/canvas/BuilderType.js").default>>}
|
||||
*/
|
||||
const VECTOR_REPLAYS = {
|
||||
'image': [ReplayType.DEFAULT],
|
||||
@@ -229,7 +229,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
||||
}
|
||||
builderState.dirty = false;
|
||||
const builderGroup = new CanvasBuilderGroup(0, sharedExtent, resolution,
|
||||
pixelRatio, source.getOverlaps(), this.declutterTree_, layer.getRenderBuffer());
|
||||
pixelRatio, !!this.declutterTree_);
|
||||
const squaredTolerance = getSquaredRenderTolerance(resolution, pixelRatio);
|
||||
|
||||
/**
|
||||
@@ -269,7 +269,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
||||
}
|
||||
}
|
||||
const executorGroupInstructions = builderGroup.finish();
|
||||
const renderingReplayGroup = new CanvasExecutorGroup(0, sharedExtent, resolution,
|
||||
const renderingReplayGroup = new CanvasExecutorGroup(sharedExtent, resolution,
|
||||
pixelRatio, source.getOverlaps(), this.declutterTree_, executorGroupInstructions, layer.getRenderBuffer());
|
||||
sourceTile.setExecutorGroup(layer, tile.tileCoord.toString(), renderingReplayGroup);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {getUid} from '../util.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import BuilderType from '../render/ReplayType.js';
|
||||
import BuilderType from '../render/canvas/BuilderType.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ const SIMPLIFY_TOLERANCE = 0.5;
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<import("../geom/GeometryType.js").default,
|
||||
* function(import("../render/BuilderGroup.js").default, import("../geom/Geometry.js").default,
|
||||
* function(import("../render/canvas/BuilderGroup.js").default, import("../geom/Geometry.js").default,
|
||||
* import("../style/Style.js").default, Object)>}
|
||||
*/
|
||||
const GEOMETRY_RENDERERS = {
|
||||
@@ -64,7 +64,7 @@ export function getTolerance(resolution, pixelRatio) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} builderGroup Builder group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Builder group.
|
||||
* @param {import("../geom/Circle.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
@@ -87,7 +87,7 @@ function renderCircleGeometry(builderGroup, geometry, style, feature) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} replayGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} replayGroup Replay group.
|
||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
@@ -119,7 +119,7 @@ export function renderFeature(replayGroup, feature, style, squaredTolerance, lis
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} replayGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} replayGroup Replay group.
|
||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
@@ -141,7 +141,7 @@ function renderFeatureInternal(replayGroup, feature, style, squaredTolerance) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} replayGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} replayGroup Replay group.
|
||||
* @param {import("../geom/Geometry.js").default|import("../render/Feature.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
||||
@@ -160,7 +160,7 @@ function renderGeometry(replayGroup, geometry, style, feature) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} replayGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} replayGroup Replay group.
|
||||
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
@@ -177,7 +177,7 @@ function renderGeometryCollectionGeometry(replayGroup, geometry, style, feature)
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../geom/LineString.js").default|import("../render/Feature.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
||||
@@ -199,7 +199,7 @@ function renderLineStringGeometry(builderGroup, geometry, style, feature) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../geom/MultiLineString.js").default|import("../render/Feature.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
||||
@@ -221,7 +221,7 @@ function renderMultiLineStringGeometry(builderGroup, geometry, style, feature) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
@@ -244,7 +244,7 @@ function renderMultiPolygonGeometry(builderGroup, geometry, style, feature) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../geom/Point.js").default|import("../render/Feature.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
||||
@@ -269,7 +269,7 @@ function renderPointGeometry(builderGroup, geometry, style, feature) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../geom/MultiPoint.js").default|import("../render/Feature.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
||||
@@ -294,7 +294,7 @@ function renderMultiPointGeometry(builderGroup, geometry, style, feature) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../render/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
|
||||
* @param {import("../geom/Polygon.js").default|import("../render/Feature.js").default} geometry Geometry.
|
||||
* @param {import("../style/Style.js").default} style Style.
|
||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {getCircleArray} from '../../../../../src/ol/render/canvas/BuilderGroup.js';
|
||||
import {getCircleArray} from '../../../../../src/ol/render/canvas/ExecutorGroup.js';
|
||||
|
||||
|
||||
describe('ol.render.canvas.ReplayGroup', function() {
|
||||
describe('ol.render.canvas.ExecutorGroup', function() {
|
||||
|
||||
describe('#getCircleArray_', function() {
|
||||
it('creates an array with a pixelated circle marked with true', function() {
|
||||
@@ -1,13 +1,13 @@
|
||||
import Feature from '../../../../../src/ol/Feature.js';
|
||||
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
|
||||
import Polygon from '../../../../../src/ol/geom/Polygon.js';
|
||||
import CanvasTextReplay from '../../../../../src/ol/render/canvas/TextBuilder.js';
|
||||
import InstructionExecutor from '../../../../../src/ol/render/canvas/Executor.js';
|
||||
import TextBuilder from '../../../../../src/ol/render/canvas/TextBuilder.js';
|
||||
import Executor from '../../../../../src/ol/render/canvas/Executor.js';
|
||||
import Text from '../../../../../src/ol/style/Text.js';
|
||||
import {create as createTransform} from '../../../../../src/ol/transform.js';
|
||||
|
||||
function createBuilder() {
|
||||
return new CanvasTextReplay(1, [-180, -90, 180, 90], 0.02, 1, true);
|
||||
return new TextBuilder(1, [-180, -90, 180, 90], 0.02, 1, true);
|
||||
}
|
||||
|
||||
function createContext() {
|
||||
@@ -25,18 +25,18 @@ function createContext() {
|
||||
};
|
||||
}
|
||||
|
||||
function executeInstructions(builder, expectedDrawTextImageCalls, expectedReplayImageCalls) {
|
||||
function executeInstructions(builder, expectedDrawTextImageCalls, expectedBuilderImageCalls) {
|
||||
const transform = createTransform();
|
||||
const context = createContext();
|
||||
const executor = new InstructionExecutor(1, [-180, -90, 180, 90], 0.02, 1, false, null, builder.finish());
|
||||
const executor = new Executor([-180, -90, 180, 90], 0.02, 1, false, null, builder.finish());
|
||||
sinon.spy(executor, 'drawTextImageWithPointPlacement_');
|
||||
const replayImageStub = sinon.stub(executor, 'replayImage_');
|
||||
executor.execute(context, transform);
|
||||
expect(executor.drawTextImageWithPointPlacement_.callCount).to.be(expectedDrawTextImageCalls);
|
||||
expect(replayImageStub.callCount).to.be(expectedReplayImageCalls);
|
||||
expect(replayImageStub.callCount).to.be(expectedBuilderImageCalls);
|
||||
}
|
||||
|
||||
describe('ol.render.canvas.TextReplay', function() {
|
||||
describe('ol.render.canvas.TextBuilder', function() {
|
||||
|
||||
it('renders polygon labels only when they fit', function() {
|
||||
let builder = createBuilder();
|
||||
@@ -9,16 +9,16 @@ import Point from '../../../../../src/ol/geom/Point.js';
|
||||
import Polygon from '../../../../../src/ol/geom/Polygon.js';
|
||||
import CanvasLineStringBuilder from '../../../../../src/ol/render/canvas/LineStringBuilder.js';
|
||||
import CanvasPolygonBuilder from '../../../../../src/ol/render/canvas/PolygonBuilder.js';
|
||||
import CanvasReplay from '../../../../../src/ol/render/canvas/Builder.js';
|
||||
import CanvasInstructionsGroupBuilder from '../../../../../src/ol/render/canvas/BuilderGroup.js';
|
||||
import CanvasInstructionsGroupExecutor from '../../../../../src/ol/render/canvas/ExecutorGroup.js';
|
||||
import CanvasBuilder from '../../../../../src/ol/render/canvas/Builder.js';
|
||||
import BuilderGroup from '../../../../../src/ol/render/canvas/BuilderGroup.js';
|
||||
import ExecutorGroup from '../../../../../src/ol/render/canvas/ExecutorGroup.js';
|
||||
import {renderFeature} from '../../../../../src/ol/renderer/vector.js';
|
||||
import Fill from '../../../../../src/ol/style/Fill.js';
|
||||
import Stroke from '../../../../../src/ol/style/Stroke.js';
|
||||
import Style from '../../../../../src/ol/style/Style.js';
|
||||
import {create as createTransform, scale as scaleTransform} from '../../../../../src/ol/transform.js';
|
||||
|
||||
describe('ol.render.canvas.ReplayGroup', function() {
|
||||
describe('ol.render.canvas.BuilderGroup', function() {
|
||||
|
||||
describe('#replay', function() {
|
||||
|
||||
@@ -28,20 +28,20 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
let fill0, fill1, style1, style2;
|
||||
|
||||
/**
|
||||
* @param {CanvasInstructionsGroupBuilder} builder The builder to get instructions from.
|
||||
* @param {BuilderGroup} builder The builder to get instructions from.
|
||||
* @param {Object=} skippedUids The ids to skip.
|
||||
* @param {number=} pixelRatio The pixel ratio.
|
||||
* @param {boolean=} overlaps Whether there is overlaps.
|
||||
*/
|
||||
function execute(builder, skippedUids, pixelRatio, overlaps) {
|
||||
const executor = new CanvasInstructionsGroupExecutor(1, [-180, -90, 180, 90], 1,
|
||||
const executor = new ExecutorGroup([-180, -90, 180, 90], 1,
|
||||
pixelRatio || 1, !!overlaps, null, builder.finish());
|
||||
executor.execute(context, transform, 0, skippedUids || {});
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
transform = createTransform();
|
||||
builder = new CanvasInstructionsGroupBuilder(1, [-180, -90, 180, 90], 1, 1, false);
|
||||
builder = new BuilderGroup(1, [-180, -90, 180, 90], 1, 1, false);
|
||||
feature0 = new Feature(new Polygon(
|
||||
[[[-90, 0], [-45, 45], [0, 0], [1, 1], [0, -45], [-90, 0]]]));
|
||||
feature1 = new Feature(new Polygon(
|
||||
@@ -185,7 +185,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
});
|
||||
|
||||
it('does not batch when overlaps is set to true', function() {
|
||||
builder = new CanvasInstructionsGroupBuilder(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
builder = new BuilderGroup(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
renderFeature(builder, feature1, style1, 1);
|
||||
renderFeature(builder, feature2, style1, 1);
|
||||
renderFeature(builder, feature3, style1, 1);
|
||||
@@ -197,7 +197,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
|
||||
it('applies the pixelRatio to the linedash array and offset', function() {
|
||||
// replay with a pixelRatio of 2
|
||||
builder = new CanvasInstructionsGroupBuilder(1, [-180, -90, 180, 90], 1, 2, true);
|
||||
builder = new BuilderGroup(1, [-180, -90, 180, 90], 1, 2, true);
|
||||
|
||||
let lineDash, lineDashCount = 0,
|
||||
lineDashOffset, lineDashOffsetCount = 0;
|
||||
@@ -254,7 +254,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
[polygon.getGeometry().getCoordinates(), polygon.getGeometry().getCoordinates()]));
|
||||
const geometrycollection = new Feature(new GeometryCollection(
|
||||
[point.getGeometry(), linestring.getGeometry(), polygon.getGeometry()]));
|
||||
builder = new CanvasInstructionsGroupBuilder(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
builder = new BuilderGroup(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
renderFeature(builder, point, style, 1);
|
||||
renderFeature(builder, multipoint, style, 1);
|
||||
renderFeature(builder, linestring, style, 1);
|
||||
@@ -291,15 +291,15 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('ol.render.canvas.Replay', function() {
|
||||
describe('ol.render.canvas.Builder', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new replay batch', function() {
|
||||
const tolerance = 10;
|
||||
const extent = [-180, -90, 180, 90];
|
||||
const replay = new CanvasReplay(tolerance, extent, 1, 1, true);
|
||||
expect(replay).to.be.a(CanvasReplay);
|
||||
const replay = new CanvasBuilder(tolerance, extent, 1, 1, true);
|
||||
expect(replay).to.be.a(CanvasBuilder);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -308,7 +308,7 @@ describe('ol.render.canvas.Replay', function() {
|
||||
|
||||
let replay;
|
||||
beforeEach(function() {
|
||||
replay = new CanvasReplay(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
replay = new CanvasBuilder(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
});
|
||||
|
||||
it('appends coordinates that are within the max extent', function() {
|
||||
@@ -451,7 +451,7 @@ describe('ol.render.canvas.Replay', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('ol.render.canvas.LineStringReplay', function() {
|
||||
describe('ol.render.canvas.LineStringBuilder', function() {
|
||||
|
||||
describe('#getBufferedMaxExtent()', function() {
|
||||
|
||||
@@ -473,7 +473,7 @@ describe('ol.render.canvas.LineStringReplay', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('ol.render.canvas.PolygonReplay', function() {
|
||||
describe('ol.render.canvas.PolygonBuilder', function() {
|
||||
|
||||
let replay;
|
||||
|
||||
Reference in New Issue
Block a user