ol 7.3.1-dev.1680098251703 → 7.3.1-dev.1680103314833
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/package.json +1 -1
- package/render/webgl/BatchRenderer.d.ts +11 -8
- package/render/webgl/BatchRenderer.d.ts.map +1 -1
- package/render/webgl/BatchRenderer.js +20 -27
- package/render/webgl/MixedGeometryBatch.d.ts +36 -48
- package/render/webgl/MixedGeometryBatch.d.ts.map +1 -1
- package/render/webgl/MixedGeometryBatch.js +229 -110
- package/renderer/webgl/VectorLayer.d.ts +17 -0
- package/renderer/webgl/VectorLayer.d.ts.map +1 -1
- package/renderer/webgl/VectorLayer.js +55 -18
- package/renderer/webgl/VectorTileLayer.d.ts +160 -0
- package/renderer/webgl/VectorTileLayer.d.ts.map +1 -0
- package/renderer/webgl/VectorTileLayer.js +335 -0
- package/renderer/webgl/shaders.d.ts.map +1 -1
- package/renderer/webgl/shaders.js +68 -3
- package/util.js +1 -1
- package/webgl/Helper.d.ts +2 -2
- package/webgl/Helper.d.ts.map +1 -1
- package/webgl/Helper.js +4 -6
- package/webgl/TileGeometry.d.ts +37 -0
- package/webgl/TileGeometry.d.ts.map +1 -0
- package/webgl/TileGeometry.js +106 -0
|
@@ -5,10 +5,21 @@ import WebGLArrayBuffer from '../../webgl/Buffer.js';
|
|
|
5
5
|
import {ARRAY_BUFFER, DYNAMIC_DRAW, ELEMENT_ARRAY_BUFFER} from '../../webgl.js';
|
|
6
6
|
import {create as createTransform} from '../../transform.js';
|
|
7
7
|
import {getUid} from '../../util.js';
|
|
8
|
+
import {linearRingIsClockwise} from '../../geom/flat/orient.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import("../../render/Feature").default} RenderFeature
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import("../../Feature").default} Feature
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {import("../../geom/Geometry.js").Type} GeometryType
|
|
18
|
+
*/
|
|
8
19
|
|
|
9
20
|
/**
|
|
10
21
|
* @typedef {Object} GeometryBatchItem Object that holds a reference to a feature as well as the raw coordinates of its various geometries
|
|
11
|
-
* @property {
|
|
22
|
+
* @property {Feature|RenderFeature} feature Feature
|
|
12
23
|
* @property {Array<Array<number>>} flatCoordss Array of flat coordinates arrays, one for each geometry related to the feature
|
|
13
24
|
* @property {number} [verticesCount] Only defined for linestring and polygon batches
|
|
14
25
|
* @property {number} [ringsCount] Only defined for polygon batches
|
|
@@ -29,7 +40,6 @@ import {getUid} from '../../util.js';
|
|
|
29
40
|
* @property {WebGLArrayBuffer} verticesBuffer Vertices WebGL buffer
|
|
30
41
|
* @property {WebGLArrayBuffer} indicesBuffer Indices WebGL buffer
|
|
31
42
|
* @property {import("../../transform.js").Transform} renderInstructionsTransform Converts world space coordinates to screen space; applies to the rendering instructions
|
|
32
|
-
* @property {import("../../transform.js").Transform} verticesBufferTransform Converts world space coordinates to screen space; applies to the webgl vertices buffer
|
|
33
43
|
* @property {import("../../transform.js").Transform} invertVerticesBufferTransform Screen space to world space; applies to the webgl vertices buffer
|
|
34
44
|
* @property {number} verticesCount Amount of vertices from geometries in the batch.
|
|
35
45
|
* @property {number} ringsCount How many outer and inner rings in this batch.
|
|
@@ -45,7 +55,6 @@ import {getUid} from '../../util.js';
|
|
|
45
55
|
* @property {WebGLArrayBuffer} verticesBuffer Vertices WebGL buffer
|
|
46
56
|
* @property {WebGLArrayBuffer} indicesBuffer Indices WebGL buffer
|
|
47
57
|
* @property {import("../../transform.js").Transform} renderInstructionsTransform Converts world space coordinates to screen space; applies to the rendering instructions
|
|
48
|
-
* @property {import("../../transform.js").Transform} verticesBufferTransform Converts world space coordinates to screen space; applies to the webgl vertices buffer
|
|
49
58
|
* @property {import("../../transform.js").Transform} invertVerticesBufferTransform Screen space to world space; applies to the webgl vertices buffer
|
|
50
59
|
* @property {number} verticesCount Amount of vertices from geometries in the batch.
|
|
51
60
|
*/
|
|
@@ -60,7 +69,6 @@ import {getUid} from '../../util.js';
|
|
|
60
69
|
* @property {WebGLArrayBuffer} verticesBuffer Vertices WebGL buffer
|
|
61
70
|
* @property {WebGLArrayBuffer} indicesBuffer Indices WebGL buffer
|
|
62
71
|
* @property {import("../../transform.js").Transform} renderInstructionsTransform Converts world space coordinates to screen space; applies to the rendering instructions
|
|
63
|
-
* @property {import("../../transform.js").Transform} verticesBufferTransform Converts world space coordinates to screen space; applies to the webgl vertices buffer
|
|
64
72
|
* @property {import("../../transform.js").Transform} invertVerticesBufferTransform Screen space to world space; applies to the webgl vertices buffer
|
|
65
73
|
*/
|
|
66
74
|
|
|
@@ -97,7 +105,6 @@ class MixedGeometryBatch {
|
|
|
97
105
|
verticesBuffer: new WebGLArrayBuffer(ARRAY_BUFFER, DYNAMIC_DRAW),
|
|
98
106
|
indicesBuffer: new WebGLArrayBuffer(ELEMENT_ARRAY_BUFFER, DYNAMIC_DRAW),
|
|
99
107
|
renderInstructionsTransform: createTransform(),
|
|
100
|
-
verticesBufferTransform: createTransform(),
|
|
101
108
|
invertVerticesBufferTransform: createTransform(),
|
|
102
109
|
};
|
|
103
110
|
|
|
@@ -111,7 +118,6 @@ class MixedGeometryBatch {
|
|
|
111
118
|
verticesBuffer: new WebGLArrayBuffer(ARRAY_BUFFER, DYNAMIC_DRAW),
|
|
112
119
|
indicesBuffer: new WebGLArrayBuffer(ELEMENT_ARRAY_BUFFER, DYNAMIC_DRAW),
|
|
113
120
|
renderInstructionsTransform: createTransform(),
|
|
114
|
-
verticesBufferTransform: createTransform(),
|
|
115
121
|
invertVerticesBufferTransform: createTransform(),
|
|
116
122
|
};
|
|
117
123
|
|
|
@@ -126,13 +132,12 @@ class MixedGeometryBatch {
|
|
|
126
132
|
verticesBuffer: new WebGLArrayBuffer(ARRAY_BUFFER, DYNAMIC_DRAW),
|
|
127
133
|
indicesBuffer: new WebGLArrayBuffer(ELEMENT_ARRAY_BUFFER, DYNAMIC_DRAW),
|
|
128
134
|
renderInstructionsTransform: createTransform(),
|
|
129
|
-
verticesBufferTransform: createTransform(),
|
|
130
135
|
invertVerticesBufferTransform: createTransform(),
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
/**
|
|
135
|
-
* @param {Array<
|
|
140
|
+
* @param {Array<Feature|RenderFeature>} features Array of features to add to the batch
|
|
136
141
|
*/
|
|
137
142
|
addFeatures(features) {
|
|
138
143
|
for (let i = 0; i < features.length; i++) {
|
|
@@ -141,7 +146,7 @@ class MixedGeometryBatch {
|
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
/**
|
|
144
|
-
* @param {
|
|
149
|
+
* @param {Feature|RenderFeature} feature Feature to add to the batch
|
|
145
150
|
*/
|
|
146
151
|
addFeature(feature) {
|
|
147
152
|
const geometry = feature.getGeometry();
|
|
@@ -152,59 +157,7 @@ class MixedGeometryBatch {
|
|
|
152
157
|
}
|
|
153
158
|
|
|
154
159
|
/**
|
|
155
|
-
* @param {
|
|
156
|
-
* @return {GeometryBatchItem} Batch item added (or existing one)
|
|
157
|
-
* @private
|
|
158
|
-
*/
|
|
159
|
-
addFeatureEntryInPointBatch_(feature) {
|
|
160
|
-
const uid = getUid(feature);
|
|
161
|
-
if (!(uid in this.pointBatch.entries)) {
|
|
162
|
-
this.pointBatch.entries[uid] = {
|
|
163
|
-
feature: feature,
|
|
164
|
-
flatCoordss: [],
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
return this.pointBatch.entries[uid];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @param {import("../../Feature").default} feature Feature
|
|
172
|
-
* @return {GeometryBatchItem} Batch item added (or existing one)
|
|
173
|
-
* @private
|
|
174
|
-
*/
|
|
175
|
-
addFeatureEntryInLineStringBatch_(feature) {
|
|
176
|
-
const uid = getUid(feature);
|
|
177
|
-
if (!(uid in this.lineStringBatch.entries)) {
|
|
178
|
-
this.lineStringBatch.entries[uid] = {
|
|
179
|
-
feature: feature,
|
|
180
|
-
flatCoordss: [],
|
|
181
|
-
verticesCount: 0,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
return this.lineStringBatch.entries[uid];
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @param {import("../../Feature").default} feature Feature
|
|
189
|
-
* @return {GeometryBatchItem} Batch item added (or existing one)
|
|
190
|
-
* @private
|
|
191
|
-
*/
|
|
192
|
-
addFeatureEntryInPolygonBatch_(feature) {
|
|
193
|
-
const uid = getUid(feature);
|
|
194
|
-
if (!(uid in this.polygonBatch.entries)) {
|
|
195
|
-
this.polygonBatch.entries[uid] = {
|
|
196
|
-
feature: feature,
|
|
197
|
-
flatCoordss: [],
|
|
198
|
-
verticesCount: 0,
|
|
199
|
-
ringsCount: 0,
|
|
200
|
-
ringsVerticesCounts: [],
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
return this.polygonBatch.entries[uid];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* @param {import("../../Feature").default} feature Feature
|
|
160
|
+
* @param {Feature|RenderFeature} feature Feature
|
|
208
161
|
* @private
|
|
209
162
|
*/
|
|
210
163
|
clearFeatureEntryInPointBatch_(feature) {
|
|
@@ -217,7 +170,7 @@ class MixedGeometryBatch {
|
|
|
217
170
|
}
|
|
218
171
|
|
|
219
172
|
/**
|
|
220
|
-
* @param {
|
|
173
|
+
* @param {Feature|RenderFeature} feature Feature
|
|
221
174
|
* @private
|
|
222
175
|
*/
|
|
223
176
|
clearFeatureEntryInLineStringBatch_(feature) {
|
|
@@ -231,7 +184,7 @@ class MixedGeometryBatch {
|
|
|
231
184
|
}
|
|
232
185
|
|
|
233
186
|
/**
|
|
234
|
-
* @param {
|
|
187
|
+
* @param {Feature|RenderFeature} feature Feature
|
|
235
188
|
* @private
|
|
236
189
|
*/
|
|
237
190
|
clearFeatureEntryInPolygonBatch_(feature) {
|
|
@@ -246,79 +199,245 @@ class MixedGeometryBatch {
|
|
|
246
199
|
}
|
|
247
200
|
|
|
248
201
|
/**
|
|
249
|
-
* @param {import("../../geom").Geometry} geometry Geometry
|
|
250
|
-
* @param {
|
|
202
|
+
* @param {import("../../geom").Geometry|RenderFeature} geometry Geometry
|
|
203
|
+
* @param {Feature|RenderFeature} feature Feature
|
|
251
204
|
* @private
|
|
252
205
|
*/
|
|
253
206
|
addGeometry_(geometry, feature) {
|
|
254
207
|
const type = geometry.getType();
|
|
255
|
-
let flatCoords;
|
|
256
|
-
let verticesCount;
|
|
257
|
-
let batchEntry;
|
|
258
208
|
switch (type) {
|
|
259
209
|
case 'GeometryCollection':
|
|
260
|
-
|
|
261
|
-
.
|
|
262
|
-
|
|
210
|
+
const geometries =
|
|
211
|
+
/** @type {import("../../geom").GeometryCollection} */ (
|
|
212
|
+
geometry
|
|
213
|
+
).getGeometriesArray();
|
|
214
|
+
for (const geometry of geometries) {
|
|
215
|
+
this.addGeometry_(geometry, feature);
|
|
216
|
+
}
|
|
263
217
|
break;
|
|
264
218
|
case 'MultiPolygon':
|
|
265
|
-
|
|
266
|
-
.
|
|
267
|
-
|
|
219
|
+
const multiPolygonGeom =
|
|
220
|
+
/** @type {import("../../geom").MultiPolygon|RenderFeature} */ (
|
|
221
|
+
geometry
|
|
222
|
+
);
|
|
223
|
+
this.addCoordinates_(
|
|
224
|
+
type,
|
|
225
|
+
multiPolygonGeom.getFlatCoordinates(),
|
|
226
|
+
multiPolygonGeom.getEndss(),
|
|
227
|
+
feature,
|
|
228
|
+
getUid(feature)
|
|
229
|
+
);
|
|
268
230
|
break;
|
|
269
231
|
case 'MultiLineString':
|
|
270
|
-
|
|
271
|
-
.
|
|
272
|
-
|
|
232
|
+
const multiLineGeom =
|
|
233
|
+
/** @type {import("../../geom").MultiLineString|RenderFeature} */ (
|
|
234
|
+
geometry
|
|
235
|
+
);
|
|
236
|
+
this.addCoordinates_(
|
|
237
|
+
type,
|
|
238
|
+
multiLineGeom.getFlatCoordinates(),
|
|
239
|
+
multiLineGeom.getEnds(),
|
|
240
|
+
feature,
|
|
241
|
+
getUid(feature)
|
|
242
|
+
);
|
|
273
243
|
break;
|
|
274
244
|
case 'MultiPoint':
|
|
275
|
-
|
|
276
|
-
.
|
|
277
|
-
|
|
245
|
+
const multiPointGeom =
|
|
246
|
+
/** @type {import("../../geom").MultiPoint|RenderFeature} */ (
|
|
247
|
+
geometry
|
|
248
|
+
);
|
|
249
|
+
this.addCoordinates_(
|
|
250
|
+
type,
|
|
251
|
+
multiPointGeom.getFlatCoordinates(),
|
|
252
|
+
null,
|
|
253
|
+
feature,
|
|
254
|
+
getUid(feature)
|
|
255
|
+
);
|
|
278
256
|
break;
|
|
279
257
|
case 'Polygon':
|
|
280
|
-
const polygonGeom =
|
|
258
|
+
const polygonGeom =
|
|
259
|
+
/** @type {import("../../geom").Polygon|RenderFeature} */ (geometry);
|
|
260
|
+
this.addCoordinates_(
|
|
261
|
+
type,
|
|
262
|
+
polygonGeom.getFlatCoordinates(),
|
|
263
|
+
polygonGeom.getEnds(),
|
|
264
|
+
feature,
|
|
265
|
+
getUid(feature)
|
|
266
|
+
);
|
|
267
|
+
break;
|
|
268
|
+
case 'Point':
|
|
269
|
+
const pointGeom = /** @type {import("../../geom").Point} */ (geometry);
|
|
270
|
+
this.addCoordinates_(
|
|
271
|
+
type,
|
|
272
|
+
pointGeom.getFlatCoordinates(),
|
|
273
|
+
null,
|
|
274
|
+
feature,
|
|
275
|
+
getUid(feature)
|
|
276
|
+
);
|
|
277
|
+
break;
|
|
278
|
+
case 'LineString':
|
|
279
|
+
case 'LinearRing':
|
|
280
|
+
const lineGeom = /** @type {import("../../geom").LineString} */ (
|
|
281
281
|
geometry
|
|
282
282
|
);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
283
|
+
this.addCoordinates_(
|
|
284
|
+
type,
|
|
285
|
+
lineGeom.getFlatCoordinates(),
|
|
286
|
+
null,
|
|
287
|
+
feature,
|
|
288
|
+
getUid(feature)
|
|
289
|
+
);
|
|
290
|
+
break;
|
|
291
|
+
default:
|
|
292
|
+
// pass
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @param {GeometryType} type Geometry type
|
|
298
|
+
* @param {Array<number>} flatCoords Flat coordinates
|
|
299
|
+
* @param {Array<number> | Array<Array<number>> | null} ends Coordinate ends
|
|
300
|
+
* @param {Feature|RenderFeature} feature Feature
|
|
301
|
+
* @param {string} featureUid Feature uid
|
|
302
|
+
* @private
|
|
303
|
+
*/
|
|
304
|
+
addCoordinates_(type, flatCoords, ends, feature, featureUid) {
|
|
305
|
+
/** @type {number} */
|
|
306
|
+
let verticesCount;
|
|
307
|
+
switch (type) {
|
|
308
|
+
case 'MultiPolygon':
|
|
309
|
+
const multiPolygonEndss = /** @type {Array<Array<number>>} */ (ends);
|
|
310
|
+
for (let i = 0, ii = multiPolygonEndss.length; i < ii; i++) {
|
|
311
|
+
let polygonEnds = multiPolygonEndss[i];
|
|
312
|
+
const prevPolygonEnds = i > 0 ? multiPolygonEndss[i - 1] : null;
|
|
313
|
+
const startIndex = prevPolygonEnds
|
|
314
|
+
? prevPolygonEnds[prevPolygonEnds.length - 1]
|
|
315
|
+
: 0;
|
|
316
|
+
const endIndex = polygonEnds[polygonEnds.length - 1];
|
|
317
|
+
const polygonCoords = flatCoords.slice(startIndex, endIndex);
|
|
318
|
+
polygonEnds =
|
|
319
|
+
startIndex > 0
|
|
320
|
+
? polygonEnds.map((end) => end - startIndex)
|
|
321
|
+
: polygonEnds;
|
|
322
|
+
this.addCoordinates_(
|
|
323
|
+
'Polygon',
|
|
324
|
+
polygonCoords,
|
|
325
|
+
polygonEnds,
|
|
326
|
+
feature,
|
|
327
|
+
featureUid
|
|
291
328
|
);
|
|
329
|
+
}
|
|
330
|
+
break;
|
|
331
|
+
case 'MultiLineString':
|
|
332
|
+
const multiLineEnds = /** @type {Array<number>} */ (ends);
|
|
333
|
+
for (let i = 0, ii = multiLineEnds.length; i < ii; i++) {
|
|
334
|
+
const startIndex = i > 0 ? multiLineEnds[i - 1] : 0;
|
|
335
|
+
const ringCoords = flatCoords.slice(startIndex, multiLineEnds[i]);
|
|
336
|
+
this.addCoordinates_(
|
|
337
|
+
'LinearRing',
|
|
338
|
+
ringCoords,
|
|
339
|
+
null,
|
|
340
|
+
feature,
|
|
341
|
+
featureUid
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
break;
|
|
345
|
+
case 'MultiPoint':
|
|
346
|
+
for (let i = 0, ii = flatCoords.length; i < ii; i += 2) {
|
|
347
|
+
this.addCoordinates_(
|
|
348
|
+
'Point',
|
|
349
|
+
flatCoords.slice(i, i + 2),
|
|
350
|
+
null,
|
|
351
|
+
feature,
|
|
352
|
+
featureUid
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
break;
|
|
356
|
+
case 'Polygon':
|
|
357
|
+
const polygonEnds = /** @type {Array<number>} */ (ends);
|
|
358
|
+
// first look for a CW ring; if so, handle it and following rings as another polygon
|
|
359
|
+
for (let i = 1, ii = polygonEnds.length; i < ii; i++) {
|
|
360
|
+
const ringStartIndex = polygonEnds[i - 1];
|
|
361
|
+
if (
|
|
362
|
+
i > 0 &&
|
|
363
|
+
linearRingIsClockwise(flatCoords, ringStartIndex, polygonEnds[i], 2)
|
|
364
|
+
) {
|
|
365
|
+
this.addCoordinates_(
|
|
366
|
+
'Polygon',
|
|
367
|
+
flatCoords.slice(0, ringStartIndex),
|
|
368
|
+
polygonEnds.slice(0, i),
|
|
369
|
+
feature,
|
|
370
|
+
featureUid
|
|
371
|
+
);
|
|
372
|
+
this.addCoordinates_(
|
|
373
|
+
'Polygon',
|
|
374
|
+
flatCoords.slice(ringStartIndex),
|
|
375
|
+
polygonEnds.slice(i).map((end) => end - polygonEnds[i - 1]),
|
|
376
|
+
feature,
|
|
377
|
+
featureUid
|
|
378
|
+
);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (!this.polygonBatch.entries[featureUid]) {
|
|
383
|
+
this.polygonBatch.entries[featureUid] = {
|
|
384
|
+
feature: feature,
|
|
385
|
+
flatCoordss: [],
|
|
386
|
+
verticesCount: 0,
|
|
387
|
+
ringsCount: 0,
|
|
388
|
+
ringsVerticesCounts: [],
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
verticesCount = flatCoords.length / 2;
|
|
392
|
+
const ringsCount = ends.length;
|
|
393
|
+
const ringsVerticesCount = ends.map((end, ind, arr) =>
|
|
394
|
+
ind > 0 ? (end - arr[ind - 1]) / 2 : end / 2
|
|
395
|
+
);
|
|
292
396
|
this.polygonBatch.verticesCount += verticesCount;
|
|
293
397
|
this.polygonBatch.ringsCount += ringsCount;
|
|
294
398
|
this.polygonBatch.geometriesCount++;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
399
|
+
this.polygonBatch.entries[featureUid].flatCoordss.push(flatCoords);
|
|
400
|
+
this.polygonBatch.entries[featureUid].ringsVerticesCounts.push(
|
|
401
|
+
ringsVerticesCount
|
|
402
|
+
);
|
|
403
|
+
this.polygonBatch.entries[featureUid].verticesCount += verticesCount;
|
|
404
|
+
this.polygonBatch.entries[featureUid].ringsCount += ringsCount;
|
|
405
|
+
for (let i = 0, ii = polygonEnds.length; i < ii; i++) {
|
|
406
|
+
const startIndex = i > 0 ? polygonEnds[i - 1] : 0;
|
|
407
|
+
const ringCoords = flatCoords.slice(startIndex, polygonEnds[i]);
|
|
408
|
+
this.addCoordinates_(
|
|
409
|
+
'LinearRing',
|
|
410
|
+
ringCoords,
|
|
411
|
+
null,
|
|
412
|
+
feature,
|
|
413
|
+
featureUid
|
|
414
|
+
);
|
|
415
|
+
}
|
|
302
416
|
break;
|
|
303
417
|
case 'Point':
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
418
|
+
if (!this.pointBatch.entries[featureUid]) {
|
|
419
|
+
this.pointBatch.entries[featureUid] = {
|
|
420
|
+
feature: feature,
|
|
421
|
+
flatCoordss: [],
|
|
422
|
+
};
|
|
423
|
+
}
|
|
307
424
|
this.pointBatch.geometriesCount++;
|
|
308
|
-
|
|
425
|
+
this.pointBatch.entries[featureUid].flatCoordss.push(flatCoords);
|
|
309
426
|
break;
|
|
310
427
|
case 'LineString':
|
|
311
428
|
case 'LinearRing':
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
429
|
+
if (!this.lineStringBatch.entries[featureUid]) {
|
|
430
|
+
this.lineStringBatch.entries[featureUid] = {
|
|
431
|
+
feature: feature,
|
|
432
|
+
flatCoordss: [],
|
|
433
|
+
verticesCount: 0,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
317
436
|
verticesCount = flatCoords.length / 2;
|
|
318
437
|
this.lineStringBatch.verticesCount += verticesCount;
|
|
319
438
|
this.lineStringBatch.geometriesCount++;
|
|
320
|
-
|
|
321
|
-
|
|
439
|
+
this.lineStringBatch.entries[featureUid].flatCoordss.push(flatCoords);
|
|
440
|
+
this.lineStringBatch.entries[featureUid].verticesCount += verticesCount;
|
|
322
441
|
break;
|
|
323
442
|
default:
|
|
324
443
|
// pass
|
|
@@ -326,7 +445,7 @@ class MixedGeometryBatch {
|
|
|
326
445
|
}
|
|
327
446
|
|
|
328
447
|
/**
|
|
329
|
-
* @param {
|
|
448
|
+
* @param {Feature|RenderFeature} feature Feature
|
|
330
449
|
*/
|
|
331
450
|
changeFeature(feature) {
|
|
332
451
|
this.clearFeatureEntryInPointBatch_(feature);
|
|
@@ -340,7 +459,7 @@ class MixedGeometryBatch {
|
|
|
340
459
|
}
|
|
341
460
|
|
|
342
461
|
/**
|
|
343
|
-
* @param {
|
|
462
|
+
* @param {Feature|RenderFeature} feature Feature
|
|
344
463
|
*/
|
|
345
464
|
removeFeature(feature) {
|
|
346
465
|
this.clearFeatureEntryInPointBatch_(feature);
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export const Uniforms: {
|
|
2
|
+
RENDER_EXTENT: string;
|
|
3
|
+
GLOBAL_ALPHA: string;
|
|
4
|
+
PROJECTION_MATRIX: string;
|
|
5
|
+
OFFSET_SCALE_MATRIX: string;
|
|
6
|
+
OFFSET_ROTATION_MATRIX: string;
|
|
7
|
+
TIME: string;
|
|
8
|
+
ZOOM: string;
|
|
9
|
+
RESOLUTION: string;
|
|
10
|
+
SIZE_PX: string;
|
|
11
|
+
PIXEL_RATIO: string;
|
|
12
|
+
};
|
|
1
13
|
export default WebGLVectorLayerRenderer;
|
|
2
14
|
/**
|
|
3
15
|
* A callback computing
|
|
@@ -88,6 +100,11 @@ declare class WebGLVectorLayerRenderer extends WebGLLayerRenderer<any> {
|
|
|
88
100
|
* @private
|
|
89
101
|
*/
|
|
90
102
|
private currentTransform_;
|
|
103
|
+
/**
|
|
104
|
+
* @type {import("../../transform.js").Transform}
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
private currentFrameStateTransform_;
|
|
91
108
|
fillVertexShader_: string;
|
|
92
109
|
fillFragmentShader_: string;
|
|
93
110
|
fillAttributes_: import("../../render/webgl/BatchRenderer").CustomAttribute[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VectorLayer.d.ts","sourceRoot":"","sources":["VectorLayer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VectorLayer.d.ts","sourceRoot":"","sources":["VectorLayer.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;EAIE;;;;;;;6CAGoB,OAAO,eAAe,EAAE,OAAO;QAAS,MAAM;MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgChF;;;;;;;;;;;;;;;;;GAiBG;AACH;IACE;;;OAGG;IACH,mBAHW,OAAO,sBAAsB,EAAE,OAAO,WACtC,OAAO,EA2HjB;IA7GC,wBAAyB;IAEzB,kDAAoC;IAEpC;;;;;;OAMG;IACH,0BAAkD;IAElD;;;OAGG;IACH,oCAAoD;IAmCpD,0BACmE;IACnE,4BACuE;IACvE,8EAAwD;IAExD,4BACyE;IACzE,8BAEwB;IACxB,gFAA4D;IAE5D,2BACsE;IACtE,6BAC0E;IAC1E,+EAA0D;IAE1D;;OAEG;IACH,gBAAkC;IAElC;;OAEG;IACH,eAAsC;IAItC,yDAyBC;IAID,mDAMC;IACD,+CAMC;IACD,yDAMC;IAGH;;;OAGG;IACH,kCAGC;IAED;;;OAGG;IACH,oCAGC;IAED;;;OAGG;IACH,mCAGC;IAED;;OAEG;IACH,kCAEC;IAED;;;;OAIG;IACH,wBAHW,OAAO,cAAc,EAAE,UAAU,GAChC,WAAW,CAkEtB;CAoGF;+BAjb8B,YAAY;iCAHV,4CAA4C;+BAD9C,0CAA0C;oCAFrC,+CAA+C"}
|
|
@@ -20,10 +20,21 @@ import {
|
|
|
20
20
|
packColor,
|
|
21
21
|
} from './shaders.js';
|
|
22
22
|
import {buffer, createEmpty, equals, getWidth} from '../../extent.js';
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
create as createTransform,
|
|
25
|
+
multiply as multiplyTransform,
|
|
26
|
+
setFromArray as setFromTransform,
|
|
27
|
+
translate as translateTransform,
|
|
28
|
+
} from '../../transform.js';
|
|
24
29
|
import {create as createWebGLWorker} from '../../worker/webgl.js';
|
|
25
30
|
import {listen, unlistenByKey} from '../../events.js';
|
|
26
31
|
|
|
32
|
+
export const Uniforms = {
|
|
33
|
+
...DefaultUniform,
|
|
34
|
+
RENDER_EXTENT: 'u_renderExtent', // intersection of layer, source, and view extent
|
|
35
|
+
GLOBAL_ALPHA: 'u_globalAlpha',
|
|
36
|
+
};
|
|
37
|
+
|
|
27
38
|
/**
|
|
28
39
|
* @typedef {function(import("../../Feature").default, Object<string, *>):number} CustomAttributeCallback A callback computing
|
|
29
40
|
* the value of a custom attribute (different for each feature) to be passed on to the GPU.
|
|
@@ -83,7 +94,9 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
|
|
|
83
94
|
constructor(layer, options) {
|
|
84
95
|
const uniforms = options.uniforms || {};
|
|
85
96
|
const projectionMatrixTransform = createTransform();
|
|
86
|
-
uniforms[
|
|
97
|
+
uniforms[Uniforms.PROJECTION_MATRIX] = projectionMatrixTransform;
|
|
98
|
+
uniforms[Uniforms.RENDER_EXTENT] = [0, 0, 0, 0];
|
|
99
|
+
uniforms[Uniforms.GLOBAL_ALPHA] = 1;
|
|
87
100
|
|
|
88
101
|
super(layer, {
|
|
89
102
|
uniforms: uniforms,
|
|
@@ -103,6 +116,12 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
|
|
|
103
116
|
*/
|
|
104
117
|
this.currentTransform_ = projectionMatrixTransform;
|
|
105
118
|
|
|
119
|
+
/**
|
|
120
|
+
* @type {import("../../transform.js").Transform}
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
this.currentFrameStateTransform_ = createTransform();
|
|
124
|
+
|
|
106
125
|
const fillAttributes = {
|
|
107
126
|
color: function () {
|
|
108
127
|
return packColor('#ddd');
|
|
@@ -276,25 +295,39 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
|
|
|
276
295
|
? Math.floor((extent[0] - projectionExtent[0]) / worldWidth)
|
|
277
296
|
: 0;
|
|
278
297
|
|
|
298
|
+
const baseTransform = this.helper.makeProjectionTransform(
|
|
299
|
+
frameState,
|
|
300
|
+
this.currentFrameStateTransform_
|
|
301
|
+
);
|
|
302
|
+
translateTransform(baseTransform, world * worldWidth, 0);
|
|
303
|
+
|
|
279
304
|
do {
|
|
280
|
-
this.
|
|
281
|
-
|
|
305
|
+
setFromTransform(this.currentTransform_, baseTransform);
|
|
306
|
+
multiplyTransform(
|
|
282
307
|
this.currentTransform_,
|
|
283
|
-
|
|
284
|
-
world * worldWidth
|
|
308
|
+
this.batch_.polygonBatch.invertVerticesBufferTransform
|
|
285
309
|
);
|
|
286
|
-
this.
|
|
287
|
-
|
|
310
|
+
this.polygonRenderer_.preRender(this.batch_.polygonBatch, frameState);
|
|
311
|
+
this.polygonRenderer_.render(this.batch_.polygonBatch);
|
|
312
|
+
setFromTransform(this.currentTransform_, baseTransform);
|
|
313
|
+
multiplyTransform(
|
|
288
314
|
this.currentTransform_,
|
|
289
|
-
|
|
290
|
-
world * worldWidth
|
|
315
|
+
this.batch_.lineStringBatch.invertVerticesBufferTransform
|
|
291
316
|
);
|
|
292
|
-
this.
|
|
293
|
-
this.batch_.
|
|
317
|
+
this.lineStringRenderer_.preRender(
|
|
318
|
+
this.batch_.lineStringBatch,
|
|
319
|
+
frameState
|
|
320
|
+
);
|
|
321
|
+
this.lineStringRenderer_.render(this.batch_.lineStringBatch);
|
|
322
|
+
setFromTransform(this.currentTransform_, baseTransform);
|
|
323
|
+
multiplyTransform(
|
|
294
324
|
this.currentTransform_,
|
|
295
|
-
|
|
296
|
-
world * worldWidth
|
|
325
|
+
this.batch_.lineStringBatch.invertVerticesBufferTransform
|
|
297
326
|
);
|
|
327
|
+
this.pointRenderer_.preRender(this.batch_.pointBatch, frameState);
|
|
328
|
+
this.pointRenderer_.render(this.batch_.pointBatch);
|
|
329
|
+
|
|
330
|
+
translateTransform(baseTransform, worldWidth, 0);
|
|
298
331
|
} while (++world < endWorld);
|
|
299
332
|
|
|
300
333
|
this.helper.finalizeDraw(frameState);
|
|
@@ -346,28 +379,32 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
|
|
|
346
379
|
this.getLayer().changed();
|
|
347
380
|
};
|
|
348
381
|
|
|
382
|
+
const transform = this.helper.makeProjectionTransform(
|
|
383
|
+
frameState,
|
|
384
|
+
createTransform()
|
|
385
|
+
);
|
|
386
|
+
|
|
349
387
|
this.polygonRenderer_.rebuild(
|
|
350
388
|
this.batch_.polygonBatch,
|
|
351
|
-
|
|
389
|
+
transform,
|
|
352
390
|
'Polygon',
|
|
353
391
|
rebuildCb
|
|
354
392
|
);
|
|
355
393
|
this.lineStringRenderer_.rebuild(
|
|
356
394
|
this.batch_.lineStringBatch,
|
|
357
|
-
|
|
395
|
+
transform,
|
|
358
396
|
'LineString',
|
|
359
397
|
rebuildCb
|
|
360
398
|
);
|
|
361
399
|
this.pointRenderer_.rebuild(
|
|
362
400
|
this.batch_.pointBatch,
|
|
363
|
-
|
|
401
|
+
transform,
|
|
364
402
|
'Point',
|
|
365
403
|
rebuildCb
|
|
366
404
|
);
|
|
367
405
|
this.previousExtent_ = frameState.extent.slice();
|
|
368
406
|
}
|
|
369
407
|
|
|
370
|
-
this.helper.makeProjectionTransform(frameState, this.currentTransform_);
|
|
371
408
|
this.helper.prepareDraw(frameState);
|
|
372
409
|
|
|
373
410
|
return true;
|