diff --git a/examples/webgl-vector-layer.js b/examples/webgl-vector-layer.js index e7e60bc762..68dd7442b1 100644 --- a/examples/webgl-vector-layer.js +++ b/examples/webgl-vector-layer.js @@ -18,8 +18,8 @@ class WebGLLayer extends Layer { className: this.getClassName(), fill: { attributes: { - [DefaultAttributes.COLOR]: function (feature, properties) { - const color = asArray(properties.COLOR || '#eee'); + [DefaultAttributes.COLOR]: function (feature) { + const color = asArray(feature.get('COLOR') || '#eee'); color[3] = 0.85; return packColor(color); }, @@ -30,8 +30,8 @@ class WebGLLayer extends Layer { }, stroke: { attributes: { - [DefaultAttributes.COLOR]: function (feature, properties) { - const color = [...asArray(properties.COLOR || '#eee')]; + [DefaultAttributes.COLOR]: function (feature) { + const color = [...asArray(feature.get('COLOR') || '#eee')]; color.forEach((_, i) => (color[i] = Math.round(color[i] * 0.75))); // darken slightly return packColor(color); }, diff --git a/src/ol/render/webgl/BatchRenderer.js b/src/ol/render/webgl/BatchRenderer.js index 5745e4c502..aae3e73733 100644 --- a/src/ol/render/webgl/BatchRenderer.js +++ b/src/ol/render/webgl/BatchRenderer.js @@ -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):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; diff --git a/src/ol/render/webgl/LineStringBatchRenderer.js b/src/ol/render/webgl/LineStringBatchRenderer.js index 7698e835c7..c4ee9f0bf8 100644 --- a/src/ol/render/webgl/LineStringBatchRenderer.js +++ b/src/ol/render/webgl/LineStringBatchRenderer.js @@ -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; } diff --git a/src/ol/render/webgl/MixedGeometryBatch.js b/src/ol/render/webgl/MixedGeometryBatch.js index a6b21013fc..2ae4728901 100644 --- a/src/ol/render/webgl/MixedGeometryBatch.js +++ b/src/ol/render/webgl/MixedGeometryBatch.js @@ -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} properties Feature properties * @property {Array>} 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, diff --git a/src/ol/render/webgl/PointBatchRenderer.js b/src/ol/render/webgl/PointBatchRenderer.js index d593499f69..3c211c3661 100644 --- a/src/ol/render/webgl/PointBatchRenderer.js +++ b/src/ol/render/webgl/PointBatchRenderer.js @@ -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; } } diff --git a/src/ol/render/webgl/PolygonBatchRenderer.js b/src/ol/render/webgl/PolygonBatchRenderer.js index b102840e1a..1c6b262820 100644 --- a/src/ol/render/webgl/PolygonBatchRenderer.js +++ b/src/ol/render/webgl/PolygonBatchRenderer.js @@ -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; } diff --git a/test/browser/spec/ol/render/webgl/BatchRenderer.test.js b/test/browser/spec/ol/render/webgl/BatchRenderer.test.js index f4bdfdaa57..1c46a69679 100644 --- a/test/browser/spec/ol/render/webgl/BatchRenderer.test.js +++ b/test/browser/spec/ol/render/webgl/BatchRenderer.test.js @@ -39,7 +39,7 @@ describe('Batch renderers', function () { { name: 'test', callback: function (feature, properties) { - return properties.test; + return feature.get('test'); }, }, ]; diff --git a/test/browser/spec/ol/render/webgl/MixedGeometryBatch.test.js b/test/browser/spec/ol/render/webgl/MixedGeometryBatch.test.js index dba8e79485..d870a9f8a4 100644 --- a/test/browser/spec/ol/render/webgl/MixedGeometryBatch.test.js +++ b/test/browser/spec/ol/render/webgl/MixedGeometryBatch.test.js @@ -62,12 +62,10 @@ describe('MixedGeometryBatch', function () { expect(keys).to.eql([uid1, uid2]); expect(mixedBatch.pointBatch.entries[uid1]).to.eql({ feature: feature1, - properties: feature1.getProperties(), flatCoordss: [[0, 1]], }); expect(mixedBatch.pointBatch.entries[uid2]).to.eql({ feature: feature2, - properties: feature2.getProperties(), flatCoordss: [[2, 3]], }); }); @@ -95,7 +93,7 @@ describe('MixedGeometryBatch', function () { }); it('updates the modified properties and geometry in the point batch', () => { const entry = mixedBatch.pointBatch.entries[getUid(feature1)]; - expect(entry.properties.prop1).to.eql('changed'); + expect(entry.feature.get('prop1')).to.eql('changed'); }); it('keeps geometry count the same', () => { expect(mixedBatch.pointBatch.geometriesCount).to.be(2); @@ -173,13 +171,11 @@ describe('MixedGeometryBatch', function () { expect(keys).to.eql([uid1, uid2]); expect(mixedBatch.lineStringBatch.entries[uid1]).to.eql({ feature: feature1, - properties: feature1.getProperties(), flatCoordss: [[0, 1, 2, 3, 4, 5, 6, 7]], verticesCount: 4, }); expect(mixedBatch.lineStringBatch.entries[uid2]).to.eql({ feature: feature2, - properties: feature2.getProperties(), flatCoordss: [[8, 9, 10, 11, 12, 13]], verticesCount: 3, }); @@ -208,7 +204,7 @@ describe('MixedGeometryBatch', function () { }); it('updates the modified properties and geometry in the linestring batch', () => { const entry = mixedBatch.lineStringBatch.entries[getUid(feature1)]; - expect(entry.properties.prop1).to.eql('changed'); + expect(entry.feature.get('prop1')).to.eql('changed'); expect(entry.verticesCount).to.eql(6); expect(entry.flatCoordss).to.eql([ [0, 1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103], @@ -316,7 +312,6 @@ describe('MixedGeometryBatch', function () { expect(keys).to.eql([uid1, uid2]); expect(mixedBatch.polygonBatch.entries[uid1]).to.eql({ feature: feature1, - properties: feature1.getProperties(), flatCoordss: [[0, 1, 2, 3, 4, 5, 6, 7, 20, 21, 22, 23, 24, 25]], verticesCount: 7, ringsCount: 2, @@ -324,7 +319,6 @@ describe('MixedGeometryBatch', function () { }); expect(mixedBatch.polygonBatch.entries[uid2]).to.eql({ feature: feature2, - properties: feature2.getProperties(), flatCoordss: [ [ 8, 9, 10, 11, 12, 13, 30, 31, 32, 33, 34, 35, 40, 41, 42, 43, 44, @@ -346,7 +340,6 @@ describe('MixedGeometryBatch', function () { expect(keys).to.eql([getUid(feature1), getUid(feature2)]); expect(mixedBatch.lineStringBatch.entries[getUid(feature1)]).to.eql({ feature: feature1, - properties: feature1.getProperties(), flatCoordss: [ [0, 1, 2, 3, 4, 5, 6, 7], [20, 21, 22, 23, 24, 25], @@ -355,7 +348,6 @@ describe('MixedGeometryBatch', function () { }); expect(mixedBatch.lineStringBatch.entries[getUid(feature2)]).to.eql({ feature: feature2, - properties: feature2.getProperties(), flatCoordss: [ [8, 9, 10, 11, 12, 13], [30, 31, 32, 33, 34, 35], @@ -393,7 +385,7 @@ describe('MixedGeometryBatch', function () { }); it('updates the modified properties and geometry in the polygon batch', () => { const entry = mixedBatch.polygonBatch.entries[getUid(feature1)]; - expect(entry.properties.prop1).to.eql('changed'); + expect(entry.feature.get('prop1')).to.eql('changed'); expect(entry.verticesCount).to.eql(11); expect(entry.ringsCount).to.eql(3); expect(entry.ringsVerticesCounts).to.eql([[4, 3, 4]]); @@ -529,7 +521,6 @@ describe('MixedGeometryBatch', function () { const uid = getUid(feature); expect(mixedBatch.polygonBatch.entries[uid]).to.eql({ feature: feature, - properties: feature.getProperties(), flatCoordss: [ [0, 1, 2, 3, 4, 5, 6, 7, 20, 21, 22, 23, 24, 25], [ @@ -549,7 +540,6 @@ describe('MixedGeometryBatch', function () { const uid = getUid(feature); expect(mixedBatch.lineStringBatch.entries[uid]).to.eql({ feature: feature, - properties: feature.getProperties(), flatCoordss: [ [0, 1, 2, 3, 4, 5, 6, 7], [20, 21, 22, 23, 24, 25], @@ -566,7 +556,6 @@ describe('MixedGeometryBatch', function () { const uid = getUid(feature); expect(mixedBatch.pointBatch.entries[uid]).to.eql({ feature: feature, - properties: feature.getProperties(), flatCoordss: [ [101, 102], [201, 202], @@ -619,7 +608,6 @@ describe('MixedGeometryBatch', function () { const entry = mixedBatch.polygonBatch.entries[getUid(feature)]; expect(entry).to.eql({ feature: feature, - properties: feature.getProperties(), flatCoordss: [ [0, 1, 2, 3, 4, 5, 6, 7, 20, 21, 22, 23, 24, 25], [ @@ -637,7 +625,6 @@ describe('MixedGeometryBatch', function () { const entry = mixedBatch.lineStringBatch.entries[getUid(feature)]; expect(entry).to.eql({ feature: feature, - properties: feature.getProperties(), flatCoordss: [ [0, 1, 2, 3, 4, 5, 6, 7], [20, 21, 22, 23, 24, 25], @@ -680,7 +667,6 @@ describe('MixedGeometryBatch', function () { const entry = mixedBatch.polygonBatch.entries[getUid(feature)]; expect(entry).to.eql({ feature: feature, - properties: feature.getProperties(), flatCoordss: [[201, 202, 203, 204, 205, 206, 207, 208]], verticesCount: 4, ringsCount: 1, @@ -691,7 +677,6 @@ describe('MixedGeometryBatch', function () { const entry = mixedBatch.lineStringBatch.entries[getUid(feature)]; expect(entry).to.eql({ feature: feature, - properties: feature.getProperties(), flatCoordss: [[201, 202, 203, 204, 205, 206, 207, 208]], verticesCount: 4, });