@pirireis/webglobeplugins 0.10.9-alpha → 0.10.11-alpha
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/package.json +1 -1
- package/point-heat-map/plugin-webworker.js +0 -3
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +13 -19
- package/timetracks/index.js +0 -2
- package/util/heatwavedatamanager/index.js +1 -2
- package/util/heatwavedatamanager/texture-point-sampler.js +1 -0
- package/waveparticles/plugin.js +1 -11
- package/programs/globeshell/noise/noises.js +0 -1
- package/programs/line-on-globe/angled-line.js +0 -173
- package/timetracks/adaptors.js +0 -117
- package/timetracks/plugin.js +0 -248
- package/timetracks/program.js +0 -769
- package/timetracks/programpoint.js +0 -144
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator1.js +0 -116
- package/util/interpolation/timetrack/web-worker-str.js +0 -180
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PointHeatmapFlow } from "./point-to-heat-map-flow";
|
|
2
|
-
// import { webworkerStr } from "../util/interpolation/timetrack/web-worker-str"; // TODO: Delete When this plugin is tested on production
|
|
3
2
|
import { createWorker } from "../util/interpolation/timetrack/index";
|
|
4
3
|
import { createTexture, getColorRampModed } from "../util";
|
|
5
4
|
import { opacityCheck, constraintFloat } from "../util/check/typecheck";
|
|
@@ -15,8 +14,6 @@ class PointHeatmapPlugin {
|
|
|
15
14
|
this._legendTexture = null;
|
|
16
15
|
this._throttleListener = null;
|
|
17
16
|
this._timeTracksAreSet = false;
|
|
18
|
-
// const blob = new Blob([webworkerStr], { type: 'application/javascript' });
|
|
19
|
-
// this.timeTrackInterpolationWorker = new Worker(URL.createObjectURL(blob), { type: 'module' });
|
|
20
17
|
this.timeTrackInterpolationWorker = createWorker();
|
|
21
18
|
this.timeTrackInterpolationWorker.onmessage = (e) => {
|
|
22
19
|
if (e.data.error) {
|
|
@@ -161,19 +161,9 @@ export class BufferManager extends BufferOffsetManager {
|
|
|
161
161
|
gl.bindVertexArray(null);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
__centerMapMethod(rings, paddingAngles) {
|
|
165
|
-
return new Map([
|
|
166
|
-
["rings", rings],
|
|
167
|
-
["paddingAngles", paddingAngles]
|
|
168
|
-
]);
|
|
169
|
-
}
|
|
170
164
|
bindPaddingVAO() {
|
|
171
165
|
this.gl.bindVertexArray(this.vao);
|
|
172
166
|
}
|
|
173
|
-
//TODO: implement this
|
|
174
|
-
// insertBulk is gone. no update feature
|
|
175
|
-
// addBulk is added.
|
|
176
|
-
// deletes old centers given
|
|
177
167
|
insertBulk(data) {
|
|
178
168
|
const { gl, buffer } = this;
|
|
179
169
|
const deleteCentersList = [];
|
|
@@ -233,7 +223,6 @@ export class BufferManager extends BufferOffsetManager {
|
|
|
233
223
|
}
|
|
234
224
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
235
225
|
}
|
|
236
|
-
//TODO: test
|
|
237
226
|
updateCentersHide(data) {
|
|
238
227
|
const { gl, buffer } = this;
|
|
239
228
|
const items = [];
|
|
@@ -275,14 +264,6 @@ export class BufferManager extends BufferOffsetManager {
|
|
|
275
264
|
}
|
|
276
265
|
this._updatePartial(items, 4, gl, buffer);
|
|
277
266
|
}
|
|
278
|
-
__requiredSpaceForBulk(data) {
|
|
279
|
-
let space = 0;
|
|
280
|
-
for (const { paddingAngles, rings } of data) {
|
|
281
|
-
space += paddingAngles.length * rings.length;
|
|
282
|
-
}
|
|
283
|
-
return space;
|
|
284
|
-
}
|
|
285
|
-
// TODO: TEST IT WITH INSERT
|
|
286
267
|
removeCenters(centerIDs) {
|
|
287
268
|
const keys = [];
|
|
288
269
|
for (const centerID of centerIDs) {
|
|
@@ -300,6 +281,19 @@ export class BufferManager extends BufferOffsetManager {
|
|
|
300
281
|
}
|
|
301
282
|
this._removeFromBuffer(keys);
|
|
302
283
|
}
|
|
284
|
+
__requiredSpaceForBulk(data) {
|
|
285
|
+
let space = 0;
|
|
286
|
+
for (const { paddingAngles, rings } of data) {
|
|
287
|
+
space += paddingAngles.length * rings.length;
|
|
288
|
+
}
|
|
289
|
+
return space;
|
|
290
|
+
}
|
|
291
|
+
__centerMapMethod(rings, paddingAngles) {
|
|
292
|
+
return new Map([
|
|
293
|
+
["rings", rings],
|
|
294
|
+
["paddingAngles", paddingAngles]
|
|
295
|
+
]);
|
|
296
|
+
}
|
|
303
297
|
}
|
|
304
298
|
const offsetMapKey = (centerID, ringID, paddingAngle) => `${centerID}_${ringID}_${paddingAngle}`;
|
|
305
299
|
/**
|
package/timetracks/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import TimeTracks from './plugin';
|
|
2
|
-
import { Adaptor, fillSliceOfFloat32Array, createFloat32Array } from './adaptors';
|
|
3
1
|
import TimeTracksLineStrip from './plugin-line-strip';
|
|
4
2
|
import { addCuttingPointLineStrip, featuresToLineStringData, fillSliceOfFloat32ArrayLineStrip, latLongToPixelXY } from './adaptors-line-strip';
|
|
5
3
|
export { Adaptor, fillSliceOfFloat32Array, createFloat32Array, TimeTracks, TimeTracksLineStrip, addCuttingPointLineStrip, featuresToLineStringData, fillSliceOfFloat32ArrayLineStrip, latLongToPixelXY };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import PointCoordinatesDataCalculator1 from "./pointcoordinatesdatacalculator1";
|
|
2
1
|
import HeatWaveDataManager from "./datamanager";
|
|
3
|
-
export { HeatWaveDataManager
|
|
2
|
+
export { HeatWaveDataManager };
|
|
@@ -122,6 +122,7 @@ export class TexturePointSampler {
|
|
|
122
122
|
const { posIndex, callback } = pointObject;
|
|
123
123
|
if (posIndex === -1 || !this._isReady || this._ratio < 0 || this._ratio > 1) {
|
|
124
124
|
callback(null, null, null);
|
|
125
|
+
return;
|
|
125
126
|
}
|
|
126
127
|
const data0 = this._textures[0][posIndex];
|
|
127
128
|
if (this._textureCount === 1) {
|
package/waveparticles/plugin.js
CHANGED
|
@@ -16,7 +16,7 @@ const { PingPongBufferManager, WaveParticalUboManager } = vectorfield;
|
|
|
16
16
|
*/
|
|
17
17
|
const MAX_PIXELS_ON_DIMENSION = 2200;
|
|
18
18
|
export default class Plugin {
|
|
19
|
-
constructor(id, { dataWidth, dataHeight, fadeOpacity = 0.83, opacity = 0.75, minLon = -180, minLat = -90, maxLon = 180, maxLat = 90,
|
|
19
|
+
constructor(id, { dataWidth, dataHeight, fadeOpacity = 0.83, opacity = 0.75, minLon = -180, minLat = -90, maxLon = 180, maxLat = 90, patricleCount = 8000, flipY = true, drawTextureMaxPixelOnDimension = MAX_PIXELS_ON_DIMENSION } = {}) {
|
|
20
20
|
this.id = id;
|
|
21
21
|
this.globe = null;
|
|
22
22
|
this.gl = null;
|
|
@@ -34,7 +34,6 @@ export default class Plugin {
|
|
|
34
34
|
this._particleCount = patricleCount;
|
|
35
35
|
this._dataWidth = dataWidth;
|
|
36
36
|
this._dataHeight = dataHeight;
|
|
37
|
-
this._escapeValue = escapeValue;
|
|
38
37
|
this._drawTextureMaxPixelOnDimension = drawTextureMaxPixelOnDimension;
|
|
39
38
|
this._globeshellparameters = {
|
|
40
39
|
minLon,
|
|
@@ -61,7 +60,6 @@ export default class Plugin {
|
|
|
61
60
|
this._frameBuffer = gl.createFramebuffer();
|
|
62
61
|
this.setBBox(this._globeshellparameters);
|
|
63
62
|
this.setOpacity(this._opacity);
|
|
64
|
-
this.setEscapeValue(this._escapeValue);
|
|
65
63
|
this.____drawIndex = 0;
|
|
66
64
|
}
|
|
67
65
|
draw3D() {
|
|
@@ -167,14 +165,6 @@ export default class Plugin {
|
|
|
167
165
|
this.waveUbo.updateSingle("drop_rate", new Float32Array([value]));
|
|
168
166
|
;
|
|
169
167
|
}
|
|
170
|
-
setEscapeValue(value) {
|
|
171
|
-
if (typeof value !== 'number') {
|
|
172
|
-
console.error("escape value must be a number");
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
this._escapeValue = value;
|
|
176
|
-
this.waveUbo.updateSingle("escape_value", value);
|
|
177
|
-
}
|
|
178
168
|
setDrawTextureMaxPixelOnDimension(value) {
|
|
179
169
|
this._drawTextureMaxPixelOnDimension = value;
|
|
180
170
|
this._drawTextureResolution = this._drawTextureSizeFromBbox(this._globeshellparameters);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
// angle radius, rgba, dashRatio, rgbaMode
|
|
2
|
-
import { createProgram } from "../../util";
|
|
3
|
-
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
|
|
4
|
-
import { longLatRadToMercator, longLatRadToCartesian3D, cartesian3DToGLPosition, mercatorXYToGLPosition, circleLimpFromLongLatRadCenterCartesian3D, circleLimpFromLongLatRadCenterMercatorCompass, circleLimpFromLongLatRadCenterMercatorRealDistance, POLE } from "../../util/shaderfunctions/geometrytransformations";
|
|
5
|
-
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
6
|
-
const EDGE_COUNT_ON_SPHERE = 50;
|
|
7
|
-
const vertexShaderSource = `#version 300 es
|
|
8
|
-
precision highp float;
|
|
9
|
-
|
|
10
|
-
${CameraUniformBlockString}
|
|
11
|
-
${longLatRadToMercator}
|
|
12
|
-
${longLatRadToCartesian3D}
|
|
13
|
-
${cartesian3DToGLPosition}
|
|
14
|
-
${mercatorXYToGLPosition}
|
|
15
|
-
${circleLimpFromLongLatRadCenterCartesian3D}
|
|
16
|
-
${circleLimpFromLongLatRadCenterMercatorCompass}
|
|
17
|
-
${circleLimpFromLongLatRadCenterMercatorRealDistance}
|
|
18
|
-
|
|
19
|
-
in vec2 center_point;
|
|
20
|
-
in float angle;
|
|
21
|
-
in float radius;
|
|
22
|
-
in vec4 rgba;
|
|
23
|
-
in float dash_ratio;
|
|
24
|
-
in float dash_opacity;
|
|
25
|
-
|
|
26
|
-
out vec4 v_color;
|
|
27
|
-
out float v_dash_ratio;
|
|
28
|
-
out float interpolation;
|
|
29
|
-
out float v_dash_opacity;
|
|
30
|
-
out vec2 v_limp;
|
|
31
|
-
// TODO: Draw World Boundaries
|
|
32
|
-
void main() {
|
|
33
|
-
if ( is3D ) {
|
|
34
|
-
interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE - 1}.0;
|
|
35
|
-
float radius_ = radius* interpolation;
|
|
36
|
-
vec3 position = circleLimpFromLongLatRadCenterCartesian3D( center_point, radius_, angle);
|
|
37
|
-
gl_Position = cartesian3DToGLPosition( position);
|
|
38
|
-
v_limp = vec2(0.0, 0.0);
|
|
39
|
-
} else {
|
|
40
|
-
interpolation = float( gl_VertexID );
|
|
41
|
-
float radius_ = radius * interpolation;
|
|
42
|
-
vec2 position = circleLimpFromLongLatRadCenterMercatorRealDistance( center_point, radius_, angle);
|
|
43
|
-
v_limp = position;
|
|
44
|
-
gl_Position = mercatorXYToGLPosition( position);
|
|
45
|
-
}
|
|
46
|
-
v_dash_opacity = dash_opacity;
|
|
47
|
-
v_color = rgba;
|
|
48
|
-
v_dash_ratio = dash_ratio;
|
|
49
|
-
}`;
|
|
50
|
-
const fragmentShaderSource = `#version 300 es
|
|
51
|
-
${POLE}
|
|
52
|
-
precision highp float;
|
|
53
|
-
|
|
54
|
-
uniform float opacity;
|
|
55
|
-
in vec4 v_color;
|
|
56
|
-
in float v_dash_ratio;
|
|
57
|
-
in float v_dash_opacity;
|
|
58
|
-
in float interpolation;
|
|
59
|
-
in vec2 v_limp;
|
|
60
|
-
out vec4 color;
|
|
61
|
-
|
|
62
|
-
void main() {
|
|
63
|
-
if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ color = vec4(0.0,0.0,0.0,0.0); return; }
|
|
64
|
-
color = vec4(v_color.rgb, v_color.a * opacity);
|
|
65
|
-
if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
|
|
66
|
-
color.a *= v_dash_opacity;
|
|
67
|
-
}
|
|
68
|
-
}`;
|
|
69
|
-
class Logic {
|
|
70
|
-
constructor(globe) {
|
|
71
|
-
this.globe = globe;
|
|
72
|
-
this.gl = globe.gl;
|
|
73
|
-
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
74
|
-
this._lastOpacity = 1;
|
|
75
|
-
const { gl, program } = this;
|
|
76
|
-
{ // assign attribute locations
|
|
77
|
-
gl.bindAttribLocation(program, 0, "center_point");
|
|
78
|
-
gl.bindAttribLocation(program, 1, "angle");
|
|
79
|
-
gl.bindAttribLocation(program, 2, "radius");
|
|
80
|
-
gl.bindAttribLocation(program, 3, "rgba");
|
|
81
|
-
gl.bindAttribLocation(program, 4, "dash_ratio");
|
|
82
|
-
gl.bindAttribLocation(program, 5, "dash_opacity");
|
|
83
|
-
}
|
|
84
|
-
{
|
|
85
|
-
this._opacityLocation = gl.getUniformLocation(program, "opacity");
|
|
86
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
87
|
-
gl.useProgram(program);
|
|
88
|
-
gl.uniform1f(this._opacityLocation, this._lastOpacity);
|
|
89
|
-
gl.useProgram(currentProgram);
|
|
90
|
-
}
|
|
91
|
-
this.cameraBlockBindingPoint = 0;
|
|
92
|
-
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
93
|
-
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
94
|
-
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
95
|
-
}
|
|
96
|
-
draw(vao, length, opacity) {
|
|
97
|
-
const { gl, program, globe, cameraBlockTotem, cameraBlockBindingPoint } = this;
|
|
98
|
-
gl.useProgram(program);
|
|
99
|
-
if (opacity !== this._lastOpacity) {
|
|
100
|
-
gl.uniform1f(this._opacityLocation, opacity);
|
|
101
|
-
this._lastOpacity = opacity;
|
|
102
|
-
}
|
|
103
|
-
const drawCount = globe.api_GetCurrentGeometry() === 0 ? EDGE_COUNT_ON_SPHERE : 2;
|
|
104
|
-
gl.bindVertexArray(vao);
|
|
105
|
-
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
106
|
-
// gl.disable(gl.DEPTH_TEST);
|
|
107
|
-
gl.drawArraysInstanced(gl.LINE_STRIP, 0, drawCount, length);
|
|
108
|
-
gl.bindVertexArray(null);
|
|
109
|
-
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
110
|
-
// gl.enable(gl.DEPTH_TEST);
|
|
111
|
-
}
|
|
112
|
-
createVAO(centerCoords, angle, radius, rgba, dashRatio, dashOpacity) {
|
|
113
|
-
const { gl } = this;
|
|
114
|
-
const vao = gl.createVertexArray();
|
|
115
|
-
gl.bindVertexArray(vao);
|
|
116
|
-
{
|
|
117
|
-
const { buffer, stride = 0, offset = 0 } = centerCoords;
|
|
118
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
119
|
-
gl.enableVertexAttribArray(0);
|
|
120
|
-
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
|
|
121
|
-
gl.vertexAttribDivisor(0, 1);
|
|
122
|
-
}
|
|
123
|
-
{
|
|
124
|
-
const { buffer, stride = 0, offset = 0 } = angle;
|
|
125
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
126
|
-
gl.enableVertexAttribArray(1);
|
|
127
|
-
gl.vertexAttribPointer(1, 1, gl.FLOAT, false, stride, offset);
|
|
128
|
-
gl.vertexAttribDivisor(1, 1);
|
|
129
|
-
}
|
|
130
|
-
{
|
|
131
|
-
const { buffer, stride = 0, offset = 0 } = radius;
|
|
132
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
133
|
-
gl.enableVertexAttribArray(2);
|
|
134
|
-
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
|
|
135
|
-
gl.vertexAttribDivisor(2, 1);
|
|
136
|
-
}
|
|
137
|
-
{
|
|
138
|
-
const { buffer, stride = 0, offset = 0 } = rgba;
|
|
139
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
140
|
-
gl.enableVertexAttribArray(3);
|
|
141
|
-
gl.vertexAttribPointer(3, 4, gl.FLOAT, false, stride, offset);
|
|
142
|
-
gl.vertexAttribDivisor(3, 1);
|
|
143
|
-
}
|
|
144
|
-
{
|
|
145
|
-
const { buffer, stride = 0, offset = 0 } = dashRatio;
|
|
146
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
147
|
-
gl.enableVertexAttribArray(4);
|
|
148
|
-
gl.vertexAttribPointer(4, 1, gl.FLOAT, false, stride, offset);
|
|
149
|
-
gl.vertexAttribDivisor(4, 1);
|
|
150
|
-
}
|
|
151
|
-
{
|
|
152
|
-
const { buffer, stride = 0, offset = 0 } = dashOpacity;
|
|
153
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
154
|
-
gl.enableVertexAttribArray(5);
|
|
155
|
-
gl.vertexAttribPointer(5, 1, gl.FLOAT, false, stride, offset);
|
|
156
|
-
gl.vertexAttribDivisor(5, 1);
|
|
157
|
-
}
|
|
158
|
-
gl.bindVertexArray(null);
|
|
159
|
-
return vao;
|
|
160
|
-
}
|
|
161
|
-
free() {
|
|
162
|
-
if (this.isFreed)
|
|
163
|
-
return;
|
|
164
|
-
CameraUniformBlockTotemCache.release(this.globe);
|
|
165
|
-
this.cameraBlockTotem = null;
|
|
166
|
-
this.gl.deleteProgram(this.program);
|
|
167
|
-
this.isFreed = true;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
export const AngledLineProgramCache = Object.freeze({
|
|
171
|
-
get: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic); },
|
|
172
|
-
release: (globe) => { return noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
173
|
-
});
|
package/timetracks/adaptors.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { latLongToPixelXY } from "../util";
|
|
2
|
-
const _latLongToPixelXY = latLongToPixelXY;
|
|
3
|
-
class Adaptor {
|
|
4
|
-
/**
|
|
5
|
-
* @param {Object.<string, Color>} groupColorMap
|
|
6
|
-
* @typedef {Array} Color | [r, g, b] | between 0-1
|
|
7
|
-
*/
|
|
8
|
-
constructor(groupColorMap) {
|
|
9
|
-
this._groupColorMap = groupColorMap;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @param {Object} geojsonObject
|
|
13
|
-
* @param {number} startTime
|
|
14
|
-
* @param {string} timePropertyName
|
|
15
|
-
* @param {string} styleGroupPropertyName
|
|
16
|
-
* @returns {lineData} lineData for Plugin
|
|
17
|
-
*/
|
|
18
|
-
fromGeoJson(geojsonObject, startTime, timePropertyName = "messageTime", styleGroupPropertyName = "styleGroup") {
|
|
19
|
-
const features = geojsonObject.features.filter(feature => feature.geometry.coordinates.length > 1);
|
|
20
|
-
const buffer = createFloat32Array(features.map(feature => feature.geometry.coordinates));
|
|
21
|
-
let offset = 0;
|
|
22
|
-
for (let feature of features) {
|
|
23
|
-
const coordinates = feature.geometry.coordinates;
|
|
24
|
-
const timestamps = feature.properties[timePropertyName].map((time) => (time - startTime) / 1000);
|
|
25
|
-
const styleGroupNameArray = feature.properties[styleGroupPropertyName];
|
|
26
|
-
offset = fillSliceOfFloat32Array(coordinates, timestamps, styleGroupNameArray, this._groupColorMap, buffer, offset);
|
|
27
|
-
}
|
|
28
|
-
return buffer;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Inputs are lists of tracks. Each track is a list of coordinates, timestamps and styleGroupNames.
|
|
32
|
-
* @param {Array.<Array.<Array.<number>>>} coordinatesList | [ [ [lon, lat, z], [lon, lat, z], ...], ...
|
|
33
|
-
* @param {Array.<Array.<number>>} timestampsList | [ [time, time, ...], ...
|
|
34
|
-
* @param {Array.<Array.<String>>} colorGroupList | [ [styleGroupName, styleGroupName, ...], ...
|
|
35
|
-
* @param {number} startTime | epoch time
|
|
36
|
-
* @returns {lineData} lineData for Plugin
|
|
37
|
-
*/
|
|
38
|
-
fromLists(coordinatesList, timestampsList, colorGroupList, startTime) {
|
|
39
|
-
const buffer = createFloat32Array(coordinatesList);
|
|
40
|
-
let offset = 0;
|
|
41
|
-
for (let i = 0; i < coordinatesList.length; i++) {
|
|
42
|
-
const coordinates = coordinatesList[i];
|
|
43
|
-
const timestamps = timestampsList[i].map((time) => (time - startTime) / 1000);
|
|
44
|
-
const styleGroupNameArray = colorGroupList[i];
|
|
45
|
-
offset = fillSliceOfFloat32Array(coordinates, timestamps, styleGroupNameArray, this._groupColorMap, buffer, offset);
|
|
46
|
-
}
|
|
47
|
-
return buffer;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @param {Array.<Array.<number>>} coordinates
|
|
52
|
-
* @param {Array.<number>} timestamps
|
|
53
|
-
* @param {Array.<String>} styleGroupNameArray
|
|
54
|
-
* @param {Object.<string, TrackStyleGroup>} _groupColorMap
|
|
55
|
-
* @param {Float32Array} floatArray
|
|
56
|
-
* @param {number} offset
|
|
57
|
-
*
|
|
58
|
-
* create floatArray with createFloat32Array before calling this function.
|
|
59
|
-
* start offset from 0.
|
|
60
|
-
* feed the floatArray with a track data and offset that is returned from the previous call.
|
|
61
|
-
*/
|
|
62
|
-
function fillSliceOfFloat32Array(coordinates, timestamps, styleGroupNameArray, _groupColorMap, floatArray, offset) {
|
|
63
|
-
if (coordinates[0].length === 2) {
|
|
64
|
-
const startTime = timestamps[0];
|
|
65
|
-
const endTime = timestamps[timestamps.length - 1];
|
|
66
|
-
let prevPointData = null;
|
|
67
|
-
{ // first point
|
|
68
|
-
const { x, y } = _latLongToPixelXY(coordinates[0][1], coordinates[0][0]);
|
|
69
|
-
prevPointData = [x, y, 0, timestamps[0], ..._groupColorMap[styleGroupNameArray[0]]];
|
|
70
|
-
}
|
|
71
|
-
{ // middle points until end
|
|
72
|
-
for (let i = 1; i < coordinates.length; i++) {
|
|
73
|
-
const time = timestamps[i];
|
|
74
|
-
const coord = coordinates[i];
|
|
75
|
-
const { x, y } = _latLongToPixelXY(coord[1], coord[0]);
|
|
76
|
-
floatArray.set([...prevPointData, startTime, endTime, x, y, 0, time, ..._groupColorMap[styleGroupNameArray[i]], startTime, endTime], offset);
|
|
77
|
-
prevPointData = [x, y, 0, time, ..._groupColorMap[styleGroupNameArray[i]]];
|
|
78
|
-
offset += 18;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
const startTime = timestamps[0];
|
|
84
|
-
const endTime = timestamps[timestamps.length - 1];
|
|
85
|
-
let prevPointData = null;
|
|
86
|
-
{ // first point
|
|
87
|
-
const { x, y } = _latLongToPixelXY(coordinates[0][1], coordinates[0][0]);
|
|
88
|
-
prevPointData = [x, y, coordinates[0][2] / 1000.0, timestamps[0], ..._groupColorMap[styleGroupNameArray[0]]];
|
|
89
|
-
}
|
|
90
|
-
{ // middle points until end
|
|
91
|
-
for (let i = 1; i < coordinates.length; i++) {
|
|
92
|
-
const time = timestamps[i];
|
|
93
|
-
const coord = coordinates[i];
|
|
94
|
-
const { x, y } = _latLongToPixelXY(coord[1], coord[0]);
|
|
95
|
-
floatArray.set([...prevPointData, startTime, endTime, x, y, coord[2] / 1000.0, time, ..._groupColorMap[styleGroupNameArray[i]], startTime, endTime], offset);
|
|
96
|
-
prevPointData = [x, y, coord[2] / 1000.0, time, ..._groupColorMap[styleGroupNameArray[i]]];
|
|
97
|
-
offset += 18;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return offset;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @param {*} coordinatesArray
|
|
106
|
-
* @returns Float32Array
|
|
107
|
-
* Coordinates array is needed to calculate the size of the buffer.
|
|
108
|
-
*/
|
|
109
|
-
function createFloat32Array(coordinatesArray) {
|
|
110
|
-
let filteredSize = 0;
|
|
111
|
-
for (let coordinates of coordinatesArray) {
|
|
112
|
-
filteredSize += coordinates.length * 2 - 2;
|
|
113
|
-
}
|
|
114
|
-
const array = new Float32Array(filteredSize * 9);
|
|
115
|
-
return array;
|
|
116
|
-
}
|
|
117
|
-
export { Adaptor, fillSliceOfFloat32Array, createFloat32Array };
|