ol 8.1.1-dev.1694687206621 → 8.1.1-dev.1694712969002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ol.js +2 -2
- package/dist/ol.js.map +1 -1
- package/expr/cpu.js +2 -8
- package/expr/expression.d.ts +18 -3
- package/expr/expression.d.ts.map +1 -1
- package/expr/expression.js +420 -59
- package/package.json +1 -1
- package/render/webgl/MixedGeometryBatch.d.ts +51 -3
- package/render/webgl/MixedGeometryBatch.d.ts.map +1 -1
- package/render/webgl/MixedGeometryBatch.js +145 -42
- package/render/webgl/VectorStyleRenderer.d.ts +16 -5
- package/render/webgl/VectorStyleRenderer.d.ts.map +1 -1
- package/render/webgl/VectorStyleRenderer.js +29 -7
- package/render/webgl/constants.d.ts +2 -2
- package/render/webgl/constants.js +2 -2
- package/render/webgl/renderinstructions.js +1 -1
- package/renderer/webgl/PointsLayer.d.ts +0 -7
- package/renderer/webgl/PointsLayer.d.ts.map +1 -1
- package/renderer/webgl/PointsLayer.js +9 -34
- package/renderer/webgl/VectorLayer.d.ts +26 -18
- package/renderer/webgl/VectorLayer.d.ts.map +1 -1
- package/renderer/webgl/VectorLayer.js +104 -38
- package/renderer/webgl/VectorTileLayer.d.ts +12 -0
- package/renderer/webgl/VectorTileLayer.d.ts.map +1 -1
- package/renderer/webgl/VectorTileLayer.js +10 -1
- package/renderer/webgl/worldUtil.d.ts +8 -0
- package/renderer/webgl/worldUtil.d.ts.map +1 -0
- package/renderer/webgl/worldUtil.js +27 -0
- package/util.js +1 -1
- package/webgl/ShaderBuilder.d.ts.map +1 -1
- package/webgl/ShaderBuilder.js +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default MixedGeometryBatch;
|
|
2
|
-
export type Feature = import("../../Feature").default;
|
|
2
|
+
export type Feature = import("../../Feature.js").default;
|
|
3
3
|
export type GeometryType = import("../../geom/Geometry.js").Type;
|
|
4
4
|
/**
|
|
5
5
|
* Object that holds a reference to a feature as well as the raw coordinates of its various geometries
|
|
@@ -25,6 +25,10 @@ export type GeometryBatchItem = {
|
|
|
25
25
|
* Array of vertices counts in each ring for each geometry; only defined for polygons batches
|
|
26
26
|
*/
|
|
27
27
|
ringsVerticesCounts?: number[][] | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The reference in the global batch (used for hit detection)
|
|
30
|
+
*/
|
|
31
|
+
ref?: number | undefined;
|
|
28
32
|
};
|
|
29
33
|
export type GeometryBatch = PointGeometryBatch | LineStringGeometryBatch | PolygonGeometryBatch;
|
|
30
34
|
/**
|
|
@@ -88,7 +92,7 @@ export type PointGeometryBatch = {
|
|
|
88
92
|
geometriesCount: number;
|
|
89
93
|
};
|
|
90
94
|
/**
|
|
91
|
-
* @typedef {import("../../Feature").default} Feature
|
|
95
|
+
* @typedef {import("../../Feature.js").default} Feature
|
|
92
96
|
*/
|
|
93
97
|
/**
|
|
94
98
|
* @typedef {import("../../geom/Geometry.js").Type} GeometryType
|
|
@@ -100,6 +104,7 @@ export type PointGeometryBatch = {
|
|
|
100
104
|
* @property {number} [verticesCount] Only defined for linestring and polygon batches
|
|
101
105
|
* @property {number} [ringsCount] Only defined for polygon batches
|
|
102
106
|
* @property {Array<Array<number>>} [ringsVerticesCounts] Array of vertices counts in each ring for each geometry; only defined for polygons batches
|
|
107
|
+
* @property {number} [ref] The reference in the global batch (used for hit detection)
|
|
103
108
|
*/
|
|
104
109
|
/**
|
|
105
110
|
* @typedef {PointGeometryBatch|LineStringGeometryBatch|PolygonGeometryBatch} GeometryBatch
|
|
@@ -145,6 +150,26 @@ export type PointGeometryBatch = {
|
|
|
145
150
|
* the WebGL buffers.
|
|
146
151
|
*/
|
|
147
152
|
declare class MixedGeometryBatch {
|
|
153
|
+
globalCounter_: number;
|
|
154
|
+
/**
|
|
155
|
+
* Refs are used as keys for hit detection.
|
|
156
|
+
* @type {Map<number, Feature|RenderFeature>}
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
private refToFeature_;
|
|
160
|
+
/**
|
|
161
|
+
* Features are split in "entries", which are individual geometries. We use the following map to share a single ref for all those entries.
|
|
162
|
+
* @type {Map<string, number>}
|
|
163
|
+
* @private
|
|
164
|
+
*/
|
|
165
|
+
private uidToRef_;
|
|
166
|
+
/**
|
|
167
|
+
* The precision in WebGL shaders is limited.
|
|
168
|
+
* To keep the refs as small as possible we maintain an array of returned references.
|
|
169
|
+
* @type {Array<number>}
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
private freeGlobalRef_;
|
|
148
173
|
/**
|
|
149
174
|
* @type {PolygonGeometryBatch}
|
|
150
175
|
*/
|
|
@@ -169,21 +194,24 @@ declare class MixedGeometryBatch {
|
|
|
169
194
|
addFeature(feature: Feature | RenderFeature, projectionTransform?: import("../../proj.js").TransformFunction | undefined): void;
|
|
170
195
|
/**
|
|
171
196
|
* @param {Feature|RenderFeature} feature Feature
|
|
197
|
+
* @return {GeometryBatchItem|void} the cleared entry
|
|
172
198
|
* @private
|
|
173
199
|
*/
|
|
174
200
|
private clearFeatureEntryInPointBatch_;
|
|
175
201
|
/**
|
|
176
202
|
* @param {Feature|RenderFeature} feature Feature
|
|
203
|
+
* @return {GeometryBatchItem|void} the cleared entry
|
|
177
204
|
* @private
|
|
178
205
|
*/
|
|
179
206
|
private clearFeatureEntryInLineStringBatch_;
|
|
180
207
|
/**
|
|
181
208
|
* @param {Feature|RenderFeature} feature Feature
|
|
209
|
+
* @return {GeometryBatchItem|void} the cleared entry
|
|
182
210
|
* @private
|
|
183
211
|
*/
|
|
184
212
|
private clearFeatureEntryInPolygonBatch_;
|
|
185
213
|
/**
|
|
186
|
-
* @param {import("../../geom").Geometry|RenderFeature} geometry Geometry
|
|
214
|
+
* @param {import("../../geom.js").Geometry|RenderFeature} geometry Geometry
|
|
187
215
|
* @param {Feature|RenderFeature} feature Feature
|
|
188
216
|
* @private
|
|
189
217
|
*/
|
|
@@ -198,6 +226,20 @@ declare class MixedGeometryBatch {
|
|
|
198
226
|
* @private
|
|
199
227
|
*/
|
|
200
228
|
private addCoordinates_;
|
|
229
|
+
/**
|
|
230
|
+
* @param {string} featureUid Feature uid
|
|
231
|
+
* @param {GeometryBatchItem} entry The entry to add
|
|
232
|
+
* @return {GeometryBatchItem} the added entry
|
|
233
|
+
* @private
|
|
234
|
+
*/
|
|
235
|
+
private addRefToEntry_;
|
|
236
|
+
/**
|
|
237
|
+
* Return a ref to the pool of available refs.
|
|
238
|
+
* @param {number} ref the ref to return
|
|
239
|
+
* @param {string} featureUid the feature uid
|
|
240
|
+
* @private
|
|
241
|
+
*/
|
|
242
|
+
private returnRef_;
|
|
201
243
|
/**
|
|
202
244
|
* @param {Feature|RenderFeature} feature Feature
|
|
203
245
|
*/
|
|
@@ -207,6 +249,12 @@ declare class MixedGeometryBatch {
|
|
|
207
249
|
*/
|
|
208
250
|
removeFeature(feature: Feature | RenderFeature): void;
|
|
209
251
|
clear(): void;
|
|
252
|
+
/**
|
|
253
|
+
* Resolve the feature associated to a ref.
|
|
254
|
+
* @param {number} ref Hit detected ref
|
|
255
|
+
* @return {Feature|RenderFeature} feature
|
|
256
|
+
*/
|
|
257
|
+
getFeatureFromRef(ref: number): Feature | RenderFeature;
|
|
210
258
|
}
|
|
211
259
|
import RenderFeature from '../../render/Feature.js';
|
|
212
260
|
//# sourceMappingURL=MixedGeometryBatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixedGeometryBatch.d.ts","sourceRoot":"","sources":["MixedGeometryBatch.js"],"names":[],"mappings":";sBAQa,OAAO,
|
|
1
|
+
{"version":3,"file":"MixedGeometryBatch.d.ts","sourceRoot":"","sources":["MixedGeometryBatch.js"],"names":[],"mappings":";sBAQa,OAAO,kBAAkB,EAAE,OAAO;2BAGlC,OAAO,wBAAwB,EAAE,IAAI;;;;;;;;aAKpC,OAAO,GAAC,aAAa;;;;iBACrB,MAAM,MAAM,MAAM,CAAC,CAAC;;;;;;;;;;;;;;;;;;4BAQrB,kBAAkB,GAAC,uBAAuB,GAAC,oBAAoB;;;;;;;;;;YAKvD,MAAM,GAAE,iBAAiB;;;;;qBAEhC,MAAM;;;;mBACN,MAAM;;;;gBACN,MAAM;;;;;;;;;;;YAKC,MAAM,GAAE,iBAAiB;;;;;qBAEhC,MAAM;;;;mBACN,MAAM;;;;;;;;;;;YAKC,MAAM,GAAE,iBAAiB;;;;;qBAEhC,MAAM;;AA1CpB;;GAEG;AACH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAEI,uBAAuB;IACvB;;;;OAIG;IACH,sBAA8B;IAE9B;;;;OAIG;IACH,kBAA0B;IAE1B;;;;;OAKG;IACH,uBAAwB;IAExB;;OAEG;IACH,cAFU,oBAAoB,CAO7B;IAED;;OAEG;IACH,YAFU,kBAAkB,CAK3B;IAED;;OAEG;IACH,iBAFU,uBAAuB,CAMhC;IAGH;;;OAGG;IACH,sBAHW,MAAM,OAAO,GAAC,aAAa,CAAC,qFAOtC;IAED;;;OAGG;IACH,oBAHW,OAAO,GAAC,aAAa,qFAa/B;IAED;;;;OAIG;IACH,uCAQC;IAED;;;;OAIG;IACH,4CASC;IAED;;;;OAIG;IACH,yCAUC;IAED;;;;OAIG;IACH,qBAuGC;IAED;;;;;;;;OAQG;IACH,wBAoJC;IAED;;;;;OAKG;IACH,uBAYC;IAED;;;;;OAKG;IACH,mBAOC;IAED;;OAEG;IACH,uBAFW,OAAO,GAAC,aAAa,QAS/B;IAED;;OAEG;IACH,uBAFW,OAAO,GAAC,aAAa,QAU/B;IAED,cAcC;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,GAAC,aAAa,CAIhC;CACF;0BApiByB,yBAAyB"}
|
|
@@ -6,7 +6,7 @@ import {getUid} from '../../util.js';
|
|
|
6
6
|
import {inflateEnds} from '../../geom/flat/orient.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @typedef {import("../../Feature").default} Feature
|
|
9
|
+
* @typedef {import("../../Feature.js").default} Feature
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {import("../../geom/Geometry.js").Type} GeometryType
|
|
@@ -19,6 +19,7 @@ import {inflateEnds} from '../../geom/flat/orient.js';
|
|
|
19
19
|
* @property {number} [verticesCount] Only defined for linestring and polygon batches
|
|
20
20
|
* @property {number} [ringsCount] Only defined for polygon batches
|
|
21
21
|
* @property {Array<Array<number>>} [ringsVerticesCounts] Array of vertices counts in each ring for each geometry; only defined for polygons batches
|
|
22
|
+
* @property {number} [ref] The reference in the global batch (used for hit detection)
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -70,6 +71,29 @@ import {inflateEnds} from '../../geom/flat/orient.js';
|
|
|
70
71
|
*/
|
|
71
72
|
class MixedGeometryBatch {
|
|
72
73
|
constructor() {
|
|
74
|
+
this.globalCounter_ = 0;
|
|
75
|
+
/**
|
|
76
|
+
* Refs are used as keys for hit detection.
|
|
77
|
+
* @type {Map<number, Feature|RenderFeature>}
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
this.refToFeature_ = new Map();
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Features are split in "entries", which are individual geometries. We use the following map to share a single ref for all those entries.
|
|
84
|
+
* @type {Map<string, number>}
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
this.uidToRef_ = new Map();
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The precision in WebGL shaders is limited.
|
|
91
|
+
* To keep the refs as small as possible we maintain an array of returned references.
|
|
92
|
+
* @type {Array<number>}
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
this.freeGlobalRef_ = [];
|
|
96
|
+
|
|
73
97
|
/**
|
|
74
98
|
* @type {PolygonGeometryBatch}
|
|
75
99
|
*/
|
|
@@ -126,6 +150,7 @@ class MixedGeometryBatch {
|
|
|
126
150
|
|
|
127
151
|
/**
|
|
128
152
|
* @param {Feature|RenderFeature} feature Feature
|
|
153
|
+
* @return {GeometryBatchItem|void} the cleared entry
|
|
129
154
|
* @private
|
|
130
155
|
*/
|
|
131
156
|
clearFeatureEntryInPointBatch_(feature) {
|
|
@@ -135,10 +160,12 @@ class MixedGeometryBatch {
|
|
|
135
160
|
}
|
|
136
161
|
this.pointBatch.geometriesCount -= entry.flatCoordss.length;
|
|
137
162
|
delete this.pointBatch.entries[getUid(feature)];
|
|
163
|
+
return entry;
|
|
138
164
|
}
|
|
139
165
|
|
|
140
166
|
/**
|
|
141
167
|
* @param {Feature|RenderFeature} feature Feature
|
|
168
|
+
* @return {GeometryBatchItem|void} the cleared entry
|
|
142
169
|
* @private
|
|
143
170
|
*/
|
|
144
171
|
clearFeatureEntryInLineStringBatch_(feature) {
|
|
@@ -149,10 +176,12 @@ class MixedGeometryBatch {
|
|
|
149
176
|
this.lineStringBatch.verticesCount -= entry.verticesCount;
|
|
150
177
|
this.lineStringBatch.geometriesCount -= entry.flatCoordss.length;
|
|
151
178
|
delete this.lineStringBatch.entries[getUid(feature)];
|
|
179
|
+
return entry;
|
|
152
180
|
}
|
|
153
181
|
|
|
154
182
|
/**
|
|
155
183
|
* @param {Feature|RenderFeature} feature Feature
|
|
184
|
+
* @return {GeometryBatchItem|void} the cleared entry
|
|
156
185
|
* @private
|
|
157
186
|
*/
|
|
158
187
|
clearFeatureEntryInPolygonBatch_(feature) {
|
|
@@ -164,28 +193,30 @@ class MixedGeometryBatch {
|
|
|
164
193
|
this.polygonBatch.ringsCount -= entry.ringsCount;
|
|
165
194
|
this.polygonBatch.geometriesCount -= entry.flatCoordss.length;
|
|
166
195
|
delete this.polygonBatch.entries[getUid(feature)];
|
|
196
|
+
return entry;
|
|
167
197
|
}
|
|
168
198
|
|
|
169
199
|
/**
|
|
170
|
-
* @param {import("../../geom").Geometry|RenderFeature} geometry Geometry
|
|
200
|
+
* @param {import("../../geom.js").Geometry|RenderFeature} geometry Geometry
|
|
171
201
|
* @param {Feature|RenderFeature} feature Feature
|
|
172
202
|
* @private
|
|
173
203
|
*/
|
|
174
204
|
addGeometry_(geometry, feature) {
|
|
175
205
|
const type = geometry.getType();
|
|
176
206
|
switch (type) {
|
|
177
|
-
case 'GeometryCollection':
|
|
207
|
+
case 'GeometryCollection': {
|
|
178
208
|
const geometries =
|
|
179
|
-
/** @type {import("../../geom").GeometryCollection} */ (
|
|
209
|
+
/** @type {import("../../geom.js").GeometryCollection} */ (
|
|
180
210
|
geometry
|
|
181
211
|
).getGeometriesArray();
|
|
182
212
|
for (const geometry of geometries) {
|
|
183
213
|
this.addGeometry_(geometry, feature);
|
|
184
214
|
}
|
|
185
215
|
break;
|
|
186
|
-
|
|
216
|
+
}
|
|
217
|
+
case 'MultiPolygon': {
|
|
187
218
|
const multiPolygonGeom =
|
|
188
|
-
/** @type {import("../../geom").MultiPolygon} */ (geometry);
|
|
219
|
+
/** @type {import("../../geom.js").MultiPolygon} */ (geometry);
|
|
189
220
|
this.addCoordinates_(
|
|
190
221
|
type,
|
|
191
222
|
multiPolygonGeom.getFlatCoordinates(),
|
|
@@ -195,9 +226,10 @@ class MixedGeometryBatch {
|
|
|
195
226
|
multiPolygonGeom.getStride()
|
|
196
227
|
);
|
|
197
228
|
break;
|
|
198
|
-
|
|
229
|
+
}
|
|
230
|
+
case 'MultiLineString': {
|
|
199
231
|
const multiLineGeom =
|
|
200
|
-
/** @type {import("../../geom").MultiLineString|RenderFeature} */ (
|
|
232
|
+
/** @type {import("../../geom.js").MultiLineString|RenderFeature} */ (
|
|
201
233
|
geometry
|
|
202
234
|
);
|
|
203
235
|
this.addCoordinates_(
|
|
@@ -209,9 +241,10 @@ class MixedGeometryBatch {
|
|
|
209
241
|
multiLineGeom.getStride()
|
|
210
242
|
);
|
|
211
243
|
break;
|
|
212
|
-
|
|
244
|
+
}
|
|
245
|
+
case 'MultiPoint': {
|
|
213
246
|
const multiPointGeom =
|
|
214
|
-
/** @type {import("../../geom").MultiPoint|RenderFeature} */ (
|
|
247
|
+
/** @type {import("../../geom.js").MultiPoint|RenderFeature} */ (
|
|
215
248
|
geometry
|
|
216
249
|
);
|
|
217
250
|
this.addCoordinates_(
|
|
@@ -223,9 +256,12 @@ class MixedGeometryBatch {
|
|
|
223
256
|
multiPointGeom.getStride()
|
|
224
257
|
);
|
|
225
258
|
break;
|
|
226
|
-
|
|
259
|
+
}
|
|
260
|
+
case 'Polygon': {
|
|
227
261
|
const polygonGeom =
|
|
228
|
-
/** @type {import("../../geom").Polygon|RenderFeature} */ (
|
|
262
|
+
/** @type {import("../../geom.js").Polygon|RenderFeature} */ (
|
|
263
|
+
geometry
|
|
264
|
+
);
|
|
229
265
|
this.addCoordinates_(
|
|
230
266
|
type,
|
|
231
267
|
polygonGeom.getFlatCoordinates(),
|
|
@@ -235,8 +271,11 @@ class MixedGeometryBatch {
|
|
|
235
271
|
polygonGeom.getStride()
|
|
236
272
|
);
|
|
237
273
|
break;
|
|
238
|
-
|
|
239
|
-
|
|
274
|
+
}
|
|
275
|
+
case 'Point': {
|
|
276
|
+
const pointGeom = /** @type {import("../../geom.js").Point} */ (
|
|
277
|
+
geometry
|
|
278
|
+
);
|
|
240
279
|
this.addCoordinates_(
|
|
241
280
|
type,
|
|
242
281
|
pointGeom.getFlatCoordinates(),
|
|
@@ -246,9 +285,10 @@ class MixedGeometryBatch {
|
|
|
246
285
|
pointGeom.getStride()
|
|
247
286
|
);
|
|
248
287
|
break;
|
|
288
|
+
}
|
|
249
289
|
case 'LineString':
|
|
250
|
-
case 'LinearRing':
|
|
251
|
-
const lineGeom = /** @type {import("../../geom").LineString} */ (
|
|
290
|
+
case 'LinearRing': {
|
|
291
|
+
const lineGeom = /** @type {import("../../geom.js").LineString} */ (
|
|
252
292
|
geometry
|
|
253
293
|
);
|
|
254
294
|
this.addCoordinates_(
|
|
@@ -260,6 +300,7 @@ class MixedGeometryBatch {
|
|
|
260
300
|
lineGeom.getStride()
|
|
261
301
|
);
|
|
262
302
|
break;
|
|
303
|
+
}
|
|
263
304
|
default:
|
|
264
305
|
// pass
|
|
265
306
|
}
|
|
@@ -278,7 +319,7 @@ class MixedGeometryBatch {
|
|
|
278
319
|
/** @type {number} */
|
|
279
320
|
let verticesCount;
|
|
280
321
|
switch (type) {
|
|
281
|
-
case 'MultiPolygon':
|
|
322
|
+
case 'MultiPolygon': {
|
|
282
323
|
const multiPolygonEndss = /** @type {Array<Array<number>>} */ (ends);
|
|
283
324
|
for (let i = 0, ii = multiPolygonEndss.length; i < ii; i++) {
|
|
284
325
|
let polygonEnds = multiPolygonEndss[i];
|
|
@@ -301,12 +342,13 @@ class MixedGeometryBatch {
|
|
|
301
342
|
);
|
|
302
343
|
}
|
|
303
344
|
break;
|
|
304
|
-
|
|
345
|
+
}
|
|
346
|
+
case 'MultiLineString': {
|
|
305
347
|
const multiLineEnds = /** @type {Array<number>} */ (ends);
|
|
306
348
|
for (let i = 0, ii = multiLineEnds.length; i < ii; i++) {
|
|
307
349
|
const startIndex = i > 0 ? multiLineEnds[i - 1] : 0;
|
|
308
350
|
this.addCoordinates_(
|
|
309
|
-
'
|
|
351
|
+
'LineString',
|
|
310
352
|
flatCoords.slice(startIndex, multiLineEnds[i]),
|
|
311
353
|
null,
|
|
312
354
|
feature,
|
|
@@ -315,6 +357,7 @@ class MixedGeometryBatch {
|
|
|
315
357
|
);
|
|
316
358
|
}
|
|
317
359
|
break;
|
|
360
|
+
}
|
|
318
361
|
case 'MultiPoint':
|
|
319
362
|
for (let i = 0, ii = flatCoords.length; i < ii; i += stride) {
|
|
320
363
|
this.addCoordinates_(
|
|
@@ -327,7 +370,7 @@ class MixedGeometryBatch {
|
|
|
327
370
|
);
|
|
328
371
|
}
|
|
329
372
|
break;
|
|
330
|
-
case 'Polygon':
|
|
373
|
+
case 'Polygon': {
|
|
331
374
|
const polygonEnds = /** @type {Array<number>} */ (ends);
|
|
332
375
|
if (feature instanceof RenderFeature) {
|
|
333
376
|
const multiPolygonEnds = inflateEnds(flatCoords, polygonEnds);
|
|
@@ -344,13 +387,16 @@ class MixedGeometryBatch {
|
|
|
344
387
|
}
|
|
345
388
|
}
|
|
346
389
|
if (!this.polygonBatch.entries[featureUid]) {
|
|
347
|
-
this.polygonBatch.entries[featureUid] =
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
390
|
+
this.polygonBatch.entries[featureUid] = this.addRefToEntry_(
|
|
391
|
+
featureUid,
|
|
392
|
+
{
|
|
393
|
+
feature: feature,
|
|
394
|
+
flatCoordss: [],
|
|
395
|
+
verticesCount: 0,
|
|
396
|
+
ringsCount: 0,
|
|
397
|
+
ringsVerticesCounts: [],
|
|
398
|
+
}
|
|
399
|
+
);
|
|
354
400
|
}
|
|
355
401
|
verticesCount = flatCoords.length / stride;
|
|
356
402
|
const ringsCount = ends.length;
|
|
@@ -380,12 +426,16 @@ class MixedGeometryBatch {
|
|
|
380
426
|
);
|
|
381
427
|
}
|
|
382
428
|
break;
|
|
429
|
+
}
|
|
383
430
|
case 'Point':
|
|
384
431
|
if (!this.pointBatch.entries[featureUid]) {
|
|
385
|
-
this.pointBatch.entries[featureUid] =
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
432
|
+
this.pointBatch.entries[featureUid] = this.addRefToEntry_(
|
|
433
|
+
featureUid,
|
|
434
|
+
{
|
|
435
|
+
feature: feature,
|
|
436
|
+
flatCoordss: [],
|
|
437
|
+
}
|
|
438
|
+
);
|
|
389
439
|
}
|
|
390
440
|
this.pointBatch.geometriesCount++;
|
|
391
441
|
this.pointBatch.entries[featureUid].flatCoordss.push(flatCoords);
|
|
@@ -393,11 +443,14 @@ class MixedGeometryBatch {
|
|
|
393
443
|
case 'LineString':
|
|
394
444
|
case 'LinearRing':
|
|
395
445
|
if (!this.lineStringBatch.entries[featureUid]) {
|
|
396
|
-
this.lineStringBatch.entries[featureUid] =
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
446
|
+
this.lineStringBatch.entries[featureUid] = this.addRefToEntry_(
|
|
447
|
+
featureUid,
|
|
448
|
+
{
|
|
449
|
+
feature: feature,
|
|
450
|
+
flatCoordss: [],
|
|
451
|
+
verticesCount: 0,
|
|
452
|
+
}
|
|
453
|
+
);
|
|
401
454
|
}
|
|
402
455
|
verticesCount = flatCoords.length / stride;
|
|
403
456
|
this.lineStringBatch.verticesCount += verticesCount;
|
|
@@ -412,13 +465,46 @@ class MixedGeometryBatch {
|
|
|
412
465
|
}
|
|
413
466
|
}
|
|
414
467
|
|
|
468
|
+
/**
|
|
469
|
+
* @param {string} featureUid Feature uid
|
|
470
|
+
* @param {GeometryBatchItem} entry The entry to add
|
|
471
|
+
* @return {GeometryBatchItem} the added entry
|
|
472
|
+
* @private
|
|
473
|
+
*/
|
|
474
|
+
addRefToEntry_(featureUid, entry) {
|
|
475
|
+
const currentRef = this.uidToRef_.get(featureUid);
|
|
476
|
+
|
|
477
|
+
// the ref starts at 1 to distinguish from white color (no feature)
|
|
478
|
+
const ref =
|
|
479
|
+
currentRef || this.freeGlobalRef_.pop() || ++this.globalCounter_;
|
|
480
|
+
entry.ref = ref;
|
|
481
|
+
if (!currentRef) {
|
|
482
|
+
this.refToFeature_.set(ref, entry.feature);
|
|
483
|
+
this.uidToRef_.set(featureUid, ref);
|
|
484
|
+
}
|
|
485
|
+
return entry;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Return a ref to the pool of available refs.
|
|
490
|
+
* @param {number} ref the ref to return
|
|
491
|
+
* @param {string} featureUid the feature uid
|
|
492
|
+
* @private
|
|
493
|
+
*/
|
|
494
|
+
returnRef_(ref, featureUid) {
|
|
495
|
+
if (!ref) {
|
|
496
|
+
throw new Error('This feature has no ref: ' + featureUid);
|
|
497
|
+
}
|
|
498
|
+
this.refToFeature_.delete(ref);
|
|
499
|
+
this.uidToRef_.delete(featureUid);
|
|
500
|
+
this.freeGlobalRef_.push(ref);
|
|
501
|
+
}
|
|
502
|
+
|
|
415
503
|
/**
|
|
416
504
|
* @param {Feature|RenderFeature} feature Feature
|
|
417
505
|
*/
|
|
418
506
|
changeFeature(feature) {
|
|
419
|
-
this.
|
|
420
|
-
this.clearFeatureEntryInPolygonBatch_(feature);
|
|
421
|
-
this.clearFeatureEntryInLineStringBatch_(feature);
|
|
507
|
+
this.removeFeature(feature);
|
|
422
508
|
const geometry = feature.getGeometry();
|
|
423
509
|
if (!geometry) {
|
|
424
510
|
return;
|
|
@@ -430,9 +516,13 @@ class MixedGeometryBatch {
|
|
|
430
516
|
* @param {Feature|RenderFeature} feature Feature
|
|
431
517
|
*/
|
|
432
518
|
removeFeature(feature) {
|
|
433
|
-
|
|
434
|
-
this.
|
|
435
|
-
this.
|
|
519
|
+
let entry;
|
|
520
|
+
entry = this.clearFeatureEntryInPointBatch_(feature) || entry;
|
|
521
|
+
entry = this.clearFeatureEntryInPolygonBatch_(feature) || entry;
|
|
522
|
+
entry = this.clearFeatureEntryInLineStringBatch_(feature) || entry;
|
|
523
|
+
if (entry) {
|
|
524
|
+
this.returnRef_(entry.ref, getUid(entry.feature));
|
|
525
|
+
}
|
|
436
526
|
}
|
|
437
527
|
|
|
438
528
|
clear() {
|
|
@@ -445,6 +535,19 @@ class MixedGeometryBatch {
|
|
|
445
535
|
this.lineStringBatch.verticesCount = 0;
|
|
446
536
|
this.pointBatch.entries = {};
|
|
447
537
|
this.pointBatch.geometriesCount = 0;
|
|
538
|
+
this.globalCounter_ = 0;
|
|
539
|
+
this.freeGlobalRef_ = [];
|
|
540
|
+
this.refToFeature_.clear();
|
|
541
|
+
this.uidToRef_.clear();
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Resolve the feature associated to a ref.
|
|
546
|
+
* @param {number} ref Hit detected ref
|
|
547
|
+
* @return {Feature|RenderFeature} feature
|
|
548
|
+
*/
|
|
549
|
+
getFeatureFromRef(ref) {
|
|
550
|
+
return this.refToFeature_.get(ref);
|
|
448
551
|
}
|
|
449
552
|
}
|
|
450
553
|
|
|
@@ -27,7 +27,7 @@ export type AttributeDefinition = {
|
|
|
27
27
|
* This callback computes the numerical value of the
|
|
28
28
|
* attribute for a given feature.
|
|
29
29
|
*/
|
|
30
|
-
callback: (
|
|
30
|
+
callback: (this: import("./MixedGeometryBatch.js").GeometryBatchItem, arg1: import("../../Feature").FeatureLike) => number | Array<number>;
|
|
31
31
|
};
|
|
32
32
|
export type AttributeDefinitions = {
|
|
33
33
|
[x: string]: AttributeDefinition;
|
|
@@ -113,7 +113,7 @@ export type VectorStyle = import('../../style/literal.js').LiteralStyle | StyleS
|
|
|
113
113
|
* for each feature.
|
|
114
114
|
* @property {number} [size] Amount of numerical values composing the attribute, either 1, 2, 3 or 4; in case size is > 1, the return value
|
|
115
115
|
* of the callback should be an array; if unspecified, assumed to be a single float value
|
|
116
|
-
* @property {function(import("../../Feature").FeatureLike):number|Array<number>} callback This callback computes the numerical value of the
|
|
116
|
+
* @property {function(this:import("./MixedGeometryBatch.js").GeometryBatchItem, import("../../Feature").FeatureLike):number|Array<number>} callback This callback computes the numerical value of the
|
|
117
117
|
* attribute for a given feature.
|
|
118
118
|
*/
|
|
119
119
|
/**
|
|
@@ -167,9 +167,11 @@ declare class VectorStyleRenderer {
|
|
|
167
167
|
/**
|
|
168
168
|
* @param {VectorStyle} styleOrShaders Literal style or custom shaders
|
|
169
169
|
* @param {import('../../webgl/Helper.js').default} helper Helper
|
|
170
|
+
* @param {boolean} enableHitDetection Whether to enable the hit detection (needs compatible shader)
|
|
170
171
|
*/
|
|
171
|
-
constructor(styleOrShaders: VectorStyle, helper: import('../../webgl/Helper.js').default);
|
|
172
|
+
constructor(styleOrShaders: VectorStyle, helper: import('../../webgl/Helper.js').default, enableHitDetection: boolean);
|
|
172
173
|
helper_: import("../../webgl/Helper.js").default;
|
|
174
|
+
hitDetectionEnabled_: boolean;
|
|
173
175
|
/**
|
|
174
176
|
* @type {boolean}
|
|
175
177
|
* @private
|
|
@@ -194,9 +196,18 @@ declare class VectorStyleRenderer {
|
|
|
194
196
|
symbolVertexShader_: string | undefined;
|
|
195
197
|
symbolFragmentShader_: string | undefined;
|
|
196
198
|
symbolProgram_: WebGLProgram | undefined;
|
|
197
|
-
customAttributes_: {
|
|
199
|
+
customAttributes_: ({
|
|
200
|
+
hitColor: {
|
|
201
|
+
callback(): number[];
|
|
202
|
+
size: number;
|
|
203
|
+
};
|
|
204
|
+
} & {
|
|
198
205
|
[x: string]: AttributeDefinition;
|
|
199
|
-
} |
|
|
206
|
+
}) | ({
|
|
207
|
+
hitColor?: undefined;
|
|
208
|
+
} & {
|
|
209
|
+
[x: string]: AttributeDefinition;
|
|
210
|
+
});
|
|
200
211
|
uniforms_: {
|
|
201
212
|
[x: string]: import("../../webgl/Helper.js").UniformValue;
|
|
202
213
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VectorStyleRenderer.d.ts","sourceRoot":"","sources":["VectorStyleRenderer.js"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"VectorStyleRenderer.d.ts","sourceRoot":"","sources":["VectorStyleRenderer.js"],"names":[],"mappings":";;;;yBA4BU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;qBAiBY,OAAO,yBAAyB,EAAE,iBAAiB,QAAE,OAAO,eAAe,EAAE,WAAW,KAAE,MAAM,GAAC,MAAM,MAAM,CAAC;;;QAKtH,MAAM,GAAE,mBAAmB;;;QAC3B,MAAM,GAAE,OAAO,oBAAoB,EAAE,YAAY;;;;;;oBAKvD,MAAM,gBAAgB,CAAC;;;;uBACvB,MAAM,gBAAgB,CAAC;;;;kBACvB,MAAM,gBAAgB,CAAC;;;;6BACvB,OAAO,oBAAoB,EAAE,SAAS;;;;;;yBAKtC,YAAY,GAAC,IAAI;;;;4BACjB,YAAY,GAAC,IAAI;;;;uBACjB,YAAY,GAAC,IAAI;;;;;;;;;YAKjB,MAAM;;;;cACN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAcP,OAAO,wBAAwB,EAAE,YAAY,GAAC,YAAY;AA9CvE;;;;;;;GAOG;AAEH;;;GAGG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH;IACE;;;;OAIG;IACH,4BAJW,WAAW,UACX,OAAO,uBAAuB,EAAE,OAAO,sBACvC,OAAO,EAyKjB;IAtKC,iDAAqB;IAErB,8BAA8C;IAgC9C;;;OAGG;IACH,iBAAsC;IAEpC,sCAA4C;IAC5C,wCAAgD;IAChD,uCAGC;IAGH;;;OAGG;IACH,mBAA0C;IAExC,wCAAkE;IAClE,0CAAsE;IACtE,yCAGC;IAGH;;;OAGG;IACH,mBAA0C;IAExC,wCAAkE;IAClE,0CAAsE;IACtE,yCAGC;IAcH;;;;;;;;;;;OAIC;IACD;;kBAAiC;IASjC;;;OAGG;IACH,+BAOC;IACD;;;OAGG;IACH,kCA2BC;IACD;;;OAGG;IACH,6BAYC;IAOH;;;;OAIG;IACH,+BAJW,OAAO,yBAAyB,EAAE,OAAO,aACzC,OAAO,oBAAoB,EAAE,SAAS,GACrC,QAAQ,YAAY,CAAC,CAqChC;IAED;;;;;OAKG;IACH,oCA+BC;IAED;;;;;;OAMG;IACH,gCAuEC;IAED;;;;;OAKG;IACH,gBAJW,YAAY,cACZ,OAAO,cAAc,EAAE,UAAU,2BACrB,IAAI,QA8B1B;IAED;;;;;;;;OAQG;IACH,wBAkBC;CACF;6BAnf4B,uBAAuB"}
|
|
@@ -5,6 +5,7 @@ import WebGLArrayBuffer from '../../webgl/Buffer.js';
|
|
|
5
5
|
import {ARRAY_BUFFER, DYNAMIC_DRAW, ELEMENT_ARRAY_BUFFER} from '../../webgl.js';
|
|
6
6
|
import {AttributeType} from '../../webgl/Helper.js';
|
|
7
7
|
import {WebGLWorkerMessageType} from './constants.js';
|
|
8
|
+
import {colorEncodeId} from './utils.js';
|
|
8
9
|
import {
|
|
9
10
|
create as createTransform,
|
|
10
11
|
makeInverse as makeInverseTransform,
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
} from './renderinstructions.js';
|
|
19
20
|
import {parseLiteralStyle} from '../../webgl/styleparser.js';
|
|
20
21
|
|
|
22
|
+
const tmpColor = [];
|
|
21
23
|
const WEBGL_WORKER = createWebGLWorker();
|
|
22
24
|
let workerMessageCounter = 0;
|
|
23
25
|
|
|
@@ -41,7 +43,7 @@ export const Attributes = {
|
|
|
41
43
|
* for each feature.
|
|
42
44
|
* @property {number} [size] Amount of numerical values composing the attribute, either 1, 2, 3 or 4; in case size is > 1, the return value
|
|
43
45
|
* of the callback should be an array; if unspecified, assumed to be a single float value
|
|
44
|
-
* @property {function(import("../../Feature").FeatureLike):number|Array<number>} callback This callback computes the numerical value of the
|
|
46
|
+
* @property {function(this:import("./MixedGeometryBatch.js").GeometryBatchItem, import("../../Feature").FeatureLike):number|Array<number>} callback This callback computes the numerical value of the
|
|
45
47
|
* attribute for a given feature.
|
|
46
48
|
*/
|
|
47
49
|
|
|
@@ -102,10 +104,12 @@ class VectorStyleRenderer {
|
|
|
102
104
|
/**
|
|
103
105
|
* @param {VectorStyle} styleOrShaders Literal style or custom shaders
|
|
104
106
|
* @param {import('../../webgl/Helper.js').default} helper Helper
|
|
107
|
+
* @param {boolean} enableHitDetection Whether to enable the hit detection (needs compatible shader)
|
|
105
108
|
*/
|
|
106
|
-
constructor(styleOrShaders, helper) {
|
|
109
|
+
constructor(styleOrShaders, helper, enableHitDetection) {
|
|
107
110
|
this.helper_ = helper;
|
|
108
111
|
|
|
112
|
+
this.hitDetectionEnabled_ = enableHitDetection;
|
|
109
113
|
let shaders = /** @type {StyleShaders} */ (styleOrShaders);
|
|
110
114
|
|
|
111
115
|
// TODO: improve discrimination between shaders and style
|
|
@@ -179,13 +183,28 @@ class VectorStyleRenderer {
|
|
|
179
183
|
);
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
|
|
186
|
+
const hitDetectionAttributes = this.hitDetectionEnabled_
|
|
187
|
+
? {
|
|
188
|
+
hitColor: {
|
|
189
|
+
callback() {
|
|
190
|
+
return colorEncodeId(this.ref, tmpColor);
|
|
191
|
+
},
|
|
192
|
+
size: 4,
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
: {};
|
|
196
|
+
|
|
197
|
+
this.customAttributes_ = Object.assign(
|
|
198
|
+
{},
|
|
199
|
+
hitDetectionAttributes,
|
|
200
|
+
shaders.attributes
|
|
201
|
+
);
|
|
183
202
|
this.uniforms_ = shaders.uniforms;
|
|
184
203
|
|
|
185
|
-
const customAttributesDesc = Object.
|
|
186
|
-
(name) => ({
|
|
204
|
+
const customAttributesDesc = Object.entries(this.customAttributes_).map(
|
|
205
|
+
([name, value]) => ({
|
|
187
206
|
name: `a_${name}`,
|
|
188
|
-
size:
|
|
207
|
+
size: value.size || 1,
|
|
189
208
|
type: AttributeType.FLOAT,
|
|
190
209
|
})
|
|
191
210
|
);
|
|
@@ -470,12 +489,15 @@ class VectorStyleRenderer {
|
|
|
470
489
|
frameState,
|
|
471
490
|
preRenderCallback
|
|
472
491
|
) {
|
|
492
|
+
const renderCount = indicesBuffer.getSize();
|
|
493
|
+
if (renderCount === 0) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
473
496
|
this.helper_.useProgram(program, frameState);
|
|
474
497
|
this.helper_.bindBuffer(verticesBuffer);
|
|
475
498
|
this.helper_.bindBuffer(indicesBuffer);
|
|
476
499
|
this.helper_.enableAttributes(attributes);
|
|
477
500
|
preRenderCallback();
|
|
478
|
-
const renderCount = indicesBuffer.getSize();
|
|
479
501
|
this.helper_.drawElements(0, renderCount);
|
|
480
502
|
}
|
|
481
503
|
}
|
|
@@ -20,11 +20,11 @@ export type WebGLWorkerGenerateBuffersMessage = {
|
|
|
20
20
|
*/
|
|
21
21
|
type: WebGLWorkerMessageType;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* render instructions raw binary buffer.
|
|
24
24
|
*/
|
|
25
25
|
renderInstructions: ArrayBuffer;
|
|
26
26
|
/**
|
|
27
|
-
* Amount of custom attributes count in the
|
|
27
|
+
* Amount of hit detection + custom attributes count in the render instructions.
|
|
28
28
|
*/
|
|
29
29
|
customAttributesSize?: number | undefined;
|
|
30
30
|
/**
|
|
@@ -19,8 +19,8 @@ export const WebGLWorkerMessageType = {
|
|
|
19
19
|
* Note that any addition properties present in the message *will* be sent back to the main thread.
|
|
20
20
|
* @property {number} id Message id; will be used both in request and response as a means of identification
|
|
21
21
|
* @property {WebGLWorkerMessageType} type Message type
|
|
22
|
-
* @property {ArrayBuffer} renderInstructions
|
|
23
|
-
* @property {number} [customAttributesSize] Amount of custom attributes count in the
|
|
22
|
+
* @property {ArrayBuffer} renderInstructions render instructions raw binary buffer.
|
|
23
|
+
* @property {number} [customAttributesSize] Amount of hit detection + custom attributes count in the render instructions.
|
|
24
24
|
* @property {ArrayBuffer} [vertexBuffer] Vertices array raw binary buffer (sent by the worker).
|
|
25
25
|
* @property {ArrayBuffer} [indexBuffer] Indices array raw binary buffer (sent by the worker).
|
|
26
26
|
* @property {import("../../transform").Transform} [renderInstructionsTransform] Transformation matrix used to project the instructions coordinates
|