@pirireis/webglobeplugins 0.1.4 → 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.
@@ -29,11 +29,11 @@ const object = {
29
29
  "text": "'${title}'",
30
30
  "textCallback": null,
31
31
  "offset": {
32
- "x": 16,
33
- "y": -16
32
+ "x": 0,
33
+ "y": 0
34
34
  },
35
- "vAlignment": 0,
36
- "hAlignment": 0,
35
+ "vAlignment": 2,
36
+ "hAlignment": 2,
37
37
  "size": 20,
38
38
  "hollowColor": "#000",
39
39
  "textColor": "#FFF",
@@ -208,37 +208,6 @@ const setFIDKey = (object, key) => {
208
208
  object.style.fidKey = key;
209
209
  }
210
210
 
211
- const IMAGE_URL = "10494_1024px-compass-rose-simple.svg.png";
212
-
213
- export class RotationalIcon2D {
214
- constructor(id, globe) {
215
- this.id = id;
216
- this.globe = globe;
217
- this.objectType = CSObjectTypes.POINT;
218
- const symbolSet = "symbolSetName";
219
- // copy object
220
- this.object = object;
221
- this.setData(
222
- [
223
- {
224
- coords: [32, 40, 34, 42, 35, 41],
225
- coordsZ: [0, 0, 0],
226
- attribs: [
227
- ]
228
- }
229
- ]
230
- )
231
- setIconSize(this.object, 100);
232
- setMapName(this.object, symbolSet);
233
- setIconName(this.object, symbolSet);
234
- addSingleImageIconMap(symbolSet)(IMAGE_URL);
235
- globe.ObjectArray.Add(this.object);
236
- }
237
- setData(data) {
238
- const { globe, object } = this;
239
- setData(object, data);
240
- }
241
- }
242
211
 
243
212
 
244
213
  export default class CompassRose {
@@ -1,3 +1,2 @@
1
1
  import CompassRose from "./compassrose";
2
- import { RotationalIcon2D } from "./compassrose";
3
- export { CompassRose, RotationalIcon2D };
2
+ export { CompassRose };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.1.4",
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, { 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 });
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;
@@ -85,11 +94,10 @@ export default class RangeRingAngleText {
85
94
 
86
95
  free() {
87
96
  this.flush();
88
- this.ObjectArray.RemoveObject(this.object);
97
+ this.ObjectArray.Delete(this.id);
89
98
  }
90
99
 
91
100
 
92
-
93
101
  /**
94
102
  * @param {Array<{centerID,stepAngle, x, y, rings>} ringDatas
95
103
  * centerID: string | ObjectArray fidKey de kullanilir
@@ -101,7 +109,7 @@ export default class RangeRingAngleText {
101
109
  *
102
110
  * */
103
111
  insertBulk(ringDatas) {
104
-
112
+ const { _hideAll } = this;
105
113
  const addBucket = {
106
114
  coords: [],
107
115
  coordsZ: [],
@@ -119,7 +127,8 @@ export default class RangeRingAngleText {
119
127
  this._fillDeleteBucket(centerID, deleteBucket);
120
128
  }
121
129
  const maxRadius = rings.reduce((acc, { radius }) => Math.max(acc, radius), 0);
122
- 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;
123
132
  if (show) this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
124
133
  this._centerCollection.set(centerID,
125
134
  new Map([
@@ -128,10 +137,10 @@ export default class RangeRingAngleText {
128
137
  ["x", x],
129
138
  ["y", y],
130
139
  ["hide", hide],
131
- ["textHide", textHide]
140
+ ["textHide", textHide_]
132
141
  ]));
133
142
  }
134
-
143
+ if (this._hideAll) return;
135
144
  if (deleteBucket.coords.length > 0) this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
136
145
  if (addBucket.coords.length > 0) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
137
146
 
@@ -150,18 +159,22 @@ export default class RangeRingAngleText {
150
159
  for (const { centerID, x, y } of centerDatas) {
151
160
  if (this._centerCollection.has(centerID)) {
152
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;
153
168
  const maxRadius = centerMap.get("maxRadius");
154
169
  const stepAngle = centerMap.get("stepAngle");
155
170
  // long, lat, radius, step, centerID, outBucket
156
171
  this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
157
- centerMap.set("x", x);
158
- centerMap.set("y", y);
159
172
 
160
173
  }
161
174
  }
162
- for (const attribs of updateBucket.attribs) {
163
- delete attribs["aci"];
164
- }
175
+ // for (const attribs of updateBucket.attribs) {
176
+ // delete attribs["aci"];
177
+ // }
165
178
  if (updateBucket.coords.length > 0) {
166
179
  this._updateData(updateBucket, CSObjectArrayUpdateTypes.UPDATE);
167
180
  }
@@ -174,6 +187,10 @@ export default class RangeRingAngleText {
174
187
  * @param {Array<{centerID:string, hide: bool}} centerHides
175
188
  */
176
189
  updateCentersHide(centerHides) {
190
+ if (this._hideAll) {
191
+ console.warn("Tum mesafe halkasi yazilari gizli durum. Islem yapilamaz");
192
+ return;
193
+ };
177
194
  const addBucket = {
178
195
  coords: [],
179
196
  coordsZ: [],
@@ -224,6 +241,46 @@ export default class RangeRingAngleText {
224
241
  }
225
242
 
226
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
+ }
227
284
 
228
285
 
229
286
 
@@ -22,15 +22,17 @@ 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;
32
33
  }
33
34
 
35
+
34
36
  setOneDegreePaddingOn(oneDegreePadding) {
35
37
  this._onedegreepaddingOn = oneDegreePadding;
36
38
  }
@@ -42,7 +44,8 @@ export default class {
42
44
  this.paddyFlatProgram = new PaddyFlatProgram(globe, gl);
43
45
  this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
44
46
  if (this._showNumbers) {
45
- this._textPlugin = new RangeRingAngleText(globe, { flatCompassMode: this.compass });
47
+ this.textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass, style: this._numbersStyle });
48
+ delete this._numbersStyle;
46
49
  }
47
50
  }
48
51
 
@@ -50,16 +53,15 @@ export default class {
50
53
  free() {
51
54
  this.circleFlatProgram.free();
52
55
  this.paddyFlatProgram.free();
53
- if (this.bufferManager !== null) {
54
- this.bufferManager.free();
55
- }
56
+ this.bufferManager?.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
  }