@sapui5/sap.ui.vbm 1.131.0 → 1.133.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 +1 -1
- package/src/sap/ui/vbm/.library +1 -1
- package/src/sap/ui/vbm/Adapter.js +13 -7
- package/src/sap/ui/vbm/Adapter3D.js +1 -1
- package/src/sap/ui/vbm/Viewport.js +1 -1
- package/src/sap/ui/vbm/adapter3d/ColladaBounds.js +1 -1
- package/src/sap/ui/vbm/adapter3d/DragDropHandler.js +1 -1
- package/src/sap/ui/vbm/adapter3d/ModelHandler.js +1 -1
- package/src/sap/ui/vbm/adapter3d/ObjectFactory.js +1 -1
- package/src/sap/ui/vbm/adapter3d/PolygonHandler.js +1 -1
- package/src/sap/ui/vbm/adapter3d/RectangleTracker.js +1 -1
- package/src/sap/ui/vbm/adapter3d/SceneBuilder.js +1 -1
- package/src/sap/ui/vbm/adapter3d/VBIJSONParser.js +1 -1
- package/src/sap/ui/vbm/i18n/messagebundle_ar.properties +1 -1
- package/src/sap/ui/vbm/i18n/messagebundle_en_US_saptrc.properties +23 -23
- package/src/sap/ui/vbm/lib/sapvbmenu.js +14 -3
- package/src/sap/ui/vbm/library.js +2 -2
- package/src/sap/ui/vbm/vector/LassoSelection.js +201 -0
- package/src/sap/ui/vbm/vector/MapRenderer.js +388 -375
- package/src/sap/ui/vbm/vector/PayloadGenerator.js +177 -17
- package/src/sap/ui/vbm/vector/RectangularSelection.js +119 -0
- package/src/sap/ui/vbm/vector/VBITransformer.js +257 -287
- package/src/sap/ui/vbm/vector/VectorUtils.js +327 -3
- package/src/sap/ui/vbm/vector/thirdparty/MaplibreStyles.js +11 -1
package/package.json
CHANGED
package/src/sap/ui/vbm/.library
CHANGED
|
@@ -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.
|
|
6
|
+
<version>1.133.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.
|
|
27
|
+
* @version 1.133.0
|
|
28
28
|
* @extends sap.ui.core.Element
|
|
29
29
|
* @constructor
|
|
30
30
|
* @public
|
|
@@ -288,7 +288,11 @@ sap.ui.define([
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
} else if (obj?.SAPVB?.Scenes?.Merge) {
|
|
291
|
-
|
|
291
|
+
var mapLayerStack = obj?.SAPVB?.Scenes?.Merge?.SceneGeo?.refMapLayerStack
|
|
292
|
+
if (mapLayerStack) {
|
|
293
|
+
const provider = this._mapConfiguration.MapProvider.find(provider => provider.name === mapLayerStack);
|
|
294
|
+
return provider.type === "vector" ? true : false;
|
|
295
|
+
}
|
|
292
296
|
}
|
|
293
297
|
}
|
|
294
298
|
|
|
@@ -344,10 +348,12 @@ sap.ui.define([
|
|
|
344
348
|
this._processClusters(obj.SAPVB.Clustering);
|
|
345
349
|
}
|
|
346
350
|
|
|
347
|
-
VBI.
|
|
351
|
+
if (VBI.VBITransformer.getVectorFlag() == true) {
|
|
352
|
+
VBI.MapRenderer.setAdapter(this);
|
|
353
|
+
}
|
|
348
354
|
return (obj.SAPVB.MapProviders ? this._processMapProviders(obj.SAPVB.MapProviders)
|
|
349
355
|
: Promise.resolve()).then(function() {
|
|
350
|
-
if (obj.SAPVB.MapLayerStacks) {
|
|
356
|
+
if (obj.SAPVB.MapLayerStacks && VBI.VBITransformer.getVectorFlag() == false) {
|
|
351
357
|
this._processMapLayerStacks(obj.SAPVB.MapLayerStacks);
|
|
352
358
|
}
|
|
353
359
|
|
|
@@ -363,11 +369,11 @@ sap.ui.define([
|
|
|
363
369
|
this._processActions(obj.SAPVB.Actions);
|
|
364
370
|
}
|
|
365
371
|
|
|
366
|
-
if (obj.SAPVB.Automation && obj.SAPVB.Automation.Call) {
|
|
372
|
+
if (obj.SAPVB.Automation && obj.SAPVB.Automation.Call && VBI.VBITransformer.getVectorFlag() == false) {
|
|
367
373
|
this._processAutomation(obj.SAPVB.Automation, obj.SAPVB.Menus);
|
|
368
374
|
}
|
|
369
375
|
|
|
370
|
-
if (obj.SAPVB.Windows) {
|
|
376
|
+
if (obj.SAPVB.Windows && VBI.VBITransformer.getVectorFlag() == false) {
|
|
371
377
|
this._processDetailWindows(obj);
|
|
372
378
|
}
|
|
373
379
|
}.bind(this));
|
|
@@ -925,7 +931,7 @@ sap.ui.define([
|
|
|
925
931
|
oMap.addVo(voAggregation);
|
|
926
932
|
}.bind(this));
|
|
927
933
|
} else if (oScenes.Merge && oScenes.Merge.SceneGeo
|
|
928
|
-
&& oScenes.Merge.SceneGeo.refMapLayerStack) {
|
|
934
|
+
&& oScenes.Merge.SceneGeo.refMapLayerStack && VBI.VBITransformer.getVectorFlag() == false) {
|
|
929
935
|
this._map().setRefMapLayerStack(oScenes.Merge.SceneGeo.refMapLayerStack);
|
|
930
936
|
}
|
|
931
937
|
return this;
|
|
@@ -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.
|
|
50
|
+
* @version 1.133.0
|
|
51
51
|
* @extends sap.ui.core.Element
|
|
52
52
|
* @constructor
|
|
53
53
|
* @public
|
|
@@ -22,7 +22,7 @@ sap.ui.define([
|
|
|
22
22
|
*
|
|
23
23
|
* @private
|
|
24
24
|
* @author SAP SE
|
|
25
|
-
* @version 1.
|
|
25
|
+
* @version 1.133.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.
|
|
86
|
+
* @version 1.133.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.
|
|
32
|
+
* @version 1.133.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.
|
|
380
|
+
* @version 1.133.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.
|
|
35
|
+
* @version 1.133.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.
|
|
42
|
+
* @version 1.133.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.
|
|
50
|
+
* @version 1.133.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.
|
|
59
|
+
* @version 1.133.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 */ {
|
|
@@ -4,7 +4,7 @@ NAVCTL_TITLE_ZOOM=\u062A\u0643\u0628\u064A\u0631 {0}
|
|
|
4
4
|
NAVCTL_TITLE_MOVE_UP=\u062A\u062D\u0631\u064A\u0643 \u0644\u0623\u0639\u0644\u0649
|
|
5
5
|
NAVCTL_TITLE_MOVE_DOWN=\u062A\u062D\u0631\u064A\u0643 \u0644\u0623\u0633\u0641\u0644
|
|
6
6
|
NAVCTL_TITLE_MOVE_LEFT=\u0627\u0644\u0627\u0646\u062A\u0642\u0627\u0644 \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646
|
|
7
|
-
NAVCTL_TITLE_MOVE_RIGHT=\u0627\u0644\u0627\u0646\u062A\u0642\u0627\u0644 \u0625\u0644\u0649 \u0627\u0644\u064A\
|
|
7
|
+
NAVCTL_TITLE_MOVE_RIGHT=\u0627\u0644\u0627\u0646\u062A\u0642\u0627\u0644 \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646
|
|
8
8
|
WINDOW_CLOSE=\u0625\u063A\u0644\u0627\u0642
|
|
9
9
|
LEGEND_COLLAPSE=\u0637\u064A
|
|
10
10
|
LEGEND_EXPAND=\u062A\u0648\u0633\u064A\u0639
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
|
|
2
|
-
NAVCTL_TITLE_MOVE=
|
|
3
|
-
NAVCTL_TITLE_ZOOM=
|
|
4
|
-
NAVCTL_TITLE_MOVE_UP=
|
|
5
|
-
NAVCTL_TITLE_MOVE_DOWN=
|
|
6
|
-
NAVCTL_TITLE_MOVE_LEFT=
|
|
7
|
-
NAVCTL_TITLE_MOVE_RIGHT=
|
|
8
|
-
WINDOW_CLOSE=
|
|
9
|
-
LEGEND_COLLAPSE=
|
|
10
|
-
LEGEND_EXPAND=
|
|
11
|
-
CAPTION_LEGEND=
|
|
2
|
+
NAVCTL_TITLE_MOVE=970/69gkzkdj6OaR6IEeRg_Double-click to return to start position
|
|
3
|
+
NAVCTL_TITLE_ZOOM=BihGfsldx1AOxxTRxnOc2A_Zoom {0}
|
|
4
|
+
NAVCTL_TITLE_MOVE_UP=sBGfHpJN1US/+w19T9TrEA_Move Up
|
|
5
|
+
NAVCTL_TITLE_MOVE_DOWN=EgEN3ozMG5ix9G/JIgo7Ew_Move Down
|
|
6
|
+
NAVCTL_TITLE_MOVE_LEFT=t4DfFmHFqa06hM6fp/rnlg_Move Left
|
|
7
|
+
NAVCTL_TITLE_MOVE_RIGHT=ChseCQWrpiKnkOMpYgTB0A_Move Right
|
|
8
|
+
WINDOW_CLOSE=NvNXt+Dni3zr+OIQoGQy6g_Close
|
|
9
|
+
LEGEND_COLLAPSE=Yim/keZQzOF2cxfEdEQ56A_Collapse
|
|
10
|
+
LEGEND_EXPAND=3c6HMI1fgHX/S63bC+16+w_Expand
|
|
11
|
+
CAPTION_LEGEND=KtbTQvnhPQFzFf7zcjqaNw_Legend
|
|
12
12
|
|
|
13
|
-
GEOMAP_INVALID_CENTER_POSITION=
|
|
14
|
-
GEOMAP_INVALID_ZOOM_LEVEL=
|
|
13
|
+
GEOMAP_INVALID_CENTER_POSITION=R8Ad0kUscG7KSrY6j5OhJA_Invalid center position given
|
|
14
|
+
GEOMAP_INVALID_ZOOM_LEVEL=SPIIRdu0m+Q8Ieqj790+rA_Invalid zoom level given
|
|
15
15
|
|
|
16
|
-
CONTAINERBASE_FULLSCREEN=
|
|
17
|
-
CONTAINERBASE_SETTINGS
|
|
18
|
-
CONTAINERBASE_MENU=
|
|
19
|
-
CONTAINERBASE_SELECTION=
|
|
20
|
-
CONTAINERBASE_MENU_RECT=
|
|
21
|
-
CONTAINERBASE_MENU_LASSO
|
|
22
|
-
CONTAINERBASE_MENU_SINGLE=
|
|
16
|
+
CONTAINERBASE_FULLSCREEN=l92Y4q9p+urWIT2+sAKZfA_Full Screen
|
|
17
|
+
CONTAINERBASE_SETTINGS=+M9V7u3bfMIdfiukOgZHJA_Settings
|
|
18
|
+
CONTAINERBASE_MENU=IdZ9EmX+P3tVtICpu7kzDw_Menu
|
|
19
|
+
CONTAINERBASE_SELECTION=E314dAx1Fv7fscTpa9bdfw_Selection Mode
|
|
20
|
+
CONTAINERBASE_MENU_RECT=wIeLGRVNQxAhJB3EevbJzg_Rectangular Selection
|
|
21
|
+
CONTAINERBASE_MENU_LASSO=FBwPDfuk0U5enzDROggvZA_Lasso Selection
|
|
22
|
+
CONTAINERBASE_MENU_SINGLE=t6hkbrNBJkMGNFS8nrdT7Q_Single Selection
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
MAPCONTAINER_ZOOMIN=
|
|
26
|
-
MAPCONTAINER_ZOOMOUT=
|
|
27
|
-
MAPCONTAINER_HOME=
|
|
28
|
-
MAPCONTAINER_RECT_ZOOM
|
|
25
|
+
MAPCONTAINER_ZOOMIN=36demzd2ZEdd6KJNnhlroA_Zoom In
|
|
26
|
+
MAPCONTAINER_ZOOMOUT=TMXZHw75FiMOLMLog73qww_Zoom Out
|
|
27
|
+
MAPCONTAINER_HOME=jGKXlprGCAFO5Tol2tls/Q_Home
|
|
28
|
+
MAPCONTAINER_RECT_ZOOM=YIbGeSk7RnurJHo1VeHxPA_Rectangular Zoom
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
sap.ui.define([
|
|
11
11
|
"sap/ui/unified/Menu",
|
|
12
12
|
"sap/ui/unified/MenuItem",
|
|
13
|
+
"sap/ui/vbm/vector/PayloadGenerator",
|
|
13
14
|
"./sapvbi"
|
|
14
|
-
], function(Menu, MenuItem) {
|
|
15
|
+
], function(Menu, MenuItem, PayloadGenerator) {
|
|
15
16
|
"use strict";
|
|
16
17
|
|
|
17
18
|
VBI.Menus = function() {
|
|
@@ -34,7 +35,10 @@ VBI.Menus = function() {
|
|
|
34
35
|
oMenuObject.vbi_data = {};
|
|
35
36
|
oMenuObject.vbi_data.menuRef = dat.id;
|
|
36
37
|
oMenuObject.vbi_data.VBIName = dat.name;
|
|
37
|
-
|
|
38
|
+
if (VBI.vectorFlag == true) {
|
|
39
|
+
oMenuObject.vbi_data.object = ctx.object;
|
|
40
|
+
oMenuObject.vbi_data.instance = ctx.instance;
|
|
41
|
+
};
|
|
38
42
|
oMenuObject.attachItemSelect(function(e) {
|
|
39
43
|
var retval = {};
|
|
40
44
|
retval.refid = e.mParameters.item.vbi_data.refid;
|
|
@@ -162,6 +166,13 @@ VBI.Menus = function() {
|
|
|
162
166
|
|
|
163
167
|
menus.OnSelected = function(retval) {
|
|
164
168
|
var refObj = retval.menu.vbi_data.object;
|
|
169
|
+
if (VBI.vectorFlag == true) {
|
|
170
|
+
if (_adapter._actions) {
|
|
171
|
+
var m_name = "FCODE_SELECT";
|
|
172
|
+
var refid = retval.refid;
|
|
173
|
+
PayloadGenerator.fcodeSelect(m_name, refid, refObj, retval.menu.vbi_data.instance);
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
165
176
|
if (retval.refid == undefined) {
|
|
166
177
|
return;
|
|
167
178
|
}
|
|
@@ -176,7 +187,7 @@ VBI.Menus = function() {
|
|
|
176
187
|
}
|
|
177
188
|
}
|
|
178
189
|
};
|
|
179
|
-
|
|
190
|
+
}
|
|
180
191
|
return menus;
|
|
181
192
|
};
|
|
182
193
|
|
|
@@ -20,7 +20,7 @@ sap.ui.define([
|
|
|
20
20
|
* @namespace
|
|
21
21
|
* @alias sap.ui.vbm
|
|
22
22
|
* @author SAP SE
|
|
23
|
-
* @version 1.
|
|
23
|
+
* @version 1.133.0
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
26
|
|
|
@@ -45,7 +45,7 @@ sap.ui.define([
|
|
|
45
45
|
"sap.ui.vbm.ClusterBase", "sap.ui.vbm.ClusterTree", "sap.ui.vbm.ClusterGrid", "sap.ui.vbm.ClusterDistance", "sap.ui.vbm.Heatmap",
|
|
46
46
|
"sap.ui.vbm.HeatPoint", "sap.ui.vbm.ClusterContainer", "sap.ui.vbm.Adapter", "sap.ui.vbm.Adapter3D"
|
|
47
47
|
],
|
|
48
|
-
version: "1.
|
|
48
|
+
version: "1.133.0"
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
sap.ui.loader.config({
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
sap.ui.define([
|
|
2
|
+
"sap/ui/base/Object",
|
|
3
|
+
"./PayloadGenerator"
|
|
4
|
+
], function (BaseObject, PayloadGenerator) {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Constructor for a new LassoSelection.
|
|
9
|
+
*
|
|
10
|
+
* @class
|
|
11
|
+
* Provides a class for doing Lasso Selection on map.
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
* @alias sap.ui.vbm.vector.LassoSelection
|
|
15
|
+
*/
|
|
16
|
+
const LassoSelection = BaseObject.extend("sap.ui.vbm.vector.LassoSelection", {
|
|
17
|
+
constructor: function (map) {
|
|
18
|
+
BaseObject.call(this);
|
|
19
|
+
this._map = map;
|
|
20
|
+
this._coordinates = [];
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
mouseDown(e, aPressed) {
|
|
24
|
+
const map = this._map;
|
|
25
|
+
const canvas = map.getCanvasContainer();
|
|
26
|
+
const lassoPolygon = createLassoSVG();
|
|
27
|
+
|
|
28
|
+
if (!(aPressed && e.button === 0)) return;
|
|
29
|
+
|
|
30
|
+
map.dragPan.disable();
|
|
31
|
+
var that = this;
|
|
32
|
+
this._coordinates = [mousePos(e)];
|
|
33
|
+
|
|
34
|
+
document.addEventListener('mousemove', onMouseMove);
|
|
35
|
+
document.addEventListener('mouseup', onMouseUp);
|
|
36
|
+
document.addEventListener('keydown', onKeyDown);
|
|
37
|
+
|
|
38
|
+
function mousePos(e) {
|
|
39
|
+
const rect = canvas.getBoundingClientRect();
|
|
40
|
+
return new maplibregl.Point(
|
|
41
|
+
e.clientX - rect.left - canvas.clientLeft,
|
|
42
|
+
e.clientY - rect.top - canvas.clientTop
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function onMouseMove(e) {
|
|
47
|
+
const point = mousePos(e);
|
|
48
|
+
|
|
49
|
+
that._coordinates.push(point);
|
|
50
|
+
|
|
51
|
+
updateLassoPath(lassoPolygon, that._coordinates);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function onMouseUp(e) {
|
|
55
|
+
const selectedFeatures = finishLasso();
|
|
56
|
+
// Only trigger payload if something is selected
|
|
57
|
+
if (selectedFeatures && selectedFeatures.length > 0) {
|
|
58
|
+
PayloadGenerator.selectObjects(selectedFeatures);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function onKeyDown(e) {
|
|
63
|
+
if (e.keyCode === 27) finishLasso();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function updateLassoPath(polygon, coordinates) {
|
|
67
|
+
let points = '';
|
|
68
|
+
for (let i = 0; i < coordinates.length; i++) {
|
|
69
|
+
points += `${coordinates[i].x},${coordinates[i].y} `;
|
|
70
|
+
}
|
|
71
|
+
polygon.setAttribute("points", points.trim());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function finishLasso() {
|
|
75
|
+
document.removeEventListener('mousemove', onMouseMove);
|
|
76
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
77
|
+
document.removeEventListener('mouseup', onMouseUp);
|
|
78
|
+
|
|
79
|
+
// Remove the lasso
|
|
80
|
+
lassoPolygon?.parentNode?.remove();
|
|
81
|
+
|
|
82
|
+
// Convert lasso points to geographic coordinates
|
|
83
|
+
const lassoGeoCoords = that._coordinates.map(point =>
|
|
84
|
+
that._map.unproject([point.x, point.y])
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Find the pixel bounding box for the lasso coordinates
|
|
88
|
+
const bounds = that._coordinates.reduce((bbox, point) => {
|
|
89
|
+
bbox.minX = Math.min(bbox.minX, point.x);
|
|
90
|
+
bbox.minY = Math.min(bbox.minY, point.y);
|
|
91
|
+
bbox.maxX = Math.max(bbox.maxX, point.x);
|
|
92
|
+
bbox.maxY = Math.max(bbox.maxY, point.y);
|
|
93
|
+
return bbox;
|
|
94
|
+
}, { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity });
|
|
95
|
+
|
|
96
|
+
// Create a pixel-based bounding box for queryRenderedFeatures
|
|
97
|
+
const bbox = [
|
|
98
|
+
new maplibregl.Point(bounds.minX, bounds.minY),
|
|
99
|
+
new maplibregl.Point(bounds.maxX, bounds.maxY)
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
// Query features within the pixel bounding box
|
|
103
|
+
const candidates = that._map.queryRenderedFeatures(bbox, {
|
|
104
|
+
layers: ['geojson-source-route', 'geojson-source-point']
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Filter candidates by checking if they fall within the geographic lasso polygon
|
|
108
|
+
const selectedFeatures = candidates.filter(feature => {
|
|
109
|
+
const coordinates = feature.geometry.coordinates;
|
|
110
|
+
|
|
111
|
+
if (feature.geometry.type === 'Point') {
|
|
112
|
+
// Handle points
|
|
113
|
+
return pointInPolygon(coordinates, lassoGeoCoords);
|
|
114
|
+
} else if (feature.geometry.type === 'LineString') {
|
|
115
|
+
// Handle lines by checking if any segment intersects the lasso polygon
|
|
116
|
+
return lineInPolygonOrIntersects(coordinates, lassoGeoCoords);
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
});
|
|
120
|
+
that._map.dragPan.enable();
|
|
121
|
+
return selectedFeatures;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Helper function to check if a point is inside the lasso polygon
|
|
125
|
+
function pointInPolygon(point, polygon) {
|
|
126
|
+
let inside = false;
|
|
127
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
128
|
+
const xi = polygon[i].lng, yi = polygon[i].lat;
|
|
129
|
+
const xj = polygon[j].lng, yj = polygon[j].lat;
|
|
130
|
+
|
|
131
|
+
const intersect = ((yi > point[1]) !== (yj > point[1])) &&
|
|
132
|
+
(point[0] < (xj - xi) * (point[1] - yi) / (yj - yi) + xi);
|
|
133
|
+
if (intersect) inside = !inside;
|
|
134
|
+
}
|
|
135
|
+
return inside;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function lineInPolygonOrIntersects(line, polygon) {
|
|
139
|
+
// First, check if any point in the line is inside the polygon
|
|
140
|
+
if (line.some(point => pointInPolygon(point, polygon))) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// If no points are inside, check if any line segment intersects the polygon
|
|
145
|
+
for (let i = 0; i < line.length - 1; i++) {
|
|
146
|
+
const lineStart = line[i];
|
|
147
|
+
const lineEnd = line[i + 1];
|
|
148
|
+
|
|
149
|
+
for (let j = 0; j < polygon.length - 1; j++) {
|
|
150
|
+
const polyStart = [polygon[j].lng, polygon[j].lat];
|
|
151
|
+
const polyEnd = [polygon[j + 1].lng, polygon[j + 1].lat];
|
|
152
|
+
|
|
153
|
+
if (segmentsIntersect(lineStart, lineEnd, polyStart, polyEnd)) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
function segmentsIntersect(p1, p2, q1, q2) {
|
|
161
|
+
const orientation = (p, q, r) => {
|
|
162
|
+
const val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1]);
|
|
163
|
+
return val === 0 ? 0 : (val > 0 ? 1 : 2);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const o1 = orientation(p1, p2, q1);
|
|
167
|
+
const o2 = orientation(p1, p2, q2);
|
|
168
|
+
const o3 = orientation(q1, q2, p1);
|
|
169
|
+
const o4 = orientation(q1, q2, p2);
|
|
170
|
+
|
|
171
|
+
if (o1 !== o2 && o3 !== o4) return true;
|
|
172
|
+
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function createLassoSVG() {
|
|
177
|
+
// Create the SVG namespace
|
|
178
|
+
const svgNS = "http://www.w3.org/2000/svg";
|
|
179
|
+
|
|
180
|
+
// Create the SVG element
|
|
181
|
+
const svg = document.createElementNS(svgNS, "svg");
|
|
182
|
+
svg.setAttribute("class", "lasso-svg");
|
|
183
|
+
svg.setAttribute("style", "position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none;");
|
|
184
|
+
|
|
185
|
+
// Create the polygon element for the lasso
|
|
186
|
+
const polygon = document.createElementNS(svgNS, "polygon");
|
|
187
|
+
polygon.setAttribute("style", "fill: rgba(205, 245, 255, 0.5); stroke: #000000; stroke-width: 2; stroke-dasharray: 1, 1;");
|
|
188
|
+
|
|
189
|
+
// Append the polygon to the SVG
|
|
190
|
+
svg.appendChild(polygon);
|
|
191
|
+
|
|
192
|
+
// Append the SVG to the document, e.g., within the map container
|
|
193
|
+
canvas.appendChild(svg);
|
|
194
|
+
|
|
195
|
+
return polygon; // Return the polygon so we can update its points dynamically
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
return LassoSelection;
|
|
201
|
+
});
|