@sapui5/sap.ui.vbm 1.143.0 → 1.145.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapui5/sap.ui.vbm",
3
- "version": "1.143.0",
3
+ "version": "1.145.0",
4
4
  "description": "SAPUI5 Library sap.ui.vbm",
5
5
  "homepage": "https://sap.github.io/ui5-tooling/pages/SAPUI5/",
6
6
  "author": "SAP SE (https://www.sap.com)",
@@ -3,7 +3,7 @@
3
3
  <name>sap.ui.vbm</name>
4
4
  <vendor>SAP SE</vendor>
5
5
  <copyright>SAP UI development toolkit for HTML5 (SAPUI5) (c) Copyright 2009-2012 SAP AG. All rights reserved</copyright>
6
- <version>1.143.0</version>
6
+ <version>1.145.0</version>
7
7
 
8
8
  <documentation>SAP UI library: sap.ui.vbm</documentation>
9
9
 
@@ -24,7 +24,7 @@ sap.ui.define([
24
24
  * @param {string} [sId] id for the new control, generated automatically if no id is given
25
25
  * @param {object} [mSettings] initial settings for the new object
26
26
  * @author SAP SE
27
- * @version 1.143.0
27
+ * @version 1.145.0
28
28
  * @extends sap.ui.core.Element
29
29
  * @constructor
30
30
  * @public
@@ -47,7 +47,7 @@ sap.ui.define([
47
47
  * @param {string} [sId] id for the new control, generated automatically if no id is given
48
48
  * @param {object} [mSettings] initial settings for the new object
49
49
  * @author SAP SE
50
- * @version 1.143.0
50
+ * @version 1.145.0
51
51
  * @extends sap.ui.core.Element
52
52
  * @constructor
53
53
  * @public
@@ -561,7 +561,7 @@ sap.ui.define([
561
561
  this._$overlay = jQuery("<div id='" + uid() + "'></div>");
562
562
  this._$overlay.addClass("sapUiVkContainerBaseOverlay");
563
563
  this._$overlay.append(this.$content);
564
- this._oPopup.setContent(this._$overlay);
564
+ this._oPopup.setContent(this._$overlay[0]);
565
565
  } else {
566
566
  Log.warning("Overlay: content does not exist or contains more than one child");
567
567
  }
@@ -23,7 +23,7 @@ sap.ui.define([
23
23
  *
24
24
  * @public
25
25
  * @author SAP SE
26
- * @version 1.143.0
26
+ * @version 1.145.0
27
27
  * @extends sap.ui.core.Control
28
28
  * @alias sap.ui.vbm.Viewport
29
29
  */
@@ -22,7 +22,7 @@ sap.ui.define([
22
22
  *
23
23
  * @private
24
24
  * @author SAP SE
25
- * @version 1.143.0
25
+ * @version 1.145.0
26
26
  * @alias sap.ui.vbm.adapter3d.ColladaBounds
27
27
  */
28
28
  var ColladaBounds = BaseObject.extend("sap.ui.vbm.adapter3d.ColladaBounds", /** @lends sap.ui.vbm.adapter3d.ColladaBounds.prototype */ {
@@ -83,7 +83,7 @@ sap.ui.define([
83
83
  *
84
84
  * @private
85
85
  * @author SAP SE
86
- * @version 1.143.0
86
+ * @version 1.145.0
87
87
  * @alias sap.ui.vbm.adapter3d.DragDropHandler
88
88
  */
89
89
  var DragDropHandler = BaseObject.extend("sap.ui.vbm.adapter3d.DragDropHandler", /** @lends sap.ui.vbm.adapter3d.DragDropHandler.prototype */ {
@@ -29,7 +29,7 @@ sap.ui.define([
29
29
  *
30
30
  * @private
31
31
  * @author SAP SE
32
- * @version 1.143.0
32
+ * @version 1.145.0
33
33
  * @alias sap.ui.vbm.adapter3d.ModelHandler
34
34
  */
35
35
  var ModelHandler = BaseObject.extend("sap.ui.vbm.adapter3d.ModelHandler", /** @lends sap.ui.vbm.adapter3d.ModelHandler.prototype */ {
@@ -377,7 +377,7 @@ sap.ui.define([
377
377
  *
378
378
  * @private
379
379
  * @author SAP SE
380
- * @version 1.143.0
380
+ * @version 1.145.0
381
381
  * @alias sap.ui.vbm.adapter3d.ObjectFactory
382
382
  */
383
383
  var ObjectFactory = BaseObject.extend("sap.ui.vbm.adapter3d.ObjectFactory", /** @lends sap.ui.vbm.adapter3d.ObjectFactory.prototype */ {});
@@ -32,7 +32,7 @@ sap.ui.define([
32
32
  *
33
33
  * @private
34
34
  * @author SAP SE
35
- * @version 1.143.0
35
+ * @version 1.145.0
36
36
  * @alias sap.ui.vbm.adapter3d.PolygonHandler
37
37
  */
38
38
  var PolygonHandler = BaseObject.extend("sap.ui.vbm.adapter3d.PolygonHandler", /** @lends sap.ui.vbm.adapter3d.PolygonHandler.prototype */ {
@@ -39,7 +39,7 @@ sap.ui.define([
39
39
  *
40
40
  * @private
41
41
  * @author SAP SE
42
- * @version 1.143.0
42
+ * @version 1.145.0
43
43
  * @alias sap.ui.vbm.adapter3d.RectangleTracker
44
44
  */
45
45
  var RectangleTracker = BaseObject.extend("sap.ui.vbm.adapter3d.RectangleTracker", /** @lends sap.ui.vbm.adapter3d.RectangleTracker.prototype */ {
@@ -47,7 +47,7 @@ sap.ui.define([
47
47
  *
48
48
  * @private
49
49
  * @author SAP SE
50
- * @version 1.143.0
50
+ * @version 1.145.0
51
51
  * @alias sap.ui.vbm.adapter3d.SceneBuilder
52
52
  */
53
53
  var SceneBuilder = BaseObject.extend("sap.ui.vbm.adapter3d.SceneBuilder", /** @lends sap.ui.vbm.adapter3d.SceneBuilder.prototype */ {
@@ -56,7 +56,7 @@ sap.ui.define([
56
56
  *
57
57
  * @private
58
58
  * @author SAP SE
59
- * @version 1.143.0
59
+ * @version 1.145.0
60
60
  * @alias sap.ui.vbm.adapter3d.VBIJSONParser
61
61
  */
62
62
  var VBIJSONParser = BaseObject.extend("sap.ui.vbm.adapter3d.VBIJSONParser", /** @lends sap.ui.vbm.adapter3d.VBIJSONParser.prototype */ {
@@ -20,7 +20,7 @@ sap.ui.define([
20
20
  * @namespace
21
21
  * @alias sap.ui.vbm
22
22
  * @author SAP SE
23
- * @version 1.143.0
23
+ * @version 1.145.0
24
24
  * @public
25
25
  */
26
26
 
@@ -46,7 +46,7 @@ sap.ui.define([
46
46
  "sap.ui.vbm.ClusterBase", "sap.ui.vbm.ClusterTree", "sap.ui.vbm.ClusterGrid", "sap.ui.vbm.ClusterDistance", "sap.ui.vbm.Heatmap",
47
47
  "sap.ui.vbm.HeatPoint", "sap.ui.vbm.ClusterContainer", "sap.ui.vbm.Adapter", "sap.ui.vbm.Adapter3D"
48
48
  ],
49
- version: "1.143.0"
49
+ version: "1.145.0"
50
50
  });
51
51
 
52
52
  sap.ui.loader.config({
@@ -515,22 +515,33 @@ sap.ui.define([
515
515
  predefinedMarkers.push(markerCoordinates);
516
516
  }
517
517
  } else if (marker.geometry.type == "LineString") {
518
-
518
+
519
519
  if (marker.properties.Label) {
520
- const midpoint = getMidpoint(marker.geometry.coordinates);
520
+ const coords = marker.geometry.coordinates;
521
+ let midpoint = VectorUtils.getVisualMidpoint(coords, map);
521
522
 
522
523
  const routeLabelEl = VectorUtils.createRouteLabel(
523
524
  marker.properties.Label,
524
525
  marker.properties.LabelBGColor
525
526
  );
526
-
527
- new maplibregl.Marker({
527
+ const labelMarker = new maplibregl.Marker({
528
528
  element: routeLabelEl,
529
- anchor: 'left',
529
+ anchor: 'left',
530
+ offset: [10, 0]
530
531
  })
531
532
  .setLngLat(midpoint)
532
533
  .addTo(map);
534
+
535
+ map.on('move', () => {
536
+ try {
537
+ const newPos = VectorUtils.getVisualMidpoint(coords, map);
538
+ labelMarker.setLngLat(newPos);
539
+ } catch (e) {
540
+ console.warn("Label update failed:", e);
541
+ }
542
+ });
533
543
  }
544
+
534
545
  const coords = marker.geometry.coordinates;
535
546
  const startCoord = coords[0]; // First coordinate
536
547
  const endCoord = coords[coords.length - 1]; // Last coordinate
@@ -630,17 +641,6 @@ sap.ui.define([
630
641
  'filter': ['==', '$type', 'LineString']
631
642
  });
632
643
 
633
- function getMidpoint(coords) {
634
- if (coords.length < 2) return coords[0];
635
-
636
- const start = coords[0];
637
- const end = coords[coords.length - 1];
638
- const midLng = (start[0] + end[0]) / 2;
639
- const midLat = (start[1] + end[1]) / 2;
640
-
641
- return [midLng, midLat];
642
- }
643
-
644
644
  // Create a new FeatureCollection for the points
645
645
  const pointGeoJSON = {
646
646
  'type': 'FeatureCollection',
@@ -665,7 +665,8 @@ sap.ui.define([
665
665
  'icon-size': ['get', 'borderSize'],
666
666
  'icon-allow-overlap': true,
667
667
  'icon-rotation-alignment': 'map',
668
- 'icon-rotate': ['get', 'arrowRotation'] // Rotate based on calculated angle
668
+ 'icon-rotate': ['get', 'arrowRotation'], // Rotate based on calculated angle
669
+ 'icon-offset': [-12, 4]
669
670
  },
670
671
  'paint': {
671
672
  'icon-color': ['get', 'BorderColor'] // Match the arrow color with the line color
@@ -682,7 +683,8 @@ sap.ui.define([
682
683
  'icon-size': ['get', 'size'],
683
684
  'icon-allow-overlap': true,
684
685
  'icon-rotation-alignment': 'map',
685
- 'icon-rotate': ['get', 'arrowRotation'] // Rotate based on calculated angle
686
+ 'icon-rotate': ['get', 'arrowRotation'], // Rotate based on calculated angle
687
+ 'icon-offset': [-12, 4]
686
688
  },
687
689
  'paint': {
688
690
  'icon-color': ['get', 'Color'] // Match the arrow color with the line color
@@ -12,7 +12,7 @@ sap.ui.define([
12
12
  *
13
13
  * @private
14
14
  * @author SAP SE
15
- * @version 1.143.0
15
+ * @version 1.145.0
16
16
  * @alias sap.ui.vbm.vector.PayloadGenerator
17
17
  */
18
18
  var adapter = {};
@@ -12,7 +12,7 @@ sap.ui.define([
12
12
  *
13
13
  * @private
14
14
  * @author SAP SE
15
- * @version 1.143.0
15
+ * @version 1.145.0
16
16
  * @alias sap.ui.vbm.vector.RectangularSelection
17
17
  */
18
18
 
@@ -113,7 +113,8 @@ sap.ui.define([
113
113
  //Focus the map into the features
114
114
  if (zoombounds) {
115
115
  map.fitBounds(zoombounds, {
116
- padding: 150
116
+ padding: 150,
117
+ maxZoom: 13
117
118
  });
118
119
  }
119
120
  return true;
@@ -471,7 +471,7 @@ VectorUtils.createRouteLabel = (label, labelcolor) => {
471
471
 
472
472
  VectorUtils.getArrowHead = (callback) => {
473
473
  const svgArrow = `
474
- <svg fill="currentColor" width="60px" height="60px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
474
+ <svg fill="currentColor" width="80px" height="80px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
475
475
  <g data-name="Layer 2">
476
476
  <g data-name="arrow-right">
477
477
  <rect width="24" height="24" transform="rotate(180 12 12)" opacity="0"/>
@@ -580,6 +580,167 @@ VectorUtils.createRouteLabel = (label, labelcolor) => {
580
580
  return rect;
581
581
  };
582
582
 
583
+ VectorUtils.getVisualMidpoint = function (coords, map) {
584
+
585
+ if (!Array.isArray(coords) || coords.length < 2) {
586
+ console.warn("getVisualMidpoint(): invalid coords", coords);
587
+ return coords?.[0] || [0, 0];
588
+ }
589
+
590
+ const clean = coords.filter(c =>
591
+ Array.isArray(c) &&
592
+ typeof c[0] === "number" &&
593
+ typeof c[1] === "number" &&
594
+ isFinite(c[0]) &&
595
+ isFinite(c[1])
596
+ );
597
+
598
+ if (clean.length < 2) {
599
+ console.warn("getVisualMidpoint(): after cleaning, less than 2 coords", clean);
600
+ return clean[0] || [0, 0];
601
+ }
602
+
603
+ let projected;
604
+ try {
605
+ projected = clean.map(c => map.project({ lng: c[0], lat: c[1] }));
606
+ } catch (e) {
607
+ console.warn("project() failed", e);
608
+ return clean[0];
609
+ }
610
+
611
+ const mapSize = map.getContainer().getBoundingClientRect();
612
+ const screenBounds = {
613
+ left: 0,
614
+ right: mapSize.width,
615
+ top: 0,
616
+ bottom: mapSize.height
617
+ };
618
+
619
+ const clipped = VectorUtils._clipLineToScreen(projected, screenBounds);
620
+
621
+ if (clipped && clipped.length >= 2) {
622
+ try {
623
+ let totalLength = 0;
624
+ const segmentLengths = [];
625
+
626
+ for (let i = 0; i < clipped.length - 1; i++) {
627
+ const dx = clipped[i + 1].x - clipped[i].x;
628
+ const dy = clipped[i + 1].y - clipped[i].y;
629
+ const len = Math.sqrt(dx * dx + dy * dy);
630
+
631
+ if (len > 0 && isFinite(len)) {
632
+ segmentLengths.push(len);
633
+ totalLength += len;
634
+ }
635
+ }
636
+
637
+ if (totalLength === 0) throw "Zero total length";
638
+
639
+ let half = totalLength / 2;
640
+ let acc = 0;
641
+
642
+ for (let i = 0; i < segmentLengths.length; i++) {
643
+ const seg = segmentLengths[i];
644
+ if (acc + seg >= half) {
645
+ const ratio = (half - acc) / seg;
646
+
647
+ const x = clipped[i].x + ratio * (clipped[i + 1].x - clipped[i].x);
648
+ const y = clipped[i].y + ratio * (clipped[i + 1].y - clipped[i].y);
649
+
650
+ const mid = map.unproject({ x, y });
651
+ return [mid.lng, mid.lat];
652
+ }
653
+ acc += seg;
654
+ }
655
+ } catch (err) {
656
+ console.warn("Visual midpoint failed, fallback to geographic", err);
657
+ }
658
+ }
659
+
660
+ return VectorUtils._computeGeographicMidpoint(clean);
661
+ };
662
+ VectorUtils._computeGeographicMidpoint = function (coords) {
663
+ const mid = Math.floor(coords.length / 2);
664
+ return coords[mid];
665
+ };
666
+
667
+ VectorUtils._clipLineToScreen = function (projectedCoords, bounds) {
668
+ const clipped = [];
669
+
670
+ for (let i = 0; i < projectedCoords.length - 1; i++) {
671
+ const seg = VectorUtils._clipSegmentToRect(
672
+ projectedCoords[i],
673
+ projectedCoords[i + 1],
674
+ bounds
675
+ );
676
+
677
+ if (seg) {
678
+ if (clipped.length === 0) clipped.push(seg[0]);
679
+ clipped.push(seg[1]);
680
+ }
681
+ }
682
+
683
+ return clipped.length > 1 ? clipped : null;
684
+ };
685
+
686
+ VectorUtils._clipSegmentToRect = function (p1, p2, rect) {
687
+
688
+ const INSIDE = 0, LEFT = 1, RIGHT = 2, BOTTOM = 4, TOP = 8;
689
+
690
+ const computeOutCode = (x, y) => {
691
+ let code = INSIDE;
692
+ if (x < rect.left) code |= LEFT;
693
+ else if (x > rect.right) code |= RIGHT;
694
+ if (y < rect.top) code |= TOP;
695
+ else if (y > rect.bottom) code |= BOTTOM;
696
+ return code;
697
+ };
698
+
699
+ let x1 = p1.x, y1 = p1.y;
700
+ let x2 = p2.x, y2 = p2.y;
701
+
702
+ let outcode1 = computeOutCode(x1, y1);
703
+ let outcode2 = computeOutCode(x2, y2);
704
+
705
+ while (true) {
706
+ if (!(outcode1 | outcode2)) {
707
+ return [{ x: x1, y: y1 }, { x: x2, y: y2 }];
708
+ }
709
+ if (outcode1 & outcode2) {
710
+ return null;
711
+ }
712
+
713
+ const out = outcode1 ? outcode1 : outcode2;
714
+ const dx = x2 - x1;
715
+ const dy = y2 - y1;
716
+
717
+ let x, y;
718
+
719
+ if (out & TOP) {
720
+ x = x1 + dx * (rect.top - y1) / dy;
721
+ y = rect.top;
722
+ } else if (out & BOTTOM) {
723
+ x = x1 + dx * (rect.bottom - y1) / dy;
724
+ y = rect.bottom;
725
+ } else if (out & RIGHT) {
726
+ y = y1 + dy * (rect.right - x1) / dx;
727
+ x = rect.right;
728
+ } else {
729
+ y = y1 + dy * (rect.left - x1) / dx;
730
+ x = rect.left;
731
+ }
732
+
733
+ if (out === outcode1) {
734
+ x1 = x; y1 = y;
735
+ outcode1 = computeOutCode(x1, y1);
736
+ } else {
737
+ x2 = x; y2 = y;
738
+ outcode2 = computeOutCode(x2, y2);
739
+ }
740
+ }
741
+ };
742
+
743
+
583
744
  return VectorUtils;
584
745
 
585
746
  });