@sapui5/sap.ui.vbm 1.130.0 → 1.131.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.
@@ -0,0 +1,897 @@
1
+ // Transformer using sap ui define and the VBI namespace
2
+ /**
3
+ * JSON FORMAT
4
+ * [
5
+ * {MapProvider},
6
+ * {GeoJSON},
7
+ * {Events}
8
+ * ]
9
+ *
10
+ */
11
+
12
+ sap.ui.define([
13
+ "../lib/sapvbi",
14
+ "./MapRenderer"
15
+ ], function (vb, MapRenderer) {
16
+ 'use strict';
17
+ // var thisModule = "sap.ui.vbm.VBI.VBITransformer";
18
+ VBI.VBITransformer = {};
19
+
20
+ VBI.vectorFlag = false;
21
+
22
+ VBI.TransformedJSON = [];
23
+
24
+ var featureCollection = [];
25
+ var mapProvider = {};
26
+
27
+ var spot_id = 0;
28
+ var route_id = 0;
29
+
30
+ var ind_del;
31
+
32
+ var resources;
33
+ var menus;
34
+ // var Events
35
+
36
+ // Needs to be triggerd only for initial load
37
+ // Gets the map provider url if the payload has it
38
+ // center: [0, 0], // starting position [lng, lat]
39
+ // zoom: 1,
40
+
41
+ // Get data from config - >
42
+
43
+ // VBI.VBITransformer.init = function() {
44
+ // // event handlers from actions and automations
45
+ // this._eventHandlers = [];
46
+ // this._actions = [];
47
+
48
+ // //initialize section
49
+ // this._mapConfiguration = {};
50
+ // this._clusterVOs = new Map();
51
+
52
+ // //Dictionary for Data Attributes
53
+ // this._dataTypes = {};
54
+ // this._data = {};
55
+ // this._idKeyMap = {};
56
+
57
+ // //Properties in VBI JSON that need special handling
58
+ // this._propsAnomalies = new Map();
59
+ // }
60
+
61
+ VBI.VBITransformer._extractMapProvider = (obj) => {
62
+
63
+ var currRefMap = "DEFAULT";
64
+ var initialStartPosition = [12.980846657174002, 77.7154284936771];
65
+ var initialZoom = "0";
66
+ var scaleType = "metric";
67
+ var language = "EN";
68
+
69
+ if (obj.SAPVB.Scenes) {
70
+ if (obj.SAPVB.Scenes.Set.SceneGeo.refMapLayerStack) {
71
+ currRefMap = obj.SAPVB.Scenes.Set.SceneGeo.refMapLayerStack;
72
+ console.log(currRefMap);
73
+ if (obj.SAPVB.Scenes.Set.SceneGeo.initialStartPosition) {
74
+ // 0.0 scenario must be handled
75
+ initialStartPosition[0] = Number(obj.SAPVB.Scenes.Set.SceneGeo.initialStartPosition.split(";")[0]);
76
+ initialStartPosition[1] = Number(obj.SAPVB.Scenes.Set.SceneGeo.initialStartPosition.split(";")[1]);
77
+ // initialStartPosition ="["+obj.SAPVB.Scenes.Set.SceneGeo.initialStartPosition.split(";")[0]+","+obj.SAPVB.Scenes.Set.SceneGeo.initialStartPosition.split(";")[1]+"]";
78
+ }
79
+ if (obj.SAPVB.Scenes.Set.SceneGeo.initialZoom) {
80
+ // 0.0 scenario must be handled
81
+ initialZoom = obj.SAPVB.Scenes.Set.SceneGeo.initialZoom[0];
82
+ }
83
+ }
84
+ // Scale Control in Maplibre
85
+ // metric -> m,km
86
+ // imperial -> ft,mi
87
+ // nautical -> nm
88
+
89
+ //in VBI
90
+ // nm
91
+ // mi
92
+ // km
93
+
94
+ if (obj.SAPVB.Config) {
95
+ if (obj.SAPVB.Config.Set) {
96
+ let config = obj.SAPVB.Config.Set;
97
+ if (Array.isArray(config.P)) {
98
+ for (const conf in config.P) {
99
+ if (config.P.hasOwnProperty(conf)) {
100
+ let currConf = config.P[conf];
101
+ switch (currConf.name) {
102
+ case "UnitOfLength":
103
+ if (currConf.value == "nm") {
104
+ scaleType = "nautical";
105
+ } else if (currConf.value == "mi") {
106
+ scaleType = "imperial";
107
+ } else {
108
+ scaleType = "metric"
109
+ }
110
+ break;
111
+ case "language":
112
+ language = "EN"
113
+ // Language needs to be handled
114
+ break;
115
+ default:
116
+ // code block
117
+ }
118
+
119
+ }
120
+ }
121
+ } else {
122
+ switch (config.P.name) {
123
+ case "UnitOfLength":
124
+ if (config.P.value == "nm") {
125
+ scaleType = "nautical";
126
+ } else if (config.P.value == "mi") {
127
+ scaleType = "imperial";
128
+ } else {
129
+ scaleType = "metric"
130
+ }
131
+ break;
132
+ case "language":
133
+ language = "EN"
134
+ // Language needs to be handled
135
+ break;
136
+ default:
137
+ // code block
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ if (obj.SAPVB.MapProviders.Set.MapProvider) {
144
+ let MapProvidersArray = obj.SAPVB.MapProviders.Set.MapProvider;
145
+
146
+ for (const MapProvider in MapProvidersArray) {
147
+ if (MapProvidersArray.hasOwnProperty(MapProvider)) {
148
+ let Provider = MapProvidersArray[MapProvider];
149
+ if (Provider.name == currRefMap && Provider.type == "vector") {
150
+ mapProvider = {
151
+ "type": "MapProvider",
152
+ "provider": Provider.Source[0].url,
153
+ "center": initialStartPosition,
154
+ "zoom": Number(initialZoom),
155
+ "copyright": Provider.copyright,
156
+ "scaleType": scaleType ? scaleType : "metric",
157
+ "language": language ? language : "EN",
158
+ "header": Array.isArray(Provider.Header) ? Provider.Header.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {}) : {}
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ //DATA
168
+ //Gets the spots and its properties
169
+ VBI.VBITransformer._extractSpotsData = (spots) => {
170
+ // var spot_id = 0;
171
+ //E can be a single object too..
172
+ // For each spot
173
+ var defaultbase64 = 'iVBORw0KGgoAAAANSUhEUgAAABcAAAAfCAYAAAAMeVbNAAADGUlEQVRIia3WW2xMQRjA8f+Z3bWru622ulhVWtpQlzbFhrq1UQmpy4O+IO6C4kki4VHcIx5RJO7iSXgRSpG6e6hbo7WJRrShFVLqTtX5POxO1Wa3u9Z+ySTfnNn5zZyzc+aMISJEiDnApEDJBJ4CN4HqQAkfIhKubBORGuk+qkVkbTjDCDHzacAeIB/A9/IdN+pe8aSpldfvvzDInUR+lpuS/Aw8KU7d5zKwEmjqCgXjB4FVAHVNrRyuquPxi7ch71gpg+KRA1hWMoL+qU6ANqAEeBAKrwDKTVM4Wf2UU9d9mGbE/4MEu431cwqYmpehL43RA2h8NHBfBHafreHyo8aIaHCsK81nbmE2QD2QB/xSgbatAOfuNcQEA1RU1upHOBzYC6CAcUDpx6/tHL1aHxMMYJrC/gu1BJ5yOWBR+Ncxlx428vXHz5hxgIaWNmobOxfAbAVMBrjja/4vWMddX4tOJyugAOBZc1tc8IaWTqdAAa7v7R18a++IC9766btOPQqgvcOMCxxk2RWA02GLG+76Y31QQJNFGfRNTogLHtgKAJ4roAZgaHpKXPAcT7JOHyj8ezPenL5xwb05/XR6UwGVABNz+2O1qLCdoglPipPsPzO/pQAfcK1Xgp2iEen/hc/yZmEYAJwATD3VMwALi3OxKCMm2OWwMds7WFcPgX/jAv9eXj3Qncj0gsyY8PlThuolfR643RUHOAawtGQ4CXbrP8EZaYmUFebo6i6ddMWPAxd7JzpYPSMvatiiDDaWjcVmVQBH9KyDcYANADPHZDFhmCcqfEHRMHIHpIL/01betS0YrwcOGAZsKvOS3tvVLTx6SB8WF+fq6ibgrw9CqIW9BjjtdNjYuXhi2H1noDuRzfPGo/yr6xBQFfybcG/NcqAqPdXF9oUTsNssfzW6k3qyY1HnwKeB1aGQcPgPYAXwZNSgNLYsKKSH1T9AqsvBnmVT9IHoErAkjNHtcQ4RGSwiDSIij56/kVX7rkjzu8/6KHdFRJK76x8JR0SyRaReRMQ0O8+IlSKSFqlvNDgiYhWRigBcEWUffgN+ZuQK2lE/1gAAAABJRU5ErkJggg==';
174
+ if (Array.isArray(spots.E)) {
175
+ // console.log(spots.E.length);
176
+ for (const spot in spots.E) {
177
+ if (spots.E.hasOwnProperty(spot)) {
178
+ // console.log(spots.E[spot]);
179
+ let currSpot = spots.E[spot];
180
+
181
+ let spotProperties = {
182
+ "GeoPosition": currSpot.A ? currSpot.A : "",
183
+ "ToolTip": currSpot.B ? currSpot.B : "",
184
+ "Label": currSpot.L ? currSpot.L : "",
185
+ "LabelBGColor": currSpot.LC ? currSpot.LC : "",
186
+ "LabelAlignment": currSpot.LA ? currSpot.LA : "",
187
+ "Color": currSpot.C ? currSpot.C : "",
188
+ "HotColor": currSpot.HC ? currSpot.HC : "",
189
+ "SelectColor": currSpot.SC ? currSpot.SC : "",
190
+ "Transformation": currSpot.D ? currSpot.D : "",
191
+ "FixDir": currSpot.E ? currSpot.E : "",
192
+ "FixSize": currSpot.F ? currSpot.F : "",
193
+ "Icon": currSpot.G ? currSpot.G : "",
194
+ "Image": currSpot.I ? currSpot.I : "",
195
+ "base64": resources.find(resource => resource.name === currSpot.I)?.value || defaultbase64,
196
+ "Key": currSpot.K ? currSpot.K : "",
197
+ "Scale": currSpot.S ? currSpot.S : "",
198
+ "DisplayRole": currSpot.R ? currSpot.R : "",
199
+ "DragData": currSpot.DD ? currSpot.DD : "",
200
+ "Alignment": currSpot.AL ? currSpot.AL : "",
201
+ "height": resources.find(resource => resource.name === currSpot.I) ? '45px' : '30px',
202
+ "width": resources.find(resource => resource.name === currSpot.I) ? '45px' : '24px',
203
+ "menu": menus
204
+ };
205
+
206
+ let coord_array = currSpot.A.split(";");
207
+
208
+ let geometry = {
209
+ "coordinates": [
210
+ Number(coord_array[0]),
211
+ Number(coord_array[1])
212
+ ],
213
+ "type": "Point"
214
+ };
215
+
216
+
217
+ let spot_data = {
218
+ "type": "Feature",
219
+ "properties": spotProperties,
220
+ "geometry": geometry,
221
+ "id": spot_id++,
222
+ };
223
+
224
+ featureCollection.push(spot_data);
225
+ }
226
+ }
227
+ } else {
228
+
229
+ let currSpot = spots.E;
230
+
231
+ let spotProperties = {
232
+ "GeoPosition": currSpot.A ? currSpot.A : "",
233
+ "ToolTip": currSpot.B ? currSpot.B : "",
234
+ "Label": currSpot.L ? currSpot.L : "",
235
+ "LabelBGColor": currSpot.LC ? currSpot.LC : "",
236
+ "LabelAlignment": currSpot.LA ? currSpot.LA : "",
237
+ "Color": currSpot.C ? currSpot.C : "",
238
+ "HotColor": currSpot.HC ? currSpot.HC : "",
239
+ "SelectColor": currSpot.SC ? currSpot.SC : "",
240
+ "Transformation": currSpot.D ? currSpot.D : "",
241
+ "FixDir": currSpot.E ? currSpot.E : "",
242
+ "FixSize": currSpot.F ? currSpot.F : "",
243
+ "Icon": currSpot.G ? currSpot.G : "",
244
+ "Image": currSpot.I ? currSpot.I : "",
245
+ "base64": resources.find(resource => resource.name === currSpot.I)?.value || defaultbase64,
246
+ "Key": currSpot.K ? currSpot.K : "",
247
+ "Scale": currSpot.S ? currSpot.S : "",
248
+ "DisplayRole": currSpot.R ? currSpot.R : "",
249
+ "DragData": currSpot.DD ? currSpot.DD : "",
250
+ "Alignment": currSpot.AL ? currSpot.AL : "",
251
+ "height": resources.find(resource => resource.name === currSpot.I) ? '45px' : '30px',
252
+ "width": resources.find(resource => resource.name === currSpot.I) ? '45px' : '24px'
253
+
254
+ };
255
+
256
+ let coord_array = currSpot.A.split(";");
257
+
258
+ let geometry = {
259
+ "coordinates": [
260
+ Number(coord_array[0]),
261
+ Number(coord_array[1])
262
+ ],
263
+ "type": "Point"
264
+ };
265
+
266
+ let spot_data = {
267
+ "type": "Feature",
268
+ "properties": spotProperties,
269
+ "geometry": geometry,
270
+ "id": spot_id++,
271
+ };
272
+
273
+ featureCollection.push(spot_data);
274
+ }
275
+ }
276
+
277
+ //Gets the routes, links and its properties
278
+ VBI.VBITransformer._extractRoutesData = (routes) => {
279
+
280
+ //E can be a single object too..
281
+ // For each spot
282
+ if (Array.isArray(routes.E)) {
283
+ // console.log(spots.E.length);
284
+ for (const route in routes.E) {
285
+ if (routes.E.hasOwnProperty(route)) {
286
+ // console.log(spots.E[spot]);
287
+ let currRoute = routes.E[route];
288
+ //A5 is an vector array with all coordinates.
289
+ let routeProperties = {
290
+ "GeoPosition": currRoute.A ? currRoute.A : "",
291
+ "ToolTip": currRoute.B ? currRoute.B : "",
292
+ "Label": currRoute.L ? currRoute.L : "",
293
+ "LabelBGColor": currRoute.LC ? currRoute.LC : "",
294
+ "LabelAlignment": currRoute.LA ? currRoute.LA : "",
295
+ "Color": currRoute.C ? argbToRgba(currRoute.C) : "",
296
+ "BorderColor": currRoute.D ? argbToRgba(currRoute.D) : "",
297
+ "HotColor": currRoute.HC ? currRoute.HC : "",
298
+ "SelectColor": currRoute.SC ? currRoute.SC : "",
299
+ "PosList": currRoute.H ? currRoute.H : "",
300
+ "StartStyle": currRoute.Y ? currRoute.Y : "",
301
+ "EndStyle": currRoute.Z ? currRoute.Z : "",
302
+ "Key": currRoute.K ? currRoute.K : "",
303
+ "DisplayRole": currRoute.R ? currRoute.R : "",
304
+ "LineWidth": currRoute.LW ? currRoute.LW * 1.5 : "",
305
+ "BorderWidth": currRoute.LW ? currRoute.LW * 1.5 + 2: "",
306
+ "DotWidth": currRoute.DW ? currRoute.DW : "",
307
+ "DotColor": currRoute.DC ? currRoute.DC : "",
308
+ "LineDash": currRoute.LD ? currRoute.LD : "",
309
+ "DirectionIndicator": currRoute.DI ? currRoute.DI : "",
310
+ "DragData": currRoute.DD ? currRoute.DD : ""
311
+ };
312
+
313
+ //itearate through the route points and add the coordinates to the GeoJSON
314
+ let coord_array = currRoute.H.split(";");
315
+ let coord_collection = [];
316
+
317
+ for (let i = 0; i < coord_array.length; i = i + 3) {
318
+ coord_collection.push([Number(coord_array[i]), Number(coord_array[i + 1])])
319
+ }
320
+
321
+ let geometry = {
322
+ "coordinates": coord_collection,
323
+ "type": "LineString"
324
+ };
325
+
326
+ let route_data = {
327
+ "type": "Feature",
328
+ "properties": routeProperties,
329
+ "geometry": geometry,
330
+ // "id" : currRoute['VB:ix'],
331
+ "id": route_id++,
332
+ };
333
+
334
+ featureCollection.push(route_data);
335
+ }
336
+ }
337
+ } else {
338
+
339
+ let currRoute = routes.E;
340
+
341
+ let routeProperties = {
342
+ "GeoPosition": currRoute.A ? currRoute.A : "",
343
+ "ToolTip": currRoute.B ? currRoute.B : "",
344
+ "Label": currRoute.L ? currRoute.L : "",
345
+ "LabelBGColor": currRoute.LC ? currRoute.LC : "",
346
+ "LabelAlignment": currRoute.LA ? currRoute.LA : "",
347
+ "Color": currRoute.C ? argbToRgba(currRoute.C) : "",
348
+ "BorderColor": currRoute.D ? argbToRgba(currRoute.D) : "",
349
+ "HotColor": currRoute.HC ? currRoute.HC : "",
350
+ "SelectColor": currRoute.SC ? currRoute.SC : "",
351
+ "PosList": currRoute.H ? currRoute.H : "",
352
+ "StartStyle": currRoute.Y ? currRoute.Y : "",
353
+ "EndStyle": currRoute.Z ? currRoute.Z : "",
354
+ "Key": currRoute.K ? currRoute.K : "",
355
+ "DisplayRole": currRoute.R ? currRoute.R : "",
356
+ "LineWidth": currRoute.LW ? currRoute.LW * 1.5 : "",
357
+ "BorderWidth": currRoute.LW ? currRoute.LW * 1.5 + 2: "",
358
+ "DotWidth": currRoute.DW ? currRoute.DW : "",
359
+ "DotColor": currRoute.DC ? currRoute.DC : "",
360
+ "LineDash": currRoute.LD ? currRoute.LD : "",
361
+ "DirectionIndicator": currRoute.DI ? currRoute.DI : "",
362
+ "DragData": currRoute.DD ? currRoute.DD : ""
363
+
364
+ };
365
+
366
+ //itearate through the route points and add the coordinates to the GeoJSON
367
+ let coord_array = currRoute.H.split(";");
368
+ let coord_collection = [];
369
+
370
+ for (let i = 0; i < coord_array.length; i = i + 3) {
371
+ coord_collection.push([Number(coord_array[i]), Number(coord_array[i + 1])])
372
+ }
373
+
374
+ let geometry = {
375
+ "coordinates": coord_collection,
376
+ "type": "LineString"
377
+ };
378
+
379
+ let route_data = {
380
+ "type": "Feature",
381
+ "properties": routeProperties,
382
+ "geometry": geometry,
383
+ // "id" : currRoute['VB:ix'],
384
+ "id": route_id++,
385
+ };
386
+ featureCollection.push(route_data);
387
+ }
388
+ }
389
+
390
+ function argbToRgba(argbString) {
391
+
392
+ // Remove "ARGB(" and ")" from the string and split the values by commas
393
+ let argbValues = argbString.replace('ARGB(', '').replace(')', '').split(',');
394
+
395
+ // Parse the values as integers
396
+ let alpha = parseInt(argbValues[0].trim(), 10);
397
+ let red = parseInt(argbValues[1].trim(), 10);
398
+ let green = parseInt(argbValues[2].trim(), 10);
399
+ let blue = parseInt(argbValues[3].trim(), 10);
400
+
401
+ // Convert alpha from 0-255 range to 0-1 range
402
+ let alphaDecimal = alpha / 255;
403
+
404
+ // Return the RGBA string
405
+ return `rgba(${red}, ${green}, ${blue}, ${alphaDecimal.toFixed(2)})`;
406
+ }
407
+
408
+ VBI.VBITransformer._deleteSpotsData = (spots) => {
409
+
410
+ if (Array.isArray(spots.E)) {
411
+ // console.log(spots.E.length);
412
+ for (const spot in spots.E) {
413
+ // if (spots.E.hasOwnProperty(spot)) {
414
+ let currSpot = spots.E[spot];
415
+ for (const index in featureCollection) {
416
+ if (featureCollection[index].properties.Key == currSpot.K) {
417
+ // ind_del = featureCollection[index].id;
418
+ ind_del = index;
419
+ featureCollection.splice(ind_del, 1);
420
+ }
421
+ else {
422
+ console.log("error");
423
+ }
424
+ }
425
+ }
426
+ }
427
+
428
+ else {
429
+ let currSpot = spots.E;
430
+
431
+ for (const index in featureCollection) {
432
+ if (featureCollection[index].properties.Key == currSpot.K) {
433
+ // ind_del = featureCollection[index].id;
434
+ ind_del = index;
435
+ }
436
+ else {
437
+ console.log("error");
438
+ }
439
+ }
440
+
441
+ featureCollection.splice(ind_del, 1);
442
+ }
443
+ }
444
+
445
+
446
+ VBI.VBITransformer._deleteRoutesData = (routes) => {
447
+
448
+ //E can be a single object too..
449
+ // For each spot
450
+ if (Array.isArray(routes.E)) {
451
+ // console.log(spots.E.length);
452
+ for (const route in routes.E) {
453
+ // if (routes.E.hasOwnProperty(route)) {
454
+ // console.log(spots.E[spot]);
455
+ let currRoute = routes.E[route];
456
+ for (const index in featureCollection) {
457
+ if (featureCollection[index].properties.Key == currRoute.K) {
458
+ // ind_del = featureCollection[index].id;
459
+ ind_del = index;
460
+ featureCollection.splice(ind_del, 1);
461
+ }
462
+ else {
463
+ console.log("error");
464
+ }
465
+ }
466
+ }
467
+ }
468
+ else {
469
+
470
+ let currRoute = routes.E;
471
+
472
+ for (const index in featureCollection) {
473
+ if (featureCollection[index].properties.Key == currRoute.K) {
474
+ ind_del = [index];
475
+ }
476
+ else {
477
+ console.log("error");
478
+ }
479
+ }
480
+
481
+ featureCollection.splice(ind_del, 1);
482
+ }
483
+ }
484
+
485
+
486
+
487
+
488
+
489
+ VBI.VBITransformer._extractData = (obj) => {
490
+ // Set
491
+ if (obj.SAPVB.Data.Set) {
492
+
493
+ let set = obj.SAPVB.Data.Set;
494
+
495
+ // if Set is an array
496
+ // Set:[]
497
+ if (Array.isArray(set)) {
498
+ for (const vo in set) {
499
+ if (set.hasOwnProperty(vo)) {
500
+ let currItm = set[vo];
501
+ // N->E->[]
502
+ switch (currItm.name) {
503
+ case "Spots":
504
+ VBI.VBITransformer._extractSpotsData(currItm.N);
505
+ break;
506
+ case "Links":
507
+ VBI.VBITransformer._extractRoutesData(currItm.N)
508
+ break;
509
+ default:
510
+ // code block
511
+ }
512
+
513
+ }
514
+ }
515
+ } else {
516
+ // if Set is not an array; Set:{}
517
+ // N[] -> E[]
518
+ // N {} -> E[]
519
+ // N{} -> E {}
520
+ if (obj.SAPVB.Data.Set.N) {
521
+ // E or A within each array object. ***************
522
+ let C = obj.SAPVB.Data.Set.N;
523
+ // let C = obj.SAPVB.Data.Set.A;
524
+ if (Array.isArray(C)) {
525
+ for (const item in C) {
526
+ if (C.hasOwnProperty(item)) {
527
+ let currVO = C[item];
528
+ switch (currVO.name) {
529
+ case "Spots":
530
+ VBI.VBITransformer._extractSpotsData(currVO);
531
+ break;
532
+ case "Links":
533
+ VBI.VBITransformer._extractRoutesData(currVO)
534
+ break;
535
+ case "KeyPress":
536
+ if (this._target !== this._adapter._map()) { // only map supports key events
537
+ return false;
538
+ }
539
+ this._event = "keyDown";
540
+ this._target.setKeyEventDelay(250);
541
+ this._target.setAllowKeyEventRepeat(false);
542
+ this._handler = this._adapter._getKeyboardHandler(this.name);
543
+ break;
544
+ default:
545
+ // code block
546
+ }
547
+ }
548
+ }
549
+ } else {
550
+ switch (C.name) {
551
+ case "Spots":
552
+ VBI.VBITransformer._extractSpotsData(C);
553
+ break;
554
+ case "Links":
555
+ VBI.VBITransformer._extractRoutesData(C);
556
+ break;
557
+ default:
558
+ // code block
559
+ }
560
+ }
561
+
562
+ }
563
+ }
564
+ }
565
+
566
+
567
+ else {
568
+ if (obj.SAPVB.Data.Remove) {
569
+
570
+ let del = obj.SAPVB.Data.Remove;
571
+
572
+ if (Array.isArray(del)) {
573
+ for (const vo in del) {
574
+ if (del.hasOwnProperty(vo)) {
575
+ let currItm = del[vo];
576
+ // N->E->[]
577
+ switch (currItm.name) {
578
+ case "Spo ts":
579
+ VBI.VBITransformer._deleteSpotsData(currItm.N);
580
+ case "Links":
581
+ VBI.VBITransformer._deleteRoutesData(currItm.N);
582
+ break;
583
+ default:
584
+
585
+ }
586
+ }
587
+ }
588
+ }
589
+ else {
590
+ if (obj.SAPVB.Data.Remove.N) {
591
+ // E or A within each array object. ***************
592
+ let D = obj.SAPVB.Data.Remove.N;
593
+ // let C = obj.SAPVB.Data.Set.A;
594
+ if (Array.isArray(D)) {
595
+ for (const item in D) {
596
+ if (D.hasOwnProperty(item)) {
597
+ let currVO = D[item];
598
+ switch (currVO.name) {
599
+ case "Spots":
600
+ VBI.VBITransformer._deleteSpotsData(currVO);
601
+ break;
602
+ case "Links":
603
+ VBI.VBITransformer._deleteRoutesData(currVO);
604
+ break;
605
+
606
+ default:
607
+
608
+ }
609
+ }
610
+ }
611
+ } else {
612
+ switch (D.name) {
613
+ case "Spots":
614
+ VBI.VBITransformer._deleteSpotsData(D);
615
+ break;
616
+ case "Links":
617
+ VBI.VBITransformer._deleteRoutesData(D);
618
+ break;
619
+
620
+
621
+ default:
622
+ // code block
623
+ }
624
+ }
625
+ }
626
+
627
+ }
628
+ }
629
+ }
630
+ }
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+ // // VBI.VBITransformer._deleteData = (obj) => {
641
+
642
+ // if (obj.SAPVB.Data.Remove) {
643
+
644
+ // let del = obj.SAPVB.Data.Remove;
645
+
646
+ // if (Array.isArray(del)) {
647
+ // for (const vo in del) {
648
+ // if (del.hasOwnProperty(vo)) {
649
+ // let currItm = del[vo];
650
+ // // N->E->[]
651
+ // switch (currItm.name) {
652
+ // case "Spots":
653
+ // VBI.VBITransformer._deleteSpotsData(currItm.N);
654
+ // break;
655
+ // default:
656
+
657
+ // }
658
+ // }
659
+ // }
660
+ // }
661
+ // else{
662
+ // if (obj.SAPVB.Data.Remove.N) {
663
+ // // E or A within each array object. ***************
664
+ // let D = obj.SAPVB.Data.Remove.N;
665
+ // // let C = obj.SAPVB.Data.Set.A;
666
+ // if (Array.isArray(D)) {
667
+ // for (const item in D) {
668
+ // if (D.hasOwnProperty(item)) {
669
+ // let currVO = D[item];
670
+ // switch (currVO.name) {
671
+ // case "Spots":
672
+ // VBI.VBITransformer._extractSpotsData(currVO);
673
+ // break;
674
+
675
+ // default:
676
+ // // code block
677
+ // }
678
+ // }
679
+ // }
680
+ // } else {
681
+ // switch (D.name) {
682
+ // case "Spots":
683
+ // VBI.VBITransformer._deleteSpotsData(D);
684
+ // break;
685
+ // default:
686
+ // // code block
687
+ // }
688
+ // }
689
+ // }
690
+
691
+
692
+ // }
693
+ // }
694
+ // }
695
+ // }
696
+
697
+
698
+
699
+ // DELTA UPDATE
700
+
701
+ // if(obj.SAPVB.Data.Set.N){
702
+
703
+ // }
704
+
705
+ // Remove
706
+
707
+
708
+ // // Extract the necessary information from the payload
709
+ // const removeData = obj.SAPVB.Data.Remove;
710
+ // const spotKey = removeData.N.E.K;
711
+
712
+ // // Assuming you have a map object and spots layer initialized
713
+
714
+ // const spotsLayer = map.getLayer('Spots'); // Assuming 'Spots' is the layer name
715
+
716
+ // if (spotsLayer) {
717
+ // // Find the spot with the specific key and remove it
718
+ // const feature = spotsLayer.getFeatureById(spotKey);
719
+ // if (feature) {
720
+ // spotsLayer.removeFeature(feature);
721
+ // console.log(`Spot with key ${spotKey} removed from the map.`);
722
+ // } else {
723
+ // console.error(`Spot with key ${spotKey} not found.`);
724
+ // }
725
+ // } else {
726
+ // console.error('Spots layer not found on the map.');
727
+ // }
728
+
729
+
730
+ // console.log(obj.SAPVB.Data.Set);
731
+ // [].concat(obj.SAPVB.Data.Remove).filter(function(r){
732
+ // return(r.N && r.N.E);
733
+ // }).forEach(function(r){
734
+ // [].conact(r.N.E).foreach(function(e){
735
+ // var index=library.findIndexINArray(this._data(r.name),function(_d){ return _d.key==e.k; });
736
+
737
+ // if(index !==-1){
738
+ // history._data(r.name).splice(index,1);
739
+ // }
740
+ // },this);
741
+ // },this);
742
+ // }
743
+
744
+ // function deleteSpots(obj.SAPVB.Data.Remove) {
745
+ // // Extract the necessary information from the payload
746
+ // const removeData = paylSAPVB.Data.Remove;
747
+ // const spotKey = removeData.N.E.K;
748
+
749
+ // // Assuming you have a map object and spots layer initialized
750
+ // const map = getMapInstance(); // Replace this with your actual map instance retrieval
751
+ // const spotsLayer = map.getLayer('Spots'); // Assuming 'Spots' is the layer name
752
+
753
+ // if (spotsLayer) {
754
+ // // Find the spot with the specific key and remove it
755
+ // spotsLayer.removeFeature(spotKey);
756
+ // console.log(`Spot with key ${spotKey} removed from the map.`);
757
+ // } else {
758
+ // console.error('Spots layer not found on the map.');
759
+ // }
760
+ // }
761
+
762
+ // // Call the function to delete spots
763
+ // deleteSpots(payload);
764
+
765
+ // Get the datatypes
766
+ // Run on initial load, if the datatypes are provided
767
+ VBI.VBITransformer._extractDataTypes = (obj) => {
768
+ //check if the datatypes are provided in the obj
769
+ //If else check if the mappings are stored (from the initial load.)
770
+
771
+ }
772
+
773
+ VBI.VBITransformer._buildTransformedJSON = (featureCollection) => {
774
+
775
+ VBI.TransformedJSON = [
776
+ mapProvider ? mapProvider : {},
777
+ {
778
+ "type": "FeatureCollection",
779
+ "features": featureCollection
780
+ }
781
+ ]
782
+
783
+ }
784
+
785
+
786
+ VBI.VBITransformer.parseVBI = (obj) => {
787
+ VBI.vectorFlag = true;
788
+ // VBI.VBITransformer.init();
789
+ if (obj.SAPVB) {
790
+ // initial load
791
+ if (obj.SAPVB.MapProviders && obj.SAPVB.MapLayerStacks && obj.SAPVB.Scenes) {
792
+ VBI.VBITransformer._extractMapProvider(obj);
793
+ }
794
+
795
+ if (obj.SAPVB.DataTypes) {
796
+
797
+ }
798
+
799
+ if (obj.SAPVB.Resources) {
800
+ resources = obj.SAPVB.Resources.Set.Resource;
801
+ }
802
+
803
+ if (obj.SAPVB.Automation && obj.SAPVB.Automation.Call) {
804
+ // VBI.VBITransformer._processAutomation(obj.SAPVB.Automation, obj.SAPVB.Menus);
805
+ }
806
+
807
+ if (obj.SAPVB.Menus && Object.keys(obj.SAPVB.Menus).length != 0) {
808
+ // menus = obj.SAPVB.Menus.Set.Menu.MenuItem[0].text;
809
+ menus = obj.SAPVB.Menus.Set.Menu;
810
+ }
811
+
812
+ if (obj.SAPVB.Data) {
813
+ VBI.VBITransformer._extractData(obj);
814
+ }
815
+ // if(obj.SAPVB.Data.Remove){
816
+ // VBI.VBITransformer._deleteData(obj);
817
+ // }
818
+
819
+
820
+ // if(obj.SAPVB.Windows){
821
+
822
+ // }
823
+
824
+ // if(obj.SAPVB.Actions){
825
+
826
+ // }
827
+
828
+ // if(obj.SAPVB.Menus){
829
+
830
+ // }
831
+
832
+ if (obj.SAPVB.Automation) {
833
+ // fly to handler
834
+ }
835
+
836
+ return VBI.VBITransformer._buildTransformedJSON(featureCollection);
837
+ }
838
+ }
839
+
840
+ VBI.VBITransformer.getTransformedJSON = () => {
841
+ return VBI.TransformedJSON;
842
+ }
843
+
844
+ VBI.VBITransformer.clearTransformedJSON = () => {
845
+
846
+ VBI.TransformedJSON = [];
847
+ featureCollection = [];
848
+
849
+ }
850
+
851
+
852
+ VBI.VBITransformer.getVectorFlag = () => {
853
+ return VBI.vectorFlag;
854
+ }
855
+ VBI.VBITransformer._processAutomation = function (automation, menus) {
856
+ // var call = {};
857
+ // if (automation.Call.handler === "CONTEXTMENUHANDLER") {
858
+ // var that = this;
859
+
860
+ // var automationTarget = VBI.VBITransformer._map();
861
+ // if (menus.Set.Menu) {
862
+ // [].concat(menus.Set.Menu).forEach(function(oMenu) {
863
+ // that._attachHandler.call(
864
+ // automationTarget,
865
+ // oMenu.action ) } ) }
866
+ // }
867
+ // let menu = menus.Set.Menu.MenuItem.text;
868
+ // featureCollection.push(menu);
869
+ }
870
+ VBI.VBITransformer._map = function () {
871
+ return sap.ui.getCore().byId(this.getMap());
872
+ };
873
+ /**
874
+ * Attaches the specified event handler to the specified event with the provided listener.
875
+ * Mainly used for custom events - FCODE_SELECT & DETAILS_FCODE_SELECT
876
+ *
877
+ *
878
+ * @param {string} eventName The name of the event on 'this' to which the handler needs to be attached. <br/>
879
+ * @param {function} handler The handler needs to be attached. <br/>
880
+ * @param {object} listener The listener - would turn out to be value of 'this' inside the event handler. <br/>
881
+ * @returns {sap.ui.vbm.Adapter} <code>this</code> to allow method chaining.
882
+ * @private
883
+ */
884
+ VBI.VBITransformer._attachHandler = function (eventName, handler, listener) {
885
+ if ((eventName in this.mEventRegistry) && (this.mEventRegistry[eventName].length > 0)) {
886
+ return this;
887
+ } else {
888
+ if (!listener._eventHandlers.some(function (eh) { return eh === handler; })) {
889
+ listener._eventHandlers.push(handler);
890
+ }
891
+ this.attachEvent(eventName, handler, listener);
892
+ return this;
893
+ }
894
+ };
895
+ }
896
+ );
897
+