@pirireis/webglobeplugins 0.4.2-a → 0.5.0
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.
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { keyMethod } from "./util";
|
|
2
1
|
/**
|
|
3
2
|
* set and get node data
|
|
4
3
|
* node indexes;
|
|
5
4
|
*/
|
|
6
5
|
export class ChainListMap {
|
|
7
6
|
|
|
8
|
-
constructor() {
|
|
7
|
+
constructor(keyMethod) {
|
|
9
8
|
this._chainMap = new Map();
|
|
10
9
|
this._chainSideProperties = new Map();
|
|
11
10
|
this._indexMap = new Map(); // hold list index of lastly updated nodes. on add delete goes empty
|
|
11
|
+
this.keyMethod = keyMethod;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
getChain(chainKey) {
|
|
15
15
|
if (!this._chainMap.has(chainKey)) this._chainMap.set(chainKey, []);
|
|
16
16
|
return this._chainMap.get(chainKey);
|
|
17
|
+
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -35,6 +36,7 @@ export class ChainListMap {
|
|
|
35
36
|
break;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
node.identity = this.keyMethod(chainKey, node.key);
|
|
38
40
|
this._resetIndexChain(chainKey);
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -51,7 +53,7 @@ export class ChainListMap {
|
|
|
51
53
|
const removeSet = new Set(nodeKeys);
|
|
52
54
|
const newChain = []
|
|
53
55
|
for (const node of chain) {
|
|
54
|
-
const dKey =
|
|
56
|
+
const dKey = node.identity;
|
|
55
57
|
this._indexMap.delete(dKey);
|
|
56
58
|
if (removeSet.has(node.key)) {
|
|
57
59
|
compKeys.push(dKey);
|
|
@@ -65,7 +67,6 @@ export class ChainListMap {
|
|
|
65
67
|
|
|
66
68
|
deleteChainAndReturnChainKeys(chainKey) {
|
|
67
69
|
const keys = this.getNodeKeysOfChain(chainKey);
|
|
68
|
-
console.log('chainKey', chainKey, "keys", keys);
|
|
69
70
|
this._chainMap.delete(chainKey);
|
|
70
71
|
for (const key of keys) this._indexMap.delete(key);
|
|
71
72
|
return keys;
|
|
@@ -74,6 +75,7 @@ export class ChainListMap {
|
|
|
74
75
|
updateNode(node, chainKey) {
|
|
75
76
|
const index = this.getIndexOfNode(chainKey, node.key)
|
|
76
77
|
const chain = this._chainMap.get(chainKey);
|
|
78
|
+
node.identity = this.keyMethod(chainKey, node.key);
|
|
77
79
|
chain[index] = node;
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -81,6 +83,7 @@ export class ChainListMap {
|
|
|
81
83
|
setChain(chainKey, nodeList) {
|
|
82
84
|
if (this._chainMap.has(chainKey)) this._flushIndexMap();
|
|
83
85
|
this._chainMap.set(chainKey, nodeList);
|
|
86
|
+
nodeList.forEach((v) => v.identity = this.keyMethod(chainKey, v.key))
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
|
|
@@ -151,7 +154,7 @@ export class ChainListMap {
|
|
|
151
154
|
|
|
152
155
|
|
|
153
156
|
getIndexOfNode(chainKey, nodeKey) {
|
|
154
|
-
const key = keyMethod(chainKey, nodeKey);
|
|
157
|
+
const key = this.keyMethod(chainKey, nodeKey);
|
|
155
158
|
if (this._indexMap.has(key)) return this._indexMap.get(key);
|
|
156
159
|
|
|
157
160
|
const chain = this._chainMap.get(chainKey);
|
|
@@ -172,16 +175,14 @@ export class ChainListMap {
|
|
|
172
175
|
const chain = this._chainMap.get(chainKey);
|
|
173
176
|
for (let i = 0; i < chain.length; i++) {
|
|
174
177
|
const node = chain[i]
|
|
175
|
-
this._indexMap.set(keyMethod(chainKey, node.key), i);
|
|
178
|
+
this._indexMap.set(this.keyMethod(chainKey, node.key), i);
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
|
|
179
182
|
getNodeKeysOfChain(chainKey) {
|
|
180
183
|
const chain = this._chainMap.get(chainKey);
|
|
181
|
-
console.log("node keys", chain);
|
|
182
184
|
if (!chain) return [];
|
|
183
|
-
const result = chain.map((v) =>
|
|
184
|
-
console.log("buffer Keys", result);
|
|
185
|
+
const result = chain.map((v) => v.identity);
|
|
185
186
|
return result
|
|
186
187
|
}
|
|
187
188
|
|
|
@@ -2,8 +2,7 @@ import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
|
|
|
2
2
|
import { CircleCache } from '../programs/line-on-globe/circle';
|
|
3
3
|
import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
4
4
|
import { ChainListMap } from "./chain-list-map";
|
|
5
|
-
import { keyMethod } from
|
|
6
|
-
|
|
5
|
+
import { keyMethod } from './util';
|
|
7
6
|
// TODO: Add update buffer and update text mehods on add, delete, update methods
|
|
8
7
|
|
|
9
8
|
|
|
@@ -29,9 +28,9 @@ export class CircleLineChainPlugin {
|
|
|
29
28
|
constructor(id, { textContextWriterInjectionMap = new Map() } = {}) {
|
|
30
29
|
this.id = id;
|
|
31
30
|
this._textContextWriterInjectionMap = textContextWriterInjectionMap;
|
|
32
|
-
this._textContextWriterInjectionMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, probs) =>
|
|
31
|
+
this._textContextWriterInjectionMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, probs) => v.identity));
|
|
33
32
|
this._opacity = 1;
|
|
34
|
-
this._chainListMap = new ChainListMap();
|
|
33
|
+
this._chainListMap = new ChainListMap(keyMethod);
|
|
35
34
|
this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
|
|
36
35
|
}
|
|
37
36
|
|
|
@@ -107,7 +106,6 @@ export class CircleLineChainPlugin {
|
|
|
107
106
|
* @typedef chain
|
|
108
107
|
* @property {string} chainKey
|
|
109
108
|
* @property {Array<node>} nodes
|
|
110
|
-
*
|
|
111
109
|
* @typedef {Object} node
|
|
112
110
|
* @property {string} key
|
|
113
111
|
* @property {number} long
|
|
@@ -183,7 +181,6 @@ export class CircleLineChainPlugin {
|
|
|
183
181
|
*/
|
|
184
182
|
addNode(node, chainKey, { theNodeKeyFront = null, textWriterIDs = [] } = {}) {
|
|
185
183
|
// TODO: if before object is null update the last two elements of the chain only.
|
|
186
|
-
console.log("addNode", node, chainKey, theNodeKeyFront);
|
|
187
184
|
this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
|
|
188
185
|
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
189
186
|
this._reconstructChains([chainKey]);
|
|
@@ -219,8 +216,6 @@ export class CircleLineChainPlugin {
|
|
|
219
216
|
for (const chainKey of chainKeys) {
|
|
220
217
|
bufferKeys.push(...this._chainListMap.deleteChainAndReturnChainKeys(chainKey));
|
|
221
218
|
}
|
|
222
|
-
console.log("delete chain keys", chainKeys);
|
|
223
|
-
console.log("deletechains bufferKeys", bufferKeys);
|
|
224
219
|
this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
|
|
225
220
|
this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
|
|
226
221
|
this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
|
|
@@ -277,7 +272,7 @@ export class CircleLineChainPlugin {
|
|
|
277
272
|
lat: v.lat,
|
|
278
273
|
targetLong: array[i + 1].long,
|
|
279
274
|
targetLat: array[i + 1].lat,
|
|
280
|
-
key:
|
|
275
|
+
key: v.identity
|
|
281
276
|
}
|
|
282
277
|
}
|
|
283
278
|
const bulkData = [];
|
package/package.json
CHANGED
|
File without changes
|