@pirireis/webglobeplugins 0.1.5 → 0.1.6

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.1.5",
3
+ "version": "0.1.6",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -17,9 +17,8 @@ const fidKey = "__fid__";
17
17
 
18
18
 
19
19
  const object = {
20
- "displayName": "CompassRose",
20
+ "displayName": "RangeRingAngleText",
21
21
  "layerType": 3,
22
-
23
22
  "wkbGeom": null,
24
23
  "wfsLayerName": null,
25
24
  "objectType": "point",
@@ -33,38 +32,17 @@ const object = {
33
32
 
34
33
 
35
34
  export default class RangeRingAngleText {
36
- constructor(globe, id, { style = null, flatCompassMode = COMPASS_MODES.REAL } = {}) {
35
+ constructor(globe, id, { style = null, flatCompassMode = COMPASS_MODES.REAL, hideAll = false } = {}) {
37
36
  this.globe = globe;
38
37
  this.ObjectArray = globe.ObjectArray;
39
38
  this.id = id;
40
39
  this._flatCompassMode = flatCompassMode;
41
40
  this._lastImplicitCompassMode = this.__implicitCompassMode();
42
- if (style) {
43
- this.style = style;
44
- } else {
45
- this.style = this.ObjectArray.GetDefaultStyle();
46
- const { labels } = this.style;
47
- const label = labels[0];
48
- label.offset = { x: 0, y: 0 };
49
- label.fontFamily.hollowWidth = 1;
50
- label.vAlignment = 2;
51
- label.hAlignment = 2;
52
- label.size = 17;
53
- // this.style.filter = [
54
- // {
55
- // rule: ["any", ["<", "startLod", "LOD"]],
56
- // name: "startLODRule",
57
- // style: {
58
- // opacity: 0
59
- // }
60
-
61
- // }
62
- // ];
63
- }
64
41
 
65
- this.style.labels[0].text = "`${aci}`"
66
- this.style.fidKey = fidKey;
67
- this.object = Object.assign({}, object, { style: this.style, id: this.id });
42
+ this._hideAll = hideAll;
43
+
44
+ const style_ = style !== null ? style : this.getDefaultStyle();
45
+ this.object = Object.assign({}, object, { style: style_, id: this.id });
68
46
 
69
47
  this._centerCollection = new Map();
70
48
  // new inner MAP params
@@ -75,6 +53,37 @@ export default class RangeRingAngleText {
75
53
 
76
54
  }
77
55
 
56
+ getDefaultStyle() {
57
+ const style = this.ObjectArray.GetDefaultStyle();
58
+ style.fidKey = fidKey;
59
+ const { labels } = style;
60
+ const label = labels[0];
61
+ label.offset = { x: 0, y: 0 };
62
+ label.fontFamily.hollowWidth = 1;
63
+ label.vAlignment = 2;
64
+ label.hAlignment = 2;
65
+ label.size = 17;
66
+ label.text = "`${aci}`"
67
+ // this.style.filter = [
68
+ // {
69
+ // rule: ["any", ["<", "startLod", "LOD"]],
70
+ // name: "startLODRule",
71
+ // style: {
72
+ // opacity: 0
73
+ // }
74
+
75
+ // }
76
+ // ];
77
+ return style;
78
+ }
79
+
80
+
81
+ setStyle(style) {
82
+ if (style === null) return;
83
+ this.object.style = style;
84
+ this.ObjectArray.StyleChanged(this.object);
85
+ }
86
+
78
87
 
79
88
  setCompass(mode) {
80
89
  if (mode === this._flatCompassMode) return;
@@ -100,7 +109,7 @@ export default class RangeRingAngleText {
100
109
  *
101
110
  * */
102
111
  insertBulk(ringDatas) {
103
-
112
+ const { _hideAll } = this;
104
113
  const addBucket = {
105
114
  coords: [],
106
115
  coordsZ: [],
@@ -118,7 +127,8 @@ export default class RangeRingAngleText {
118
127
  this._fillDeleteBucket(centerID, deleteBucket);
119
128
  }
120
129
  const maxRadius = rings.reduce((acc, { radius }) => Math.max(acc, radius), 0);
121
- const show = hide !== ENUM_HIDE.HIDE && textHide === ENUM_TEXT_HIDE.SHOW;
130
+ const textHide_ = _hideAll ? ENUM_TEXT_HIDE.HIDE : textHide;
131
+ const show = hide !== ENUM_HIDE.HIDE && textHide_ === ENUM_TEXT_HIDE.SHOW;
122
132
  if (show) this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
123
133
  this._centerCollection.set(centerID,
124
134
  new Map([
@@ -127,10 +137,10 @@ export default class RangeRingAngleText {
127
137
  ["x", x],
128
138
  ["y", y],
129
139
  ["hide", hide],
130
- ["textHide", textHide]
140
+ ["textHide", textHide_]
131
141
  ]));
132
142
  }
133
-
143
+ if (this._hideAll) return;
134
144
  if (deleteBucket.coords.length > 0) this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
135
145
  if (addBucket.coords.length > 0) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
136
146
 
@@ -149,18 +159,22 @@ export default class RangeRingAngleText {
149
159
  for (const { centerID, x, y } of centerDatas) {
150
160
  if (this._centerCollection.has(centerID)) {
151
161
  const centerMap = this._centerCollection.get(centerID);
162
+ centerMap.set("x", x);
163
+ centerMap.set("y", y);
164
+ const hide = centerMap.get("hide");
165
+ const textHide = centerMap.get("textHide");
166
+ const isHidden = hide === ENUM_HIDE.HIDE || textHide === ENUM_TEXT_HIDE.HIDE;
167
+ if (isHidden) continue;
152
168
  const maxRadius = centerMap.get("maxRadius");
153
169
  const stepAngle = centerMap.get("stepAngle");
154
170
  // long, lat, radius, step, centerID, outBucket
155
171
  this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
156
- centerMap.set("x", x);
157
- centerMap.set("y", y);
158
172
 
159
173
  }
160
174
  }
161
- for (const attribs of updateBucket.attribs) {
162
- delete attribs["aci"];
163
- }
175
+ // for (const attribs of updateBucket.attribs) {
176
+ // delete attribs["aci"];
177
+ // }
164
178
  if (updateBucket.coords.length > 0) {
165
179
  this._updateData(updateBucket, CSObjectArrayUpdateTypes.UPDATE);
166
180
  }
@@ -173,6 +187,10 @@ export default class RangeRingAngleText {
173
187
  * @param {Array<{centerID:string, hide: bool}} centerHides
174
188
  */
175
189
  updateCentersHide(centerHides) {
190
+ if (this._hideAll) {
191
+ console.warn("Tum mesafe halkasi yazilari gizli durum. Islem yapilamaz");
192
+ return;
193
+ };
176
194
  const addBucket = {
177
195
  coords: [],
178
196
  coordsZ: [],
@@ -223,6 +241,46 @@ export default class RangeRingAngleText {
223
241
  }
224
242
 
225
243
 
244
+ hideAll() {
245
+ this._hideAll = true;
246
+ const deleteBucket = {
247
+ coords: [],
248
+ coordsZ: [],
249
+ attribs: []
250
+ }
251
+ for (const [centerID, centerMap] of this._centerCollection) {
252
+ const hide = centerMap.get("hide");
253
+ const hideText = centerMap.get("textHide");
254
+ const isHidden = hide === ENUM_HIDE.HIDE || hideText === ENUM_TEXT_HIDE.HIDE;
255
+ if (!isHidden) this._fillDeleteBucket(centerID, deleteBucket);
256
+ centerMap.set("hide", ENUM_HIDE.HIDE);
257
+ }
258
+ this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
259
+ }
260
+
261
+ showAll() {
262
+ this._hideAll = false;
263
+ const addBucket = {
264
+ coords: [],
265
+ coordsZ: [],
266
+ attribs: []
267
+ }
268
+ for (const [centerID, centerMap] of this._centerCollection) {
269
+ const hide = centerMap.get("hide");
270
+ const hideText = centerMap.get("textHide");
271
+ const isHidden = hide === ENUM_HIDE.HIDE || hideText === ENUM_TEXT_HIDE.HIDE;
272
+ if (isHidden) {
273
+ const x = centerMap.get("x");
274
+ const y = centerMap.get("y");
275
+ const maxRadius = centerMap.get("maxRadius");
276
+ const stepAngle = centerMap.get("stepAngle");
277
+ this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
278
+ centerMap.set("hide", ENUM_HIDE.SHOW);
279
+ centerMap.set("textHide", ENUM_TEXT_HIDE.SHOW);
280
+ }
281
+ }
282
+ if (addBucket.coords.length) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
283
+ }
226
284
 
227
285
 
228
286
 
@@ -22,10 +22,11 @@ const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
22
22
 
23
23
  export default class {
24
24
 
25
- constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.COMPASS, showNumbers = true } = {}) {
25
+ constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.REAL, showNumbers = true, numbersStyle = null } = {}) {
26
26
  this.id = id;
27
27
  this.compass = compass;
28
28
  this._showNumbers = showNumbers;
29
+ this._numbersStyle = numbersStyle;
29
30
  this.circleEdgeCount = 360;
30
31
  this._onedegreepaddingOn = oneDegreePadding;
31
32
  this.bufferManager = null;
@@ -43,7 +44,8 @@ export default class {
43
44
  this.paddyFlatProgram = new PaddyFlatProgram(globe, gl);
44
45
  this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
45
46
  if (this._showNumbers) {
46
- this._textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass });
47
+ this.textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass, style: this._numbersStyle });
48
+ delete this._numbersStyle;
47
49
  }
48
50
  }
49
51
 
@@ -52,14 +54,14 @@ export default class {
52
54
  this.circleFlatProgram.free();
53
55
  this.paddyFlatProgram.free();
54
56
  this.bufferManager?.free();
55
- this._textPlugin?.free();
57
+ this.textPlugin?.free();
56
58
  }
57
59
 
58
60
 
59
61
 
60
62
 
61
63
  setGeometry() {
62
- this._textPlugin?.setGeometry();
64
+ this.textPlugin?.setGeometry();
63
65
  }
64
66
 
65
67
 
@@ -87,7 +89,7 @@ export default class {
87
89
  */
88
90
  setCampass(compass) {
89
91
  this.compass = compass;
90
- this._textPlugin?.setCompass(compass);
92
+ this.textPlugin?.setCompass(compass);
91
93
  }
92
94
 
93
95
  initilizeBufferManager(initialRingCapacity, bufferDrawType) {
@@ -110,7 +112,7 @@ export default class {
110
112
  item.paddingAngles = angleToPaddingAngles(item.stepAngle, 0);
111
113
  }
112
114
  this.paddingBufferManager.insertBulk(items);
113
- this._textPlugin?.insertBulk(items);
115
+ this.textPlugin?.insertBulk(items);
114
116
  this.globe.DrawRender();
115
117
  }
116
118
 
@@ -118,7 +120,7 @@ export default class {
118
120
  updateCentersXY(items) {
119
121
  this.bufferManager.updateCentersXY(items);
120
122
  this.paddingBufferManager.updateCentersXY(items);
121
- this._textPlugin?.updateCentersXY(items);
123
+ this.textPlugin?.updateCentersXY(items);
122
124
  this.globe.DrawRender();
123
125
  }
124
126
 
@@ -134,7 +136,7 @@ export default class {
134
136
  removeCenters(centerIds) {
135
137
  this.bufferManager.removeCenters(centerIds);
136
138
  this.paddingBufferManager.removeCenters(centerIds);
137
- this._textPlugin?.removeCenters(centerIds);
139
+ this.textPlugin?.removeCenters(centerIds);
138
140
  // this.bufferManager.defrag();
139
141
  // this.paddingBufferManager.defrag();
140
142
  this.globe.DrawRender();
@@ -145,7 +147,7 @@ export default class {
145
147
  updateCentersHide(centerHides) {
146
148
  this.bufferManager.updateCentersHide(centerHides);
147
149
  this.paddingBufferManager.updateCentersHide(centerHides);
148
- this._textPlugin?.updateCentersHide(centerHides);
150
+ this.textPlugin?.updateCentersHide(centerHides);
149
151
  this.globe.DrawRender();
150
152
  }
151
153
  }