@pirireis/webglobeplugins 0.15.7-alpha → 0.15.9-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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.15.7-alpha",
3
+ "version": "0.15.9-alpha",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -9,12 +9,11 @@ export const circleDataAdaptor = (globe, chain) => {
9
9
  const { chainKey, chainProperties, nodes } = chain;
10
10
  for (let i = 0; i < nodes.length - 1; i++) {
11
11
  const node = nodes[i];
12
- const { key, long, lat, circleProperties } = node;
13
- const color = circleProperties?.rgba ?? chainProperties.rgba ?? [1, 1, 1, 1]; // Default color if not specified
14
- if (key === "Sakarya") {
15
- console.log("circleProperties", circleProperties, "chainProperties", chainProperties);
16
- console.log("Sakarya color", color);
17
- }
12
+ // const circleOn = nodes[i + 1]?.circleOn ?? true; // Default to true if not specified
13
+ const { key, long, lat, circleProperties, circleOn = true } = node;
14
+ if (!circleOn)
15
+ continue; // Skip if circle is not enabled for this node
16
+ const color = circleProperties?.rgba ?? chainProperties.rgba ?? [1, 1, 1, 1]; // Default color if not specifie
18
17
  const radius = globe.Math.GetDist2D(long, lat, nodes[i + 1].long, nodes[i + 1].lat);
19
18
  const nodeKey = keyMethod(chainKey, key);
20
19
  circleInputs.push({
@@ -32,8 +31,11 @@ export function arcDataAdaptor(chain) {
32
31
  const { chainKey, chainProperties, nodes } = chain;
33
32
  for (let i = 0; i < nodes.length - 1; i++) {
34
33
  const node = nodes[i];
34
+ // const arcOn = nodes[i + 1]?.arcOn ?? true; // Default to true if not specified
35
35
  const nextNode = nodes[i + 1];
36
- const { key, long, lat, lineProperties } = node;
36
+ const { key, long, lat, lineProperties, arcOn = true } = node;
37
+ if (!arcOn)
38
+ continue; // Skip if arc is not enabled for this node
37
39
  const nodeKey = keyMethod(chainKey, key);
38
40
  const { long: nextLong, lat: nextLat } = nextNode;
39
41
  const color = lineProperties?.rgba ?? chainProperties.rgba ?? [1, 1, 1, 1]; // Default color if not specified
@@ -53,7 +55,10 @@ export function lineDataAdaptor(chain) {
53
55
  for (let i = 0; i < nodes.length - 1; i++) {
54
56
  const node = nodes[i];
55
57
  const nextNode = nodes[i + 1];
56
- const { key, long, lat, lineProperties } = node;
58
+ // const lineOn = nextNode?.lineOn ?? true; // Default to true if not specified
59
+ const { key, long, lat, lineProperties, lineOn = true } = node;
60
+ if (!lineOn)
61
+ continue; // Skip if line is not enabled for this node
57
62
  const nodeKey = keyMethod(chainKey, key);
58
63
  const { long: nextLong, lat: nextLat } = nextNode;
59
64
  const color = lineProperties?.rgba ?? chainProperties.rgba ?? [1, 1, 1, 1]; // Default color if not specified
@@ -114,13 +114,13 @@ export class ChainListMap {
114
114
  chain[index] = node;
115
115
  }
116
116
  updateNodesProperties(chainKey, nodes) {
117
+ const chain = this._chainMap.get(chainKey);
118
+ if (!chain)
119
+ return;
117
120
  nodes.forEach((node) => {
118
121
  const index = this.getIndexOfNode(chainKey, node.key);
119
122
  if (index === undefined)
120
123
  return;
121
- const chain = this._chainMap.get(chainKey);
122
- if (!chain)
123
- return;
124
124
  const chainNode = chain[index];
125
125
  if (node.circleProperties) {
126
126
  if (typeof chainNode.circleProperties !== 'object')
@@ -136,6 +136,12 @@ export class ChainListMap {
136
136
  chainNode.lineProperties[key] = value;
137
137
  });
138
138
  }
139
+ if (node.circleOn !== undefined)
140
+ chainNode.circleOn = node.circleOn;
141
+ if (node.arcOn !== undefined)
142
+ chainNode.arcOn = node.arcOn;
143
+ if (node.lineOn !== undefined)
144
+ chainNode.lineOn = node.lineOn;
139
145
  });
140
146
  }
141
147
  updateCoordsinatesOfNode(node, chainKey) {
@@ -116,11 +116,17 @@ export class CircleLineChainPlugin {
116
116
  if (this._chainListMap.hasChain(chainKey)) {
117
117
  chainsToClean.push(chainKey);
118
118
  }
119
+ }
120
+ this._cleanChainsFromSemiPlugins(chainsToClean);
121
+ for (const { chainKey, chainProperties, nodes } of chains) {
122
+ if (!chainKey || !chainProperties || !nodes || nodes.length === 0) {
123
+ console.warn("Invalid chain data, skipping insertion.");
124
+ continue;
125
+ }
119
126
  this._chainListMap.setChain(chainKey, nodes);
120
127
  this._chainListMap.setChainProperties(chainKey, chainProperties);
121
128
  chainKeys.push(chainKey);
122
129
  }
123
- this._cleanChainsFromSemiPlugins(chainsToClean);
124
130
  // Reconstruct chains
125
131
  this._reconstructChains(chainKeys);
126
132
  // Update texts
@@ -191,17 +197,44 @@ export class CircleLineChainPlugin {
191
197
  this._updateTexts(chainKeysToReconstruct, Array.from(this._textWritersMap.keys()));
192
198
  this.globe?.DrawRender();
193
199
  }
194
- updateNodesProperties(chainKey, nodesAndPropertyMap, { textWriterIDs = [] } = {}) {
200
+ updateNodesProperties(chainKey, nodesAndPropertyList, { textWriterIDs = [] } = {}) {
195
201
  if (this._freed) {
196
202
  console.warn("CircleLineChainPlugin is freed, cannot update nodes properties.");
197
203
  return;
198
204
  }
199
- this._chainListMap.updateNodesProperties(chainKey, nodesAndPropertyMap);
205
+ this._chainListMap.updateNodesProperties(chainKey, nodesAndPropertyList);
200
206
  this._cleanChainsFromSemiPlugins([chainKey]);
201
207
  this._reconstructChains([chainKey]);
202
208
  this._updateTexts([chainKey], textWriterIDs);
203
209
  this.globe?.DrawRender();
204
210
  }
211
+ updateChainDrawOptionsProperties(chainKey, drawOptions) {
212
+ if (this._freed) {
213
+ console.warn("CircleLineChainPlugin is freed, cannot update chain draw options properties.");
214
+ return;
215
+ }
216
+ const chain = this._chainListMap.getChain(chainKey);
217
+ if (!chain) {
218
+ console.warn(`Chain with key ${chainKey} not found.`);
219
+ return;
220
+ }
221
+ const { nodes } = chain;
222
+ nodes.forEach((node) => {
223
+ if (drawOptions.circleOn !== undefined) {
224
+ node.circleOn = drawOptions.circleOn;
225
+ }
226
+ if (drawOptions.arcOn !== undefined) {
227
+ node.arcOn = drawOptions.arcOn;
228
+ }
229
+ if (drawOptions.line !== undefined) {
230
+ node.lineOn = drawOptions.line;
231
+ }
232
+ });
233
+ this._cleanChainsFromSemiPlugins([chainKey]);
234
+ this._reconstructChains([chainKey]);
235
+ this._updateTexts([chainKey], Array.from(this._textWritersMap.keys()));
236
+ this.globe?.DrawRender();
237
+ }
205
238
  updateCoordinatesBulk(chains, { textWriterIDs = [] } = {}) {
206
239
  if (this._freed) {
207
240
  console.warn("CircleLineChainPlugin is freed, cannot update coordinates.");