@pirireis/webglobeplugins 0.9.7 → 0.9.8
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/Math/angle-calculation.js +15 -0
- package/dist/Math/arc.js +65 -0
- package/dist/Math/bounds/line-bbox.js +188 -0
- package/dist/Math/constants.js +9 -0
- package/dist/Math/frustum/camera.js +24 -0
- package/dist/Math/frustum/from-globeinfo.js +48 -0
- package/dist/Math/frustum/types.js +2 -0
- package/dist/Math/globe-util/horizon-plane.js +112 -0
- package/dist/Math/index.js +1 -0
- package/dist/Math/juction/arc-plane.js +83 -0
- package/dist/Math/juction/line-sphere.js +25 -0
- package/dist/Math/juction/plane-plane.js +58 -0
- package/dist/Math/line.js +56 -0
- package/dist/Math/matrix4.js +1 -0
- package/dist/Math/methods.js +201 -0
- package/dist/Math/plane.js +60 -0
- package/dist/Math/quaternion.js +104 -0
- package/dist/Math/types.js +2 -0
- package/dist/Math/utils.js +4 -0
- package/dist/Math/vec3.js +126 -0
- package/dist/algorithms/search-binary.js +19 -0
- package/dist/altitude-locator/adaptors.js +1 -0
- package/dist/altitude-locator/draw-subset-obj.js +18 -0
- package/dist/altitude-locator/keymethod.js +1 -0
- package/dist/altitude-locator/plugin.js +341 -0
- package/dist/altitude-locator/types.js +23 -0
- package/dist/arrowfield/adaptor.js +14 -0
- package/dist/arrowfield/index.js +10 -0
- package/dist/arrowfield/plugin.js +86 -0
- package/dist/bearing-line/index.js +8 -0
- package/dist/bearing-line/plugin.js +449 -0
- package/dist/circle-line-chain/chain-list-map.js +205 -0
- package/dist/circle-line-chain/init.js +1 -0
- package/dist/circle-line-chain/plugin.js +424 -0
- package/dist/circle-line-chain/util.js +5 -0
- package/dist/compass-rose/compass-rose-padding-flat.js +225 -0
- package/dist/compass-rose/compass-text-writer.js +153 -0
- package/dist/compass-rose/index.js +7 -0
- package/dist/compassrose/compassrose.js +296 -0
- package/dist/compassrose/index.js +8 -0
- package/dist/globe-types.js +1 -0
- package/dist/heatwave/index.js +10 -0
- package/dist/heatwave/isobar/objectarraylabels.js +202 -0
- package/dist/heatwave/isobar/plugin.js +343 -0
- package/dist/heatwave/isobar/quadtreecontours.js +300 -0
- package/dist/heatwave/plugins/heatwaveglobeshell.js +206 -0
- package/dist/index.js +58 -0
- package/dist/jest.config.js +7 -0
- package/dist/partialrings/buffer-manager.js +81 -0
- package/dist/partialrings/index.js +41 -0
- package/dist/partialrings/plugin.js +135 -0
- package/dist/partialrings/program.js +286 -0
- package/dist/pin/pin-object-array.js +305 -0
- package/dist/pin/pin-point-totem.js +60 -0
- package/dist/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
- package/dist/point-heat-map/index.js +1 -0
- package/dist/point-heat-map/plugin-webworker.js +126 -0
- package/dist/point-heat-map/point-to-heat-map-flow.js +127 -0
- package/dist/point-tracks/key-methods.js +5 -0
- package/dist/point-tracks/plugin.js +338 -0
- package/dist/programs/arrowfield/index.js +7 -0
- package/dist/programs/arrowfield/logic.js +257 -0
- package/dist/programs/arrowfield/object.js +66 -0
- package/dist/programs/data2legend/density-to-legend.js +101 -0
- package/dist/programs/data2legend/point-to-density-texture.js +100 -0
- package/dist/programs/float2legendwithratio/index.js +8 -0
- package/dist/programs/float2legendwithratio/logic.js +171 -0
- package/dist/programs/float2legendwithratio/object.js +110 -0
- package/dist/programs/globe-util/is-globe-moved.js +21 -0
- package/dist/programs/globeshell/index.js +8 -0
- package/dist/programs/globeshell/noise/noises.js +1 -0
- package/dist/programs/globeshell/wiggle/index.js +8 -0
- package/dist/programs/globeshell/wiggle/logic.js +345 -0
- package/dist/programs/globeshell/wiggle/object.js +72 -0
- package/dist/programs/helpers/blender/index.js +1 -0
- package/dist/programs/helpers/blender/program.js +79 -0
- package/dist/programs/helpers/fadeaway/index.js +7 -0
- package/dist/programs/helpers/fadeaway/logic.js +72 -0
- package/dist/programs/helpers/fadeaway/object.js +20 -0
- package/dist/programs/helpers/index.js +8 -0
- package/dist/programs/index.js +58 -0
- package/dist/programs/interface.js +1 -0
- package/dist/programs/line-on-globe/angled-line.js +176 -0
- package/dist/programs/line-on-globe/circle-accurate-3d.js +141 -0
- package/dist/programs/line-on-globe/circle-accurate-flat.js +216 -0
- package/dist/programs/line-on-globe/circle-accurate.js +178 -0
- package/dist/programs/line-on-globe/circle.js +167 -0
- package/dist/programs/line-on-globe/degree-padding-around-circle-3d.js +159 -0
- package/dist/programs/line-on-globe/index.js +1 -0
- package/dist/programs/line-on-globe/lines-color-instanced-flat.js +136 -0
- package/dist/programs/line-on-globe/linestrip.js +171 -0
- package/dist/programs/line-on-globe/naive-accurate-flexible.js +195 -0
- package/dist/programs/line-on-globe/to-the-surface.js +111 -0
- package/dist/programs/line-on-globe/util.js +8 -0
- package/dist/programs/picking/pickable-renderer.js +188 -0
- package/dist/programs/point-on-globe/element-globe-surface-glow.js +142 -0
- package/dist/programs/point-on-globe/element-point-glow.js +153 -0
- package/dist/programs/point-on-globe/square-pixel-point.js +174 -0
- package/dist/programs/programcache.js +131 -0
- package/dist/programs/rings/distancering/circleflatprogram.js +156 -0
- package/dist/programs/rings/distancering/circlepaddingfreeangleprogram.js +369 -0
- package/dist/programs/rings/distancering/circlepaddysharedbuffer.js +357 -0
- package/dist/programs/rings/distancering/index.js +14 -0
- package/dist/programs/rings/distancering/paddyflatprogram.js +172 -0
- package/dist/programs/rings/distancering/paddyflatprogram2d.js +174 -0
- package/dist/programs/rings/distancering/paddyflatprogram3d.js +172 -0
- package/dist/programs/rings/distancering/shader.js +1 -0
- package/dist/programs/rings/index.js +17 -0
- package/dist/programs/rings/partial-ring/piece-of-pie.js +275 -0
- package/dist/programs/totems/camerauniformblock.js +160 -0
- package/dist/programs/totems/canvas-webglobe-info.js +110 -0
- package/dist/programs/totems/gpu-selection-uniform-block.js +108 -0
- package/dist/programs/totems/index.js +40 -0
- package/dist/programs/two-d/pixel-circle.js +1 -0
- package/dist/programs/two-d/pixel-padding-for-compass.js +162 -0
- package/dist/programs/util.js +17 -0
- package/dist/programs/vectorfields/index.js +23 -0
- package/dist/programs/vectorfields/logics/drawrectangleparticles.js +107 -0
- package/dist/programs/vectorfields/logics/index.js +12 -0
- package/dist/programs/vectorfields/logics/pixelbased.js +142 -0
- package/dist/programs/vectorfields/logics/ubo.js +63 -0
- package/dist/programs/vectorfields/pingpongbuffermanager.js +76 -0
- package/dist/rangerings/enum.js +5 -0
- package/dist/rangerings/index.js +15 -0
- package/dist/rangerings/plugin.js +560 -0
- package/dist/rangerings/rangeringangletext.js +329 -0
- package/dist/rangerings/ring-account.js +117 -0
- package/dist/shaders/fragment-toy/firework.js +58 -0
- package/dist/shaders/fragment-toy/singularity.js +59 -0
- package/dist/shape-on-terrain/arc/naive/plugin.js +252 -0
- package/dist/timetracks/adaptors-line-strip.js +71 -0
- package/dist/timetracks/adaptors.js +122 -0
- package/dist/timetracks/index.js +19 -0
- package/dist/timetracks/plugin-line-strip.js +250 -0
- package/dist/timetracks/plugin.js +258 -0
- package/dist/timetracks/program-line-strip.js +611 -0
- package/dist/timetracks/program.js +772 -0
- package/dist/timetracks/programpoint-line-strip.js +154 -0
- package/dist/timetracks/programpoint.js +147 -0
- package/dist/types.js +15 -0
- package/dist/util/account/bufferoffsetmanager.js +179 -0
- package/dist/util/account/index.js +23 -0
- package/dist/util/account/single-attribute-buffer-management/buffer-manager.js +108 -0
- package/dist/util/account/single-attribute-buffer-management/buffer-orchestrator.js +150 -0
- package/dist/util/account/single-attribute-buffer-management/index.js +9 -0
- package/dist/util/account/single-attribute-buffer-management/object-store.js +51 -0
- package/dist/util/account/single-attribute-buffer-management/types.js +2 -0
- package/dist/util/account/util.js +22 -0
- package/dist/util/algorithms/index.js +1 -0
- package/dist/util/algorithms/search-binary.js +28 -0
- package/dist/util/check/get.js +18 -0
- package/dist/util/check/index.js +1 -0
- package/dist/util/check/typecheck.js +49 -0
- package/dist/util/geometry/index.js +51 -0
- package/dist/util/gl-util/buffer/attribute-loader.js +69 -0
- package/dist/util/gl-util/buffer/index.js +6 -0
- package/dist/util/gl-util/buffer/types.js +1 -0
- package/dist/util/gl-util/draw-options/methods.js +38 -0
- package/dist/util/gl-util/draw-options/types.js +15 -0
- package/dist/util/gl-util/uniform-block/manager.js +156 -0
- package/dist/util/gl-util/uniform-block/shader.js +1 -0
- package/dist/util/gl-util/uniform-block/types.js +8 -0
- package/dist/util/heatwavedatamanager/datamanager.js +152 -0
- package/dist/util/heatwavedatamanager/index.js +10 -0
- package/dist/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +122 -0
- package/dist/util/heatwavedatamanager/pointcoordsmeta.js +20 -0
- package/dist/util/index.js +57 -0
- package/dist/util/interpolation/index.js +1 -0
- package/dist/util/interpolation/timetrack/index.js +5 -0
- package/dist/util/interpolation/timetrack/timetrack-interpolator.js +79 -0
- package/dist/util/interpolation/timetrack/web-worker-str.js +183 -0
- package/dist/util/interpolation/timetrack/web-worker.js +48 -0
- package/dist/util/jshelpers/data-filler.js +20 -0
- package/dist/util/jshelpers/equality.js +20 -0
- package/dist/util/jshelpers/index.js +37 -0
- package/dist/util/jshelpers/timefilters.js +32 -0
- package/dist/util/picking/fence.js +46 -0
- package/dist/util/picking/picker-displayer.js +139 -0
- package/dist/util/programs/draw-texture-on-canvas.js +89 -0
- package/dist/util/programs/index.js +17 -0
- package/dist/util/programs/shapesonglobe.js +214 -0
- package/dist/util/programs/supersampletotextures.js +113 -0
- package/dist/util/programs/texturetoglobe.js +182 -0
- package/dist/util/shaderfunctions/geometrytransformations.js +340 -0
- package/dist/util/shaderfunctions/index.js +18 -0
- package/dist/util/shaderfunctions/nodata.js +11 -0
- package/dist/util/shaderfunctions/noisefunctions.js +43 -0
- package/dist/util/surface-line-data/arc-bboxes.js +25 -0
- package/dist/util/surface-line-data/arcs-to-cuts.js +50 -0
- package/dist/util/surface-line-data/cut-arc.js +1 -0
- package/dist/util/surface-line-data/flow.js +28 -0
- package/dist/util/surface-line-data/rbush-manager.js +1 -0
- package/dist/util/surface-line-data/types.js +1 -0
- package/dist/util/surface-line-data/web-worker.js +1 -0
- package/dist/util/webglobe/gldefaultstates.js +7 -0
- package/dist/util/webglobe/index.js +18 -0
- package/dist/util/webglobe/rasteroverlay.js +78 -0
- package/dist/util/webglobjectbuilders.js +388 -0
- package/dist/util/webglobjectbuilders1.js +237 -0
- package/dist/waveparticles/adaptor.js +17 -0
- package/dist/waveparticles/index.js +10 -0
- package/dist/waveparticles/plugin.js +266 -0
- package/dist/wind/imagetovectorfieldandmagnitude.js +35 -0
- package/dist/wind/index.js +14 -0
- package/dist/wind/plugin.js +926 -0
- package/dist/wind/vectorfieldimage.js +25 -0
- package/dist/write-text/attached-text-writer.js +91 -0
- package/dist/write-text/context-text.js +98 -0
- package/dist/write-text/context-text3.js +155 -0
- package/dist/write-text/index.js +5 -0
- package/dist/write-text/writer-plugin.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RINGPARTIAL_DRAW_MODE = void 0;
|
|
4
|
+
const piece_of_pie_1 = require("../programs/rings/partial-ring/piece-of-pie");
|
|
5
|
+
const naive_accurate_flexible_1 = require("../programs/line-on-globe/naive-accurate-flexible");
|
|
6
|
+
const circle_accurate_3d_1 = require("../programs/line-on-globe/circle-accurate-3d");
|
|
7
|
+
const circle_accurate_flat_1 = require("../programs/line-on-globe/circle-accurate-flat");
|
|
8
|
+
const account_1 = require("../util/account");
|
|
9
|
+
const get_1 = require("../util/check/get");
|
|
10
|
+
const data_filler_1 = require("../util/jshelpers/data-filler");
|
|
11
|
+
const context_text3_1 = require("../write-text/context-text3");
|
|
12
|
+
const typecheck_1 = require("../util/check/typecheck");
|
|
13
|
+
const geometry_1 = require("../util/geometry");
|
|
14
|
+
const attribute_loader_1 = require("../util/gl-util/buffer/attribute-loader");
|
|
15
|
+
exports.RINGPARTIAL_DRAW_MODE = Object.freeze({
|
|
16
|
+
LINE_STRIP: "LINE_STRIP",
|
|
17
|
+
TRIANGLE_FAN: "TRIANGLE_FAN",
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{key, long, lat, endLong, endLat, bearingAngle, radius, rgba:[4numbers], rgbaMode, bigRadius, dashRatio, dashOpacity, circleDashAngle}} BearingLineItem
|
|
21
|
+
* @property {string} key
|
|
22
|
+
* @property {number} long
|
|
23
|
+
* @property {number} lat
|
|
24
|
+
* @property {number} endLong
|
|
25
|
+
* @property {number} endLat
|
|
26
|
+
* @property {number} bearingAngle 0-360
|
|
27
|
+
* @property {number} radius angle ring radius
|
|
28
|
+
* @property {number} altitude in meters effects all parts of the item
|
|
29
|
+
* @property {Array<numbers>} rgba [r,g,b,a] 0-1
|
|
30
|
+
* @property {number} rgbaMode 0 constant, 1 fading, 2 hides angle ring
|
|
31
|
+
* @property {number} bigRadius undefined means it will be calculated from long, lat, endLong, endLat
|
|
32
|
+
* @property {number} dashRatio 0-1
|
|
33
|
+
* @property {number} dashOpacity 0-1
|
|
34
|
+
* @property {number} circleDashAngle 0-360
|
|
35
|
+
*/
|
|
36
|
+
const textWriterGetOrThrow = (0, get_1.mapGetOrThrow)("BearingLine textContextInjection id does not exist in map");
|
|
37
|
+
const radian = (degree) => degree * Math.PI / 180;
|
|
38
|
+
const integralSec = (angle) => {
|
|
39
|
+
return Math.log(Math.tan(angle / 2 + Math.PI / 4));
|
|
40
|
+
};
|
|
41
|
+
const calculateStartAngle = (long, lat, endLong, endLat) => {
|
|
42
|
+
const dLat = (integralSec(endLat) - integralSec(lat)); // Because lines are strectes toward poles.
|
|
43
|
+
const dLong = endLong - long;
|
|
44
|
+
let angle = -Math.atan2(dLat, dLong);
|
|
45
|
+
return angle;
|
|
46
|
+
};
|
|
47
|
+
class BearingLinePlugin {
|
|
48
|
+
/**
|
|
49
|
+
* @param {*} id
|
|
50
|
+
* @param {Map<[key, ContextTextWriter3]>} textWritersMap
|
|
51
|
+
*/
|
|
52
|
+
constructor(id, { opacity = 1, textWritersMap = new Map(), textDataPreAdaptor = (x) => x, drawVRM = true, drawBearingLine = true, drawAngleRing = true, drawText = true, circleFlatEdgeCount = circle_accurate_flat_1.EDGE_COUNT - 2 } = {}) {
|
|
53
|
+
this.id = id;
|
|
54
|
+
this._opacity = opacity;
|
|
55
|
+
this.bufferOrchestrator = new account_1.BufferOrchestrator({ capacity: 10 });
|
|
56
|
+
this._checkTextContextWriterInjectionMap(textWritersMap);
|
|
57
|
+
this._textWritersMap = textWritersMap;
|
|
58
|
+
this._textWritersMap.forEach((writer) => writer.keyAdaptor = (item) => item.key);
|
|
59
|
+
this.drawVRM = drawVRM;
|
|
60
|
+
this.drawBearingLine = drawBearingLine;
|
|
61
|
+
this.drawAngleRing = drawAngleRing;
|
|
62
|
+
this._textDataPreAdaptor = textDataPreAdaptor;
|
|
63
|
+
this.drawText = drawText;
|
|
64
|
+
this._memoryForText = new Map();
|
|
65
|
+
this.circleFlatEdgeCount = circleFlatEdgeCount + 2;
|
|
66
|
+
}
|
|
67
|
+
setDoDrawVRM(bool) {
|
|
68
|
+
(0, typecheck_1.isBoolean)(bool);
|
|
69
|
+
if (bool === this.drawVRM)
|
|
70
|
+
return;
|
|
71
|
+
this.drawVRM = bool;
|
|
72
|
+
this.globe.DrawRender();
|
|
73
|
+
}
|
|
74
|
+
setDoDrawText(bool) {
|
|
75
|
+
(0, typecheck_1.isBoolean)(bool);
|
|
76
|
+
if (bool === this.drawText)
|
|
77
|
+
return;
|
|
78
|
+
this.drawText = bool;
|
|
79
|
+
this.globe.DrawRender();
|
|
80
|
+
}
|
|
81
|
+
setDoDrawText(bool) {
|
|
82
|
+
(0, typecheck_1.isBoolean)(bool);
|
|
83
|
+
if (bool === this.drawText)
|
|
84
|
+
return;
|
|
85
|
+
this.drawText = bool;
|
|
86
|
+
this.globe.DrawRender();
|
|
87
|
+
}
|
|
88
|
+
setDoDrawAngleRing(bool) {
|
|
89
|
+
(0, typecheck_1.isBoolean)(bool);
|
|
90
|
+
if (bool === this.drawAngleRing)
|
|
91
|
+
return;
|
|
92
|
+
this.drawAngleRing = bool;
|
|
93
|
+
this.globe.DrawRender();
|
|
94
|
+
}
|
|
95
|
+
setOpacity(opacity) {
|
|
96
|
+
(0, typecheck_1.constraintFloat)(opacity, 0, 1);
|
|
97
|
+
this._opacity = opacity;
|
|
98
|
+
this._textWritersMap.forEach((writer) => writer.setOpacity(opacity));
|
|
99
|
+
this.globe.DrawRender();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
|
|
103
|
+
* @param {Array<BearingLineItem>} items
|
|
104
|
+
* @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
|
|
105
|
+
*/
|
|
106
|
+
insertBulk(items, { textWriterIDs = [] } = {}) {
|
|
107
|
+
const { globe, bufferOrchestrator, bufferManagersCompMap } = this; // angleTextContext, distanceTextContext,
|
|
108
|
+
const data = [];
|
|
109
|
+
for (let item of items) {
|
|
110
|
+
data.push(this.__insertAdaptor(item));
|
|
111
|
+
}
|
|
112
|
+
bufferOrchestrator.insertBulk(data, bufferManagersCompMap);
|
|
113
|
+
this.__insertTexts(items, textWriterIDs);
|
|
114
|
+
globe.DrawRender();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
|
|
118
|
+
* @param {Array<string>} itemKeys | if empty, all texts will be updated.
|
|
119
|
+
*/
|
|
120
|
+
updateText(textWriterIDs = [], itemKeys = null) {
|
|
121
|
+
const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
|
|
122
|
+
if (itemKeys === null) {
|
|
123
|
+
this._memoryForText.forEach((item) => {
|
|
124
|
+
let _item = this._textDataPreAdaptor(item);
|
|
125
|
+
textWritersMap.forEach((writer) => writer.insertText(_item));
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
itemKeys.forEach((key) => {
|
|
130
|
+
let item = this._memoryForText.get(key);
|
|
131
|
+
if (item === undefined)
|
|
132
|
+
return;
|
|
133
|
+
let _item = this._textDataPreAdaptor(item);
|
|
134
|
+
textWritersMap.forEach((writer) => writer.insertText(_item));
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
this.globe.DrawRender();
|
|
138
|
+
}
|
|
139
|
+
deleteBulk(keys) {
|
|
140
|
+
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersCompMap);
|
|
141
|
+
for (const key of keys) {
|
|
142
|
+
this._memoryForText.delete(key);
|
|
143
|
+
}
|
|
144
|
+
this._deleteTexts(keys);
|
|
145
|
+
this.globe.DrawRender();
|
|
146
|
+
}
|
|
147
|
+
defrag() {
|
|
148
|
+
this.bufferOrchestrator.defrag(this.bufferManagersCompMap);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* @param {Array<{key, long, lat, endLong, endLat, bearingAngle}>} items
|
|
152
|
+
* @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
|
|
153
|
+
*/
|
|
154
|
+
updateCoordinatesBulk(items, { textWriterIDs = [] } = {}) {
|
|
155
|
+
const { globe, bufferOrchestrator, bufferManagersCompMap, } = this;
|
|
156
|
+
const data = [];
|
|
157
|
+
for (let item of items) {
|
|
158
|
+
data.push(this.__updateCoordsAdaptor(item));
|
|
159
|
+
}
|
|
160
|
+
this.__insertTexts(items, textWriterIDs);
|
|
161
|
+
bufferOrchestrator.updateBulk(data, bufferManagersCompMap, ["centerCoords2d", "centerCoords3d", "targetCoords2d", "targetCoords3d",
|
|
162
|
+
"startAngle2d", "tailAngle2d", "startAngle3d", "tailAngle3d", "bearingTargetCoords2d", "bearingTargetCoords3d", "centerCoords2dflat",
|
|
163
|
+
"bigRadius", "radius"]);
|
|
164
|
+
globe.DrawRender();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
*
|
|
168
|
+
* @param {Array<BearingLineItem>} items some colums EXCEPT positional ones
|
|
169
|
+
* @param {string} propertyIDs
|
|
170
|
+
* @param {string} textWriterIDs
|
|
171
|
+
* Do NOT send empty data if property ID of this data is entered or NaN is loaded to the buffer, resulting in an unwanted behaviour.
|
|
172
|
+
*{ textWriterIDs = []}
|
|
173
|
+
*/
|
|
174
|
+
updatePartial(items, propertyIDs = [], { textWriterIDs = [] } = {}) {
|
|
175
|
+
if (propertyIDs.length === 0)
|
|
176
|
+
console.warn("updatePartial is called with no target propertyIDs");
|
|
177
|
+
const fixedPropertyIDs = this.__fixPartialProperties(propertyIDs);
|
|
178
|
+
const { bufferOrchestrator, bufferManagersCompMap } = this;
|
|
179
|
+
bufferOrchestrator.updateBulk(items, bufferManagersCompMap, fixedPropertyIDs);
|
|
180
|
+
// patch to update text opacity
|
|
181
|
+
this.__insertTexts(items, textWriterIDs);
|
|
182
|
+
this.globe.DrawRender();
|
|
183
|
+
}
|
|
184
|
+
// Private methods
|
|
185
|
+
_checkTextContextWriterInjectionMap(textContextWriterInjectionMap) {
|
|
186
|
+
if (!(textContextWriterInjectionMap instanceof Map))
|
|
187
|
+
throw new Error("textContextWriterInjectionMap is not an instance of Map");
|
|
188
|
+
textContextWriterInjectionMap.forEach((v) => {
|
|
189
|
+
if (!(v instanceof context_text3_1.ContextTextWriter3))
|
|
190
|
+
throw new Error("textContextWriterInjectionMap element is not an instance of ContextTextWriter3");
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
__insertTexts(items, textWriterIDs) {
|
|
194
|
+
const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
|
|
195
|
+
for (const item of items) {
|
|
196
|
+
const oldItem = this._memoryForText.get(item.key);
|
|
197
|
+
let _item = oldItem !== undefined ? { ...oldItem, ...item } : item;
|
|
198
|
+
this._memoryForText.set(item.key, _item);
|
|
199
|
+
if (this._textDataPreAdaptor !== null)
|
|
200
|
+
_item = this._textDataPreAdaptor(_item);
|
|
201
|
+
textWritersMap.forEach((writer) => writer.insertText(_item));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
__insertAdaptor(item) {
|
|
205
|
+
const rgba = item.rgba !== undefined ? item.rgba : [0, 0, 0, 0];
|
|
206
|
+
const rgbaMode = item.rgbaMode !== undefined ? item.rgbaMode : 0;
|
|
207
|
+
const dashRatio = item.dashRatio !== undefined ? item.dashRatio : 1.0;
|
|
208
|
+
const dashOpacity = item.dashOpacity !== undefined ? item.dashOpacity : 0.9;
|
|
209
|
+
const circleDashAngle = item.circleDashAngle !== undefined ? item.circleDashAngle : 360;
|
|
210
|
+
const coordsData = this.__updateCoordsAdaptor(item);
|
|
211
|
+
return {
|
|
212
|
+
...coordsData,
|
|
213
|
+
rgba,
|
|
214
|
+
dashRatio,
|
|
215
|
+
dashOpacity,
|
|
216
|
+
circleDashAngle,
|
|
217
|
+
rgbaMode
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
__updateCoordsAdaptor(item) {
|
|
221
|
+
var _a, _b;
|
|
222
|
+
const { globe } = this;
|
|
223
|
+
const lat = radian(item.lat);
|
|
224
|
+
const long = radian(item.long);
|
|
225
|
+
const endLat = radian(item.endLat);
|
|
226
|
+
const endLong = radian(item.endLong);
|
|
227
|
+
const altitude = ((_a = item.altitude) !== null && _a !== void 0 ? _a : 0) / 1000;
|
|
228
|
+
const bigRadius = (_b = item.bigRadius) !== null && _b !== void 0 ? _b : globe.Math.GetDist2D(item.long, item.lat, item.endLong, item.endLat);
|
|
229
|
+
const radius = item.radius !== undefined ? item.radius : bigRadius * 0.2;
|
|
230
|
+
const { long: bearingLong, lat: bearingLat } = globe.Math.FindPointByPolar(item.long, item.lat, bigRadius, item.bearingAngle);
|
|
231
|
+
const startAngle2d = calculateStartAngle(long, lat, endLong, endLat);
|
|
232
|
+
const bearingAngle2d = calculateStartAngle(long, lat, radian(bearingLong), radian(bearingLat));
|
|
233
|
+
let tailAngle2d = bearingAngle2d - startAngle2d;
|
|
234
|
+
if (tailAngle2d > 0) {
|
|
235
|
+
tailAngle2d -= Math.PI * 2;
|
|
236
|
+
}
|
|
237
|
+
const bearingAngle = radian(item.bearingAngle - 90);
|
|
238
|
+
const startAngleOfCircle = globe.Math.GetAzimuthAngle(item.long, item.lat, item.endLong, item.endLat); //startAngle2d * 180 / Math.PI;
|
|
239
|
+
const startAngle3d = radian(startAngleOfCircle) - radian(90);
|
|
240
|
+
let tailAngle3d = bearingAngle - startAngle3d;
|
|
241
|
+
if (tailAngle3d > 0) {
|
|
242
|
+
tailAngle3d -= Math.PI * 2;
|
|
243
|
+
}
|
|
244
|
+
const centerCoords2dflat = (0, circle_accurate_flat_1.centerCoords2dflatDataCreator)(globe, item.long, item.lat, item.endLong, item.endLat, { startAngleOfCircle, edgeCount: this.circleFlatEdgeCount });
|
|
245
|
+
return {
|
|
246
|
+
key: item.key,
|
|
247
|
+
lat: item.lat,
|
|
248
|
+
long: item.long,
|
|
249
|
+
endLat: item.endLat,
|
|
250
|
+
endLong: item.endLong,
|
|
251
|
+
altitude,
|
|
252
|
+
bearingAngle,
|
|
253
|
+
radius,
|
|
254
|
+
bigRadius,
|
|
255
|
+
startAngle2d,
|
|
256
|
+
tailAngle2d,
|
|
257
|
+
startAngle3d,
|
|
258
|
+
tailAngle3d,
|
|
259
|
+
bearingLong,
|
|
260
|
+
bearingLat,
|
|
261
|
+
centerCoords2dflat
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
__fixPartialProperties(propertyIDs) {
|
|
265
|
+
const s = new Set(["rgba", "dashOpacity", "circleDashAngle"]);
|
|
266
|
+
const result = [];
|
|
267
|
+
for (const item of propertyIDs) {
|
|
268
|
+
result.push(item);
|
|
269
|
+
if (s.has(item)) {
|
|
270
|
+
result.push(item + "Mercator");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
275
|
+
// Globe API
|
|
276
|
+
init(globe, gl) {
|
|
277
|
+
this.gl = gl;
|
|
278
|
+
this.globe = globe;
|
|
279
|
+
this.lineProgram = naive_accurate_flexible_1.LineOnGlobeCache.get(globe);
|
|
280
|
+
this.pieceOfPieProgram = piece_of_pie_1.PieceOfPieProgramCache.get(globe);
|
|
281
|
+
this.circleProgram = circle_accurate_flat_1.CircleCache.get(globe);
|
|
282
|
+
this.circle3DProgram = circle_accurate_3d_1.CircleCache.get(globe);
|
|
283
|
+
const circleFlatEdgeCount = this.circleFlatEdgeCount;
|
|
284
|
+
{
|
|
285
|
+
// createBuffers
|
|
286
|
+
const bufferType = "DYNAMIC_DRAW";
|
|
287
|
+
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
288
|
+
this.bufferManagersCompMap = new Map([
|
|
289
|
+
["centerCoords2d", {
|
|
290
|
+
'bufferManager': new account_1.BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
291
|
+
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.long, item.lat)),
|
|
292
|
+
}],
|
|
293
|
+
["centerCoords2dflat", {
|
|
294
|
+
'bufferManager': new account_1.BufferManager(gl, circleFlatEdgeCount * 2, { bufferType, initialCapacity }),
|
|
295
|
+
'adaptor': (item) => item.centerCoords2dflat,
|
|
296
|
+
}],
|
|
297
|
+
["centerCoords3d", {
|
|
298
|
+
'bufferManager': new account_1.BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
299
|
+
'adaptor': (item) => (0, geometry_1.sphereCoord)(item.long, item.lat, globe, item.altitude),
|
|
300
|
+
}],
|
|
301
|
+
["targetCoords2d", {
|
|
302
|
+
'bufferManager': new account_1.BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
303
|
+
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.endLong, item.endLat))
|
|
304
|
+
}],
|
|
305
|
+
["targetCoords3d", {
|
|
306
|
+
'bufferManager': new account_1.BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
307
|
+
'adaptor': (item) => (0, geometry_1.sphereCoord)(item.endLong, item.endLat, globe, item.altitude)
|
|
308
|
+
}],
|
|
309
|
+
["bearingTargetCoords2d", {
|
|
310
|
+
'bufferManager': new account_1.BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
311
|
+
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.bearingLong, item.bearingLat))
|
|
312
|
+
}],
|
|
313
|
+
["bearingTargetCoords3d", {
|
|
314
|
+
'bufferManager': new account_1.BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
315
|
+
'adaptor': (item) => (0, geometry_1.sphereCoord)(item.bearingLong, item.bearingLat, globe, item.altitude)
|
|
316
|
+
}],
|
|
317
|
+
["startAngle2d", {
|
|
318
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
319
|
+
'adaptor': (item) => new Float32Array([item.startAngle2d])
|
|
320
|
+
}],
|
|
321
|
+
["tailAngle2d", {
|
|
322
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
323
|
+
'adaptor': (item) => new Float32Array([item.tailAngle2d])
|
|
324
|
+
}],
|
|
325
|
+
["startAngle3d", {
|
|
326
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
327
|
+
'adaptor': (item) => new Float32Array([item.startAngle3d])
|
|
328
|
+
}],
|
|
329
|
+
["tailAngle3d", {
|
|
330
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
331
|
+
'adaptor': (item) => new Float32Array([item.tailAngle3d])
|
|
332
|
+
}],
|
|
333
|
+
["bearingDashRatio", {
|
|
334
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
335
|
+
'adaptor': (item) => new Float32Array([0])
|
|
336
|
+
}],
|
|
337
|
+
["rgba", {
|
|
338
|
+
'bufferManager': new account_1.BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
339
|
+
'adaptor': (item) => new Float32Array(item.rgba)
|
|
340
|
+
}],
|
|
341
|
+
["radius", {
|
|
342
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
343
|
+
'adaptor': (item) => new Float32Array([item.radius])
|
|
344
|
+
}],
|
|
345
|
+
["rgbaMode", {
|
|
346
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
347
|
+
'adaptor': (item) => new Float32Array([item.rgbaMode])
|
|
348
|
+
}],
|
|
349
|
+
["dashRatio", {
|
|
350
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
351
|
+
'adaptor': (item) => new Float32Array([item.dashRatio])
|
|
352
|
+
}],
|
|
353
|
+
["bigRadius", {
|
|
354
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
355
|
+
'adaptor': (item) => new Float32Array([item.bigRadius])
|
|
356
|
+
}],
|
|
357
|
+
["dashOpacity", {
|
|
358
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
359
|
+
'adaptor': (item) => new Float32Array([item.dashOpacity]),
|
|
360
|
+
}],
|
|
361
|
+
["circleDashAngle", {
|
|
362
|
+
'bufferManager': new account_1.BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
363
|
+
'adaptor': (item) => new Float32Array([item.circleDashAngle / 360]),
|
|
364
|
+
}],
|
|
365
|
+
// Mercator circle properties are duplicated for the sake of performance.
|
|
366
|
+
["rgbaMercator", {
|
|
367
|
+
'bufferManager': new account_1.BufferManager(gl, 4 * circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
368
|
+
'adaptor': (item) => data_filler_1.populateFloat32Array.fillWithListData(circleFlatEdgeCount, item.rgba),
|
|
369
|
+
}],
|
|
370
|
+
["circleDashAngleMercator", {
|
|
371
|
+
'bufferManager': new account_1.BufferManager(gl, circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
372
|
+
'adaptor': (item) => data_filler_1.populateFloat32Array.fillFloat32Array(circleFlatEdgeCount, item.circleDashAngle / 360),
|
|
373
|
+
}],
|
|
374
|
+
["dashOpacityMercator", {
|
|
375
|
+
'bufferManager': new account_1.BufferManager(gl, circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
376
|
+
'adaptor': (item) => data_filler_1.populateFloat32Array.fillFloat32Array(circleFlatEdgeCount, item.dashOpacity),
|
|
377
|
+
}],
|
|
378
|
+
]);
|
|
379
|
+
}
|
|
380
|
+
const vaoOBJ = (key) => (0, attribute_loader_1.createBufferAndReadInfo)(this.bufferManagersCompMap.get(key).bufferManager.buffer);
|
|
381
|
+
this.lineVao = this.lineProgram.createVAO(...['centerCoords2d', 'centerCoords3d', 'targetCoords2d', 'targetCoords3d', 'dashOpacity', 'dashOpacity', 'rgba'].map(key => vaoOBJ(key)));
|
|
382
|
+
this.ringVao = this.pieceOfPieProgram.createVAO(...['centerCoords2d',
|
|
383
|
+
'centerCoords3d',
|
|
384
|
+
'startAngle2d',
|
|
385
|
+
'tailAngle2d',
|
|
386
|
+
'startAngle3d',
|
|
387
|
+
'tailAngle3d',
|
|
388
|
+
'rgba',
|
|
389
|
+
'radius',
|
|
390
|
+
'rgbaMode'].map(key => vaoOBJ(key)));
|
|
391
|
+
this.bearingLineVAO = this.lineProgram.createVAO(...['centerCoords2d', 'centerCoords3d', 'bearingTargetCoords2d', 'bearingTargetCoords3d', 'bearingDashRatio', 'dashOpacity', 'rgba'
|
|
392
|
+
].map(key => vaoOBJ(key)));
|
|
393
|
+
this.circleVao = this.circleProgram.createVAO(...["centerCoords2dflat", "rgbaMercator", "circleDashAngleMercator", "dashOpacityMercator"
|
|
394
|
+
].map(key => vaoOBJ(key)));
|
|
395
|
+
this.circle3DVao = this.circle3DProgram.createVAO(...["centerCoords3d", "targetCoords3d", "rgba", "circleDashAngle", "dashOpacity"
|
|
396
|
+
].map(key => vaoOBJ(key)));
|
|
397
|
+
}
|
|
398
|
+
draw3D() {
|
|
399
|
+
const { gl } = this;
|
|
400
|
+
gl.disable(gl.DEPTH_TEST);
|
|
401
|
+
const is3D = this.globe.api_GetCurrentGeometry() === 0;
|
|
402
|
+
const drawRange = { first: 0, count: this.bufferOrchestrator.length };
|
|
403
|
+
this.lineProgram.draw(this.lineVao, { drawRange }, this._opacity);
|
|
404
|
+
if (this.drawAngleRing) {
|
|
405
|
+
this.pieceOfPieProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, this._opacity * 0.8, exports.RINGPARTIAL_DRAW_MODE.TRIANGLE_FAN);
|
|
406
|
+
this.pieceOfPieProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, this._opacity * 0.8, exports.RINGPARTIAL_DRAW_MODE.LINE_STRIP);
|
|
407
|
+
}
|
|
408
|
+
if (this.drawBearingLine) {
|
|
409
|
+
// this.lineProgram.draw(this.bearingLineVAO, this.bufferOrchestrator.length, this._opacity );
|
|
410
|
+
this.lineProgram.draw(this.bearingLineVAO, { drawRange }, this._opacity);
|
|
411
|
+
}
|
|
412
|
+
if (this.drawVRM) {
|
|
413
|
+
if (is3D) {
|
|
414
|
+
this.circle3DProgram.draw(this.circle3DVao, this.bufferOrchestrator.length, this._opacity);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
this.circleProgram.draw(this.circleVao, this.bufferOrchestrator.length, this.circleFlatEdgeCount, this._opacity);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (this.drawText) {
|
|
421
|
+
this._textWritersMap.forEach((writer) => writer.draw());
|
|
422
|
+
}
|
|
423
|
+
gl.enable(gl.DEPTH_TEST);
|
|
424
|
+
}
|
|
425
|
+
free() {
|
|
426
|
+
if (this.isFreed)
|
|
427
|
+
return;
|
|
428
|
+
this.bufferManagersCompMap.forEach(({ bufferManager, adaptor }) => {
|
|
429
|
+
bufferManager.free();
|
|
430
|
+
});
|
|
431
|
+
const { gl, globe } = this;
|
|
432
|
+
gl.deleteVertexArray(this.lineVao);
|
|
433
|
+
gl.deleteVertexArray(this.ringVao);
|
|
434
|
+
gl.deleteVertexArray(this.bearingLineVAO);
|
|
435
|
+
gl.deleteVertexArray(this.circleVao);
|
|
436
|
+
gl.deleteVertexArray(this.circle3DVao);
|
|
437
|
+
naive_accurate_flexible_1.LineOnGlobeCache.release(globe);
|
|
438
|
+
piece_of_pie_1.PieceOfPieProgramCache.release(globe);
|
|
439
|
+
circle_accurate_flat_1.CircleCache.release(globe);
|
|
440
|
+
circle_accurate_3d_1.CircleCache.release(globe);
|
|
441
|
+
this.isFreed = true;
|
|
442
|
+
}
|
|
443
|
+
_deleteTexts(keys) {
|
|
444
|
+
this._textWritersMap.forEach((writer) => {
|
|
445
|
+
writer.deleteTextBulk(keys);
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
exports.default = BearingLinePlugin;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChainListMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* set and get node data
|
|
6
|
+
* node indexes;
|
|
7
|
+
*/
|
|
8
|
+
class ChainListMap {
|
|
9
|
+
constructor(keyMethod) {
|
|
10
|
+
this._chainMap = new Map();
|
|
11
|
+
this._chainSideProperties = new Map();
|
|
12
|
+
this._indexMap = new Map(); // hold list index of lastly updated nodes. on add delete goes empty
|
|
13
|
+
this.keyMethod = keyMethod;
|
|
14
|
+
}
|
|
15
|
+
getChain(chainKey) {
|
|
16
|
+
return this._chainMap.get(chainKey);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {*} node
|
|
21
|
+
* @param {*} chainKey
|
|
22
|
+
* @param {string|null} theNodeKeyFront
|
|
23
|
+
*/
|
|
24
|
+
addNode(node, chainKey, theNodeKeyFront = null) {
|
|
25
|
+
const chain = this.getChain(chainKey);
|
|
26
|
+
let frontIndex = null;
|
|
27
|
+
for (let i = 0; i < chain.length; i++) {
|
|
28
|
+
const n_ode = chain[i];
|
|
29
|
+
if (n_ode.key === node.key) {
|
|
30
|
+
throw new Error("Chain node already exists");
|
|
31
|
+
}
|
|
32
|
+
if (n_ode.key === theNodeKeyFront) {
|
|
33
|
+
frontIndex = i;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (theNodeKeyFront !== null) {
|
|
37
|
+
if (frontIndex !== null) {
|
|
38
|
+
chain.splice(frontIndex, 0, node);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new Error("Could not find theNodeKeyFront");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
chain.push(node);
|
|
46
|
+
}
|
|
47
|
+
node.__identity__ = this.keyMethod(chainKey, node.key);
|
|
48
|
+
this._resetIndexChain(chainKey);
|
|
49
|
+
}
|
|
50
|
+
deleteNodesBelongToAChain(chainKey, nodeKeys) {
|
|
51
|
+
const chain = this._chainMap.get(chainKey);
|
|
52
|
+
const deleteKeys = [];
|
|
53
|
+
const removeSet = new Set(nodeKeys);
|
|
54
|
+
const newChain = [];
|
|
55
|
+
for (let i = 0; i < chain.length - 1; i++) {
|
|
56
|
+
const node = chain[i];
|
|
57
|
+
const dKey = node.__identity__;
|
|
58
|
+
this._indexMap.delete(dKey);
|
|
59
|
+
if (removeSet.has(node.key)) {
|
|
60
|
+
deleteKeys.push(dKey);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
newChain.push(node);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
{ // last item case
|
|
67
|
+
const lastItem = chain[chain.length - 1];
|
|
68
|
+
this._indexMap.delete(lastItem.__identity__);
|
|
69
|
+
if (removeSet.has(lastItem.key)) {
|
|
70
|
+
if (chain.length > 1) {
|
|
71
|
+
deleteKeys.push(chain[chain.length - 2].__identity__);
|
|
72
|
+
deleteKeys.push(chain[chain.length - 1].__identity__);
|
|
73
|
+
}
|
|
74
|
+
;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
newChain.push(lastItem);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
this._chainMap.set(chainKey, newChain);
|
|
81
|
+
return deleteKeys;
|
|
82
|
+
}
|
|
83
|
+
deleteChainAndReturnChainKeys(chainKey) {
|
|
84
|
+
const keys = this.getNodeKeysOfChain(chainKey);
|
|
85
|
+
this._chainMap.delete(chainKey);
|
|
86
|
+
for (const key of keys)
|
|
87
|
+
this._indexMap.delete(key);
|
|
88
|
+
return keys;
|
|
89
|
+
}
|
|
90
|
+
updateNode(node, chainKey) {
|
|
91
|
+
const index = this.getIndexOfNode(chainKey, node.key);
|
|
92
|
+
const chain = this._chainMap.get(chainKey);
|
|
93
|
+
node.__identity__ = this.keyMethod(chainKey, node.key);
|
|
94
|
+
chain[index] = node;
|
|
95
|
+
}
|
|
96
|
+
updateNodesProperties(chainKey, nodes) {
|
|
97
|
+
nodes.forEach((node) => {
|
|
98
|
+
const index = this.getIndexOfNode(chainKey, node.key);
|
|
99
|
+
const chainNode = this._chainMap.get(chainKey)[index];
|
|
100
|
+
if (node.circleProperties) {
|
|
101
|
+
if (typeof chainNode.circleProperties !== 'object')
|
|
102
|
+
chainNode.circleProperties = {};
|
|
103
|
+
node.circleProperties.forEach((value, key, container) => chainNode.circleProperties[key] = value);
|
|
104
|
+
}
|
|
105
|
+
if (node.lineProperties) {
|
|
106
|
+
if (typeof chainNode.lineProperties !== 'object')
|
|
107
|
+
chainNode.lineProperties = {};
|
|
108
|
+
node.lineProperties.forEach((value, key, container) => chainNode.lineProperties[key] = value);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
updateCoordsinatesOfNode(node, chainKey) {
|
|
113
|
+
const index = this.getIndexOfNode(chainKey, node.key);
|
|
114
|
+
const chain = this._chainMap.get(chainKey);
|
|
115
|
+
chain[index].long = node.long;
|
|
116
|
+
chain[index].lat = node.lat;
|
|
117
|
+
}
|
|
118
|
+
setChain(chainKey, nodeList) {
|
|
119
|
+
if (this._chainMap.has(chainKey))
|
|
120
|
+
this._flushIndexMap();
|
|
121
|
+
this._chainMap.set(chainKey, nodeList);
|
|
122
|
+
nodeList.forEach((v) => v.__identity__ = this.keyMethod(chainKey, v.key));
|
|
123
|
+
}
|
|
124
|
+
setChainProperties(chainKey, properties) {
|
|
125
|
+
this._chainSideProperties.set(chainKey, properties);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @param {string} chainKey
|
|
130
|
+
* @param {Map} properties
|
|
131
|
+
* // after this method update text and buffer data of the chain
|
|
132
|
+
*/
|
|
133
|
+
updateChainProperties(chainKey, properties) {
|
|
134
|
+
const memoryProperties = this._chainSideProperties.get(chainKey);
|
|
135
|
+
properties.forEach((value, key, m) => {
|
|
136
|
+
memoryProperties[key] = value;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
getChainProperties(chainKey) {
|
|
140
|
+
this._chainSideProperties.get(chainKey);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @param {*} chainKey
|
|
145
|
+
* @param {*} callback | (value, index, array) => expexted output
|
|
146
|
+
*/
|
|
147
|
+
calculateBufferPropertiesChain(chainKey, callback, result) {
|
|
148
|
+
const chain = this._chainMap.get(chainKey);
|
|
149
|
+
const props = this._chainSideProperties.get(chainKey);
|
|
150
|
+
for (let i = 0; i < chain.length - 1; i++) {
|
|
151
|
+
const node = callback(chain[i], i, chain, props);
|
|
152
|
+
if (node !== null)
|
|
153
|
+
result.push(node);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* @param {*} chainKey
|
|
158
|
+
* @param {*} textWriterObjs
|
|
159
|
+
* @param {*} nodeKeys use nodeKeys on updateCoordinatesOnly
|
|
160
|
+
*/
|
|
161
|
+
textUpdate(chainKey, textWriterObjs, dataPreAdaptor) {
|
|
162
|
+
const chain = this._chainMap.get(chainKey);
|
|
163
|
+
if (!chain)
|
|
164
|
+
return;
|
|
165
|
+
const data = (dataPreAdaptor) ? chain.map(dataPreAdaptor) : chain;
|
|
166
|
+
const properties = this._chainSideProperties.get(chainKey);
|
|
167
|
+
textWriterObjs.forEach((writer) => {
|
|
168
|
+
writer.insertTextBulk(data, properties);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
getAllChainKeysIterator() {
|
|
172
|
+
return this._chainMap.keys();
|
|
173
|
+
}
|
|
174
|
+
getIndexOfNode(chainKey, nodeKey) {
|
|
175
|
+
const key = this.keyMethod(chainKey, nodeKey);
|
|
176
|
+
if (this._indexMap.has(key))
|
|
177
|
+
return this._indexMap.get(key);
|
|
178
|
+
const chain = this._chainMap.get(chainKey);
|
|
179
|
+
for (let i = 0; i < chain.length; i++) {
|
|
180
|
+
const node = chain[i];
|
|
181
|
+
this._indexMap.set(key, i);
|
|
182
|
+
if (node.key === nodeKey) {
|
|
183
|
+
return i;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
_flushIndexMap() {
|
|
188
|
+
this._indexMap.clear();
|
|
189
|
+
}
|
|
190
|
+
_resetIndexChain(chainKey) {
|
|
191
|
+
const chain = this._chainMap.get(chainKey);
|
|
192
|
+
for (let i = 0; i < chain.length; i++) {
|
|
193
|
+
const node = chain[i];
|
|
194
|
+
this._indexMap.set(this.keyMethod(chainKey, node.key), i);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
getNodeKeysOfChain(chainKey) {
|
|
198
|
+
const chain = this._chainMap.get(chainKey);
|
|
199
|
+
if (!chain)
|
|
200
|
+
return [];
|
|
201
|
+
const result = chain.map((v) => v.__identity__);
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.ChainListMap = ChainListMap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|