Reduce usage of "replay" term
This commit is contained in:
38
src/ol/render/BuilderGroup.js
Normal file
38
src/ol/render/BuilderGroup.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @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,19 +1,19 @@
|
||||
/**
|
||||
* @module ol/render/ReplayGroup
|
||||
* @module ol/render/ExecutorGroup
|
||||
*/
|
||||
import {abstract} from '../util.js';
|
||||
|
||||
/**
|
||||
* Base class for replay groups.
|
||||
*/
|
||||
class ReplayGroup {
|
||||
class ExecutorGroup {
|
||||
/**
|
||||
* @abstract
|
||||
* @param {number|undefined} zIndex Z index.
|
||||
* @param {import("./ReplayType.js").default} replayType Replay type.
|
||||
* @return {import("./VectorContext.js").default} Replay.
|
||||
*/
|
||||
getReplay(zIndex, replayType) {
|
||||
getExecutor(zIndex, replayType) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -35,4 +35,4 @@ class ReplayGroup {
|
||||
}
|
||||
}
|
||||
|
||||
export default ReplayGroup;
|
||||
export default ExecutorGroup;
|
||||
@@ -10,7 +10,7 @@ class CanvasImageBuilder extends CanvasInstructionsBuilder {
|
||||
* @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 {boolean} overlaps The builder can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
*/
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class CanvasInstructionsBuilder extends VectorContext {
|
||||
* @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 {boolean} overlaps The builder can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
*/
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
@@ -230,14 +230,14 @@ class CanvasInstructionsBuilder extends VectorContext {
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<number>} ends Ends.
|
||||
* @param {number} stride Stride.
|
||||
* @param {Array<number>} replayEnds Replay ends.
|
||||
* @param {Array<number>} builderEnds Builder ends.
|
||||
* @return {number} Offset.
|
||||
*/
|
||||
drawCustomCoordinates_(flatCoordinates, offset, ends, stride, replayEnds) {
|
||||
drawCustomCoordinates_(flatCoordinates, offset, ends, stride, builderEnds) {
|
||||
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);
|
||||
const builderEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false);
|
||||
builderEnds.push(builderEnd);
|
||||
offset = end;
|
||||
}
|
||||
return offset;
|
||||
@@ -250,44 +250,44 @@ class CanvasInstructionsBuilder extends VectorContext {
|
||||
this.beginGeometry(geometry, feature);
|
||||
const type = geometry.getType();
|
||||
const stride = geometry.getStride();
|
||||
const replayBegin = this.coordinates.length;
|
||||
let flatCoordinates, replayEnd, replayEnds, replayEndss;
|
||||
const builderBegin = this.coordinates.length;
|
||||
let flatCoordinates, builderEnd, builderEnds, builderEndss;
|
||||
let offset;
|
||||
if (type == GeometryType.MULTI_POLYGON) {
|
||||
geometry = /** @type {import("../../geom/MultiPolygon.js").default} */ (geometry);
|
||||
flatCoordinates = geometry.getOrientedFlatCoordinates();
|
||||
replayEndss = [];
|
||||
builderEndss = [];
|
||||
const endss = geometry.getEndss();
|
||||
offset = 0;
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
const myEnds = [];
|
||||
offset = this.drawCustomCoordinates_(flatCoordinates, offset, endss[i], stride, myEnds);
|
||||
replayEndss.push(myEnds);
|
||||
builderEndss.push(myEnds);
|
||||
}
|
||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||
replayBegin, replayEndss, geometry, renderer, inflateMultiCoordinatesArray]);
|
||||
builderBegin, builderEndss, geometry, renderer, inflateMultiCoordinatesArray]);
|
||||
} else if (type == GeometryType.POLYGON || type == GeometryType.MULTI_LINE_STRING) {
|
||||
replayEnds = [];
|
||||
builderEnds = [];
|
||||
flatCoordinates = (type == GeometryType.POLYGON) ?
|
||||
/** @type {import("../../geom/Polygon.js").default} */ (geometry).getOrientedFlatCoordinates() :
|
||||
geometry.getFlatCoordinates();
|
||||
offset = this.drawCustomCoordinates_(flatCoordinates, 0,
|
||||
/** @type {import("../../geom/Polygon.js").default|import("../../geom/MultiLineString.js").default} */ (geometry).getEnds(),
|
||||
stride, replayEnds);
|
||||
stride, builderEnds);
|
||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||
replayBegin, replayEnds, geometry, renderer, inflateCoordinatesArray]);
|
||||
builderBegin, builderEnds, geometry, renderer, inflateCoordinatesArray]);
|
||||
} else if (type == GeometryType.LINE_STRING || type == GeometryType.MULTI_POINT) {
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
replayEnd = this.appendFlatCoordinates(
|
||||
builderEnd = this.appendFlatCoordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||
replayBegin, replayEnd, geometry, renderer, inflateCoordinates]);
|
||||
builderBegin, builderEnd, geometry, renderer, inflateCoordinates]);
|
||||
} else if (type == GeometryType.POINT) {
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
||||
replayEnd = this.coordinates.length;
|
||||
builderEnd = this.coordinates.length;
|
||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||
replayBegin, replayEnd, geometry, renderer]);
|
||||
builderBegin, builderEnd, geometry, renderer]);
|
||||
}
|
||||
this.endGeometry(geometry, feature);
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ class CanvasInstructionsExecutor {
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
replay_(
|
||||
execute_(
|
||||
context,
|
||||
transform,
|
||||
skippedFeaturesHash,
|
||||
@@ -909,9 +909,9 @@ class CanvasInstructionsExecutor {
|
||||
* to skip.
|
||||
* @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
|
||||
*/
|
||||
replay(context, transform, viewRotation, skippedFeaturesHash, snapToPixel) {
|
||||
execute(context, transform, viewRotation, skippedFeaturesHash, snapToPixel) {
|
||||
this.viewRotation_ = viewRotation;
|
||||
this.replay_(context, transform,
|
||||
this.execute_(context, transform,
|
||||
skippedFeaturesHash, this.instructions, snapToPixel, undefined, undefined);
|
||||
}
|
||||
|
||||
@@ -928,7 +928,7 @@ class CanvasInstructionsExecutor {
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
replayHitDetection(
|
||||
executeHitDetection(
|
||||
context,
|
||||
transform,
|
||||
viewRotation,
|
||||
@@ -937,7 +937,7 @@ class CanvasInstructionsExecutor {
|
||||
opt_hitExtent
|
||||
) {
|
||||
this.viewRotation_ = viewRotation;
|
||||
return this.replay_(context, transform, skippedFeaturesHash,
|
||||
return this.execute_(context, transform, skippedFeaturesHash,
|
||||
this.hitDetectionInstructions, true, opt_featureCallback, opt_hitExtent);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ 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 ReplayGroup from '../ReplayGroup.js';
|
||||
import BuilderGroup from '../BuilderGroup.js';
|
||||
import ReplayType from '../ReplayType.js';
|
||||
import CanvasInstructionsBuilder from './InstructionsBuilder.js';
|
||||
import CanvasImageBuilder from './ImageBuilder.js';
|
||||
@@ -31,13 +31,13 @@ const BATCH_CONSTRUCTORS = {
|
||||
};
|
||||
|
||||
|
||||
class CanvasInstructionsGroupBuilder extends ReplayGroup {
|
||||
class CanvasBuilderGroup extends 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 replay group can have overlapping geometries.
|
||||
* @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.
|
||||
*/
|
||||
@@ -104,7 +104,7 @@ class CanvasInstructionsGroupBuilder extends ReplayGroup {
|
||||
* @private
|
||||
* @type {!Object<string, !Object<ReplayType, CanvasInstructionsBuilder>>}
|
||||
*/
|
||||
this.replaysByZIndex_ = {};
|
||||
this.buildersByZIndex_ = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -150,31 +150,16 @@ class CanvasInstructionsGroupBuilder extends ReplayGroup {
|
||||
context.clip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recreate replays and populate them using the provided instructions.
|
||||
* @param {!Object<string, !Object<ReplayType, import("./InstructionsBuilder.js").SerializableInstructions>>} allInstructions The serializable instructions
|
||||
*/
|
||||
replaceInstructions(allInstructions) {
|
||||
this.replaysByZIndex_ = {};
|
||||
for (const zIndex in allInstructions) {
|
||||
const instructionByZindex = allInstructions[zIndex];
|
||||
for (const replayType in instructionByZindex) {
|
||||
const instructions = instructionByZindex[replayType];
|
||||
const replay = this.getReplay(zIndex, replayType);
|
||||
replay.replaceInstructions(instructions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<ReplayType>} replays Replays.
|
||||
* @return {boolean} Has replays of the provided types.
|
||||
* @param {Array<ReplayType>} builders Builders.
|
||||
* @return {boolean} Has builders of the provided types.
|
||||
*/
|
||||
hasReplays(replays) {
|
||||
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) {
|
||||
hasBuilders(builders) {
|
||||
for (const zIndex in this.buildersByZIndex_) {
|
||||
const candidates = this.buildersByZIndex_[zIndex];
|
||||
for (let i = 0, ii = builders.length; i < ii; ++i) {
|
||||
if (builders[i] in candidates) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -186,16 +171,16 @@ class CanvasInstructionsGroupBuilder extends ReplayGroup {
|
||||
* @return {!Object<string, !Object<ReplayType, import("./InstructionsBuilder.js").SerializableInstructions>>} The serializable instructions
|
||||
*/
|
||||
finish() {
|
||||
const replaysInstructions = {};
|
||||
for (const zKey in this.replaysByZIndex_) {
|
||||
replaysInstructions[zKey] = replaysInstructions[zKey] || {};
|
||||
const replays = this.replaysByZIndex_[zKey];
|
||||
for (const replayKey in replays) {
|
||||
const replayInstructions = replays[replayKey].finish();
|
||||
replaysInstructions[zKey][replayKey] = replayInstructions;
|
||||
const builderInstructions = {};
|
||||
for (const zKey in this.buildersByZIndex_) {
|
||||
builderInstructions[zKey] = builderInstructions[zKey] || {};
|
||||
const builders = this.buildersByZIndex_[zKey];
|
||||
for (const builderKey in builders) {
|
||||
const builderInstruction = builders[builderKey].finish();
|
||||
builderInstructions[zKey][builderKey] = builderInstruction;
|
||||
}
|
||||
}
|
||||
return replaysInstructions;
|
||||
return builderInstructions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,27 +268,27 @@ class CanvasInstructionsGroupBuilder extends ReplayGroup {
|
||||
}
|
||||
|
||||
/** @type {Array<number>} */
|
||||
const zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
const zs = Object.keys(this.buildersByZIndex_).map(Number);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
|
||||
let i, j, replays, replay, result;
|
||||
let i, j, builders, builder, result;
|
||||
for (i = zs.length - 1; i >= 0; --i) {
|
||||
const zIndexKey = zs[i].toString();
|
||||
replays = this.replaysByZIndex_[zIndexKey];
|
||||
builders = this.buildersByZIndex_[zIndexKey];
|
||||
for (j = ORDER.length - 1; j >= 0; --j) {
|
||||
replayType = ORDER[j];
|
||||
replay = replays[replayType];
|
||||
if (replay !== undefined) {
|
||||
builder = builders[replayType];
|
||||
if (builder !== undefined) {
|
||||
if (declutterReplays &&
|
||||
(replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) {
|
||||
const declutter = declutterReplays[zIndexKey];
|
||||
if (!declutter) {
|
||||
declutterReplays[zIndexKey] = [replay, transform.slice(0)];
|
||||
declutterReplays[zIndexKey] = [builder, transform.slice(0)];
|
||||
} else {
|
||||
declutter.push(replay, transform.slice(0));
|
||||
declutter.push(builder, transform.slice(0));
|
||||
}
|
||||
} else {
|
||||
result = replay.replayHitDetection(context, transform, rotation,
|
||||
result = builder.executeHitDetection(context, transform, rotation,
|
||||
skippedFeaturesHash, featureCallback, hitExtent);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -341,12 +326,12 @@ class CanvasInstructionsGroupBuilder extends ReplayGroup {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getReplay(zIndex, replayType) {
|
||||
getBuilder(zIndex, replayType) {
|
||||
const zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
||||
let replays = this.replaysByZIndex_[zIndexKey];
|
||||
let replays = this.buildersByZIndex_[zIndexKey];
|
||||
if (replays === undefined) {
|
||||
replays = {};
|
||||
this.replaysByZIndex_[zIndexKey] = replays;
|
||||
this.buildersByZIndex_[zIndexKey] = replays;
|
||||
}
|
||||
let replay = replays[replayType];
|
||||
if (replay === undefined) {
|
||||
@@ -362,70 +347,14 @@ class CanvasInstructionsGroupBuilder extends ReplayGroup {
|
||||
* @return {Object<string, Object<ReplayType, CanvasInstructionsBuilder>>} Replays.
|
||||
*/
|
||||
getReplays() {
|
||||
return this.replaysByZIndex_;
|
||||
return this.buildersByZIndex_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
isEmpty() {
|
||||
return isEmpty(this.replaysByZIndex_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {import("../../transform.js").Transform} transform Transform.
|
||||
* @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.
|
||||
* Default is {@link module:ol/render/replay~ORDER}
|
||||
* @param {Object<string, import("../canvas.js").DeclutterGroup>=} opt_declutterReplays Declutter replays.
|
||||
*/
|
||||
replay(
|
||||
context,
|
||||
transform,
|
||||
viewRotation,
|
||||
skippedFeaturesHash,
|
||||
snapToPixel,
|
||||
opt_replayTypes,
|
||||
opt_declutterReplays
|
||||
) {
|
||||
|
||||
/** @type {Array<number>} */
|
||||
const zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
|
||||
// setup clipping so that the parts of over-simplified geometries are not
|
||||
// visible outside the current extent when panning
|
||||
context.save();
|
||||
this.clip(context, transform);
|
||||
|
||||
const replayTypes = opt_replayTypes ? opt_replayTypes : ORDER;
|
||||
let i, ii, j, jj, replays, replay;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
const zIndexKey = zs[i].toString();
|
||||
replays = this.replaysByZIndex_[zIndexKey];
|
||||
for (j = 0, jj = replayTypes.length; j < jj; ++j) {
|
||||
const replayType = replayTypes[j];
|
||||
replay = replays[replayType];
|
||||
if (replay !== undefined) {
|
||||
if (opt_declutterReplays &&
|
||||
(replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) {
|
||||
const declutter = opt_declutterReplays[zIndexKey];
|
||||
if (!declutter) {
|
||||
opt_declutterReplays[zIndexKey] = [replay, transform.slice(0)];
|
||||
} else {
|
||||
declutter.push(replay, transform.slice(0));
|
||||
}
|
||||
} else {
|
||||
replay.replay(context, transform, viewRotation, skippedFeaturesHash, snapToPixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.restore();
|
||||
return isEmpty(this.buildersByZIndex_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,10 +451,10 @@ export function replayDeclutter(declutterReplays, context, rotation, snapToPixel
|
||||
for (let i = 0, ii = replayData.length; i < ii;) {
|
||||
const replay = replayData[i++];
|
||||
const transform = replayData[i++];
|
||||
replay.replay(context, transform, rotation, skippedFeatureUids, snapToPixel);
|
||||
replay.execute(context, transform, rotation, skippedFeatureUids, snapToPixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default CanvasInstructionsGroupBuilder;
|
||||
export default CanvasBuilderGroup;
|
||||
|
||||
@@ -7,20 +7,20 @@ 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 ReplayGroup from '../ReplayGroup.js';
|
||||
import ExecutorGroup from '../ExecutorGroup.js';
|
||||
import ReplayType from '../ReplayType.js';
|
||||
import {ORDER} from '../replay.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../../transform.js';
|
||||
import CanvasInstructionsExecutor from './InstructionsExecutor.js';
|
||||
|
||||
|
||||
class InstructionsGroupExectuor extends ReplayGroup {
|
||||
class InstructionsGroupExectuor extends ExecutorGroup {
|
||||
/**
|
||||
* @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 replay group can have overlapping geometries.
|
||||
* @param {boolean} overlaps The executor group can have overlapping geometries.
|
||||
* @param {?} declutterTree Declutter tree for declutter processing in postrender.
|
||||
* @param {number=} opt_renderBuffer Optional rendering buffer.
|
||||
*/
|
||||
@@ -87,7 +87,7 @@ class InstructionsGroupExectuor extends ReplayGroup {
|
||||
* @private
|
||||
* @type {!Object<string, !Object<ReplayType, CanvasReplay>>}
|
||||
*/
|
||||
this.replaysByZIndex_ = {};
|
||||
this.executorsByZIndex_ = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -134,30 +134,30 @@ class InstructionsGroupExectuor extends ReplayGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Recreate replays and populate them using the provided instructions.
|
||||
* Create executors and populate them using the provided instructions.
|
||||
* @param {!Object<string, !Object<ReplayType, import("./InstructionsBuilder.js").SerializableInstructions>>} allInstructions The serializable instructions
|
||||
*/
|
||||
replaceInstructions(allInstructions) {
|
||||
this.replaysByZIndex_ = {};
|
||||
this.executorsByZIndex_ = {};
|
||||
for (const zIndex in allInstructions) {
|
||||
const instructionByZindex = allInstructions[zIndex];
|
||||
for (const replayType in instructionByZindex) {
|
||||
const instructions = instructionByZindex[replayType];
|
||||
const replay = this.getReplay(zIndex, replayType);
|
||||
replay.replaceInstructions(instructions);
|
||||
const executor = this.getExecutor(zIndex, replayType);
|
||||
executor.replaceInstructions(instructions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<ReplayType>} replays Replays.
|
||||
* @return {boolean} Has replays of the provided types.
|
||||
* @param {Array<ReplayType>} executors Executors.
|
||||
* @return {boolean} Has executors of the provided types.
|
||||
*/
|
||||
hasReplays(replays) {
|
||||
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) {
|
||||
hasExecutors(executors) {
|
||||
for (const zIndex in this.executorsByZIndex_) {
|
||||
const candidates = this.executorsByZIndex_[zIndex];
|
||||
for (let i = 0, ii = executors.length; i < ii; ++i) {
|
||||
if (executors[i] in candidates) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -251,27 +251,27 @@ class InstructionsGroupExectuor extends ReplayGroup {
|
||||
}
|
||||
|
||||
/** @type {Array<number>} */
|
||||
const zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
const zs = Object.keys(this.executorsByZIndex_).map(Number);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
|
||||
let i, j, replays, replay, result;
|
||||
let i, j, executors, executor, result;
|
||||
for (i = zs.length - 1; i >= 0; --i) {
|
||||
const zIndexKey = zs[i].toString();
|
||||
replays = this.replaysByZIndex_[zIndexKey];
|
||||
executors = this.executorsByZIndex_[zIndexKey];
|
||||
for (j = ORDER.length - 1; j >= 0; --j) {
|
||||
replayType = ORDER[j];
|
||||
replay = replays[replayType];
|
||||
if (replay !== undefined) {
|
||||
executor = executors[replayType];
|
||||
if (executor !== undefined) {
|
||||
if (declutterReplays &&
|
||||
(replayType == ReplayType.IMAGE || replayType == ReplayType.TEXT)) {
|
||||
const declutter = declutterReplays[zIndexKey];
|
||||
if (!declutter) {
|
||||
declutterReplays[zIndexKey] = [replay, transform.slice(0)];
|
||||
declutterReplays[zIndexKey] = [executor, transform.slice(0)];
|
||||
} else {
|
||||
declutter.push(replay, transform.slice(0));
|
||||
declutter.push(executor, transform.slice(0));
|
||||
}
|
||||
} else {
|
||||
result = replay.replayHitDetection(context, transform, rotation,
|
||||
result = executor.executeHitDetection(context, transform, rotation,
|
||||
skippedFeaturesHash, featureCallback, hitExtent);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -302,34 +302,34 @@ class InstructionsGroupExectuor extends ReplayGroup {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getReplay(zIndex, replayType) {
|
||||
getExecutor(zIndex, replayType) {
|
||||
const zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
||||
let replays = this.replaysByZIndex_[zIndexKey];
|
||||
if (replays === undefined) {
|
||||
replays = {};
|
||||
this.replaysByZIndex_[zIndexKey] = replays;
|
||||
let executors = this.executorsByZIndex_[zIndexKey];
|
||||
if (executors === undefined) {
|
||||
executors = {};
|
||||
this.executorsByZIndex_[zIndexKey] = executors;
|
||||
}
|
||||
let replay = replays[replayType];
|
||||
if (replay === undefined) {
|
||||
replay = new CanvasInstructionsExecutor(this.tolerance_, this.maxExtent_,
|
||||
let executor = executors[replayType];
|
||||
if (executor === undefined) {
|
||||
executor = new CanvasInstructionsExecutor(this.tolerance_, this.maxExtent_,
|
||||
this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_);
|
||||
replays[replayType] = replay;
|
||||
executors[replayType] = executor;
|
||||
}
|
||||
return replay;
|
||||
return executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Object<string, Object<ReplayType, CanvasReplay>>} Replays.
|
||||
*/
|
||||
getReplays() {
|
||||
return this.replaysByZIndex_;
|
||||
getExecutors() {
|
||||
return this.executorsByZIndex_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
isEmpty() {
|
||||
return isEmpty(this.replaysByZIndex_);
|
||||
return isEmpty(this.executorsByZIndex_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,7 +353,7 @@ class InstructionsGroupExectuor extends ReplayGroup {
|
||||
) {
|
||||
|
||||
/** @type {Array<number>} */
|
||||
const zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
const zs = Object.keys(this.executorsByZIndex_).map(Number);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
|
||||
// setup clipping so that the parts of over-simplified geometries are not
|
||||
@@ -365,7 +365,7 @@ class InstructionsGroupExectuor extends ReplayGroup {
|
||||
let i, ii, j, jj, replays, replay;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
const zIndexKey = zs[i].toString();
|
||||
replays = this.replaysByZIndex_[zIndexKey];
|
||||
replays = this.executorsByZIndex_[zIndexKey];
|
||||
for (j = 0, jj = replayTypes.length; j < jj; ++j) {
|
||||
const replayType = replayTypes[j];
|
||||
replay = replays[replayType];
|
||||
@@ -379,7 +379,7 @@ class InstructionsGroupExectuor extends ReplayGroup {
|
||||
declutter.push(replay, transform.slice(0));
|
||||
}
|
||||
} else {
|
||||
replay.replay(context, transform, viewRotation, skippedFeaturesHash, snapToPixel);
|
||||
replay.execute(context, transform, viewRotation, skippedFeaturesHash, snapToPixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -482,7 +482,7 @@ export function replayDeclutter(declutterReplays, context, rotation, snapToPixel
|
||||
for (let i = 0, ii = replayData.length; i < ii;) {
|
||||
const replay = replayData[i++];
|
||||
const transform = replayData[i++];
|
||||
replay.replay(context, transform, rotation, skippedFeatureUids, snapToPixel);
|
||||
replay.execute(context, transform, rotation, skippedFeatureUids, snapToPixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class WebGLImmediateRenderer extends VectorContext {
|
||||
drawText_(replayGroup, geometry) {
|
||||
const context = this.context_;
|
||||
const replay = /** @type {import("./TextReplay.js").default} */ (
|
||||
replayGroup.getReplay(0, ReplayType.TEXT));
|
||||
replayGroup.getBuilder(0, ReplayType.TEXT));
|
||||
replay.setTextStyle(this.textStyle_);
|
||||
replay.drawText(geometry, null);
|
||||
replay.finish(context);
|
||||
@@ -191,7 +191,7 @@ class WebGLImmediateRenderer extends VectorContext {
|
||||
const context = this.context_;
|
||||
const replayGroup = new WebGLReplayGroup(1, this.extent_);
|
||||
const replay = /** @type {import("./ImageReplay.js").default} */ (
|
||||
replayGroup.getReplay(0, ReplayType.IMAGE));
|
||||
replayGroup.getBuilder(0, ReplayType.IMAGE));
|
||||
replay.setImageStyle(this.imageStyle_);
|
||||
replay.drawPoint(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -218,7 +218,7 @@ class WebGLImmediateRenderer extends VectorContext {
|
||||
const context = this.context_;
|
||||
const replayGroup = new WebGLReplayGroup(1, this.extent_);
|
||||
const replay = /** @type {import("./ImageReplay.js").default} */ (
|
||||
replayGroup.getReplay(0, ReplayType.IMAGE));
|
||||
replayGroup.getBuilder(0, ReplayType.IMAGE));
|
||||
replay.setImageStyle(this.imageStyle_);
|
||||
replay.drawMultiPoint(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -244,7 +244,7 @@ class WebGLImmediateRenderer extends VectorContext {
|
||||
const context = this.context_;
|
||||
const replayGroup = new WebGLReplayGroup(1, this.extent_);
|
||||
const replay = /** @type {import("./LineStringReplay.js").default} */ (
|
||||
replayGroup.getReplay(0, ReplayType.LINE_STRING));
|
||||
replayGroup.getBuilder(0, ReplayType.LINE_STRING));
|
||||
replay.setFillStrokeStyle(null, this.strokeStyle_);
|
||||
replay.drawLineString(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -270,7 +270,7 @@ class WebGLImmediateRenderer extends VectorContext {
|
||||
const context = this.context_;
|
||||
const replayGroup = new WebGLReplayGroup(1, this.extent_);
|
||||
const replay = /** @type {import("./LineStringReplay.js").default} */ (
|
||||
replayGroup.getReplay(0, ReplayType.LINE_STRING));
|
||||
replayGroup.getBuilder(0, ReplayType.LINE_STRING));
|
||||
replay.setFillStrokeStyle(null, this.strokeStyle_);
|
||||
replay.drawMultiLineString(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -296,7 +296,7 @@ class WebGLImmediateRenderer extends VectorContext {
|
||||
const context = this.context_;
|
||||
const replayGroup = new WebGLReplayGroup(1, this.extent_);
|
||||
const replay = /** @type {import("./PolygonReplay.js").default} */ (
|
||||
replayGroup.getReplay(0, ReplayType.POLYGON));
|
||||
replayGroup.getBuilder(0, ReplayType.POLYGON));
|
||||
replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_);
|
||||
replay.drawPolygon(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -322,7 +322,7 @@ class WebGLImmediateRenderer extends VectorContext {
|
||||
const context = this.context_;
|
||||
const replayGroup = new WebGLReplayGroup(1, this.extent_);
|
||||
const replay = /** @type {import("./PolygonReplay.js").default} */ (
|
||||
replayGroup.getReplay(0, ReplayType.POLYGON));
|
||||
replayGroup.getBuilder(0, ReplayType.POLYGON));
|
||||
replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_);
|
||||
replay.drawMultiPolygon(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -348,7 +348,7 @@ class WebGLImmediateRenderer extends VectorContext {
|
||||
const context = this.context_;
|
||||
const replayGroup = new WebGLReplayGroup(1, this.extent_);
|
||||
const replay = /** @type {import("./CircleReplay.js").default} */ (
|
||||
replayGroup.getReplay(0, ReplayType.CIRCLE));
|
||||
replayGroup.getBuilder(0, ReplayType.CIRCLE));
|
||||
replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_);
|
||||
replay.drawCircle(geometry, data);
|
||||
replay.finish(context);
|
||||
|
||||
@@ -6,7 +6,7 @@ import {numberSafeCompareFunction} from '../../array.js';
|
||||
import {buffer, createOrUpdateFromCoordinate} from '../../extent.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import {ORDER} from '../replay.js';
|
||||
import ReplayGroup from '../ReplayGroup.js';
|
||||
import ReplayGroup from '../BuilderGroup.js';
|
||||
import WebGLCircleReplay from './CircleReplay.js';
|
||||
import WebGLImageReplay from './ImageReplay.js';
|
||||
import WebGLLineStringReplay from './LineStringReplay.js';
|
||||
@@ -113,7 +113,7 @@ class WebGLReplayGroup extends ReplayGroup {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getReplay(zIndex, replayType) {
|
||||
getBuilder(zIndex, replayType) {
|
||||
const zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
||||
let replays = this.replaysByZIndex_[zIndexKey];
|
||||
if (replays === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user