venue-js 1.1.1 → 1.2.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +39 -126
- package/dist/index.d.ts +39 -126
- package/dist/index.js +307 -325
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +298 -318
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -58,7 +58,8 @@ __export(index_exports, {
|
|
|
58
58
|
createSpriteMaterialByLabelSymbol: () => createSpriteMaterialByLabelSymbol,
|
|
59
59
|
createStyledUIMarkerElement: () => createStyledUIMarkerElement,
|
|
60
60
|
defaultFeatureQueryOptionsMap: () => defaultFeatureQueryOptionsMap,
|
|
61
|
-
|
|
61
|
+
fetchDeliveryApi: () => fetchDeliveryApi,
|
|
62
|
+
fetchPreviewApi: () => fetchPreviewApi,
|
|
62
63
|
getBearingBetweenPoints: () => getBearingBetweenPoints,
|
|
63
64
|
getCenterFromGeometry: () => getCenterFromGeometry,
|
|
64
65
|
getDataClient: () => getDataClient,
|
|
@@ -161,7 +162,7 @@ var defaultFeatureQueryOptionsMap = {
|
|
|
161
162
|
};
|
|
162
163
|
|
|
163
164
|
// src/data/api/delivery-project.ts
|
|
164
|
-
async function
|
|
165
|
+
async function fetchDeliveryApi(projectId, apiKey, featureType, baseUrl = DEFAULT_BASE_URL) {
|
|
165
166
|
switch (featureType) {
|
|
166
167
|
case "label":
|
|
167
168
|
case "element": {
|
|
@@ -195,14 +196,78 @@ async function fetchFeature(projectId, apiKey, featureType, baseUrl = DEFAULT_BA
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
|
-
|
|
199
|
+
async function fetchPreviewApi(projectId, previewToken, featureType, baseUrl = DEFAULT_BASE_URL) {
|
|
200
|
+
switch (featureType) {
|
|
201
|
+
case "label":
|
|
202
|
+
case "element": {
|
|
203
|
+
const pluralFeatureType = `${featureType}s`;
|
|
204
|
+
const res = await fetch(
|
|
205
|
+
`${baseUrl}/preview/projects/${projectId}/${pluralFeatureType}.geojson`,
|
|
206
|
+
{
|
|
207
|
+
headers: {
|
|
208
|
+
Authorization: `Bearer ${previewToken}`
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
if (res.status !== 200) return [];
|
|
213
|
+
const items = await res.json();
|
|
214
|
+
return items;
|
|
215
|
+
}
|
|
216
|
+
case "sponsored-content": {
|
|
217
|
+
const res = await fetch(
|
|
218
|
+
`${baseUrl}/preview/projects/${projectId}/sponsored-content.json`,
|
|
219
|
+
{
|
|
220
|
+
headers: {
|
|
221
|
+
Authorization: `Bearer ${previewToken}`
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
if (res.status !== 200) return [];
|
|
226
|
+
const jsonRes = await res.json();
|
|
227
|
+
const items = jsonRes.data;
|
|
228
|
+
return items.map((item) => ({
|
|
229
|
+
id: item.id,
|
|
230
|
+
...item.attributes
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
default: {
|
|
234
|
+
const res = await fetch(
|
|
235
|
+
`${baseUrl}/preview/projects/${projectId}/imdf/${featureType}.geojson`,
|
|
236
|
+
{
|
|
237
|
+
headers: {
|
|
238
|
+
Authorization: `Bearer ${previewToken}`
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
if (res.status !== 200) return [];
|
|
243
|
+
const collections = await res.json();
|
|
244
|
+
return collections.features;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
var safeFetchFeature = async (featureType, params) => {
|
|
249
|
+
const mode = params.mode ?? "delivery";
|
|
250
|
+
const projectId = params.projectId;
|
|
251
|
+
const apiKey = params.apiKey;
|
|
252
|
+
const previewToken = params.previewToken;
|
|
253
|
+
const baseUrl = params.baseUrl ?? DEFAULT_BASE_URL;
|
|
199
254
|
try {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
255
|
+
let result = [];
|
|
256
|
+
if (mode === "delivery") {
|
|
257
|
+
result = await fetchDeliveryApi(
|
|
258
|
+
projectId,
|
|
259
|
+
apiKey,
|
|
260
|
+
featureType,
|
|
261
|
+
baseUrl
|
|
262
|
+
);
|
|
263
|
+
} else if (mode === "preview") {
|
|
264
|
+
result = await fetchPreviewApi(
|
|
265
|
+
projectId,
|
|
266
|
+
previewToken,
|
|
267
|
+
featureType,
|
|
268
|
+
baseUrl
|
|
269
|
+
);
|
|
270
|
+
}
|
|
206
271
|
return result ?? [];
|
|
207
272
|
} catch (e) {
|
|
208
273
|
return Promise.resolve([]);
|
|
@@ -481,18 +546,22 @@ function matchFilters(item, filters) {
|
|
|
481
546
|
var getDataClient = (options) => {
|
|
482
547
|
const observers = /* @__PURE__ */ new Map();
|
|
483
548
|
const queryClient = options.queryClient ?? new import_query_core.QueryClient();
|
|
484
|
-
const { projectId, apiKey, baseUrl } = options;
|
|
549
|
+
const { mode = "delivery", projectId, apiKey, baseUrl, previewToken } = options;
|
|
485
550
|
if (!projectId)
|
|
486
551
|
throw new Error(
|
|
487
552
|
"Cannot create VenueDataClient. Reason: `projectId` is missing"
|
|
488
553
|
);
|
|
489
|
-
if (!apiKey)
|
|
554
|
+
if (mode === "delivery" && !apiKey)
|
|
490
555
|
throw new Error(
|
|
491
556
|
"Cannot create VenueDataClient. Reason: `apiKey` is missing"
|
|
492
557
|
);
|
|
558
|
+
if (mode === "preview" && !previewToken)
|
|
559
|
+
throw new Error(
|
|
560
|
+
"Cannot create VenueDataClient. Reason: `previewToken` is missing"
|
|
561
|
+
);
|
|
493
562
|
const createDeliveryApiQueryOptions = (featureType) => ({
|
|
494
563
|
queryKey: ["_deliveryapi", featureType],
|
|
495
|
-
queryFn: () => safeFetchFeature(projectId, apiKey,
|
|
564
|
+
queryFn: () => safeFetchFeature(featureType, { mode, projectId, apiKey, previewToken, baseUrl })
|
|
496
565
|
});
|
|
497
566
|
const internalFilterByType = async (featureType) => {
|
|
498
567
|
try {
|
|
@@ -682,132 +751,6 @@ function isNumber(num) {
|
|
|
682
751
|
// src/IndoorMap/IndoorMap.ts
|
|
683
752
|
var import_distance = __toESM(require("@turf/distance"));
|
|
684
753
|
var import_center4 = __toESM(require("@turf/center"));
|
|
685
|
-
|
|
686
|
-
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
687
|
-
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
688
|
-
if (geojson === null) return;
|
|
689
|
-
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
690
|
-
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
691
|
-
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
692
|
-
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
693
|
-
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
694
|
-
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
695
|
-
var multiFeatureIndex = 0;
|
|
696
|
-
var geometryIndex = 0;
|
|
697
|
-
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
698
|
-
if (geometry === null) continue;
|
|
699
|
-
coords = geometry.coordinates;
|
|
700
|
-
var geomType = geometry.type;
|
|
701
|
-
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
702
|
-
switch (geomType) {
|
|
703
|
-
case null:
|
|
704
|
-
break;
|
|
705
|
-
case "Point":
|
|
706
|
-
if (callback(
|
|
707
|
-
coords,
|
|
708
|
-
coordIndex,
|
|
709
|
-
featureIndex,
|
|
710
|
-
multiFeatureIndex,
|
|
711
|
-
geometryIndex
|
|
712
|
-
) === false)
|
|
713
|
-
return false;
|
|
714
|
-
coordIndex++;
|
|
715
|
-
multiFeatureIndex++;
|
|
716
|
-
break;
|
|
717
|
-
case "LineString":
|
|
718
|
-
case "MultiPoint":
|
|
719
|
-
for (j = 0; j < coords.length; j++) {
|
|
720
|
-
if (callback(
|
|
721
|
-
coords[j],
|
|
722
|
-
coordIndex,
|
|
723
|
-
featureIndex,
|
|
724
|
-
multiFeatureIndex,
|
|
725
|
-
geometryIndex
|
|
726
|
-
) === false)
|
|
727
|
-
return false;
|
|
728
|
-
coordIndex++;
|
|
729
|
-
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
730
|
-
}
|
|
731
|
-
if (geomType === "LineString") multiFeatureIndex++;
|
|
732
|
-
break;
|
|
733
|
-
case "Polygon":
|
|
734
|
-
case "MultiLineString":
|
|
735
|
-
for (j = 0; j < coords.length; j++) {
|
|
736
|
-
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
737
|
-
if (callback(
|
|
738
|
-
coords[j][k],
|
|
739
|
-
coordIndex,
|
|
740
|
-
featureIndex,
|
|
741
|
-
multiFeatureIndex,
|
|
742
|
-
geometryIndex
|
|
743
|
-
) === false)
|
|
744
|
-
return false;
|
|
745
|
-
coordIndex++;
|
|
746
|
-
}
|
|
747
|
-
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
748
|
-
if (geomType === "Polygon") geometryIndex++;
|
|
749
|
-
}
|
|
750
|
-
if (geomType === "Polygon") multiFeatureIndex++;
|
|
751
|
-
break;
|
|
752
|
-
case "MultiPolygon":
|
|
753
|
-
for (j = 0; j < coords.length; j++) {
|
|
754
|
-
geometryIndex = 0;
|
|
755
|
-
for (k = 0; k < coords[j].length; k++) {
|
|
756
|
-
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
757
|
-
if (callback(
|
|
758
|
-
coords[j][k][l],
|
|
759
|
-
coordIndex,
|
|
760
|
-
featureIndex,
|
|
761
|
-
multiFeatureIndex,
|
|
762
|
-
geometryIndex
|
|
763
|
-
) === false)
|
|
764
|
-
return false;
|
|
765
|
-
coordIndex++;
|
|
766
|
-
}
|
|
767
|
-
geometryIndex++;
|
|
768
|
-
}
|
|
769
|
-
multiFeatureIndex++;
|
|
770
|
-
}
|
|
771
|
-
break;
|
|
772
|
-
case "GeometryCollection":
|
|
773
|
-
for (j = 0; j < geometry.geometries.length; j++)
|
|
774
|
-
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
775
|
-
return false;
|
|
776
|
-
break;
|
|
777
|
-
default:
|
|
778
|
-
throw new Error("Unknown Geometry Type");
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
785
|
-
function bbox(geojson, options = {}) {
|
|
786
|
-
if (geojson.bbox != null && true !== options.recompute) {
|
|
787
|
-
return geojson.bbox;
|
|
788
|
-
}
|
|
789
|
-
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
790
|
-
coordEach(geojson, (coord) => {
|
|
791
|
-
if (result[0] > coord[0]) {
|
|
792
|
-
result[0] = coord[0];
|
|
793
|
-
}
|
|
794
|
-
if (result[1] > coord[1]) {
|
|
795
|
-
result[1] = coord[1];
|
|
796
|
-
}
|
|
797
|
-
if (result[2] < coord[0]) {
|
|
798
|
-
result[2] = coord[0];
|
|
799
|
-
}
|
|
800
|
-
if (result[3] < coord[1]) {
|
|
801
|
-
result[3] = coord[1];
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
return result;
|
|
805
|
-
}
|
|
806
|
-
var index_default = bbox;
|
|
807
|
-
|
|
808
|
-
// src/IndoorMap/IndoorMap.ts
|
|
809
|
-
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
810
|
-
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
811
754
|
var import_three8 = require("three");
|
|
812
755
|
|
|
813
756
|
// src/IndoorMap/constants.ts
|
|
@@ -2987,8 +2930,133 @@ var createHighlighExtrudeObjectController = (obj, { color }) => {
|
|
|
2987
2930
|
};
|
|
2988
2931
|
|
|
2989
2932
|
// src/IndoorMap/camera/CameraManager.ts
|
|
2990
|
-
var
|
|
2991
|
-
|
|
2933
|
+
var import_maptalks6 = require("maptalks");
|
|
2934
|
+
|
|
2935
|
+
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
2936
|
+
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
2937
|
+
if (geojson === null) return;
|
|
2938
|
+
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
2939
|
+
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
2940
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
2941
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
2942
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
2943
|
+
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
2944
|
+
var multiFeatureIndex = 0;
|
|
2945
|
+
var geometryIndex = 0;
|
|
2946
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
2947
|
+
if (geometry === null) continue;
|
|
2948
|
+
coords = geometry.coordinates;
|
|
2949
|
+
var geomType = geometry.type;
|
|
2950
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
2951
|
+
switch (geomType) {
|
|
2952
|
+
case null:
|
|
2953
|
+
break;
|
|
2954
|
+
case "Point":
|
|
2955
|
+
if (callback(
|
|
2956
|
+
coords,
|
|
2957
|
+
coordIndex,
|
|
2958
|
+
featureIndex,
|
|
2959
|
+
multiFeatureIndex,
|
|
2960
|
+
geometryIndex
|
|
2961
|
+
) === false)
|
|
2962
|
+
return false;
|
|
2963
|
+
coordIndex++;
|
|
2964
|
+
multiFeatureIndex++;
|
|
2965
|
+
break;
|
|
2966
|
+
case "LineString":
|
|
2967
|
+
case "MultiPoint":
|
|
2968
|
+
for (j = 0; j < coords.length; j++) {
|
|
2969
|
+
if (callback(
|
|
2970
|
+
coords[j],
|
|
2971
|
+
coordIndex,
|
|
2972
|
+
featureIndex,
|
|
2973
|
+
multiFeatureIndex,
|
|
2974
|
+
geometryIndex
|
|
2975
|
+
) === false)
|
|
2976
|
+
return false;
|
|
2977
|
+
coordIndex++;
|
|
2978
|
+
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
2979
|
+
}
|
|
2980
|
+
if (geomType === "LineString") multiFeatureIndex++;
|
|
2981
|
+
break;
|
|
2982
|
+
case "Polygon":
|
|
2983
|
+
case "MultiLineString":
|
|
2984
|
+
for (j = 0; j < coords.length; j++) {
|
|
2985
|
+
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
2986
|
+
if (callback(
|
|
2987
|
+
coords[j][k],
|
|
2988
|
+
coordIndex,
|
|
2989
|
+
featureIndex,
|
|
2990
|
+
multiFeatureIndex,
|
|
2991
|
+
geometryIndex
|
|
2992
|
+
) === false)
|
|
2993
|
+
return false;
|
|
2994
|
+
coordIndex++;
|
|
2995
|
+
}
|
|
2996
|
+
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
2997
|
+
if (geomType === "Polygon") geometryIndex++;
|
|
2998
|
+
}
|
|
2999
|
+
if (geomType === "Polygon") multiFeatureIndex++;
|
|
3000
|
+
break;
|
|
3001
|
+
case "MultiPolygon":
|
|
3002
|
+
for (j = 0; j < coords.length; j++) {
|
|
3003
|
+
geometryIndex = 0;
|
|
3004
|
+
for (k = 0; k < coords[j].length; k++) {
|
|
3005
|
+
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
3006
|
+
if (callback(
|
|
3007
|
+
coords[j][k][l],
|
|
3008
|
+
coordIndex,
|
|
3009
|
+
featureIndex,
|
|
3010
|
+
multiFeatureIndex,
|
|
3011
|
+
geometryIndex
|
|
3012
|
+
) === false)
|
|
3013
|
+
return false;
|
|
3014
|
+
coordIndex++;
|
|
3015
|
+
}
|
|
3016
|
+
geometryIndex++;
|
|
3017
|
+
}
|
|
3018
|
+
multiFeatureIndex++;
|
|
3019
|
+
}
|
|
3020
|
+
break;
|
|
3021
|
+
case "GeometryCollection":
|
|
3022
|
+
for (j = 0; j < geometry.geometries.length; j++)
|
|
3023
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
3024
|
+
return false;
|
|
3025
|
+
break;
|
|
3026
|
+
default:
|
|
3027
|
+
throw new Error("Unknown Geometry Type");
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
3034
|
+
function bbox(geojson, options = {}) {
|
|
3035
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
3036
|
+
return geojson.bbox;
|
|
3037
|
+
}
|
|
3038
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
3039
|
+
coordEach(geojson, (coord) => {
|
|
3040
|
+
if (result[0] > coord[0]) {
|
|
3041
|
+
result[0] = coord[0];
|
|
3042
|
+
}
|
|
3043
|
+
if (result[1] > coord[1]) {
|
|
3044
|
+
result[1] = coord[1];
|
|
3045
|
+
}
|
|
3046
|
+
if (result[2] < coord[0]) {
|
|
3047
|
+
result[2] = coord[0];
|
|
3048
|
+
}
|
|
3049
|
+
if (result[3] < coord[1]) {
|
|
3050
|
+
result[3] = coord[1];
|
|
3051
|
+
}
|
|
3052
|
+
});
|
|
3053
|
+
return result;
|
|
3054
|
+
}
|
|
3055
|
+
var index_default = bbox;
|
|
3056
|
+
|
|
3057
|
+
// src/IndoorMap/camera/CameraManager.ts
|
|
3058
|
+
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
3059
|
+
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
2992
3060
|
var CameraManager = class {
|
|
2993
3061
|
map;
|
|
2994
3062
|
constructor(map, options) {
|
|
@@ -2997,73 +3065,61 @@ var CameraManager = class {
|
|
|
2997
3065
|
this.setView(options?.defaultView);
|
|
2998
3066
|
}
|
|
2999
3067
|
}
|
|
3000
|
-
/** Private method */
|
|
3001
|
-
#animateflyTo(viewOptions = {}, options = {}, callbackOption = () => {
|
|
3002
|
-
}) {
|
|
3003
|
-
const { start, end } = {
|
|
3004
|
-
start: (frame) => {
|
|
3005
|
-
},
|
|
3006
|
-
end: (frame) => {
|
|
3007
|
-
},
|
|
3008
|
-
...callbackOption
|
|
3009
|
-
};
|
|
3010
|
-
this.map.flyTo(viewOptions, options, (frame) => {
|
|
3011
|
-
if (frame.state.playState === "running" && frame.state.progress === 0)
|
|
3012
|
-
start(frame);
|
|
3013
|
-
if (frame.state.playState === "finished") end(frame);
|
|
3014
|
-
});
|
|
3015
|
-
}
|
|
3016
3068
|
/** Public methods */
|
|
3017
3069
|
getView = () => {
|
|
3018
3070
|
return this.map.getView();
|
|
3019
3071
|
};
|
|
3020
|
-
getZoom = () => {
|
|
3021
|
-
return this.map.getView().zoom;
|
|
3022
|
-
};
|
|
3023
3072
|
setView = (value) => {
|
|
3024
3073
|
this.map.setView(value);
|
|
3025
3074
|
};
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
const {
|
|
3029
|
-
zoom = ZOOM_OUT_LEVEL,
|
|
3030
|
-
pitch = 60,
|
|
3031
|
-
duration = 600,
|
|
3032
|
-
easing = "out",
|
|
3033
|
-
bearing = currentView.bearing
|
|
3034
|
-
} = options;
|
|
3035
|
-
this.#animateflyTo(
|
|
3036
|
-
{
|
|
3037
|
-
center: center2,
|
|
3038
|
-
zoom,
|
|
3039
|
-
pitch,
|
|
3040
|
-
bearing
|
|
3041
|
-
},
|
|
3042
|
-
{ duration, easing }
|
|
3043
|
-
);
|
|
3075
|
+
animateTo = (view, options = {}, step) => {
|
|
3076
|
+
this.map.animateTo(view, options, step);
|
|
3044
3077
|
};
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
} = options;
|
|
3052
|
-
this.#animateflyTo(
|
|
3053
|
-
{
|
|
3054
|
-
center: centerPoint,
|
|
3055
|
-
zoom,
|
|
3056
|
-
pitch
|
|
3057
|
-
},
|
|
3058
|
-
{ duration, easing }
|
|
3078
|
+
setMaxExtent(extent) {
|
|
3079
|
+
return this.map.setMaxExtent(extent);
|
|
3080
|
+
}
|
|
3081
|
+
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
3082
|
+
const [minX, minY, maxX, maxY] = index_default(
|
|
3083
|
+
(0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
|
|
3059
3084
|
);
|
|
3085
|
+
return new import_maptalks6.Extent(minX, minY, maxX, maxY);
|
|
3060
3086
|
};
|
|
3087
|
+
getExtentZoom = (extent, options = {
|
|
3088
|
+
isFraction: false,
|
|
3089
|
+
padding: {
|
|
3090
|
+
paddingLeft: 0,
|
|
3091
|
+
paddingRight: 0,
|
|
3092
|
+
paddingTop: 0,
|
|
3093
|
+
paddingBottom: 0
|
|
3094
|
+
}
|
|
3095
|
+
}) => {
|
|
3096
|
+
const { isFraction = false, padding } = options;
|
|
3097
|
+
return this.map.getFitZoom(extent, isFraction, padding);
|
|
3098
|
+
};
|
|
3099
|
+
set maxZoom(value) {
|
|
3100
|
+
this.map.setMaxZoom(value);
|
|
3101
|
+
const spatialReference = {
|
|
3102
|
+
projection: "EPSG:3857",
|
|
3103
|
+
resolutions: (function() {
|
|
3104
|
+
const resolutions = [];
|
|
3105
|
+
const d = 2 * 6378137 * Math.PI;
|
|
3106
|
+
for (let i = 0; i < value; i++) {
|
|
3107
|
+
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
3108
|
+
}
|
|
3109
|
+
return resolutions;
|
|
3110
|
+
})()
|
|
3111
|
+
};
|
|
3112
|
+
this.map.setSpatialReference(spatialReference);
|
|
3113
|
+
}
|
|
3114
|
+
set minZoom(value) {
|
|
3115
|
+
this.map.setMinZoom(value);
|
|
3116
|
+
}
|
|
3061
3117
|
};
|
|
3062
3118
|
|
|
3063
3119
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3064
3120
|
var import_min = __toESM(require("lodash/min"));
|
|
3065
3121
|
var import_center3 = require("@turf/center");
|
|
3066
|
-
var
|
|
3122
|
+
var import_maptalks9 = require("maptalks.three");
|
|
3067
3123
|
var THREE3 = __toESM(require("three"));
|
|
3068
3124
|
|
|
3069
3125
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
@@ -3099,9 +3155,9 @@ var element3DRendererOptions = {
|
|
|
3099
3155
|
};
|
|
3100
3156
|
|
|
3101
3157
|
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3102
|
-
var
|
|
3158
|
+
var import_maptalks7 = require("maptalks");
|
|
3103
3159
|
var THREE = __toESM(require("three"));
|
|
3104
|
-
var
|
|
3160
|
+
var import_maptalks8 = require("maptalks.three");
|
|
3105
3161
|
var import_lodash6 = require("lodash");
|
|
3106
3162
|
|
|
3107
3163
|
// src/IndoorMap/renderer/utils/interpolateStops.ts
|
|
@@ -3139,12 +3195,12 @@ var OPTIONS4 = {
|
|
|
3139
3195
|
altitude: 0,
|
|
3140
3196
|
opacity: 1
|
|
3141
3197
|
};
|
|
3142
|
-
var TextSpriteMarker = class extends
|
|
3198
|
+
var TextSpriteMarker = class extends import_maptalks8.BaseObject {
|
|
3143
3199
|
#altitudeOffset = 0;
|
|
3144
3200
|
constructor(coordinate, options, layer, properties = {}) {
|
|
3145
|
-
options =
|
|
3201
|
+
options = import_maptalks7.Util.extend({}, OPTIONS4, options, { layer });
|
|
3146
3202
|
super();
|
|
3147
|
-
this._coordinate = new
|
|
3203
|
+
this._coordinate = new import_maptalks7.Coordinate(coordinate);
|
|
3148
3204
|
this._initOptions(options);
|
|
3149
3205
|
this._createGroup();
|
|
3150
3206
|
this.properties = { ...properties };
|
|
@@ -3359,41 +3415,45 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3359
3415
|
} = getGeometryOption(feature2, this.options);
|
|
3360
3416
|
const _this = this;
|
|
3361
3417
|
const createPolygon = (geometry, feature3) => {
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3418
|
+
try {
|
|
3419
|
+
const [outerRing, ...innerRings] = geometry.coordinates;
|
|
3420
|
+
const offsetFeature = offset !== 0 ? (0, import_buffer2.default)(geometry, offset, { units: "meters" }) : feature3;
|
|
3421
|
+
const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#ffffff";
|
|
3422
|
+
if (color === "transparent") return;
|
|
3423
|
+
const material = this.getOrCreateMaterialByColor(color);
|
|
3424
|
+
const altitude = feature3.properties.ordinal * HEIGHT_METER;
|
|
3425
|
+
const height = feature3.properties.height ?? heightOptions ?? HEIGHT_METER;
|
|
3426
|
+
const bottomHeight = feature3.properties.bottomHeight ?? bottomHeightOptions ?? 0;
|
|
3427
|
+
const extrudedPolygon = this.threeLayer.toExtrudePolygon(
|
|
3428
|
+
offsetFeature,
|
|
3429
|
+
{ asynchronous: true, ...options, height, bottomHeight, altitude },
|
|
3430
|
+
material
|
|
3431
|
+
);
|
|
3432
|
+
extrudedPolygon.on("click", (e) => {
|
|
3433
|
+
console.log(e.target.options.polygon.id);
|
|
3434
|
+
});
|
|
3435
|
+
const topLineStrings = [
|
|
3436
|
+
new maptalks4.LineString(outerRing),
|
|
3437
|
+
...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
|
|
3438
|
+
];
|
|
3439
|
+
const topLines = this.threeLayer.toLines(
|
|
3440
|
+
topLineStrings,
|
|
3441
|
+
{ altitude, bottomHeight: bottomHeight + height + 1e-3, interactive: false },
|
|
3442
|
+
this.lineMaterial
|
|
3443
|
+
);
|
|
3444
|
+
const bottomLineStrings = [
|
|
3445
|
+
new maptalks4.LineString(outerRing),
|
|
3446
|
+
...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
|
|
3447
|
+
];
|
|
3448
|
+
const bottomLines = this.threeLayer.toLines(
|
|
3449
|
+
bottomLineStrings,
|
|
3450
|
+
{ altitude, bottomHeight, interactive: false },
|
|
3451
|
+
this.lineMaterial
|
|
3452
|
+
);
|
|
3453
|
+
return [extrudedPolygon, topLines, bottomLines];
|
|
3454
|
+
} catch (err) {
|
|
3455
|
+
throw new Error(`Cannot create polygon, ${err.message}`);
|
|
3456
|
+
}
|
|
3397
3457
|
};
|
|
3398
3458
|
try {
|
|
3399
3459
|
switch (feature2.geometry.type) {
|
|
@@ -3413,7 +3473,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3413
3473
|
}
|
|
3414
3474
|
}
|
|
3415
3475
|
} catch (err) {
|
|
3416
|
-
console.log(`error createGeometry`, { feature: feature2, options });
|
|
3476
|
+
console.log(`error createGeometry`, err, { feature: feature2, options });
|
|
3417
3477
|
}
|
|
3418
3478
|
};
|
|
3419
3479
|
async createEscalator(f, coordinate, options) {
|
|
@@ -3874,7 +3934,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3874
3934
|
this.markersByOrdinal = /* @__PURE__ */ new Map();
|
|
3875
3935
|
this.#dataClient = dataClient;
|
|
3876
3936
|
if (options.type === "3D") {
|
|
3877
|
-
const threeLayer = new
|
|
3937
|
+
const threeLayer = new import_maptalks9.ThreeLayer("elements", {
|
|
3878
3938
|
forceRenderOnMoving: true,
|
|
3879
3939
|
forceRenderOnRotating: true
|
|
3880
3940
|
});
|
|
@@ -3983,6 +4043,8 @@ var RendererManager = class extends EventTarget {
|
|
|
3983
4043
|
}
|
|
3984
4044
|
const thisOrdinal = escalator.properties.ordinal;
|
|
3985
4045
|
const relationship = escalatorRelationships[0];
|
|
4046
|
+
if (!relationship.properties.origin?.id) throw new Error(`relationship (id=${relationship.id}) - origin not exists`);
|
|
4047
|
+
if (!relationship.properties.destination?.id) throw new Error(`relationship (id=${relationship.id}) - destination not exists`);
|
|
3986
4048
|
const bothOpeningIds = [relationship.properties.origin.id, relationship.properties.destination.id];
|
|
3987
4049
|
const bothOpenings = await Promise.all(
|
|
3988
4050
|
bothOpeningIds.map((id) => this.#dataClient.findById("opening", id, { populate: true }))
|
|
@@ -3998,7 +4060,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3998
4060
|
this.addElementsToManager(escalator.id, _elements, escalator.properties.ordinal);
|
|
3999
4061
|
}
|
|
4000
4062
|
} catch (err) {
|
|
4001
|
-
console.log(`cannot create escalator`, err);
|
|
4063
|
+
console.log(`cannot create escalator`, err.message);
|
|
4002
4064
|
}
|
|
4003
4065
|
}
|
|
4004
4066
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
@@ -4134,7 +4196,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4134
4196
|
layers: []
|
|
4135
4197
|
});
|
|
4136
4198
|
this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer);
|
|
4137
|
-
this.camera = new CameraManager(this.map);
|
|
4199
|
+
this.camera = new CameraManager(this.map, options.camera);
|
|
4138
4200
|
this.locale = locale;
|
|
4139
4201
|
this.pixelRatio = pixelRatio;
|
|
4140
4202
|
this.onMapReady = onMapReady;
|
|
@@ -4152,12 +4214,12 @@ var IndoorMap = class extends EventTarget {
|
|
|
4152
4214
|
this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
|
|
4153
4215
|
});
|
|
4154
4216
|
}
|
|
4155
|
-
on(eventName, handler) {
|
|
4156
|
-
this.map.on(eventName, handler);
|
|
4157
|
-
}
|
|
4158
4217
|
/**
|
|
4159
4218
|
* Events
|
|
4160
4219
|
*/
|
|
4220
|
+
on(eventName, handler) {
|
|
4221
|
+
this.map.on(eventName, handler);
|
|
4222
|
+
}
|
|
4161
4223
|
handleMapClick = ({ coordinate }) => {
|
|
4162
4224
|
const { x, y } = coordinate;
|
|
4163
4225
|
console.log(
|
|
@@ -4213,40 +4275,12 @@ var IndoorMap = class extends EventTarget {
|
|
|
4213
4275
|
this.map.off("moveend", this.#findAndSetVenueInView);
|
|
4214
4276
|
}
|
|
4215
4277
|
}
|
|
4216
|
-
get ordinals() {
|
|
4217
|
-
return this.#ordinals || [];
|
|
4218
|
-
}
|
|
4219
|
-
set ordinals(value) {
|
|
4220
|
-
if (!Array.isArray(value)) throw new Error("ordinals must be Array");
|
|
4221
|
-
this.#ordinals = value;
|
|
4222
|
-
}
|
|
4223
4278
|
set billboards(value) {
|
|
4224
4279
|
this.#billboards = value;
|
|
4225
4280
|
}
|
|
4226
|
-
set mapConfig(value) {
|
|
4227
|
-
this.#mapConfig = value;
|
|
4228
|
-
}
|
|
4229
4281
|
set mapDecorations(value) {
|
|
4230
4282
|
this.#mapDecorations = value;
|
|
4231
4283
|
}
|
|
4232
|
-
set maxZoom(value) {
|
|
4233
|
-
this.map.setMaxZoom(value);
|
|
4234
|
-
const spatialReference = {
|
|
4235
|
-
projection: "EPSG:3857",
|
|
4236
|
-
resolutions: (function() {
|
|
4237
|
-
const resolutions = [];
|
|
4238
|
-
const d = 2 * 6378137 * Math.PI;
|
|
4239
|
-
for (let i = 0; i < value; i++) {
|
|
4240
|
-
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
4241
|
-
}
|
|
4242
|
-
return resolutions;
|
|
4243
|
-
})()
|
|
4244
|
-
};
|
|
4245
|
-
this.map.setSpatialReference(spatialReference);
|
|
4246
|
-
}
|
|
4247
|
-
set minZoom(value) {
|
|
4248
|
-
this.map.setMinZoom(value);
|
|
4249
|
-
}
|
|
4250
4284
|
set groundLabels(value) {
|
|
4251
4285
|
this.#groundLabels = value;
|
|
4252
4286
|
}
|
|
@@ -4282,9 +4316,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4282
4316
|
this.#onClickElement(e);
|
|
4283
4317
|
this.#isClicked = false;
|
|
4284
4318
|
};
|
|
4285
|
-
setCenter(center2, padding) {
|
|
4286
|
-
this.map.setCenter(center2, padding);
|
|
4287
|
-
}
|
|
4288
4319
|
async #legacy_createElements() {
|
|
4289
4320
|
const {
|
|
4290
4321
|
// 2D
|
|
@@ -4506,7 +4537,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4506
4537
|
const {
|
|
4507
4538
|
geometry: { coordinates }
|
|
4508
4539
|
} = (0, import_center4.default)(feature2);
|
|
4509
|
-
this.camera.
|
|
4540
|
+
this.camera.animateTo({ center: coordinates, pitch: 45 });
|
|
4510
4541
|
});
|
|
4511
4542
|
object3ds.push(object);
|
|
4512
4543
|
this.#objects.push(object);
|
|
@@ -4589,27 +4620,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4589
4620
|
changeLevelByOrdinal(ordinal) {
|
|
4590
4621
|
this.rendererManager.changeLevelByOrdinal(ordinal);
|
|
4591
4622
|
}
|
|
4592
|
-
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
4593
|
-
const [minX, minY, maxX, maxY] = index_default(
|
|
4594
|
-
(0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
|
|
4595
|
-
);
|
|
4596
|
-
return new import_maptalks_gl.Extent(minX, minY, maxX, maxY);
|
|
4597
|
-
};
|
|
4598
|
-
getExtentCenter = (extent) => {
|
|
4599
|
-
return extent.getCenter();
|
|
4600
|
-
};
|
|
4601
|
-
getExtentZoom = (extent, options = {
|
|
4602
|
-
isFraction: false,
|
|
4603
|
-
padding: {
|
|
4604
|
-
paddingLeft: 0,
|
|
4605
|
-
paddingRight: 0,
|
|
4606
|
-
paddingTop: 0,
|
|
4607
|
-
paddingBottom: 0
|
|
4608
|
-
}
|
|
4609
|
-
}) => {
|
|
4610
|
-
const { isFraction = false, padding } = options;
|
|
4611
|
-
return this.map.getFitZoom(extent, isFraction, padding);
|
|
4612
|
-
};
|
|
4613
4623
|
findVenueInView = () => {
|
|
4614
4624
|
const mapCenter = this.map.getCenter();
|
|
4615
4625
|
const result = this.#venues.reduce((closest, venue) => {
|
|
@@ -4622,9 +4632,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4622
4632
|
}, null);
|
|
4623
4633
|
return result;
|
|
4624
4634
|
};
|
|
4625
|
-
flyTo = (center2, options) => {
|
|
4626
|
-
this.camera.flyTo(center2, options);
|
|
4627
|
-
};
|
|
4628
4635
|
getLineStringBearing = (feature2) => {
|
|
4629
4636
|
const { geometry } = feature2;
|
|
4630
4637
|
const path = new import_maptalks_gl.LineString(geometry.coordinates);
|
|
@@ -5140,33 +5147,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
5140
5147
|
/**
|
|
5141
5148
|
* render (frame)
|
|
5142
5149
|
*/
|
|
5143
|
-
getTargetViewCenter = (targetView, options = { offset: { top: 0, left: 0, right: 0, bottom: 0 } }) => {
|
|
5144
|
-
const map = this.map;
|
|
5145
|
-
const { offset } = options;
|
|
5146
|
-
const { top = 0, left = 0, right = 0, bottom = 0 } = offset;
|
|
5147
|
-
const originalState = {
|
|
5148
|
-
bearing: map.getBearing(),
|
|
5149
|
-
center: map.getCenter(),
|
|
5150
|
-
pitch: map.getPitch(),
|
|
5151
|
-
zoom: map.getZoom()
|
|
5152
|
-
};
|
|
5153
|
-
const finalView = {
|
|
5154
|
-
bearing: import_lodash7.default.isNil(targetView.bearing) ? map.getBearing() : targetView.bearing,
|
|
5155
|
-
center: import_lodash7.default.isNil(targetView.center) ? map.getCenter() : targetView.center,
|
|
5156
|
-
pitch: import_lodash7.default.isNil(targetView.pitch) ? map.getPitch() : targetView.pitch,
|
|
5157
|
-
zoom: import_lodash7.default.isNil(targetView.zoom) ? map.getZoom() : targetView.zoom
|
|
5158
|
-
};
|
|
5159
|
-
map.setView(finalView);
|
|
5160
|
-
const projectedTargetCenter = map.coordinateToContainerPoint(finalView.center).add(right / 2 - left / 2, bottom / 2 - top / 2);
|
|
5161
|
-
const adjustedTargetCenter = map.containerPointToCoordinate(
|
|
5162
|
-
projectedTargetCenter
|
|
5163
|
-
);
|
|
5164
|
-
map.setView(originalState);
|
|
5165
|
-
return adjustedTargetCenter;
|
|
5166
|
-
};
|
|
5167
|
-
setMaxExtent(extent) {
|
|
5168
|
-
return this.map.setMaxExtent(extent);
|
|
5169
|
-
}
|
|
5170
5150
|
render() {
|
|
5171
5151
|
const view = this.map.getView();
|
|
5172
5152
|
const currBearing = view.bearing;
|
|
@@ -5175,7 +5155,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
5175
5155
|
this.threeLayer.redraw();
|
|
5176
5156
|
}
|
|
5177
5157
|
if (this.threeLayer) {
|
|
5178
|
-
const
|
|
5158
|
+
const currentView = this.camera.getView();
|
|
5159
|
+
const objectOpacity = import_lodash7.default.clamp(38 - 2 * currentView.zoom, 0, 1);
|
|
5179
5160
|
this.#objects.forEach((object) => {
|
|
5180
5161
|
object.getObject3d().traverse((child) => {
|
|
5181
5162
|
if (child.isMesh) child.material.opacity = objectOpacity;
|
|
@@ -5186,7 +5167,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5186
5167
|
if (this.#billboardObjects) {
|
|
5187
5168
|
this.#billboardObjects.forEach((object) => {
|
|
5188
5169
|
const objectScale = import_lodash7.default.clamp(
|
|
5189
|
-
20 - 1 *
|
|
5170
|
+
20 - 1 * currentView.zoom,
|
|
5190
5171
|
1,
|
|
5191
5172
|
1.05
|
|
5192
5173
|
);
|
|
@@ -5248,7 +5229,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
5248
5229
|
createSpriteMaterialByLabelSymbol,
|
|
5249
5230
|
createStyledUIMarkerElement,
|
|
5250
5231
|
defaultFeatureQueryOptionsMap,
|
|
5251
|
-
|
|
5232
|
+
fetchDeliveryApi,
|
|
5233
|
+
fetchPreviewApi,
|
|
5252
5234
|
getBearingBetweenPoints,
|
|
5253
5235
|
getCenterFromGeometry,
|
|
5254
5236
|
getDataClient,
|