Only pass the feature to the attribute getter

This commit is contained in:
Tim Schaub
2022-07-21 13:43:53 -07:00
parent bd9e73a534
commit 7e424be66b
8 changed files with 13 additions and 41 deletions

View File

@@ -14,8 +14,8 @@ import {
* @typedef {Object} CustomAttribute A description of a custom attribute to be passed on to the GPU, with a value different
* for each feature.
* @property {string} name Attribute name.
* @property {function(import("../../Feature").default, Object<string, *>):number} callback This callback computes the numerical value of the
* attribute for a given feature (properties are available as 2nd arg for quicker access).
* @property {function(import("../../Feature").default):number} callback This callback computes the numerical value of the
* attribute for a given feature.
*/
let workerMessageCounter = 0;

View File

@@ -96,10 +96,7 @@ class LineStringBatchRenderer extends AbstractBatchRenderer {
// custom attributes
for (let k = 0, kk = this.customAttributes.length; k < kk; k++) {
value = this.customAttributes[k].callback(
batchEntry.feature,
batchEntry.properties
);
value = this.customAttributes[k].callback(batchEntry.feature);
batch.renderInstructions[renderIndex++] = value;
}

View File

@@ -9,7 +9,6 @@ import {getUid} from '../../util.js';
/**
* @typedef {Object} GeometryBatchItem Object that holds a reference to a feature as well as the raw coordinates of its various geometries
* @property {import("../../Feature").default} feature Feature
* @property {Object<string, *>} properties Feature properties
* @property {Array<Array<number>>} flatCoordss Array of flat coordinates arrays, one for each geometry related to the feature
* @property {number} [verticesCount] Only defined for linestring and polygon batches
* @property {number} [ringsCount] Only defined for polygon batches
@@ -162,7 +161,6 @@ class MixedGeometryBatch {
if (!(uid in this.pointBatch.entries)) {
this.pointBatch.entries[uid] = {
feature: feature,
properties: feature.getProperties(),
flatCoordss: [],
};
}
@@ -179,7 +177,6 @@ class MixedGeometryBatch {
if (!(uid in this.lineStringBatch.entries)) {
this.lineStringBatch.entries[uid] = {
feature: feature,
properties: feature.getProperties(),
flatCoordss: [],
verticesCount: 0,
};
@@ -197,7 +194,6 @@ class MixedGeometryBatch {
if (!(uid in this.polygonBatch.entries)) {
this.polygonBatch.entries[uid] = {
feature: feature,
properties: feature.getProperties(),
flatCoordss: [],
verticesCount: 0,
ringsCount: 0,

View File

@@ -86,10 +86,7 @@ class PointBatchRenderer extends AbstractBatchRenderer {
// pushing custom attributes
for (let j = 0, jj = this.customAttributes.length; j < jj; j++) {
value = this.customAttributes[j].callback(
batchEntry.feature,
batchEntry.properties
);
value = this.customAttributes[j].callback(batchEntry.feature);
batch.renderInstructions[renderIndex++] = value;
}
}

View File

@@ -86,10 +86,7 @@ class PolygonBatchRenderer extends AbstractBatchRenderer {
// custom attributes
for (let k = 0, kk = this.customAttributes.length; k < kk; k++) {
value = this.customAttributes[k].callback(
batchEntry.feature,
batchEntry.properties
);
value = this.customAttributes[k].callback(batchEntry.feature);
batch.renderInstructions[renderIndex++] = value;
}