@pirireis/webglobeplugins 0.0.1 → 0.0.2

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,4 +1,3 @@
1
1
  import ArrowField from "./plugin";
2
2
  import { centigradePlus90ToRadians } from "./adaptor";
3
- export default ArrowField;
4
- export { centigradePlus90ToRadians };
3
+ export { ArrowField, centigradePlus90ToRadians };
@@ -14,26 +14,12 @@ import {
14
14
  GlobeManager
15
15
  } from "@pirireis/webglobe";
16
16
 
17
-
18
-
19
-
20
-
21
17
  const object = {
22
- "displayName": "rotaionalIcon",
18
+ "displayName": "CompassRose",
23
19
  "layerType": 3,
24
- "objectParams": {
25
- "Fid": null,
26
- "sx": 10,
27
- "sy": 10,
28
- "sz": 10,
29
- "rotXY": 0,
30
- "rotZ": 0,
31
- "rotRoll": 0,
32
- "objUrl": "https://mhs.pirireis.com.tr/models/TB2.obj"
33
- },
20
+
34
21
  "wkbGeom": null,
35
22
  "wfsLayerName": null,
36
- "url": "https://servis.pirireis.com.tr/sqlpg254/GPbf/{z}/{x}/{y}.pbf?enc=DsTX5MTbGW7dp1PyxvvB8ij2DTP2ZPG3i5ZU2ZRrOu%2BwYra1uZp3LfP5V2lio19C54EiV69032fs1L9vfnl4O%2Bw4LLO39n8K%2BPfWW%2FNsQg0%3D",
37
23
  "style": {
38
24
  "labels": [
39
25
  {
@@ -213,24 +199,56 @@ const setData = (object, data) => {
213
199
  object.data = data;
214
200
  }
215
201
 
216
- const IMAGE_URL = "10494_1024px-compass-rose-simple.svg.png";
217
202
 
218
203
  const addSingleImageIconMap = symbolSet => url => {
219
204
  GlobeManager.api_AddIconMap(symbolSet, url, null);
205
+ }
220
206
 
207
+ const setFIDKey = (object, key) => {
208
+ object.style.fidKey = key;
221
209
  }
222
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
+ }
223
242
 
224
243
 
225
244
  export default class CompassRose {
226
- constructor(id, globe, { size = 100, symbolSet = "compassRose", iconSet = null, imageURL = null, data = null }) {
245
+ constructor(id, globe, { size = 100, primaryKey = "__key__", symbolSet = "compassRose", iconSet = null, imageURL = null, data = null }) {
227
246
 
228
247
  this.id = id;
229
248
  this.globe = globe;
230
-
231
249
  this._idCollector = new Set();
232
250
 
233
- this.primaryKey = "__key__";
251
+ this.primaryKey = primaryKey;
234
252
 
235
253
  this.object = Object.assign({}, object);
236
254
 
@@ -239,156 +257,117 @@ export default class CompassRose {
239
257
  addSingleImageIconMap(symbolSet)(imageURL);
240
258
  }
241
259
 
242
- if (data) {
243
- setData(this.object, data);
244
- }
245
-
246
260
  setMapName(this.object, symbolSet);
247
- setIconName(this.object, iconSet | symbolSet);
261
+ setIconName(this.object, symbolSet);
262
+ setFIDKey(this.object, primaryKey);
248
263
  globe.ObjectArray.Add(this.object);
249
- }
250
264
 
251
- setData(data) {
252
- setData(this.object, data);
265
+ if (data) this.setControlledData(data);
253
266
  }
254
267
 
268
+
255
269
  setIconSize(size) {
256
270
  const { object, globe } = this;
257
271
  setIconSize(object, size);
258
-
259
- const canChange = {
260
- attribs: false,
261
- icon: true,
262
- label: false,
263
- heading: false,
264
- }
265
-
266
- globe.ObjectArray.UpdateData(object, CSObjectArrayUpdateTypes.UPDATE, [], canChange);
272
+ globe.ObjectArray.StyleChanged(object);
267
273
  }
268
274
 
269
275
 
270
276
  setMapName(mapName) {
271
277
  const { object, globe } = this;
272
278
  setMapName(object, mapName);
273
-
274
- const canChange = {
275
- attribs: false,
276
- icon: true,
277
- label: false,
278
- heading: false,
279
- }
280
-
281
- globe.ObjectArray.UpdateData(object, CSObjectArrayUpdateTypes.UPDATE, canChange);
279
+ globe.ObjectArray.StyleChanged(object);
282
280
  }
283
281
 
284
282
 
285
- setData(data) {
286
- const { globe, object } = this;
287
- globe.ObjectArray.SetData(object, [data]);
288
- }
289
283
 
290
- /**
291
- * @param {PointObjectArray} data
292
- * @param {CSObjectArrayUpdateTypes} operation
293
- * @param {CanChangeOptions} [canChange]
294
- */
295
- updateData(data, operation, canChange) {
296
- // console.log( "updateData", operation, data);
297
- const { globe, object } = this;
298
- globe.ObjectArray.UpdateData(object, operation, [data], canChange);
284
+ flush() {
285
+ this._idCollector.clear();
286
+ this._setData({ coords: [], coordsZ: [], attribs: [] });
299
287
  }
300
288
 
301
- setConrolledData(data) {
302
-
303
- const paritalData = {
304
- add: {
305
- coords: [],
306
- coordsZ: [],
307
- attribs: [],
308
- },
309
- update: {
310
- coords: [],
311
- coordsZ: [],
312
- attribs: [],
313
- },
314
- delete: {
315
- coords: [],
316
- coordsZ: [],
317
- attribs: [],
318
- },
319
- canChange: {
320
- // Tüm değişimler gözardı edilecek
321
- attribs: false,
322
- icon: false,
323
- label: false,
324
- heading: false,
325
- },
326
- };
327
-
328
- // İlk toplu ekleme adımı
329
- if (this._idCollector.size === 0) {
330
- this.setData(data);
331
- // Eklenen id'ler set edildi
332
- for (let i = 0; i < data.attribs.length; i++) {
333
- const currentPayload = data.attribs[i];
334
- const id = currentPayload[this.primaryKey];
335
-
336
- this._idCollector.add(id);
337
- }
338
- return;
339
- }
340
-
341
- /** @type {Set<string>} */
342
- const dataIds = new Set();
343
289
 
290
+ insert(data) {
291
+ const updateBucket = {
292
+ coords: [],
293
+ coordsZ: [],
294
+ attribs: [],
295
+ };
296
+ const addBucket = {
297
+ coords: [],
298
+ coordsZ: [],
299
+ attribs: [],
300
+ };
301
+ let bucket;
344
302
  for (let i = 0; i < data.attribs.length; i++) {
345
303
  const currentPayload = data.attribs[i];
346
304
  const id = currentPayload[this.primaryKey];
347
305
 
348
- let bucket = paritalData.add;
349
-
350
- dataIds.add(id);
351
-
352
306
  if (this._idCollector.has(id)) {
353
- bucket = paritalData.update;
307
+ bucket = updateBucket;
354
308
  } else {
355
309
  this._idCollector.add(id);
310
+ bucket = addBucket;
356
311
  }
357
-
358
312
  bucket.coords.push(data.coords[2 * i], data.coords[2 * i + 1]);
359
313
  bucket.coordsZ.push(data.coordsZ[i]);
360
314
  bucket.attribs.push(currentPayload);
361
315
  }
362
316
 
363
- // Artık varolmayan elemenları sil
364
- const deleteBucket = paritalData.delete;
365
- this._idCollector.forEach(id => {
366
- if (!dataIds.has(id)) {
367
- this._idCollector.delete(id);
317
+ if (addBucket.coords.length > 0) {
318
+ this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD, { attribs: false, icon: false, label: false, heading: false });
319
+ }
320
+
321
+ if (updateBucket.coords.length > 0) {
322
+ this._updateData(
323
+ updateBucket,
324
+ CSObjectArrayUpdateTypes.UPDATE,
325
+ { attribs: false, icon: false, label: false, heading: false },
326
+ );
327
+ }
328
+ }
368
329
 
330
+ delete(dataIDs) {
331
+ const deleteBucket = {
332
+ coords: [],
333
+ coordsZ: [],
334
+ attribs: [],
335
+ };
336
+ dataIDs.forEach(id => {
337
+ if (this._idCollector.has(id)) {
338
+ this._idCollector.delete(id);
369
339
  deleteBucket.coords.push(0, 0);
370
340
  deleteBucket.coordsZ.push(0);
341
+ // also can be written as follows
371
342
  deleteBucket.attribs.push({
372
343
  [this.primaryKey]: id,
373
344
  });
374
345
  }
375
346
  });
376
347
 
377
- if (paritalData.add.coords.length > 0) {
378
- this.updateData(paritalData.add, CSObjectArrayUpdateTypes.ADD);
379
- }
348
+ if (deleteBucket.coords.length > 0) {
380
349
 
381
- if (paritalData.update.coords.length > 0) {
382
- this.updateData(
383
- paritalData.update,
384
- CSObjectArrayUpdateTypes.UPDATE,
385
- paritalData.canChange,
386
- );
350
+ this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
387
351
  }
352
+ }
388
353
 
389
- if (paritalData.delete.coords.length > 0) {
390
- this.updateData(paritalData.delete, CSObjectArrayUpdateTypes.DELETE);
391
- }
354
+
355
+ // private
356
+ _setData(data) {
357
+ const { globe, object } = this;
358
+ globe.ObjectArray.SetData(object, [data]);
359
+ }
360
+
361
+ /**
362
+ * @param {PointObjectArray} data
363
+ * @param {CSObjectArrayUpdateTypes} operation
364
+ * @param {CanChangeOptions} [canChange]
365
+ */
366
+ _updateData(data, operation, canChange) {
367
+ const { globe, object } = this;
368
+ globe.ObjectArray.UpdateData(object, operation, [data], canChange);
392
369
  }
393
370
 
394
- }
371
+ }
372
+
373
+ const getID = (data, primaryKey) => data.attribs[primaryKey];
@@ -1,2 +1,3 @@
1
1
  import CompassRose from "./compassrose";
2
- export { CompassRose };
2
+ import { RotationalIcon2D } from "./compassrose";
3
+ export { CompassRose, RotationalIcon2D };
@@ -0,0 +1,4 @@
1
+ import HeatWavePlugin from './plugins/heatwaveglobeshell';
2
+ import { IsobarRasterToVector } from './isobar/plugin';
3
+ export { HeatWavePlugin, IsobarRasterToVector };
4
+
@@ -0,0 +1,247 @@
1
+ import {
2
+ CSGlobe,
3
+ CSIconTypes,
4
+ CSObjectTypes,
5
+ CSObjectArrayUpdateTypes,
6
+ } from "@pirireis/webglobe";
7
+
8
+ /**
9
+ * @typedef {Object} IconPayload
10
+ * @property {string} app6DCode
11
+ * @property {string} accsCode
12
+ */
13
+
14
+ /**
15
+ * @typedef {IconPayload & Object.<string, any>} PointPayload
16
+ */
17
+
18
+ /**
19
+ * @typedef {Object} CanChangeOptions
20
+ * @property {boolean} [attribs=false]
21
+ * @property {boolean} [icon=false]
22
+ * @property {boolean} [label=false]
23
+ * @property {boolean} [heading=false]
24
+ */
25
+
26
+ /**
27
+ * @typedef {Object} PointObjectArray
28
+ * @property {number[]} coords [longitude1, latitude1, longitude2, latitude2, ....]
29
+ * @property {number[]} coordsZ [z1, z2, ....]
30
+ * @property {PointPayload[]} attribs
31
+ */
32
+
33
+ class ObjectArrayLabels {
34
+ /**
35
+ * @param {number | string} id
36
+ * @param {CSGlobe} globe
37
+ */
38
+ constructor(id, globe, labelStyle = null) {
39
+ this.id = id;
40
+ this.setGlobe(globe);
41
+
42
+ this.data = [
43
+ {
44
+ coords: [],
45
+ coordsZ: [],
46
+ attribs: [],
47
+ },
48
+ ];
49
+
50
+ this.primaryKey = "id";
51
+
52
+ this.objectType = CSObjectTypes.POINT;
53
+ this.filter = null;
54
+ this.bbox = null;
55
+ this.startLod = 2;
56
+ this.endLod = 19;
57
+ this.query = true;
58
+ this.reportObj = function (values, mouseEvent) { };
59
+ this._idCollector = new Set();
60
+ this._setStyle(labelStyle);
61
+ }
62
+
63
+
64
+
65
+ _setStyle(labelStyle) {
66
+ this.style = this.globe.ObjectArray.GetDefaultStyle();
67
+
68
+ if (labelStyle) {
69
+ this.style.labels[0] = labelStyle;
70
+ } else {
71
+ this.style.labels[0].vAlignment = 2 // dikey olarak tam noktanın ortası
72
+ this.style.labels[0].hAlignment = 2 // yatay olarak tam noktanın ortası
73
+ this.style.labels[0].size = 11;
74
+ this.style.labels[0].drawAlways = true;
75
+ this.style.labels[0].fontFamily.name = "arial";
76
+ this.style.labels[0].fontFamily.bold = false;
77
+ this.style.labels[0].fontFamily.hollow = true;
78
+ this.style.labels[0].fontFamily.hollowWidth = 1;
79
+ this.style.labels[0].fontFamily.hollowOpacity = 1;
80
+ }
81
+
82
+ this.style.labels[0].text = "${value}";
83
+ this.style.fidKey = this.primaryKey;
84
+
85
+ this.style.iconType = CSIconTypes.NOICON; // milIcon ekleyebilmek için icon tipi MAP olmalı
86
+ }
87
+ /**
88
+ * @param {CSGlobe} [globe]
89
+ */
90
+ setGlobe(globe) {
91
+ if (!globe) return;
92
+ this.globe = globe;
93
+ }
94
+
95
+ addToMap() {
96
+ this.globe.ObjectArray.Add(this);
97
+ }
98
+
99
+ removeFromMap() {
100
+ this.flush();
101
+ this.globe.ObjectArray.Delete(this.id);
102
+ }
103
+
104
+ /**
105
+ * Haritaya kullanılacak veriyi verir. Her çağrıldığında tüm hesaplamalar yeniden yapılır
106
+ * @param {PointObjectArray} data
107
+ */
108
+ setData(data) {
109
+ this.globe.ObjectArray.SetData(this, [data]);
110
+ }
111
+
112
+ /**
113
+ * @param {PointObjectArray} data
114
+ * @param {CSObjectArrayUpdateTypes} operation
115
+ * @param {CanChangeOptions} [canChange]
116
+ */
117
+ updateData(data, operation, canChange) {
118
+ this.globe.ObjectArray.UpdateData(this, operation, [data], canChange);
119
+ }
120
+
121
+ flush() {
122
+ const deleteBucket = {
123
+ coords: [],
124
+ coordsZ: [],
125
+ attribs: [],
126
+ };
127
+ this.setData(deleteBucket);
128
+ this._idCollector = new Set();
129
+ }
130
+
131
+ /**
132
+ * Haritaya kullanılacak veriyi verir. Her çağrıldığında tüm hesaplamalar yeniden yapılmaz, ancak ön hesaplama maliyeti vardır
133
+ * @param {PointObjectArray} data
134
+ */
135
+ setControlledData(data) {
136
+ const paritalData = {
137
+ add: {
138
+ coords: [],
139
+ coordsZ: [],
140
+ attribs: [],
141
+ },
142
+ update: {
143
+ coords: [],
144
+ coordsZ: [],
145
+ attribs: [],
146
+ },
147
+ delete: {
148
+ coords: [],
149
+ coordsZ: [],
150
+ attribs: [],
151
+ },
152
+ canChange: {
153
+ // Tüm değişimler gözardı edilecek
154
+ attribs: false,
155
+ icon: false,
156
+ label: false,
157
+ heading: false,
158
+ },
159
+ };
160
+ // İlk toplu ekleme adımı
161
+ if (this._idCollector.size === 0) {
162
+ this.setData(data);
163
+
164
+ // Eklenen id'ler set edildi
165
+ for (let i = 0; i < data.attribs.length; i++) {
166
+ const currentPayload = data.attribs[i];
167
+ const id = currentPayload[this.primaryKey];
168
+
169
+ this._idCollector.add(id);
170
+ }
171
+
172
+ return;
173
+ }
174
+
175
+ /** @type {Set<string>} */
176
+ const dataIds = new Set();
177
+
178
+ for (let i = 0; i < data.attribs.length; i++) {
179
+ const currentPayload = data.attribs[i];
180
+ const id = currentPayload[this.primaryKey];
181
+
182
+ let bucket = paritalData.add;
183
+
184
+ dataIds.add(id);
185
+
186
+ if (this._idCollector.has(id)) {
187
+ bucket = paritalData.update;
188
+ } else {
189
+ this._idCollector.add(id);
190
+ }
191
+
192
+ bucket.coords.push(data.coords[2 * i], data.coords[2 * i + 1]);
193
+ bucket.coordsZ.push(data.coordsZ[i]);
194
+ bucket.attribs.push(currentPayload);
195
+ }
196
+
197
+ // Artık varolmayan elemenları sil
198
+ const deleteBucket = paritalData.delete;
199
+ this._idCollector.forEach((id) => {
200
+ if (!dataIds.has(id)) {
201
+ this._idCollector.delete(id);
202
+
203
+ deleteBucket.coords.push(0, 0);
204
+ deleteBucket.coordsZ.push(0);
205
+ deleteBucket.attribs.push({
206
+ [this.primaryKey]: id,
207
+ });
208
+ }
209
+ });
210
+
211
+ if (paritalData.add.coords.length > 0) {
212
+ this.updateData(paritalData.add, CSObjectArrayUpdateTypes.ADD);
213
+ }
214
+
215
+ if (paritalData.update.coords.length > 0) {
216
+ this.updateData(
217
+ paritalData.update,
218
+ CSObjectArrayUpdateTypes.UPDATE,
219
+ paritalData.canChange
220
+ );
221
+ }
222
+
223
+ if (paritalData.delete.coords.length > 0) {
224
+ this.updateData(paritalData.delete, CSObjectArrayUpdateTypes.DELETE);
225
+ }
226
+ }
227
+
228
+
229
+ setPrimarykey(key) {
230
+ this.primaryKey = key;
231
+ }
232
+
233
+ setSymbolSet(symbolSet) {
234
+ this.symbolSet = symbolSet;
235
+ }
236
+
237
+ getLabelStyle() {
238
+ return this.style.labels[0];
239
+ }
240
+
241
+ setLabelStyle(style) {
242
+ this.style.labels[0] = style;
243
+
244
+ }
245
+ }
246
+
247
+ export default ObjectArrayLabels;