atriusmaps-node-sdk 3.3.391 → 3.3.392
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/dist/cjs/package.json.js +8 -5
- package/dist/cjs/plugins/sdkServer/src/sdkServer.js +8 -4
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -1
- package/dist/cjs/src/debugTools.js +12 -0
- package/dist/cjs/src/extModules/bustle.js +12 -6
- package/dist/cjs/src/utils/dom.js +3 -0
- package/dist/cjs/src/utils/geom.js +118 -51
- package/dist/cjs/src/utils/location.js +3 -2
- package/dist/package.json.js +1 -1
- package/dist/plugins/sdkServer/src/sdkServer.js +1 -1
- package/dist/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -1
- package/dist/src/debugTools.js +1 -1
- package/dist/src/extModules/bustle.js +1 -1
- package/dist/src/utils/dom.js +1 -1
- package/dist/src/utils/geom.js +1 -1
- package/dist/src/utils/location.js +1 -1
- package/package.json +1 -1
package/dist/cjs/package.json.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "web-engine";
|
|
6
|
-
var version = "3.3.
|
|
6
|
+
var version = "3.3.392";
|
|
7
7
|
var license = "UNLICENSED";
|
|
8
8
|
var type = "module";
|
|
9
9
|
var main = "src/main.js";
|
|
@@ -76,6 +76,9 @@ var dependencies = {
|
|
|
76
76
|
"@mapbox/mapbox-gl-draw": "^1.4.3",
|
|
77
77
|
"@mapbox/mapbox-gl-draw-static-mode": "^1.0.1",
|
|
78
78
|
"@microsoft/applicationinsights-web": "^3.3.4",
|
|
79
|
+
"@turf/area": "^7.2.0",
|
|
80
|
+
"@turf/bbox-clip": "^7.2.0",
|
|
81
|
+
"@turf/bbox-polygon": "^7.2.0",
|
|
79
82
|
"@turf/circle": "^6.5.0",
|
|
80
83
|
"@turf/helpers": "^6.5.0",
|
|
81
84
|
"@turf/point-to-line-distance": "^6.5.0",
|
|
@@ -83,8 +86,9 @@ var dependencies = {
|
|
|
83
86
|
"axe-core": "^4.9.0",
|
|
84
87
|
browserslist: "^4.24.2",
|
|
85
88
|
"crypto-browserify": "^3.12.0",
|
|
86
|
-
"cypress-axe": "^1.
|
|
89
|
+
"cypress-axe": "^1.6.0",
|
|
87
90
|
"cypress-multi-reporters": "^1.6.4",
|
|
91
|
+
"cypress-real-events": "^1.14.0",
|
|
88
92
|
"file-loader": "^6.2.0",
|
|
89
93
|
flexsearch: "^0.7.43",
|
|
90
94
|
"h3-js": "^4.1.0",
|
|
@@ -146,10 +150,9 @@ var devDependencies = {
|
|
|
146
150
|
"babel-polyfill": "^6.26.0",
|
|
147
151
|
"chai-colors": "^1.0.1",
|
|
148
152
|
"css-loader": "^5.2.4",
|
|
149
|
-
cypress: "^12.17.
|
|
153
|
+
cypress: "^12.17.4",
|
|
150
154
|
"cypress-browser-permissions": "^1.1.0",
|
|
151
|
-
"cypress-
|
|
152
|
-
"cypress-wait-until": "^1.7.1",
|
|
155
|
+
"cypress-wait-until": "^1.7.2",
|
|
153
156
|
eslint: "^8.57.0",
|
|
154
157
|
"eslint-config-standard": "^16.0.3",
|
|
155
158
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var throttleDebounce = require('throttle-debounce');
|
|
3
4
|
var geom = require('../../../src/utils/geom.js');
|
|
4
5
|
var observable = require('../../../src/utils/observable.js');
|
|
5
6
|
var sdkHeadless = require('./sdkHeadless.js');
|
|
@@ -145,10 +146,12 @@ function registerEvents (app, sendEvent) {
|
|
|
145
146
|
sendEvent('userMoveStart', { lat, lng, floorId, ord: ordinal, structureId, pitch, zoom, bearing });
|
|
146
147
|
});
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
const userMoving = async ({ pitch, zoom, bearing }) => {
|
|
149
150
|
const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
|
|
150
151
|
sendEvent('userMoving', { lat, lng, floorId, ord: ordinal, structureId, pitch, zoom, bearing });
|
|
151
|
-
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
app.bus.monitor('map/userMoving', throttleDebounce.throttle(500, userMoving));
|
|
152
155
|
|
|
153
156
|
app.bus.monitor('map/moveEnd', async ({ pitch, zoom, bearing }) => {
|
|
154
157
|
const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
|
|
@@ -172,8 +175,9 @@ function registerEvents (app, sendEvent) {
|
|
|
172
175
|
|
|
173
176
|
app.bus.monitor('map/click', async ({ lat, lng, ord }) => {
|
|
174
177
|
const structures = await app.bus.get('venueData/getStructures');
|
|
175
|
-
const
|
|
176
|
-
|
|
178
|
+
const mapviewBBox = await app.bus.get('map/getViewBBox');
|
|
179
|
+
const { building: structure, floor } = geom.getStructureAndFloorAtPoint(structures, lat, lng, ord, mapviewBBox, true);
|
|
180
|
+
sendEvent('mapClicked', { lat, lng, ord, building: structure, floor });
|
|
177
181
|
});
|
|
178
182
|
}
|
|
179
183
|
|
|
@@ -105,7 +105,7 @@ const buildStructures = (venueData) => {
|
|
|
105
105
|
return structureOrder.map(structureId => {
|
|
106
106
|
const structure = structures[structureId];
|
|
107
107
|
// Was going to use this for selecting floors - but it seems floor bounds are incorrect? (was testing LAX/lax-msc-2 for example)
|
|
108
|
-
|
|
108
|
+
Object.values(structure.levels).forEach(level => (level.bounds = bounds.findBoundsOfCoordinates(level.boundsPolygon)));
|
|
109
109
|
const bounds$1 = bounds.findBoundsOfCoordinates(structure.boundsPolygon);
|
|
110
110
|
return { ...structure, bounds: bounds$1 }
|
|
111
111
|
})
|
|
@@ -71,6 +71,7 @@ async function bounds () {
|
|
|
71
71
|
async function buildingBounds (nameFilter) {
|
|
72
72
|
this.bus.send('map/showBuildingBounds', { nameFilter });
|
|
73
73
|
monitorDebugFeaturesReset('map/resetVenueBounds', this.bus);
|
|
74
|
+
showCenter.apply(this);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
async function floorBounds (nameFilter) {
|
|
@@ -78,9 +79,11 @@ async function floorBounds (nameFilter) {
|
|
|
78
79
|
bus.send('map/showFloorBounds', { nameFilter });
|
|
79
80
|
|
|
80
81
|
monitorDebugFeaturesReset('map/resetVenueBounds', bus);
|
|
82
|
+
|
|
81
83
|
const unsubFloorChanges = bus.monitor('map/floorChanged', () =>
|
|
82
84
|
bus.send('map/showFloorBounds', { nameFilter }));
|
|
83
85
|
onNextSearchClear(unsubFloorChanges, bus);
|
|
86
|
+
showCenter.apply(this);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
async function padding () {
|
|
@@ -100,6 +103,14 @@ const onNextSearchClear = (fn, bus) => {
|
|
|
100
103
|
});
|
|
101
104
|
};
|
|
102
105
|
|
|
106
|
+
async function showCenter () {
|
|
107
|
+
const padding = await this.bus.get('map/getPadding');
|
|
108
|
+
const leftAdj = (padding.left - padding.right) / 2; // how much to adjust left from true center to account for padding
|
|
109
|
+
const topAdj = (padding.top - padding.bottom) / 2; // how much to adjust top from true center to account for padding
|
|
110
|
+
const crosshair = dom.ad({ html: `<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><path stroke="#fF000080" stroke-width="2" d="M0 50h45M55 50h45M50 0v45M50 55v45"/></svg>`, styles: { position: 'absolute', left: '50%', top: '50%', 'margin-left': (-50 + leftAdj) + 'px', 'margin-top': (-50 + topAdj) + 'px' } }, dom.$('.maplibregl-map'));
|
|
111
|
+
onNextSearchClear(() => dom.del(crosshair), this.bus);
|
|
112
|
+
}
|
|
113
|
+
|
|
103
114
|
function dndGo () {
|
|
104
115
|
const bus = this.bus;
|
|
105
116
|
const toggleActive = (e, indicateDragVisual) => {
|
|
@@ -152,6 +163,7 @@ var debugTools = {
|
|
|
152
163
|
orphanTest: navGraphDebug.orphanTest,
|
|
153
164
|
padding,
|
|
154
165
|
poisByCategory,
|
|
166
|
+
showCenter,
|
|
155
167
|
showgraph,
|
|
156
168
|
showIcons,
|
|
157
169
|
showOrphaned
|
|
@@ -67,15 +67,21 @@ function create (opts = { }) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function off (ev, fn) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
// run ASAP but not immediate, in case it removes in its own function
|
|
71
|
+
Zousan.soon(() => {
|
|
72
|
+
if (!ons[ev])
|
|
73
|
+
return
|
|
74
|
+
arRm(ons[ev], fn);
|
|
75
|
+
});
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
function moff (ev, fn) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
// run ASAP but not immediate, in case it removes in its own function
|
|
80
|
+
Zousan.soon(() => {
|
|
81
|
+
if (!mons[ev])
|
|
82
|
+
return
|
|
83
|
+
arRm(mons[ev], fn);
|
|
84
|
+
});
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
const serve = (ev, ob, done) => () => {
|
|
@@ -40,6 +40,8 @@ function ad (eConf, parent) {
|
|
|
40
40
|
return node
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
const del = element => element?.parentNode?.removeChild(element);
|
|
44
|
+
|
|
43
45
|
const setStyles = (node, styles) => {
|
|
44
46
|
for (const style in styles)
|
|
45
47
|
node.style[style] = styles[style];
|
|
@@ -48,4 +50,5 @@ const setStyles = (node, styles) => {
|
|
|
48
50
|
exports.$ = $;
|
|
49
51
|
exports.$$ = $$;
|
|
50
52
|
exports.ad = ad;
|
|
53
|
+
exports.del = del;
|
|
51
54
|
exports.setStyles = setStyles;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('@turf/
|
|
3
|
+
var area = require('@turf/area');
|
|
4
|
+
var bboxClip = require('@turf/bbox-clip');
|
|
5
|
+
var bboxPolygon = require('@turf/bbox-polygon');
|
|
6
|
+
var helpers = require('@turf/helpers');
|
|
4
7
|
require('@turf/point-to-line-distance');
|
|
5
8
|
var R = require('ramda');
|
|
6
9
|
|
|
@@ -44,57 +47,130 @@ const pointInPolygon = (point, vs) => {
|
|
|
44
47
|
return inside
|
|
45
48
|
};
|
|
46
49
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
return [[n, e], [n, w], [s, w], [s, e], [n, e]]
|
|
50
|
-
};
|
|
50
|
+
const bounds2Coords = ({ n, s, e, w }) => [[n, e], [n, w], [s, w], [s, e], [n, e]];
|
|
51
|
+
const NULL_STRUCTURE_AND_FLOOR = { structure: null, floor: null };
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
|
-
* Pass in a
|
|
54
|
-
* or
|
|
54
|
+
* Pass in a structures array and a lat,lng and ord, and this will return the structure and floor
|
|
55
|
+
* at that point or nulls if no structure exists at that point/ord. This runs very quickly as we very often
|
|
55
56
|
* can skip the slowest path (which runs pointInPolygon). Without preciseFlag we sometimes return
|
|
56
|
-
* a
|
|
57
|
-
* is actually desired behavior anyway (such as
|
|
58
|
-
* @param
|
|
57
|
+
* a structure when the point falls outside it - but won't return a wrong structure. In some cases this
|
|
58
|
+
* is actually desired behavior anyway (such as structure selector)
|
|
59
|
+
* @param {object} structures the venue data structures
|
|
59
60
|
* @param {float} lat latitude of point to check
|
|
60
61
|
* @param {float} lng longitude of point to check
|
|
61
|
-
* @param
|
|
62
|
-
* @
|
|
62
|
+
* @param {[float]} mapviewBBox the minx,miny,maxx,maxy lat lng values that define the viewable map (not req if preciseFlag === true)
|
|
63
|
+
* @param {boolean} preciseFlag if false, we provide a fuzzy reading, allowing for the map center to be "close enough" to a building/floor
|
|
64
|
+
* @returns {structure: object, floor: object} structure/building and floor that contains the point passed (or {structure:null,floor:null})
|
|
63
65
|
*/
|
|
64
|
-
function
|
|
65
|
-
if (!R__namespace.length(
|
|
66
|
+
function getStructureAndFloorAtPoint (structures, lat, lng, ord, mapviewBBox, preciseFlag = false) { // Step 1 of logic flow
|
|
67
|
+
if (!R__namespace.length(structures)) return NULL_STRUCTURE_AND_FLOOR
|
|
68
|
+
|
|
69
|
+
structures = structures.filter(s => s.shouldDisplay == null || s.shouldDisplay === true);
|
|
70
|
+
|
|
71
|
+
const floorsToConsider = structures
|
|
72
|
+
.map(structure => ({ structure, floor: ordToFloor(structure, ord) })); // array of {structure,floor} obs
|
|
73
|
+
|
|
74
|
+
return getStructureAndFloorWithinFloorsAtPoint(structures, floorsToConsider, lat, lng, mapviewBBox, preciseFlag)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Given a list of candidate floors, and a lat,lng point, determine which
|
|
79
|
+
* @param {object} structures the venue data structures
|
|
80
|
+
* @param {[{structure, floor}]} floorsToConsider A list of "tuple" objects containing structure and floor (both can be null)
|
|
81
|
+
* @param {float} lat latitude of point to check
|
|
82
|
+
* @param {float} lng longitude of point to check
|
|
83
|
+
* @param {[float]} mapviewBBox the minx,miny,maxx,maxy lat lng values that define the viewable map (not req if preciseFlag === true)
|
|
84
|
+
* @param {boolean} preciseFlag if false, we provide a fuzzy reading, allowing for the map center to be "close enough" to a building/floor
|
|
85
|
+
* @returns {structure: object, floor: object} structure/building and floor that contains the point passed (or {structure:null,floor:null})
|
|
86
|
+
*/
|
|
87
|
+
function getStructureAndFloorWithinFloorsAtPoint (structures, floorsToConsider, lat, lng, mapviewBBox, preciseFlag) {
|
|
88
|
+
// Step 2 - Select floors whose bounding box contains map center
|
|
89
|
+
const pointWithinFloorsBBox = floorsToConsider
|
|
90
|
+
.filter(ftc => ftc.floor) // ignore structures with no floor on this ord
|
|
91
|
+
.filter(ftc => pointInPolygon([lat, lng], bounds2Coords(ftc.floor.bounds)));
|
|
92
|
+
|
|
93
|
+
//
|
|
94
|
+
// First, lets handle the simpler case, where preciseFlag is true.
|
|
95
|
+
// All preciseFlag=true cases are handled within this code block.
|
|
96
|
+
//
|
|
97
|
+
if (preciseFlag) {
|
|
98
|
+
// not within any floor's bounding box? return nulls
|
|
99
|
+
if (pointWithinFloorsBBox.length === 0)
|
|
100
|
+
return NULL_STRUCTURE_AND_FLOOR
|
|
101
|
+
|
|
102
|
+
// Step 3 (precise) - We need to determine which of the floors found above are we ACTUALLY in:
|
|
103
|
+
const floorsWithinBoundsPolygon = pointWithinFloorsBBox
|
|
104
|
+
.filter(ftc => pointInPolygon([lat, lng], ftc.floor.boundsPolygon));
|
|
105
|
+
|
|
106
|
+
// We should never be in MORE than one floor's bounding polygon, so return 1st one
|
|
107
|
+
// and in unlikely case we ARE in multiple, user will get first one...
|
|
108
|
+
if (floorsWithinBoundsPolygon.length >= 1)
|
|
109
|
+
return R__namespace.head(floorsWithinBoundsPolygon)
|
|
110
|
+
|
|
111
|
+
// precise yet not within any floor polygon, "so you get nothing. you lose. good day sir!"
|
|
112
|
+
return NULL_STRUCTURE_AND_FLOOR
|
|
113
|
+
}
|
|
66
114
|
|
|
67
|
-
|
|
115
|
+
//
|
|
116
|
+
// From here forward, we handle the non-precise case (more complicated)
|
|
117
|
+
//
|
|
68
118
|
|
|
69
|
-
|
|
70
|
-
|
|
119
|
+
// Step 3 (non-precise) - We are not within any *floor* bounding box..
|
|
120
|
+
if (pointWithinFloorsBBox.length === 0) {
|
|
121
|
+
// Check to see if we are over a building (perhaps with no floor or tiny floor at this ordinal)
|
|
122
|
+
const floorsWithinBuildingBoundingBox = structures
|
|
123
|
+
.filter(structure => pointInPolygon([lat, lng], bounds2Coords(structure.bounds)))
|
|
124
|
+
// .map(structure => ({ structure, floor: structure.levels[structure.defaultLevelId] }))
|
|
125
|
+
.map(structure => ({ structure, floor: null }));
|
|
71
126
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return R__namespace.head(buildingsWithinBoundingBox)
|
|
127
|
+
if (floorsWithinBuildingBoundingBox.length >= 1)
|
|
128
|
+
return floorsWithinBuildingBoundingBox[0]
|
|
75
129
|
|
|
76
|
-
|
|
77
|
-
|
|
130
|
+
return NULL_STRUCTURE_AND_FLOOR // user does not seem to be near ANYTHING!
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Step 4 - If we are only in the bounding box of a single floor, return it
|
|
134
|
+
if (pointWithinFloorsBBox.length === 1)
|
|
135
|
+
return pointWithinFloorsBBox[0]
|
|
136
|
+
|
|
137
|
+
// Step 5 - Ok, so from here, we are NOT precise, and the map center is within MULTIPLE bounding boxes
|
|
138
|
+
// so how do we determine WHICH item to select...?
|
|
78
139
|
|
|
79
|
-
|
|
80
|
-
return R__namespace.head(buildingsWithinBoundsPolygon)
|
|
140
|
+
const floorsContainingPoint = pointWithinFloorsBBox.filter(ftc => pointInPolygon([lat, lng], ftc.floor.boundsPolygon));
|
|
81
141
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
142
|
+
// We will score the building/floor's "prominence" and pick the highest scoring building/floor
|
|
143
|
+
const prominenceScores = pointWithinFloorsBBox.map(ftc => prominence(ftc, mapviewBBox, floorsContainingPoint.some(fcp => fcp.floor.id === ftc.floor.id)));
|
|
144
|
+
console.log('!pointWithinFloorsBBox:', pointWithinFloorsBBox.map(ftc => ftc.floor.id));
|
|
145
|
+
console.log('!prominenceScores:', prominenceScores);
|
|
146
|
+
const bestScore = Math.max.apply(null, prominenceScores);
|
|
147
|
+
console.log('!bestScore:', bestScore);
|
|
85
148
|
|
|
86
|
-
return
|
|
149
|
+
return pointWithinFloorsBBox[prominenceScores.indexOf(bestScore)]
|
|
87
150
|
}
|
|
88
151
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
152
|
+
// Returns a prominenceScore from 0 to 100
|
|
153
|
+
// This is calculated by a % of screen taken by the
|
|
154
|
+
// floor polygon
|
|
155
|
+
function prominence ({ structure, floor }, mapviewBBox, pointWithinFloorPoly) {
|
|
156
|
+
// Take the polygon of the floor...
|
|
157
|
+
const floorPolygon = coords2Poly(floor.boundsPolygon);
|
|
158
|
+
|
|
159
|
+
// ...and the bounding box of the viewable map...
|
|
160
|
+
const mapviewBBoxPoly = bboxPolygon.bboxPolygon(mapviewBBox);
|
|
161
|
+
|
|
162
|
+
// ...and create a viewable floor polygone from the intercection.
|
|
163
|
+
const viewableFloorPoly = bboxClip.bboxClip(floorPolygon, mapviewBBox);
|
|
94
164
|
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
165
|
+
const floorArea = area.area(viewableFloorPoly);
|
|
166
|
+
const viewableMapArea = area.area(mapviewBBoxPoly);
|
|
167
|
+
|
|
168
|
+
// now the prominence is simply the ratio of viewable floor to viewable map (with 20% bonus if center within floor)
|
|
169
|
+
return floorArea * (pointWithinFloorPoly ? 150 : 100) / viewableMapArea
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const latLngSwap = point => [point[1], point[0]];
|
|
173
|
+
const coords2Poly = coords => helpers.polygon([coords.map(latLngSwap)]);
|
|
98
174
|
|
|
99
175
|
/**
|
|
100
176
|
* given a building and ord, return the floor (or undefined if doesn't exist)
|
|
@@ -105,23 +181,15 @@ const ordToFloor = (building, ord) =>
|
|
|
105
181
|
/**
|
|
106
182
|
* Return the floor based on its ID (pass in buildings array and floorId)
|
|
107
183
|
*/
|
|
108
|
-
const getFloor = (
|
|
109
|
-
|
|
184
|
+
const getFloor = (structures, selectedLevelId) =>
|
|
185
|
+
structures.reduce((fmatch, building) =>
|
|
110
186
|
Object.values(building.levels).find(floor => floor.id === selectedLevelId) || fmatch, undefined);
|
|
111
187
|
|
|
112
|
-
function getBuildingAndFloorAtPoint (buildings, lat, lng, ord, preciseFlag) {
|
|
113
|
-
const building = getStructureAtPoint(buildings, lat, lng, preciseFlag);
|
|
114
|
-
const floor = building
|
|
115
|
-
? ordToFloor(building, ord)
|
|
116
|
-
: null;
|
|
117
|
-
return { building, floor }
|
|
118
|
-
}
|
|
119
|
-
|
|
120
188
|
// pass in the structures array and a floorId and this will return the structure
|
|
121
189
|
// that contains the floorId.
|
|
122
|
-
const getStructureForFloorId = (
|
|
123
|
-
|
|
124
|
-
buildContainsFloorWithId(
|
|
190
|
+
const getStructureForFloorId = (structures, floorId) =>
|
|
191
|
+
structures.reduce((sMatch, structure) =>
|
|
192
|
+
buildContainsFloorWithId(structure, floorId) ? structure : sMatch, null);
|
|
125
193
|
|
|
126
194
|
// returns true if the building specified contains the floorId specified
|
|
127
195
|
const buildContainsFloorWithId = (building, floorId) =>
|
|
@@ -171,9 +239,8 @@ function bezierCurveTo (fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) {
|
|
|
171
239
|
}
|
|
172
240
|
|
|
173
241
|
exports.bezierCurveTo = bezierCurveTo;
|
|
174
|
-
exports.getBuildingAndFloorAtPoint = getBuildingAndFloorAtPoint;
|
|
175
242
|
exports.getFloor = getFloor;
|
|
176
|
-
exports.
|
|
243
|
+
exports.getStructureAndFloorAtPoint = getStructureAndFloorAtPoint;
|
|
177
244
|
exports.getStructureForFloorId = getStructureForFloorId;
|
|
178
245
|
exports.ordToFloor = ordToFloor;
|
|
179
246
|
exports.pointInPolygon = pointInPolygon;
|
|
@@ -37,9 +37,10 @@ async function locationToEndpoint (app, location) {
|
|
|
37
37
|
}
|
|
38
38
|
} else {
|
|
39
39
|
if (floorId == null) {
|
|
40
|
-
const
|
|
40
|
+
const mapviewBBox = await app.bus.get('map/getViewBBox');
|
|
41
|
+
const { structure, floor } = geom.getStructureAndFloorAtPoint(structures, lat, lng, ordinal, mapviewBBox, true);
|
|
41
42
|
floorId = floor?.id;
|
|
42
|
-
structureId =
|
|
43
|
+
structureId = structure?.id;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e="web-engine",s="3.3.
|
|
1
|
+
var e="web-engine",s="3.3.392",o="UNLICENSED",t="module",l="src/main.js",r=["demo","deploy","nodesdk","src/extModules/flexapi","services/*","libraries/*"],a={colors:"cat utils/colors1.txt && node utils/processColors.js | pbcopy && cat utils/colors2.txt","cypress:a11y":"APPLITOOLS_IS_DISABLED=true && cypress open --browser chrome --env INPUT_MODALITY='keyboard'","cypress:comp":"APPLITOOLS_IS_DISABLED=true && cypress open --component --browser chrome","cypress:e2e":"APPLITOOLS_IS_DISABLED=true && cypress open --e2e --browser chrome",demo:"cd demo/ && yarn start","e2e:comp":"cypress run --component","e2e:record":"yarn cypress run --env RECORD_MODE=true",e2eSDKTest:"yarn start-server-and-test 'cd ./deploy && yarn buildDev && yarn serveLocal' 8085 'cd ./cypress/e2e/sdk && npx http-server' 8080 'yarn cypress run --spec cypress/e2e/sdk/**'",goProd:"cd deploy && scripts/goProd.sh",goStaging:"deploy/scripts/goStaging.sh",i18nOverrides:"yarn node utils/i18nOverrideCli src/i18n src/i18n-overrides",lint:"eslint .",mod:"demo/startMod.sh",mol:"demo/startMol.sh","mol:build":"demo/startMolBuild.sh",molProd:"cd deploy && yarn buildAndRunMol",prepare:"husky install",test:"jest --no-cache --verbose","test-watch":"jest --verbose --watch","test:vitest":"vitest run"},i=["defaults"],n={react:"^18.3.1"},c={"@azure/event-hubs":"^5.12.2","@dnd-kit/core":"^6.1.0","@dnd-kit/modifiers":"^7.0.0","@dnd-kit/sortable":"^8.0.0","@dnd-kit/utilities":"^3.2.2","@locus-labs/mod-badge":"^0.1.102","@locus-labs/mod-default-theme":"^0.0.113","@locus-labs/mod-footer":"^0.0.111","@locus-labs/mod-header":"^0.0.105","@locus-labs/mod-location-marker":"^0.0.104","@locus-labs/mod-map-legend":"^0.0.104","@locus-labs/mod-offscreen-indicator":"^0.0.104","@locus-labs/mod-pin":"^0.0.104","@locus-labs/mod-qr-code-card":"^0.0.104","@locus-labs/mod-qr-code-window":"^0.0.105","@locus-labs/mod-walk-time-matrix":"^0.0.103","@locus-labs/mol-desktop-building-level-selector":"^0.1.119","@locus-labs/mol-desktop-compass":"^0.1.120","@locus-labs/mol-desktop-default-theme":"^0.2.105","@locus-labs/mol-desktop-icon":"^0.1.131","@locus-labs/mol-desktop-logo":"^0.1.101","@locus-labs/mol-desktop-map-nav-button":"^0.1.130","@locus-labs/mol-desktop-tooltip":"^0.3.102","@locus-labs/mol-desktop-zoom-control":"^0.1.141","@locus-labs/mol-mobile-box":"^0.1.115","@locus-labs/mol-mobile-floating-action-button":"^0.0.117","@locus-labs/mol-mobile-icon":"^0.1.118","@locus-labs/mol-mobile-text":"^0.1.116","@locus-labs/mol-mobile-toast":"^0.1.102","@mapbox/mapbox-gl-draw":"^1.4.3","@mapbox/mapbox-gl-draw-static-mode":"^1.0.1","@microsoft/applicationinsights-web":"^3.3.4","@turf/area":"^7.2.0","@turf/bbox-clip":"^7.2.0","@turf/bbox-polygon":"^7.2.0","@turf/circle":"^6.5.0","@turf/helpers":"^6.5.0","@turf/point-to-line-distance":"^6.5.0","@vitejs/plugin-react":"^4.0.1","axe-core":"^4.9.0",browserslist:"^4.24.2","crypto-browserify":"^3.12.0","cypress-axe":"^1.6.0","cypress-multi-reporters":"^1.6.4","cypress-real-events":"^1.14.0","file-loader":"^6.2.0",flexsearch:"^0.7.43","h3-js":"^4.1.0",i18next:"^20.3.4","i18next-browser-languagedetector":"^6.1.1","jest-transform-css":"6.0.1",jsdom:"^25.0.1",jsonschema:"^1.2.6",luxon:"^3.3.0","maplibre-gl":"^4.7.1","mini-css-extract-plugin":"^1.6.0","mocha-junit-reporter":"^2.2.1",mochawesome:"^7.1.3","node-polyfill-webpack-plugin":"^1.1.4","path-browserify":"^1.0.1",polished:"^4.0.2","prop-types":"^15.7.2","query-string":"^8.1.0",ramda:"^0.30.1",react:"^18.3.1","react-compound-slider":"^3.3.1","react-dom":"^18.3.1","react-json-editor-ajrm":"^2.5.13","react-qr-svg":"^2.2.1","react-svg":"^16.1.29","react-virtualized-auto-sizer":"^1.0.2","react-window":"^1.8.11","smoothscroll-polyfill":"^0.4.4","styled-components":"^6.1.14","styled-normalize":"^8.0.6","throttle-debounce":"^3.0.1",trackjs:"^3.7.4","ua-parser-js":"^0.7.23",uuid:"3.3.2",zousan:"^3.0.1","zousan-plus":"^4.0.1"},p={"@applitools/eyes-cypress":"^3.47.0","@babel/core":"^7.26.0","@babel/eslint-parser":"^7.25.9","@babel/plugin-proposal-class-properties":"^7.18.6","@babel/plugin-syntax-dynamic-import":"^7.8.3","@babel/plugin-syntax-import-assertions":"^7.26.0","@babel/plugin-transform-modules-commonjs":"^7.25.9","@babel/plugin-transform-runtime":"^7.25.9","@babel/preset-env":"^7.26.0","@babel/preset-react":"^7.25.9","@testing-library/jest-dom":"^6.6.3","@types/react":"^19.0.10","@types/react-dom":"^19.0.4","@typescript-eslint/eslint-plugin":"^7.13.0","@typescript-eslint/parser":"^7.13.0","babel-jest":"^27.0.6","babel-loader":"^8.2.2","babel-plugin-inline-json-import":"^0.3.2","babel-plugin-module-resolver":"^5.0.0","babel-plugin-styled-components":"^2.1.4","babel-polyfill":"^6.26.0","chai-colors":"^1.0.1","css-loader":"^5.2.4",cypress:"^12.17.4","cypress-browser-permissions":"^1.1.0","cypress-wait-until":"^1.7.2",eslint:"^8.57.0","eslint-config-standard":"^16.0.3","eslint-import-resolver-typescript":"^3.6.1","eslint-plugin-cypress":"^2.11.1","eslint-plugin-import":"^2.16.0","eslint-plugin-jest":"^28.6.0","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^5.1.0","eslint-plugin-react":"^7.12.4","eslint-plugin-standard":"^5.0.0","fetch-mock-jest":"^1.3.0",glob:"^10.3.3",husky:"^6.0.0",jest:"29.7.0","jest-environment-jsdom":"^29.7.0","lint-staged":"^11.0.1","node-fetch":"^2.6.0","null-loader":"^4.0.1",nx:"19.4.2","nx-remotecache-azure":"^19.0.0","start-server-and-test":"^2.0.0",typescript:"^5.4.5",vite:"^4.3.9",vitest:"^2.1.5",webpack:"^5.96.1","webpack-merge":"^6.0.1"},d="yarn@4.3.1",m={node:"20.x"},u={},b={name:e,version:s,private:!0,license:o,type:t,main:l,workspaces:r,scripts:a,"lint-staged":{"*.js":["eslint --fix"]},browserslist:i,resolutions:n,dependencies:c,devDependencies:p,packageManager:d,engines:m,nx:u};export{i as browserslist,b as default,c as dependencies,p as devDependencies,m as engines,o as license,l as main,e as name,u as nx,d as packageManager,n as resolutions,a as scripts,t as type,s as version,r as workspaces};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{throttle as e}from"throttle-debounce";import{getStructureAndFloorAtPoint as t}from"../../../src/utils/geom.js";import o from"../../../src/utils/observable.js";import{headlessCommands as n,handleHeadless as a}from"./sdkHeadless.js";let s=null;function r(e){const t=(e,t)=>{const o={payload:e,type:"LL-server"};t&&(o.clientMsgId=t);try{window.postMessage(o,"*")}catch(e){window.postMessage((e=>JSON.parse(JSON.stringify(e)))(o),"*")}};function o(o){const n=o.data;n&&"LL-client"===n.type&&e.bus.get("clientAPI/execute",n.payload).then((e=>t(e,n.msgId))).catch((t=>{e.config.debug&&console.error(t),((e,t)=>{const o={error:!0,payload:e,type:"LL-server"};t&&(o.clientMsgId=t),window.postMessage(o,"*")})(t.message,n.msgId)}))}return s&&s(),window.addEventListener("message",o),s=()=>window.removeEventListener("message",o),(e,t)=>{const o={event:e,payload:t,type:"LL-server"};window.postMessage(o,"*")}}async function i(s,i){const l=s.env.isBrowser?r(s):function(e){const t=o();return e.eventListener=t,(e,o)=>t.fire(e,o)}(s);return function(o,n){o.bus.monitor("map/userMoveStart",(async({pitch:e,zoom:t,bearing:a})=>{const{lat:s,lng:r,floorId:i,ordinal:l,structureId:d}=await o.bus.get("map/getMapCenter");n("userMoveStart",{lat:s,lng:r,floorId:i,ord:l,structureId:d,pitch:e,zoom:t,bearing:a})})),o.bus.monitor("map/userMoving",e(500,(async({pitch:e,zoom:t,bearing:a})=>{const{lat:s,lng:r,floorId:i,ordinal:l,structureId:d}=await o.bus.get("map/getMapCenter");n("userMoving",{lat:s,lng:r,floorId:i,ord:l,structureId:d,pitch:e,zoom:t,bearing:a})}))),o.bus.monitor("map/moveEnd",(async({pitch:e,zoom:t,bearing:a})=>{const{lat:s,lng:r,floorId:i,ordinal:l,structureId:d}=await o.bus.get("map/getMapCenter");n("moveEnd",{lat:s,lng:r,floorId:i,ord:l,structureId:d,pitch:e,zoom:t,bearing:a})})),o.bus.monitor("map/floorChanged",(({structure:e,floor:t})=>n("levelChange",{floorId:t?t.id:null,floorName:t?t.name:null,ord:t?t.ordinal:null,structureId:e?e.id:null,structureName:e?e.name:null}))),o.bus.monitor("map/poiClicked",(({poi:e})=>n("poiSelected",e))),o.bus.monitor("poiDetails/showPoi",(({poi:e})=>n("poiShown",e))),o.bus.monitor("map/click",(async({lat:e,lng:a,ord:s})=>{const r=await o.bus.get("venueData/getStructures"),i=await o.bus.get("map/getViewBBox"),{building:l,floor:d}=t(r,e,a,s,i,!0);n("mapClicked",{lat:e,lng:a,ord:s,building:l,floor:d})}))}(s,l),{init:async()=>{!function(e){e.bus.send("clientAPI/registerCustomType",{name:"latLngOrdLocation",spec:{type:"object",props:[{name:"lat",type:"float"},{name:"lng",type:"float"},{name:"ord",type:"integer"}]}}),e.bus.send("clientAPI/registerCustomType",{name:"latLngFloorLocation",spec:{type:"object",props:[{name:"lat",type:"float"},{name:"lng",type:"float"},{name:"floorId",type:"string"}]}}),e.bus.send("clientAPI/registerCustomType",{name:"poiIdLocation",spec:{type:"object",props:[{name:"poiId",type:"integer",min:0}]}}),e.bus.send("clientAPI/registerCustomType",{name:"location",spec:{type:"multi",types:[{type:"poiIdLocation"},{type:"latLngOrdLocation"},{type:"latLngFloorLocation"}]}}),e.bus.send("clientAPI/registerCustomType",{name:"viewSettings",spec:{type:"object",props:[{name:"zoom",type:"float",optional:!0},{name:"pitch",type:"float",optional:!0},{name:"bearing",type:"float",optional:!0}]}})}(s),n.forEach((e=>s.bus.send("clientAPI/registerCommand",e))),a(s),i.headless||await import("../../../_virtual/_empty_module_placeholder.js").then((e=>{e.visualCommands.forEach((e=>s.bus.send("clientAPI/registerCommand",e))),e.handleVisual(s,l)}));const e=async()=>{await s.bus.send("system/readywhenyouare"),s.bus.get("clientAPI/execute",{command:"getCommandJSON"}).then((e=>l("ready",{commandJSON:e}))),!i.headless&&s.config.uiHide&&s.config.uiHide.sidebar&&s.env.isDesktop()&&s.bus.send("map/changePadding",{padding:{left:55,right:55,top:72,bottom:22}})};i.headless?Promise.all([new Promise((e=>s.bus.monitor("venueData/navGraphLoaded",e))),new Promise((e=>s.bus.monitor("venueData/poiDataLoaded",e)))]).then(e):s.bus.on("map/mapReadyToShow",e),s.bus.on("sdkServer/sendEvent",(({eventName:e,...t})=>l(e,t)))}}}export{i as create};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"ramda";import{findBoundsOfCoordinates as t}from"../../../src/utils/bounds.js";import{global as n}from"../../../src/utils/configUtils.js";const
|
|
1
|
+
import*as e from"ramda";import{findBoundsOfCoordinates as t}from"../../../src/utils/bounds.js";import{global as n}from"../../../src/utils/configUtils.js";const s=async(e,t)=>fetch(t),a=e=>e=>s(0,e).then((e=>e.json())),o=e=>e=>s(0,e).then((e=>e.text())),l=e=>`https://api.content.locuslabs.com/${e}`,r=(t,n,s,a,o)=>e.mapObjIndexed(((e,n)=>((e,t,n,s,a,o)=>"theme"===o||"style"===o?`${l(n)}/${t}/${o}/${a}/${s}/${o}.json`:e.replace(/https:\/\/content.locuslabs.com/gi,l(n)))(e,t,s,a,o,n)),n),c=async(e,t,s)=>{const a={alpha:"alpha-a.locuslabs.com",beta:"beta-a.locuslabs.com",gamma:"gamma-a.locuslabs.com",prod:"a.locuslabs.com"},{assetStage:o,accountId:l,formatVersion:c}=e;let{venueId:i}=e;const u=`https://${a[o]||a.prod}/accounts/${l}`,d=c||"v5",g=e.dataFetch&&n[e.dataFetch]&&n[e.dataFetch].getFiles?await n[e.dataFetch].getFiles(e):await t(`${u}/${d}.json`);if(s.length>0){const t=s.map((e=>e.slice(0,2)));for(let n=0;n<t.length;n+=1)if(g[`${i}${t[n]}`]){i=`${i}${t[n]}`,e.venueId=`${i}`;break}}if(!g[i])throw Error(`Attempt to access venue ${i} which is not within venue list: ${Object.keys(g)}`);const h=g[i].files,m=(e.dataFetch&&n[e.dataFetch]&&n[e.dataFetch].getVenueData?await n[e.dataFetch].getVenueData(e):await t(h.venueData))[i];m.tileServerAuthInfo&&function(e){const t={defaultOrdinal:0,defaultStructureId:"singleBuilding",formatVersion:"v5",structures:{singleBuilding:{name:"singleBuilding",boundsPolygon:[],defaultLevelId:"singleLevel",id:"singleBuilding",levels:{singleLevel:{boundsPolygon:[],clfloor:0,details:"",id:"singleLevel",name:"singleLevel",ordinal:0}}}},structureOrder:["singleBuilding"]};for(const n in t)e[n]=t[n]}(m),m.venueList=g;const p=(e=>{const t=e.deepLinkProps?e.deepLinkProps.contentStage:null;return"alpha"===t||"beta"===t||"prod"===t?t:null})(e);return m.files=p?r(m.category,h,p,l,i):h,m},i=e=>{const{structureOrder:n,structures:s}=e;return n.map((e=>{const n=s[e];Object.values(n.levels).forEach((e=>e.bounds=t(e.boundsPolygon)));const a=t(n.boundsPolygon);return{...n,bounds:a}}))};const u=([e,t,...n])=>[t,e,...n],d=(e,t)=>{return!e||!Array.isArray(e)||e.length<1?e:(n=e[0][0],s=t.ne.lng,a=t.sw.lng,(n>s?n<=a:e=>a)?e:e.map(u));var n,s,a};export{i as buildStructures,a as createFetchJson,o as createFetchText,c as getVenueDataFromUrls,d as normalizeCoords};
|
package/dist/src/debugTools.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"ramda";import{orphanTest as
|
|
1
|
+
import*as e from"ramda";import{orphanTest as t}from"../plugins/wayfinder/src/navGraphDebug.js";import{$ as n,$$ as s,ad as o,del as a}from"./utils/dom.js";import{singleFile as r}from"./utils/funcs.js";"undefined"!=typeof window&&(window.R=e);const i=(e,t)=>d((()=>t.send(e)),t),d=(e,t)=>{const n=t.monitor("homeview/performSearch",(({term:t})=>{t||(e(),n())}))};async function u(){const e=await this.bus.get("map/getPadding"),t=(e.left-e.right)/2,s=(e.top-e.bottom)/2,r=o({html:'<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><path stroke="#fF000080" stroke-width="2" d="M0 50h45M55 50h45M50 0v45M50 55v45"/></svg>',styles:{position:"absolute",left:"50%",top:"50%","margin-left":-50+t+"px","margin-top":-50+s+"px"}},n(".maplibregl-map"));d((()=>a(r)),this.bus)}var g={bounds:async function(){const e=await this.bus.get("venueData/getVenueCenter"),{venueRadius:t,bounds:n}=await this.bus.get("venueData/getVenueData");this.bus.send("map/showVenueBounds",{venueCenter:e,venueRadius:t,bounds:n}),i("map/resetVenueBounds",this.bus)},buildingBounds:async function(e){this.bus.send("map/showBuildingBounds",{nameFilter:e}),i("map/resetVenueBounds",this.bus),u.apply(this)},dndGo:function(){const e=this.bus,t=(e,t)=>{e.preventDefault(),t?e.target.classList.add("dragover"):e.target.classList.remove("dragover")},n={drop:async function(n){t(n,!1);for(const t of n.dataTransfer.files){const n=t.name;if("application/json"===t.type||t.type.startsWith("text/")){const s=new FileReader;s.onload=r((async s=>e.send("debugTools/fileDrop",{file:t,filename:n,content:s.target.result}))),s.readAsText(t)}}},dragover:function(e){t(e,!0)},dragleave:function(e){t(e,!1)}};Object.keys(n).forEach((function(e){document.body.addEventListener(e,n[e])})),console.log("DnD Listeners installed")},floorBounds:async function(e){const t=this.bus;t.send("map/showFloorBounds",{nameFilter:e}),i("map/resetVenueBounds",t);const n=t.monitor("map/floorChanged",(()=>t.send("map/showFloorBounds",{nameFilter:e})));d(n,t),u.apply(this)},getPoiById:function(e){return this.bus.send("poi/getById",{id:e}).then((e=>e[0]))},highlightNodes:()=>o({tag:"style",html:"* { background-color: rgba(255,0,0,.2); } * * { background-color: rgba(0,255,0,.2); } * * * { background-color: rgba(0,0,255,.2); } * * * * { background-color: rgba(255,0,255,.2); } * * * * * { background-color: rgba(0,255,255,.2); } * * * * * * { background-color: rgba(255,255,0,.2); } * * * * * * * { background-color: rgba(255,0,0,.2); } * * * * * * * * { background-color: rgba(0,255,0,.2); } * * * * * * * * * { background-color: rgba(0,0,255,.2); }"},n("head")),orphanTest:t,padding:async function(){this.bus.send("map/togglePadding"),i("map/togglePadding",this.bus)},poisByCategory:function(){return this.bus.send("poi/getAll").then((e=>e[0])).then((e=>Object.values(e))).then(e.groupBy((e=>e.category)))},showCenter:u,showgraph:async function(){const e=await this.bus.get("wayfinder/getNavGraphFeatures");this.bus.send("map/showNavGraphFeatures",{navGraph:e}),i("map/resetNavGraphFeatures",this.bus)},showIcons:()=>{n("#mapRenderDiv").innerHTML="<style> div { display: inline-block; text-align: center; border: 1px solid lightblue; }</style>"+s("svg symbol").map((e=>`<div><svg><use xlink:href="#${e.id}"/></svg><br/>${e.id}</div>`)).join("")},showOrphaned:async function(){const e=await this.bus.get("wayfinder/_getNavGraph"),n=t(e._nodes);this.bus.send("map/showOrphanedGraphNodes",{orphanedNodes:n.orphaned})}};export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"zousan";const n=(o,n)=>null==o.responseOrder?null==n.responseOrder?0:1:null==n.responseOrder?-1:o.responseOrder-n.responseOrder,r=(o,n)=>o.splice(n,1)[0],e=(o,n)=>{let e=0;do{e=o.indexOf(n,e),e>=0&&r(o,e)}while(e>=0);return o};function t(r={}){const t=r.log?r.log.sublog?r.log.sublog("bustle",{color:"pink"}):r.log:console,s={},l={};function u(n,r){o.soon((()=>{s[n]&&e(s[n],r)}))}function c(n,r){o.soon((()=>{l[n]&&e(l[n],r)}))}function i(n,e){return r.showEvents&&("function"==typeof r.showEvents?r.showEvents(n,e)&&t.info("send with",n," and ",e):t.info("send with",n," and ",e)),new o((u=>o.soon(((n,e,u)=>()=>{const c=s[n],i=l[n],f=[];if(c)for(const n of c)try{f.push(n(e))}catch(n){r.reportAllErrors&&t.error(n),r.rejectOnError?f.push(o.reject(n)):f.push(n)}const h=o.all(f);if(i)for(const o of i)try{o(e,h)}catch(o){r.reportAllErrors&&t.error(o)}u(h)})(n,e,u))))}return{get:(n,r)=>i(n,r).then((r=>1!==r.length?o.reject(`${n} event did not return a single result, but ${r.length} results.`):r[0])),getFirst:(o,r)=>i(o,r).then((o=>o.length>=1?o.sort(n)[0]:void 0)),moff:c,monitor:function(o,n){return l[o]||(l[o]=[]),l[o].push(n),()=>c(o,n)},off:u,on:function(o,n){return s[o]||(s[o]=[]),s[o].push(n),()=>u(o,n)},send:i}}export{t as create};
|
package/dist/src/utils/dom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=(t,e)=>"string"==typeof t?(e||document).querySelector(t):t||null,e=(t,e)=>Array.prototype.slice.call(document.querySelectorAll(t));function n(t,e){const n=t||{};e=e?"string"==typeof e?document.querySelector(e):e:document.body;let
|
|
1
|
+
const t=(t,e)=>"string"==typeof t?(e||document).querySelector(t):t||null,e=(t,e)=>Array.prototype.slice.call(document.querySelectorAll(t));function n(t,e){const n=t||{};e=e?"string"==typeof e?document.querySelector(e):e:document.body;let o="div";n.tag&&(o=n.tag);const r=document.createElement(o);for(const t in n)null!=n[t]&&("klass"===t?r.setAttribute("class",n.klass):"tag"===t||("styles"===t?l(r,n.styles):"text"===t?r.textContent=n.text:"html"===t?r.innerHTML=n.html:r.setAttribute(t,n[t])));return e.appendChild(r),r}const o=t=>t?.parentNode?.removeChild(t),l=(t,e)=>{for(const n in e)t.style[n]=e[n]};export{t as $,e as $$,n as ad,o as del,l as setStyles};
|
package/dist/src/utils/geom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@turf/helpers";import"@turf/point-to-line-distance";import*as
|
|
1
|
+
import{area as o}from"@turf/area";import{bboxClip as r}from"@turf/bbox-clip";import{bboxPolygon as t}from"@turf/bbox-polygon";import{polygon as l}from"@turf/helpers";import"@turf/point-to-line-distance";import*as e from"ramda";const n=(o,r)=>{const t=o[0],l=o[1];let e=!1;for(let o=0,n=r.length-1;o<r.length;n=o++){const u=r[o][0],s=r[o][1],f=r[n][0],i=r[n][1];s>l!=i>l&&t<(f-u)*(l-s)/(i-s)+u&&(e=!e)}return e},u=({n:o,s:r,e:t,w:l})=>[[o,t],[o,l],[r,l],[r,t],[o,t]],s={structure:null,floor:null};function f(l,f,i,p,a,m=!1){if(!e.length(l))return s;const g=(l=l.filter((o=>null==o.shouldDisplay||!0===o.shouldDisplay))).map((o=>({structure:o,floor:d(o,p)})));return function(l,f,i,d,p,a){const m=f.filter((o=>o.floor)).filter((o=>n([i,d],u(o.floor.bounds))));if(a){if(0===m.length)return s;const o=m.filter((o=>n([i,d],o.floor.boundsPolygon)));return o.length>=1?e.head(o):s}if(0===m.length){const o=l.filter((o=>n([i,d],u(o.bounds)))).map((o=>({structure:o,floor:null})));return o.length>=1?o[0]:s}if(1===m.length)return m[0];const g=m.filter((o=>n([i,d],o.floor.boundsPolygon))),h=m.map((l=>function({structure:l,floor:e},n,u){const s=c(e.boundsPolygon),f=t(n),i=r(s,n),d=o(i),p=o(f);return d*(u?150:100)/p}(l,p,g.some((o=>o.floor.id===l.floor.id)))));console.log("!pointWithinFloorsBBox:",m.map((o=>o.floor.id))),console.log("!prominenceScores:",h);const b=Math.max.apply(null,h);return console.log("!bestScore:",b),m[h.indexOf(b)]}(l,g,f,i,a,m)}const i=o=>[o[1],o[0]],c=o=>l([o.map(i)]),d=(o,r)=>Object.values(o.levels).find((o=>o.ordinal===r)),p=(o,r)=>o.reduce(((o,t)=>Object.values(t.levels).find((o=>o.id===r))||o),void 0),a=(o,r)=>o.reduce(((o,t)=>m(t,r)?t:o),null),m=(o,r)=>Object.values(o.levels).reduce(((o,t)=>t.id===r||o),!1);function g(o,r,t,l,e,n,u,s){let f=0,i=0,c=0,d=0,p=0;const a=[{x:o,y:r}];for(let m=1,g=0;m<=20;++m)g=m/20,f=1-g,i=f*f,c=i*f,d=g*g,p=d*g,a.push({x:c*o+3*i*g*t+3*f*d*e+p*u,y:c*r+3*i*g*l+3*f*d*n+p*s});return a}export{g as bezierCurveTo,p as getFloor,f as getStructureAndFloorAtPoint,a as getStructureForFloorId,d as ordToFloor,n as pointInPolygon};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getFloor as o,
|
|
1
|
+
import{getFloor as o,getStructureAndFloorAtPoint as t,getStructureForFloorId as n}from"./geom.js";async function r(r,l){if(l.poiId)return r.bus.get("wayfinder/getNavigationEndpoint",{ep:l.poiId});let{lat:a,lng:e,ord:u,ordinal:d,floorId:s,title:f="",structureId:c}=l;if(null==a||null==e)throw Error("To obtain a location, you must provide a lat,lng or a poiId");void 0===d&&void 0!==u&&(d=u);const g=await i(r);if(null==d){if(null==s)throw Error("Call to locationToEndpoint with no ordinal and no floorId");{const t=o(g,s);if(!t)throw Error(`floor with id ${s} not found.`);d=t.ordinal}}else if(null==s){const o=await r.bus.get("map/getViewBBox"),{structure:n,floor:i}=t(g,a,e,d,o,!0);s=i?.id,c=n?.id}return null!=s&&null==c&&(c=n(g,s)?.id),{lat:a,lng:e,floorId:s,ordinal:d,title:f,structureId:c}}const i=async o=>o.bus.get("venueData/getVenueData").then((o=>o.structures));export{i as getStructures,r as locationToEndpoint};
|
package/package.json
CHANGED