Use union type instead of enum for canvas builder type
This commit is contained in:
committed by
Andreas Hocevar
parent
05f9b35eeb
commit
3a061ed576
@@ -2,7 +2,6 @@
|
||||
* @module ol/render/canvas/ExecutorGroup
|
||||
*/
|
||||
|
||||
import BuilderType from './BuilderType.js';
|
||||
import Executor from './Executor.js';
|
||||
import {buffer, createEmpty, extendCoordinate} from '../../extent.js';
|
||||
import {
|
||||
@@ -16,16 +15,9 @@ import {transform2D} from '../../geom/flat/transform.js';
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array<import("./BuilderType.js").default>}
|
||||
* @type {Array<import("../canvas.js").BuilderType>}
|
||||
*/
|
||||
const ORDER = [
|
||||
BuilderType.POLYGON,
|
||||
BuilderType.CIRCLE,
|
||||
BuilderType.LINE_STRING,
|
||||
BuilderType.IMAGE,
|
||||
BuilderType.TEXT,
|
||||
BuilderType.DEFAULT,
|
||||
];
|
||||
const ORDER = ['Polygon', 'Circle', 'LineString', 'Image', 'Text', 'Default'];
|
||||
|
||||
class ExecutorGroup {
|
||||
/**
|
||||
@@ -36,7 +28,7 @@ class ExecutorGroup {
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {boolean} overlaps The executor group can have overlapping geometries.
|
||||
* @param {!Object<string, !Object<import("./BuilderType.js").default, import("../canvas.js").SerializableInstructions>>} allInstructions
|
||||
* @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions
|
||||
* The serializable instructions.
|
||||
* @param {number} [opt_renderBuffer] Optional rendering buffer.
|
||||
*/
|
||||
@@ -80,7 +72,7 @@ class ExecutorGroup {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object<string, !Object<import("./BuilderType.js").default, import("./Executor").default>>}
|
||||
* @type {!Object<string, !Object<import("../canvas.js").BuilderType, import("./Executor").default>>}
|
||||
*/
|
||||
this.executorsByZIndex_ = {};
|
||||
|
||||
@@ -116,7 +108,7 @@ class ExecutorGroup {
|
||||
/**
|
||||
* Create executors and populate them using the provided instructions.
|
||||
* @private
|
||||
* @param {!Object<string, !Object<import("./BuilderType.js").default, import("../canvas.js").SerializableInstructions>>} allInstructions The serializable instructions
|
||||
* @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions The serializable instructions
|
||||
*/
|
||||
createExecutors_(allInstructions) {
|
||||
for (const zIndex in allInstructions) {
|
||||
@@ -139,7 +131,7 @@ class ExecutorGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<import("./BuilderType.js").default>} executors Executors.
|
||||
* @param {Array<import("../canvas.js").BuilderType>} executors Executors.
|
||||
* @return {boolean} Has executors of the provided types.
|
||||
*/
|
||||
hasExecutors(executors) {
|
||||
@@ -238,8 +230,7 @@ class ExecutorGroup {
|
||||
if (imageData[indexes[i]] > 0) {
|
||||
if (
|
||||
!declutteredFeatures ||
|
||||
(builderType !== BuilderType.IMAGE &&
|
||||
builderType !== BuilderType.TEXT) ||
|
||||
(builderType !== 'Image' && builderType !== 'Text') ||
|
||||
declutteredFeatures.indexOf(feature) !== -1
|
||||
) {
|
||||
const idx = (indexes[i] - 3) / 4;
|
||||
@@ -316,7 +307,7 @@ class ExecutorGroup {
|
||||
* @param {import("../../transform.js").Transform} transform Transform.
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @param {boolean} snapToPixel Snap point symbols and test to integer pixel.
|
||||
* @param {Array<import("./BuilderType.js").default>} [opt_builderTypes] Ordered replay types to replay.
|
||||
* @param {Array<import("../canvas.js").BuilderType>} [opt_builderTypes] Ordered replay types to replay.
|
||||
* Default is {@link module:ol/render/replay~ORDER}
|
||||
* @param {import("rbush").default} [opt_declutterTree] Declutter tree.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user