venue-js 1.2.0-next.9 → 1.3.0-next.1
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 +61 -64
- package/dist/index.d.ts +61 -64
- package/dist/index.js +1298 -959
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1262 -925
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -1
package/dist/index.mjs
CHANGED
|
@@ -81,7 +81,8 @@ var defaultFeatureQueryOptionsMap = {
|
|
|
81
81
|
// refresh every 5 min
|
|
82
82
|
},
|
|
83
83
|
element: {},
|
|
84
|
-
page: {}
|
|
84
|
+
page: {},
|
|
85
|
+
model3d: {}
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
// src/data/api/delivery-project.ts
|
|
@@ -97,6 +98,14 @@ async function fetchDeliveryApi(projectId, apiKey, featureType, baseUrl = DEFAUL
|
|
|
97
98
|
const items = await res.json();
|
|
98
99
|
return items;
|
|
99
100
|
}
|
|
101
|
+
case "model3d": {
|
|
102
|
+
const res = await fetch(
|
|
103
|
+
`${baseUrl}/delivery/projects/${projectId}/${featureType}.geojson?api-key=${apiKey}`
|
|
104
|
+
);
|
|
105
|
+
if (res.status !== 200) return [];
|
|
106
|
+
const items = await res.json();
|
|
107
|
+
return items.features;
|
|
108
|
+
}
|
|
100
109
|
case "sponsored-content": {
|
|
101
110
|
const res = await fetch(
|
|
102
111
|
`${baseUrl}/delivery/projects/${projectId}/sponsored-content.json?api-key=${apiKey}`
|
|
@@ -207,16 +216,16 @@ function isValidLinearRingCoordinates(ring) {
|
|
|
207
216
|
}
|
|
208
217
|
return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
|
|
209
218
|
}
|
|
210
|
-
var isValidPolygonCoordinates = (
|
|
211
|
-
if (Array.isArray(
|
|
212
|
-
return isValidLinearRingCoordinates(
|
|
219
|
+
var isValidPolygonCoordinates = (polygon2) => {
|
|
220
|
+
if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
|
|
221
|
+
return isValidLinearRingCoordinates(polygon2);
|
|
213
222
|
}
|
|
214
|
-
if (Array.isArray(
|
|
215
|
-
if (!isValidLinearRingCoordinates(
|
|
223
|
+
if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
|
|
224
|
+
if (!isValidLinearRingCoordinates(polygon2[0])) {
|
|
216
225
|
return false;
|
|
217
226
|
}
|
|
218
|
-
for (let i = 1; i <
|
|
219
|
-
if (!isValidLinearRingCoordinates(
|
|
227
|
+
for (let i = 1; i < polygon2.length; i++) {
|
|
228
|
+
if (!isValidLinearRingCoordinates(polygon2[i])) {
|
|
220
229
|
return false;
|
|
221
230
|
}
|
|
222
231
|
}
|
|
@@ -259,7 +268,7 @@ var isValidPoint = (geometry) => {
|
|
|
259
268
|
function isInFilter(filter) {
|
|
260
269
|
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
261
270
|
}
|
|
262
|
-
var someIntersect = (a, b) => a.some((
|
|
271
|
+
var someIntersect = (a, b) => a.some((v2) => b.includes(v2));
|
|
263
272
|
function matchFilter(value, filter) {
|
|
264
273
|
if (Array.isArray(value)) {
|
|
265
274
|
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
@@ -282,7 +291,7 @@ __export(occupant_helper_exports, {
|
|
|
282
291
|
getOccupantMainLocation: () => getOccupantMainLocation,
|
|
283
292
|
getOccupantMarkerLocations: () => getOccupantMarkerLocations
|
|
284
293
|
});
|
|
285
|
-
import
|
|
294
|
+
import { compact } from "lodash-es";
|
|
286
295
|
var getOccupantMainLocation = (occupant) => {
|
|
287
296
|
return occupant.properties.kiosk || occupant.properties.unit;
|
|
288
297
|
};
|
|
@@ -291,7 +300,7 @@ var getOccupantCorrelatedLocations = (occupant) => {
|
|
|
291
300
|
...occupant.properties.units,
|
|
292
301
|
...occupant.properties.kiosks
|
|
293
302
|
];
|
|
294
|
-
return
|
|
303
|
+
return compact(allCorrelatedLocations);
|
|
295
304
|
};
|
|
296
305
|
var getOccupantMarkerLocations = (occupant, options) => {
|
|
297
306
|
const placementType = options?.type ? options.type : occupant.properties.show_name_on_all_units ? "ALL_LOCATIONS" : "ONCE_PER_LEVEL";
|
|
@@ -299,11 +308,11 @@ var getOccupantMarkerLocations = (occupant, options) => {
|
|
|
299
308
|
const mainLocationLevel = mainLocation?.properties?.level_id;
|
|
300
309
|
const allCorrelatedLocations = getOccupantCorrelatedLocations(occupant);
|
|
301
310
|
if (placementType === "ALL_LOCATIONS") {
|
|
302
|
-
return
|
|
311
|
+
return compact([mainLocation, ...allCorrelatedLocations]);
|
|
303
312
|
}
|
|
304
313
|
const otherLevelLocations = allCorrelatedLocations.filter((f) => f.properties.level_id !== mainLocationLevel);
|
|
305
314
|
const onePerLevelLocations = [...new Map(otherLevelLocations.map((loc) => [loc.properties.level_id, loc])).values()];
|
|
306
|
-
return
|
|
315
|
+
return compact([mainLocation, ...onePerLevelLocations]);
|
|
307
316
|
};
|
|
308
317
|
|
|
309
318
|
// src/data/getDataClient.ts
|
|
@@ -685,18 +694,16 @@ var getDataClient = (options) => {
|
|
|
685
694
|
|
|
686
695
|
// src/IndoorMap/IndoorMap.ts
|
|
687
696
|
import {
|
|
688
|
-
ui as ui3,
|
|
689
697
|
Map as Map2,
|
|
690
698
|
TileLayer,
|
|
691
699
|
LineString as LineString3,
|
|
692
|
-
Marker as Marker2,
|
|
693
700
|
Coordinate as Coordinate4,
|
|
694
701
|
GroupGLLayer,
|
|
695
702
|
GLTFLayer
|
|
696
703
|
} from "maptalks-gl";
|
|
697
704
|
import "@maptalks/transcoders.draco";
|
|
698
|
-
import
|
|
699
|
-
import
|
|
705
|
+
import TWEEN from "@tweenjs/tween.js";
|
|
706
|
+
import _5 from "lodash";
|
|
700
707
|
|
|
701
708
|
// ../../node_modules/@turf/helpers/dist/esm/index.js
|
|
702
709
|
var earthRadius = 63710088e-1;
|
|
@@ -748,6 +755,28 @@ function point(coordinates, properties, options = {}) {
|
|
|
748
755
|
};
|
|
749
756
|
return feature(geom, properties, options);
|
|
750
757
|
}
|
|
758
|
+
function polygon(coordinates, properties, options = {}) {
|
|
759
|
+
for (const ring of coordinates) {
|
|
760
|
+
if (ring.length < 4) {
|
|
761
|
+
throw new Error(
|
|
762
|
+
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
766
|
+
throw new Error("First and last Position are not equivalent.");
|
|
767
|
+
}
|
|
768
|
+
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
769
|
+
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
770
|
+
throw new Error("First and last Position are not equivalent.");
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
const geom = {
|
|
775
|
+
type: "Polygon",
|
|
776
|
+
coordinates
|
|
777
|
+
};
|
|
778
|
+
return feature(geom, properties, options);
|
|
779
|
+
}
|
|
751
780
|
function lineString(coordinates, properties, options = {}) {
|
|
752
781
|
if (coordinates.length < 2) {
|
|
753
782
|
throw new Error("coordinates must be an array of two or more positions");
|
|
@@ -769,6 +798,13 @@ function featureCollection(features, options = {}) {
|
|
|
769
798
|
fc.features = features;
|
|
770
799
|
return fc;
|
|
771
800
|
}
|
|
801
|
+
function multiPoint(coordinates, properties, options = {}) {
|
|
802
|
+
const geom = {
|
|
803
|
+
type: "MultiPoint",
|
|
804
|
+
coordinates
|
|
805
|
+
};
|
|
806
|
+
return feature(geom, properties, options);
|
|
807
|
+
}
|
|
772
808
|
function isNumber(num) {
|
|
773
809
|
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
774
810
|
}
|
|
@@ -777,7 +813,7 @@ function isNumber(num) {
|
|
|
777
813
|
import turfDistance from "@turf/distance";
|
|
778
814
|
import turfCenter3 from "@turf/center";
|
|
779
815
|
import { PerspectiveCamera } from "three";
|
|
780
|
-
import { ThreeLayer as
|
|
816
|
+
import { ThreeLayer as ThreeLayer5 } from "maptalks.three";
|
|
781
817
|
|
|
782
818
|
// src/IndoorMap/constants.ts
|
|
783
819
|
var defaultLayerOption = { enableAltitude: true };
|
|
@@ -795,7 +831,6 @@ var GEOLOCATION = "geolocation";
|
|
|
795
831
|
var ORIGIN_MARKER = "origin-marker";
|
|
796
832
|
var DESTINATION_MARKER = "destination-marker";
|
|
797
833
|
var DECORATION = "decoration";
|
|
798
|
-
var ALWAYS_VISIBLE_FEATURE_TYPES = [VENUE, FOOTPRINT];
|
|
799
834
|
var BASE_LAYER_NAME = "base";
|
|
800
835
|
var POI_MARKER_LAYER_NAME = "poi";
|
|
801
836
|
var MARKER_LAYER_NAME = "marker";
|
|
@@ -807,13 +842,6 @@ var USER_LOCATION_ELEMENT_ID = "user_location";
|
|
|
807
842
|
var LAST_USER_LOCATION_ELEMENT_ID_PREFIX = "last_user_location-";
|
|
808
843
|
var LOCALE_SYMBOL_KEY = "locale_symbol";
|
|
809
844
|
var DEFAULT_LOCALE = "en";
|
|
810
|
-
var DEFAULT_HIGHLIGHT_OPTIONS = {
|
|
811
|
-
symbolSet: null
|
|
812
|
-
};
|
|
813
|
-
var DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS = {
|
|
814
|
-
symbolSet: null,
|
|
815
|
-
defaultMarker: false
|
|
816
|
-
};
|
|
817
845
|
var LAYERS = [
|
|
818
846
|
BASE_LAYER_NAME,
|
|
819
847
|
POI_MARKER_LAYER_NAME,
|
|
@@ -877,11 +905,8 @@ import turfBuffer from "@turf/buffer";
|
|
|
877
905
|
import {
|
|
878
906
|
TextureLoader as TextureLoader2,
|
|
879
907
|
SpriteMaterial as SpriteMaterial3,
|
|
880
|
-
MeshLambertMaterial
|
|
881
|
-
AmbientLight,
|
|
882
|
-
DirectionalLight
|
|
908
|
+
MeshLambertMaterial
|
|
883
909
|
} from "three";
|
|
884
|
-
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
885
910
|
|
|
886
911
|
// src/IndoorMap/object3d/Billboard.js
|
|
887
912
|
import * as maptalks from "maptalks";
|
|
@@ -921,7 +946,7 @@ var Billboard = class extends BaseObject {
|
|
|
921
946
|
this._initOptions(options);
|
|
922
947
|
const {
|
|
923
948
|
altitude = OPTIONS.altitude,
|
|
924
|
-
scale:
|
|
949
|
+
scale: scale3 = OPTIONS.scale,
|
|
925
950
|
alphaTest = OPTIONS.alphaTest,
|
|
926
951
|
legColor = OPTIONS.legColor,
|
|
927
952
|
showLeg = OPTIONS.showLeg
|
|
@@ -955,8 +980,8 @@ var Billboard = class extends BaseObject {
|
|
|
955
980
|
const sprite = new Sprite(material);
|
|
956
981
|
sprite.material.sizeAttenuation = false;
|
|
957
982
|
sprite.scale.set(
|
|
958
|
-
|
|
959
|
-
|
|
983
|
+
scale3 * naturalWidth / divider,
|
|
984
|
+
scale3 * naturalHeight / divider,
|
|
960
985
|
1
|
|
961
986
|
);
|
|
962
987
|
this.getObject3d().add(sprite);
|
|
@@ -965,7 +990,7 @@ var Billboard = class extends BaseObject {
|
|
|
965
990
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
966
991
|
_.set(this.properties, "default.position", position);
|
|
967
992
|
_.set(this.properties, "default.altitude", altitude);
|
|
968
|
-
_.set(this.properties, "default.scale",
|
|
993
|
+
_.set(this.properties, "default.scale", scale3);
|
|
969
994
|
this.getObject3d().position.copy(position);
|
|
970
995
|
}
|
|
971
996
|
setLineHeight(altitude) {
|
|
@@ -978,414 +1003,120 @@ var Billboard = class extends BaseObject {
|
|
|
978
1003
|
}
|
|
979
1004
|
};
|
|
980
1005
|
|
|
981
|
-
// src/IndoorMap/object3d/
|
|
982
|
-
import * as maptalks2 from "maptalks";
|
|
1006
|
+
// src/IndoorMap/object3d/SpriteMarker.ts
|
|
983
1007
|
import { BaseObject as BaseObject2 } from "maptalks.three";
|
|
984
|
-
import {
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
fontWeight: 600,
|
|
1000
|
-
margin: 0,
|
|
1001
|
-
scaleMin: 0.5,
|
|
1002
|
-
lineHeight: 1.05,
|
|
1003
|
-
scaleStep: 0.05,
|
|
1004
|
-
textAlign: "center",
|
|
1005
|
-
textBaseline: "middle",
|
|
1006
|
-
fillStyle: "#000"
|
|
1008
|
+
import { Sprite as Sprite2, SpriteMaterial as SpriteMaterial2 } from "three";
|
|
1009
|
+
import _2 from "lodash";
|
|
1010
|
+
var DEFAULT_SCALE = 0.05;
|
|
1011
|
+
var DEFAULT_ALTITUDE = 0;
|
|
1012
|
+
var DEFAULT_ALPHATEST = 0.3;
|
|
1013
|
+
var DEFAULT_OPTIONS = {
|
|
1014
|
+
scale: DEFAULT_SCALE,
|
|
1015
|
+
altitude: DEFAULT_ALTITUDE,
|
|
1016
|
+
alphaTest: DEFAULT_ALPHATEST,
|
|
1017
|
+
highlight: {
|
|
1018
|
+
options: {
|
|
1019
|
+
scale: DEFAULT_SCALE * 1.25
|
|
1020
|
+
},
|
|
1021
|
+
material: null
|
|
1022
|
+
}
|
|
1007
1023
|
};
|
|
1008
|
-
var
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
for (let i = 1; i < words.length; i++) {
|
|
1044
|
-
const lineToMeasure = currentLine + " " + words[i];
|
|
1045
|
-
if (ctx2.measureText(lineToMeasure).width > maxWidth) {
|
|
1046
|
-
lines.push(currentLine);
|
|
1047
|
-
currentLine = words[i];
|
|
1048
|
-
} else {
|
|
1049
|
-
currentLine = lineToMeasure;
|
|
1050
|
-
}
|
|
1024
|
+
var SpriteMarker = class extends BaseObject2 {
|
|
1025
|
+
#default = null;
|
|
1026
|
+
#highlight = null;
|
|
1027
|
+
constructor(coordinate, options, material, layer, properties) {
|
|
1028
|
+
super();
|
|
1029
|
+
this._initOptions(options);
|
|
1030
|
+
this._createGroup();
|
|
1031
|
+
const {
|
|
1032
|
+
altitude = DEFAULT_OPTIONS.altitude,
|
|
1033
|
+
scale: scale3 = DEFAULT_OPTIONS.scale,
|
|
1034
|
+
highlight = DEFAULT_OPTIONS.highlight,
|
|
1035
|
+
alphaTest = DEFAULT_OPTIONS.alphaTest
|
|
1036
|
+
} = options;
|
|
1037
|
+
this.properties = { ...properties };
|
|
1038
|
+
const modifiedAltitude = altitude + 2;
|
|
1039
|
+
this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
|
|
1040
|
+
this.#highlight = _2.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
1041
|
+
if (material && material instanceof SpriteMaterial2)
|
|
1042
|
+
material.alphaTest = alphaTest;
|
|
1043
|
+
const sprite = new Sprite2(material);
|
|
1044
|
+
sprite.scale.set(scale3, scale3, scale3);
|
|
1045
|
+
const obj3d = this.getObject3d();
|
|
1046
|
+
obj3d.add(sprite);
|
|
1047
|
+
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
1048
|
+
const position = layer.coordinateToVector3(coordinate, z);
|
|
1049
|
+
_2.set(this.properties, "default.position", position);
|
|
1050
|
+
this.getObject3d().position.copy(position);
|
|
1051
|
+
}
|
|
1052
|
+
// Different objects need to implement their own methods
|
|
1053
|
+
setSymbol(material) {
|
|
1054
|
+
if (material && material instanceof SpriteMaterial2) {
|
|
1055
|
+
const sprite = this.getObject3d().children[0];
|
|
1056
|
+
if (!sprite) return this;
|
|
1057
|
+
sprite.material = material;
|
|
1058
|
+
sprite.material.needsUpdate = true;
|
|
1051
1059
|
}
|
|
1052
|
-
|
|
1053
|
-
return lines.slice(0, MAX_LINES);
|
|
1054
|
-
};
|
|
1055
|
-
const hasManualBreaks = text.includes("\n");
|
|
1056
|
-
let texts;
|
|
1057
|
-
if (hasManualBreaks) {
|
|
1058
|
-
texts = text.split(/\n/g);
|
|
1059
|
-
} else {
|
|
1060
|
-
const maxWidth = SIZE - 2 * margin;
|
|
1061
|
-
texts = wrapText(ctx, text, maxWidth);
|
|
1060
|
+
return this;
|
|
1062
1061
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
textWidth = max(texts.map((text2) => ctx.measureText(text2).width));
|
|
1062
|
+
setScale(scaleX, scaleY = scaleX, scaleZ = scaleX) {
|
|
1063
|
+
const sprite = this.getObject3d().children[0];
|
|
1064
|
+
if (!sprite) return this;
|
|
1065
|
+
sprite.scale.set(scaleX, scaleY, scaleZ);
|
|
1066
|
+
return this;
|
|
1069
1067
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1068
|
+
// Different objects need to implement their own methods
|
|
1069
|
+
getSymbol() {
|
|
1070
|
+
return this.getObject3d()?.children[0]?.material;
|
|
1071
|
+
}
|
|
1072
|
+
highlight() {
|
|
1073
|
+
const { material, options } = this.#highlight;
|
|
1074
|
+
if (material) this.setSymbol(material);
|
|
1075
|
+
if (options.scale) this.setScale(options.scale);
|
|
1076
|
+
if (options.altitude) this.setAltitude(options.altitude);
|
|
1077
|
+
return this;
|
|
1078
|
+
}
|
|
1079
|
+
removeHighlight() {
|
|
1080
|
+
const { material, options } = this.#default;
|
|
1081
|
+
if (material) this.setSymbol(material);
|
|
1082
|
+
if (options.scale) this.setScale(options.scale);
|
|
1083
|
+
if (options.altitude) this.setAltitude(options.altitude);
|
|
1084
|
+
return this;
|
|
1081
1085
|
}
|
|
1082
|
-
const texture = new Texture(canvas);
|
|
1083
|
-
texture.needsUpdate = true;
|
|
1084
|
-
const material = new MeshPhongMaterial({
|
|
1085
|
-
map: texture,
|
|
1086
|
-
transparent: true,
|
|
1087
|
-
// @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
|
|
1088
|
-
alphaTest: 0.3
|
|
1089
|
-
});
|
|
1090
|
-
return material;
|
|
1091
1086
|
};
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1087
|
+
|
|
1088
|
+
// src/IndoorMap/object3d/NavigationPath.ts
|
|
1089
|
+
import * as maptalks2 from "maptalks";
|
|
1090
|
+
import { BaseObject as BaseObject3 } from "maptalks.three";
|
|
1091
|
+
import { MeshBasicMaterial, ShaderMaterial, Color } from "three";
|
|
1092
|
+
var OPTIONS2 = {
|
|
1093
|
+
altitude: 0
|
|
1094
|
+
};
|
|
1095
|
+
var DEFAULT_LINE_OPTION = {
|
|
1096
|
+
color: "#000",
|
|
1097
|
+
opacity: 1
|
|
1098
|
+
};
|
|
1099
|
+
var DEFAULT_LINE_EFFECT_OPTION = {
|
|
1100
|
+
color: "#000",
|
|
1101
|
+
opacity: 1
|
|
1102
|
+
};
|
|
1103
|
+
var ENABLE_ANIMATED_PATH = true;
|
|
1104
|
+
var NavigationPath = class extends BaseObject3 {
|
|
1105
|
+
constructor(feature2, layer, properties, options, lineOptions = DEFAULT_LINE_OPTION, outlineOption = DEFAULT_LINE_EFFECT_OPTION) {
|
|
1101
1106
|
options = maptalks2.Util.extend({}, OPTIONS2, options, {
|
|
1102
|
-
layer
|
|
1103
|
-
coordinate: bound
|
|
1107
|
+
layer
|
|
1104
1108
|
});
|
|
1105
|
-
const {
|
|
1106
|
-
altitude,
|
|
1107
|
-
text,
|
|
1108
|
-
fontSize,
|
|
1109
|
-
fillStyle,
|
|
1110
|
-
textAlign,
|
|
1111
|
-
fontFamily,
|
|
1112
|
-
textBaseline,
|
|
1113
|
-
strokeStyle,
|
|
1114
|
-
lineWidth,
|
|
1115
|
-
angle = defaultRectAngleToCalc,
|
|
1116
|
-
maxFontScale,
|
|
1117
|
-
offsetX = 0,
|
|
1118
|
-
offsetY = 0,
|
|
1119
|
-
...properties
|
|
1120
|
-
} = options;
|
|
1121
1109
|
super();
|
|
1122
1110
|
this._initOptions(options);
|
|
1123
|
-
|
|
1124
|
-
this
|
|
1125
|
-
this
|
|
1126
|
-
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
fontFamily,
|
|
1133
|
-
strokeStyle,
|
|
1134
|
-
lineWidth
|
|
1135
|
-
});
|
|
1136
|
-
const rectAngles = isArray(angle) ? angle : [angle];
|
|
1137
|
-
material.needsUpdate = true;
|
|
1138
|
-
const rect = largestRect(bound, {
|
|
1139
|
-
cache: true,
|
|
1140
|
-
/**
|
|
1141
|
-
* Black magic here:
|
|
1142
|
-
* For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
|
|
1143
|
-
* So we remove -90 and 90 from choices, and use -85 & 85 instead.
|
|
1144
|
-
*/
|
|
1145
|
-
angle: rectAngles
|
|
1146
|
-
});
|
|
1147
|
-
const { cx, cy, width, angle: calculatedAngle } = rect;
|
|
1148
|
-
this.#text = text;
|
|
1149
|
-
this.#angle = calculatedAngle;
|
|
1150
|
-
const geometry = new PlaneGeometry(1, 1);
|
|
1151
|
-
this._createMesh(geometry, material);
|
|
1152
|
-
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
1153
|
-
const basePosition = layer.coordinateToVector3({ x: cx, y: cy }, z);
|
|
1154
|
-
this.#originalPosition = basePosition.clone();
|
|
1155
|
-
const finalPosition = this.#calculateFinalPosition(basePosition);
|
|
1156
|
-
const scale2 = width / 6456122659e-13;
|
|
1157
|
-
const finalScale = maxFontScale && scale2 > maxFontScale ? maxFontScale : scale2;
|
|
1158
|
-
this.getObject3d().scale.set(finalScale, finalScale, finalScale);
|
|
1159
|
-
this.getObject3d().position.copy(finalPosition);
|
|
1160
|
-
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
1161
|
-
}
|
|
1162
|
-
#calculateFinalPosition(basePosition) {
|
|
1163
|
-
if (this.#offsetX === 0 && this.#offsetY === 0) {
|
|
1164
|
-
return basePosition;
|
|
1165
|
-
}
|
|
1166
|
-
const offsetCoordinate = {
|
|
1167
|
-
x: this.#offsetX,
|
|
1168
|
-
y: this.#offsetY
|
|
1169
|
-
};
|
|
1170
|
-
const z = this.#layer.altitudeToVector3(0, 0).x;
|
|
1171
|
-
const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
|
|
1172
|
-
const zeroVector = this.#layer.coordinateToVector3({ x: 0, y: 0 }, z);
|
|
1173
|
-
const worldOffsetX = offsetVector.x - zeroVector.x;
|
|
1174
|
-
const worldOffsetY = offsetVector.y - zeroVector.y;
|
|
1175
|
-
return {
|
|
1176
|
-
x: basePosition.x + worldOffsetX,
|
|
1177
|
-
y: basePosition.y + worldOffsetY,
|
|
1178
|
-
z: basePosition.z
|
|
1179
|
-
};
|
|
1180
|
-
}
|
|
1181
|
-
#updatePosition() {
|
|
1182
|
-
if (this.#originalPosition && this.#layer) {
|
|
1183
|
-
const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
|
|
1184
|
-
this.getObject3d().position.copy(finalPosition);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
set bearing(value) {
|
|
1188
|
-
this.#bearing = value;
|
|
1189
|
-
const degree = this.#angle + this.#bearing;
|
|
1190
|
-
const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
|
|
1191
|
-
this.getObject3d().rotation.z = Math.PI / 180 * angle;
|
|
1192
|
-
}
|
|
1193
|
-
get angle() {
|
|
1194
|
-
return this.#angle;
|
|
1195
|
-
}
|
|
1196
|
-
get currentAngle() {
|
|
1197
|
-
return this.#angle;
|
|
1198
|
-
}
|
|
1199
|
-
get text() {
|
|
1200
|
-
return this.#text;
|
|
1201
|
-
}
|
|
1202
|
-
get offsetX() {
|
|
1203
|
-
return this.#offsetX;
|
|
1204
|
-
}
|
|
1205
|
-
get offsetY() {
|
|
1206
|
-
return this.#offsetY;
|
|
1207
|
-
}
|
|
1208
|
-
get offset() {
|
|
1209
|
-
return { x: this.#offsetX, y: this.#offsetY };
|
|
1210
|
-
}
|
|
1211
|
-
set offsetX(value) {
|
|
1212
|
-
if (isNumber2(value)) {
|
|
1213
|
-
this.#offsetX = value;
|
|
1214
|
-
this.#updatePosition();
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
set offsetY(value) {
|
|
1218
|
-
if (isNumber2(value)) {
|
|
1219
|
-
this.#offsetY = value;
|
|
1220
|
-
this.#updatePosition();
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
set angle(newAngle) {
|
|
1224
|
-
if (isNumber2(newAngle)) {
|
|
1225
|
-
this.#angle = newAngle;
|
|
1226
|
-
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
setOffset(offsetX, offsetY) {
|
|
1230
|
-
if (isNumber2(offsetX) && isNumber2(offsetY)) {
|
|
1231
|
-
this.#offsetX = offsetX;
|
|
1232
|
-
this.#offsetY = offsetY;
|
|
1233
|
-
this.#updatePosition();
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
addOffset(deltaX, deltaY) {
|
|
1237
|
-
if (isNumber2(deltaX) && isNumber2(deltaY)) {
|
|
1238
|
-
this.#offsetX += deltaX;
|
|
1239
|
-
this.#offsetY += deltaY;
|
|
1240
|
-
this.#updatePosition();
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
resetOffset() {
|
|
1244
|
-
this.#offsetX = 0;
|
|
1245
|
-
this.#offsetY = 0;
|
|
1246
|
-
this.#updatePosition();
|
|
1247
|
-
}
|
|
1248
|
-
moveToPosition(targetX, targetY) {
|
|
1249
|
-
if (this.#originalPosition && this.#layer) {
|
|
1250
|
-
const currentCenter = this.#layer.vector3ToCoordinate(
|
|
1251
|
-
this.#originalPosition
|
|
1252
|
-
);
|
|
1253
|
-
this.#offsetX = targetX - currentCenter.x;
|
|
1254
|
-
this.#offsetY = targetY - currentCenter.y;
|
|
1255
|
-
this.#updatePosition();
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
updateText(newText, options = {}) {
|
|
1259
|
-
this.#text = newText;
|
|
1260
|
-
const materialOptions = {
|
|
1261
|
-
fillStyle: options.fillStyle || this.properties.fillStyle,
|
|
1262
|
-
fontSize: options.fontSize || this.properties.fontSize,
|
|
1263
|
-
textAlign: options.textAlign || this.properties.textAlign,
|
|
1264
|
-
textBaseline: options.textBaseline || this.properties.textBaseline,
|
|
1265
|
-
fontFamily: options.fontFamily || this.properties.fontFamily,
|
|
1266
|
-
strokeStyle: options.strokeStyle || this.properties.strokeStyle,
|
|
1267
|
-
lineWidth: options.lineWidth || this.properties.lineWidth
|
|
1268
|
-
};
|
|
1269
|
-
const newMaterial = getMaterial(newText, materialOptions);
|
|
1270
|
-
this.getObject3d().material = newMaterial;
|
|
1271
|
-
newMaterial.needsUpdate = true;
|
|
1272
|
-
}
|
|
1273
|
-
};
|
|
1274
|
-
|
|
1275
|
-
// src/IndoorMap/object3d/SpriteMarker.ts
|
|
1276
|
-
import { BaseObject as BaseObject3 } from "maptalks.three";
|
|
1277
|
-
import { Sprite as Sprite2, SpriteMaterial as SpriteMaterial2 } from "three";
|
|
1278
|
-
import _2 from "lodash";
|
|
1279
|
-
var DEFAULT_SCALE = 0.05;
|
|
1280
|
-
var DEFAULT_ALTITUDE = 0;
|
|
1281
|
-
var DEFAULT_ALPHATEST = 0.3;
|
|
1282
|
-
var DEFAULT_OPTIONS = {
|
|
1283
|
-
scale: DEFAULT_SCALE,
|
|
1284
|
-
altitude: DEFAULT_ALTITUDE,
|
|
1285
|
-
alphaTest: DEFAULT_ALPHATEST,
|
|
1286
|
-
highlight: {
|
|
1287
|
-
options: {
|
|
1288
|
-
scale: DEFAULT_SCALE * 1.25
|
|
1289
|
-
},
|
|
1290
|
-
material: null
|
|
1291
|
-
}
|
|
1292
|
-
};
|
|
1293
|
-
var SpriteMarker = class extends BaseObject3 {
|
|
1294
|
-
#default = null;
|
|
1295
|
-
#highlight = null;
|
|
1296
|
-
constructor(coordinate, options, material, layer, properties) {
|
|
1297
|
-
super();
|
|
1298
|
-
this._initOptions(options);
|
|
1299
|
-
this._createGroup();
|
|
1300
|
-
const {
|
|
1301
|
-
altitude = DEFAULT_OPTIONS.altitude,
|
|
1302
|
-
scale: scale2 = DEFAULT_OPTIONS.scale,
|
|
1303
|
-
highlight = DEFAULT_OPTIONS.highlight,
|
|
1304
|
-
alphaTest = DEFAULT_OPTIONS.alphaTest
|
|
1305
|
-
} = options;
|
|
1306
|
-
this.properties = { ...properties };
|
|
1307
|
-
const modifiedAltitude = altitude + 2;
|
|
1308
|
-
this.#default = { options: { scale: scale2, altitude: modifiedAltitude }, material };
|
|
1309
|
-
this.#highlight = _2.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
1310
|
-
if (material && material instanceof SpriteMaterial2)
|
|
1311
|
-
material.alphaTest = alphaTest;
|
|
1312
|
-
const sprite = new Sprite2(material);
|
|
1313
|
-
sprite.scale.set(scale2, scale2, scale2);
|
|
1314
|
-
const obj3d = this.getObject3d();
|
|
1315
|
-
obj3d.add(sprite);
|
|
1316
|
-
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
1317
|
-
const position = layer.coordinateToVector3(coordinate, z);
|
|
1318
|
-
_2.set(this.properties, "default.position", position);
|
|
1319
|
-
this.getObject3d().position.copy(position);
|
|
1320
|
-
}
|
|
1321
|
-
// Different objects need to implement their own methods
|
|
1322
|
-
setSymbol(material) {
|
|
1323
|
-
if (material && material instanceof SpriteMaterial2) {
|
|
1324
|
-
const sprite = this.getObject3d().children[0];
|
|
1325
|
-
if (!sprite) return this;
|
|
1326
|
-
sprite.material = material;
|
|
1327
|
-
sprite.material.needsUpdate = true;
|
|
1328
|
-
}
|
|
1329
|
-
return this;
|
|
1330
|
-
}
|
|
1331
|
-
setScale(scaleX, scaleY = scaleX, scaleZ = scaleX) {
|
|
1332
|
-
const sprite = this.getObject3d().children[0];
|
|
1333
|
-
if (!sprite) return this;
|
|
1334
|
-
sprite.scale.set(scaleX, scaleY, scaleZ);
|
|
1335
|
-
return this;
|
|
1336
|
-
}
|
|
1337
|
-
// Different objects need to implement their own methods
|
|
1338
|
-
getSymbol() {
|
|
1339
|
-
return this.getObject3d()?.children[0]?.material;
|
|
1340
|
-
}
|
|
1341
|
-
highlight() {
|
|
1342
|
-
const { material, options } = this.#highlight;
|
|
1343
|
-
if (material) this.setSymbol(material);
|
|
1344
|
-
if (options.scale) this.setScale(options.scale);
|
|
1345
|
-
if (options.altitude) this.setAltitude(options.altitude);
|
|
1346
|
-
return this;
|
|
1347
|
-
}
|
|
1348
|
-
removeHighlight() {
|
|
1349
|
-
const { material, options } = this.#default;
|
|
1350
|
-
if (material) this.setSymbol(material);
|
|
1351
|
-
if (options.scale) this.setScale(options.scale);
|
|
1352
|
-
if (options.altitude) this.setAltitude(options.altitude);
|
|
1353
|
-
return this;
|
|
1354
|
-
}
|
|
1355
|
-
};
|
|
1356
|
-
|
|
1357
|
-
// src/IndoorMap/object3d/NavigationPath.ts
|
|
1358
|
-
import * as maptalks3 from "maptalks";
|
|
1359
|
-
import { BaseObject as BaseObject4 } from "maptalks.three";
|
|
1360
|
-
import { MeshBasicMaterial, ShaderMaterial, Color } from "three";
|
|
1361
|
-
var OPTIONS3 = {
|
|
1362
|
-
altitude: 0
|
|
1363
|
-
};
|
|
1364
|
-
var DEFAULT_LINE_OPTION = {
|
|
1365
|
-
color: "#000",
|
|
1366
|
-
opacity: 1
|
|
1367
|
-
};
|
|
1368
|
-
var DEFAULT_LINE_EFFECT_OPTION = {
|
|
1369
|
-
color: "#000",
|
|
1370
|
-
opacity: 1
|
|
1371
|
-
};
|
|
1372
|
-
var ENABLE_ANIMATED_PATH = true;
|
|
1373
|
-
var NavigationPath = class extends BaseObject4 {
|
|
1374
|
-
constructor(feature2, layer, properties, options, lineOptions = DEFAULT_LINE_OPTION, outlineOption = DEFAULT_LINE_EFFECT_OPTION) {
|
|
1375
|
-
options = maptalks3.Util.extend({}, OPTIONS3, options, {
|
|
1376
|
-
layer
|
|
1377
|
-
});
|
|
1378
|
-
super();
|
|
1379
|
-
this._initOptions(options);
|
|
1380
|
-
const { altitude = OPTIONS3.altitude } = options;
|
|
1381
|
-
this.properties = { ...properties };
|
|
1382
|
-
this._createGroup();
|
|
1383
|
-
const { color: lineColor, opacity: lineOpacity } = lineOptions || DEFAULT_LINE_OPTION;
|
|
1384
|
-
const staticMaterial = new MeshBasicMaterial({
|
|
1385
|
-
transparent: true,
|
|
1386
|
-
color: lineColor || "#fff",
|
|
1387
|
-
opacity: lineOpacity || 1,
|
|
1388
|
-
depthWrite: false
|
|
1111
|
+
const { altitude = OPTIONS2.altitude } = options;
|
|
1112
|
+
this.properties = { ...properties };
|
|
1113
|
+
this._createGroup();
|
|
1114
|
+
const { color: lineColor, opacity: lineOpacity } = lineOptions || DEFAULT_LINE_OPTION;
|
|
1115
|
+
const staticMaterial = new MeshBasicMaterial({
|
|
1116
|
+
transparent: true,
|
|
1117
|
+
color: lineColor || "#fff",
|
|
1118
|
+
opacity: lineOpacity || 1,
|
|
1119
|
+
depthWrite: false
|
|
1389
1120
|
});
|
|
1390
1121
|
const uniforms = {
|
|
1391
1122
|
time: { value: 0 },
|
|
@@ -1417,7 +1148,7 @@ var NavigationPath = class extends BaseObject4 {
|
|
|
1417
1148
|
}
|
|
1418
1149
|
`
|
|
1419
1150
|
});
|
|
1420
|
-
const pathGeometry =
|
|
1151
|
+
const pathGeometry = maptalks2.GeoJSON.toGeometry(feature2);
|
|
1421
1152
|
const line = layer.toPath(
|
|
1422
1153
|
pathGeometry,
|
|
1423
1154
|
{
|
|
@@ -1475,8 +1206,8 @@ var createPolygonFromLineString = (geometry) => {
|
|
|
1475
1206
|
const right = turfLineOffset(line, -0.3, { units: "meters" });
|
|
1476
1207
|
const leftCoords = left.geometry.coordinates;
|
|
1477
1208
|
const rightCoords = right.geometry.coordinates.reverse();
|
|
1478
|
-
const
|
|
1479
|
-
return [
|
|
1209
|
+
const polygon2 = [...leftCoords, ...rightCoords, leftCoords[0]];
|
|
1210
|
+
return [polygon2];
|
|
1480
1211
|
};
|
|
1481
1212
|
|
|
1482
1213
|
// src/IndoorMap/utils/svg.ts
|
|
@@ -1510,8 +1241,8 @@ var createSVGPathFromMarkerSymbol = (style) => {
|
|
|
1510
1241
|
markerFill,
|
|
1511
1242
|
markerPath
|
|
1512
1243
|
} = style;
|
|
1513
|
-
const
|
|
1514
|
-
return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${
|
|
1244
|
+
const scale3 = markerWidth / 24;
|
|
1245
|
+
return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale3})" fill="${markerFill}"/>`;
|
|
1515
1246
|
};
|
|
1516
1247
|
|
|
1517
1248
|
// src/IndoorMap/utils/createElements.js
|
|
@@ -1652,8 +1383,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
|
|
|
1652
1383
|
if (allowOverride) _4.merge(symbolStyle, properties.style);
|
|
1653
1384
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1654
1385
|
if (geometry.type === "LineString") {
|
|
1655
|
-
const
|
|
1656
|
-
return new GeometryType["Polygon"](
|
|
1386
|
+
const polygon2 = createPolygonFromLineString(geometry);
|
|
1387
|
+
return new GeometryType["Polygon"](polygon2, {
|
|
1657
1388
|
properties: {
|
|
1658
1389
|
altitude: getAltitude(properties)
|
|
1659
1390
|
},
|
|
@@ -1769,36 +1500,6 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
|
|
|
1769
1500
|
console.log(`error creating pedestrian opening:`, feature2);
|
|
1770
1501
|
}
|
|
1771
1502
|
};
|
|
1772
|
-
var loadModel3d = (model3d, coordinate, threeLayer) => {
|
|
1773
|
-
return new Promise((resolve, reject) => {
|
|
1774
|
-
const loader = new GLTFLoader();
|
|
1775
|
-
const { url, properties: modelProperties } = model3d;
|
|
1776
|
-
loader.load(
|
|
1777
|
-
url,
|
|
1778
|
-
(gltf) => {
|
|
1779
|
-
const object3d = gltf.scene;
|
|
1780
|
-
object3d.rotation.x = _4.get(modelProperties, "rotation.x");
|
|
1781
|
-
object3d.rotation.y = _4.get(modelProperties, "rotation.y");
|
|
1782
|
-
object3d.scale.set(..._4.get(modelProperties, "scale") || []);
|
|
1783
|
-
const object = threeLayer.toModel(object3d, {
|
|
1784
|
-
coordinate
|
|
1785
|
-
});
|
|
1786
|
-
object.getObject3d().traverse((child) => {
|
|
1787
|
-
if (child.isMesh === true) {
|
|
1788
|
-
child.material.transparent = true;
|
|
1789
|
-
child.material.metalness = 0.1;
|
|
1790
|
-
}
|
|
1791
|
-
});
|
|
1792
|
-
resolve(object);
|
|
1793
|
-
},
|
|
1794
|
-
(xhr) => {
|
|
1795
|
-
},
|
|
1796
|
-
(error) => {
|
|
1797
|
-
reject(error);
|
|
1798
|
-
}
|
|
1799
|
-
);
|
|
1800
|
-
});
|
|
1801
|
-
};
|
|
1802
1503
|
var createExtrudePolygon = (geometry, threeLayer, material, height, properties = {}, options) => {
|
|
1803
1504
|
const { offset = 0, altitude = 0 } = options;
|
|
1804
1505
|
const offsetGeometry = turfBuffer(geometry, offset, { units: "meters" });
|
|
@@ -2472,104 +2173,12 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2472
2173
|
return null;
|
|
2473
2174
|
}
|
|
2474
2175
|
},
|
|
2475
|
-
/** Three JS */
|
|
2476
|
-
create3DFootprint: async (feature2, threeLayer, options) => {
|
|
2477
|
-
const objects = [];
|
|
2478
|
-
const extrudeHeight = _4.get(options, "height");
|
|
2479
|
-
if (!extrudeHeight) return objects;
|
|
2480
|
-
const { properties } = feature2;
|
|
2481
|
-
const footprintProperties = getFeatureProperties(feature2);
|
|
2482
|
-
const hasModel3ds = Array.isArray(properties.model3d) && properties.model3d.length > 0;
|
|
2483
|
-
if (hasModel3ds) {
|
|
2484
|
-
const models = properties.model3d;
|
|
2485
|
-
const center2 = turfCenter(feature2);
|
|
2486
|
-
const coordinate = _4.get(center2, "geometry.coordinates");
|
|
2487
|
-
for (const model of models) {
|
|
2488
|
-
const object = await loadModel3d(model, coordinate, threeLayer);
|
|
2489
|
-
object.properties = footprintProperties;
|
|
2490
|
-
objects.push(object);
|
|
2491
|
-
}
|
|
2492
|
-
} else {
|
|
2493
|
-
const color = footprintProperties.defaultColor;
|
|
2494
|
-
if (color === "transparent") return;
|
|
2495
|
-
const material = new MeshLambertMaterial({
|
|
2496
|
-
color,
|
|
2497
|
-
transparent: true
|
|
2498
|
-
});
|
|
2499
|
-
const object = createExtrudePolygon(
|
|
2500
|
-
feature2.geometry,
|
|
2501
|
-
threeLayer,
|
|
2502
|
-
material,
|
|
2503
|
-
extrudeHeight,
|
|
2504
|
-
footprintProperties,
|
|
2505
|
-
{}
|
|
2506
|
-
);
|
|
2507
|
-
objects.push(object);
|
|
2508
|
-
}
|
|
2509
|
-
return objects;
|
|
2510
|
-
},
|
|
2511
|
-
create3DGroundLabel: (label, threeLayer) => {
|
|
2512
|
-
const text = label.properties.name;
|
|
2513
|
-
const bound = label.geometry.coordinates[0];
|
|
2514
|
-
if (_4.isNil(bound)) throw new Error("Invalid coordinates");
|
|
2515
|
-
const groundLabelSymbol = getElementSymbol("ground-label");
|
|
2516
|
-
const featureSymbol = _4.get(label, "properties", {});
|
|
2517
|
-
const groundLabelOptions = _4.merge(
|
|
2518
|
-
{},
|
|
2519
|
-
{ text },
|
|
2520
|
-
groundLabelSymbol,
|
|
2521
|
-
featureSymbol
|
|
2522
|
-
);
|
|
2523
|
-
return new GroundLabel(bound, groundLabelOptions, threeLayer);
|
|
2524
|
-
},
|
|
2525
|
-
createOccupantGroundLabel: (feature2, location, mapConfig, threeLayer) => {
|
|
2526
|
-
const text = feature2.properties.name.en;
|
|
2527
|
-
const bound = location.geometry.coordinates[0];
|
|
2528
|
-
if (_4.isNil(bound)) throw new Error("Invalid coordinates");
|
|
2529
|
-
const groundLabelSymbol = getElementSymbol("occupant-flat-label");
|
|
2530
|
-
const groundLabelOptions = getElementOptions("occupant-flat-label");
|
|
2531
|
-
const baseAltitude = getAltitude(location.properties);
|
|
2532
|
-
const extrudeHeight = _4.get(
|
|
2533
|
-
mapConfig,
|
|
2534
|
-
"extrudeConfig.unit.room.height",
|
|
2535
|
-
0
|
|
2536
|
-
);
|
|
2537
|
-
const totalAltitude = baseAltitude + extrudeHeight + 0.05;
|
|
2538
|
-
const customAngle = _4.get(feature2, "properties.style.angle");
|
|
2539
|
-
const offsetX = _4.get(feature2, "properties.style.offsetX", 0);
|
|
2540
|
-
const offsetY = _4.get(feature2, "properties.style.offsetY", 0);
|
|
2541
|
-
const featureSymbol = {
|
|
2542
|
-
name: text,
|
|
2543
|
-
ordinal: location.properties.ordinal,
|
|
2544
|
-
venue_id: feature2.properties.venue_id
|
|
2545
|
-
};
|
|
2546
|
-
const mergedGroundLabelOptions = _4.merge(
|
|
2547
|
-
{},
|
|
2548
|
-
{ text },
|
|
2549
|
-
groundLabelSymbol,
|
|
2550
|
-
groundLabelOptions,
|
|
2551
|
-
featureSymbol,
|
|
2552
|
-
{
|
|
2553
|
-
altitude: totalAltitude,
|
|
2554
|
-
offsetX,
|
|
2555
|
-
offsetY,
|
|
2556
|
-
// set custom angle
|
|
2557
|
-
...!_4.isNil(customAngle) ? { angle: customAngle } : {}
|
|
2558
|
-
}
|
|
2559
|
-
);
|
|
2560
|
-
const groundLabel = new GroundLabel(
|
|
2561
|
-
bound,
|
|
2562
|
-
mergedGroundLabelOptions,
|
|
2563
|
-
threeLayer
|
|
2564
|
-
);
|
|
2565
|
-
return groundLabel;
|
|
2566
|
-
},
|
|
2567
2176
|
create3DBillboard: (billboard, threeLayer) => {
|
|
2568
2177
|
const { id, feature_type, properties } = billboard;
|
|
2569
2178
|
const {
|
|
2570
2179
|
logo,
|
|
2571
2180
|
altitude,
|
|
2572
|
-
scale:
|
|
2181
|
+
scale: scale3,
|
|
2573
2182
|
alphaTest,
|
|
2574
2183
|
legColor,
|
|
2575
2184
|
showLeg,
|
|
@@ -2583,7 +2192,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2583
2192
|
};
|
|
2584
2193
|
const options = {
|
|
2585
2194
|
altitude,
|
|
2586
|
-
scale:
|
|
2195
|
+
scale: scale3,
|
|
2587
2196
|
alphaTest,
|
|
2588
2197
|
legColor,
|
|
2589
2198
|
showLeg,
|
|
@@ -2722,10 +2331,10 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2722
2331
|
transparent: true
|
|
2723
2332
|
});
|
|
2724
2333
|
if (unit.geometry.type === "LineString") {
|
|
2725
|
-
const
|
|
2334
|
+
const polygon2 = createPolygonFromLineString(unit.geometry);
|
|
2726
2335
|
const geometry = {
|
|
2727
2336
|
type: "Polygon",
|
|
2728
|
-
coordinates:
|
|
2337
|
+
coordinates: polygon2
|
|
2729
2338
|
};
|
|
2730
2339
|
return createExtrudePolygon(
|
|
2731
2340
|
geometry,
|
|
@@ -2827,9 +2436,9 @@ var getRelatedLocationsByAmenity = (feature2) => {
|
|
|
2827
2436
|
var getRelatedLocationIdsByFeature = (feature2) => {
|
|
2828
2437
|
switch (feature2?.feature_type) {
|
|
2829
2438
|
case "amenity":
|
|
2830
|
-
return getRelatedLocationsByAmenity(feature2).map((
|
|
2439
|
+
return getRelatedLocationsByAmenity(feature2).map((v2) => v2?.id);
|
|
2831
2440
|
case "occupant":
|
|
2832
|
-
return getRelatedLocationsByOccupant(feature2).map((
|
|
2441
|
+
return getRelatedLocationsByOccupant(feature2).map((v2) => v2?.id);
|
|
2833
2442
|
default:
|
|
2834
2443
|
return [];
|
|
2835
2444
|
}
|
|
@@ -2874,45 +2483,6 @@ var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
|
|
|
2874
2483
|
return newBearing;
|
|
2875
2484
|
};
|
|
2876
2485
|
|
|
2877
|
-
// src/IndoorMap/utils/createHighlightElement.ts
|
|
2878
|
-
import { Color as Color2 } from "three";
|
|
2879
|
-
import _5 from "lodash";
|
|
2880
|
-
import TWEEN from "@tweenjs/tween.js";
|
|
2881
|
-
var DEFAULT_ALTITUDE_FACTOR = 0.5;
|
|
2882
|
-
var createHighlighBillboardController = (obj, { altitudeFactor = DEFAULT_ALTITUDE_FACTOR } = {}) => {
|
|
2883
|
-
const controller = { start: () => {
|
|
2884
|
-
}, clear: () => {
|
|
2885
|
-
} };
|
|
2886
|
-
if (!(obj instanceof Billboard)) return controller;
|
|
2887
|
-
const altitude = obj.properties.default.altitude;
|
|
2888
|
-
const newAltitude = _5.clamp(altitude * altitudeFactor, 0, altitude);
|
|
2889
|
-
const tween = new TWEEN.Tween({ altitude }).to({ altitude: newAltitude }, 800).easing(TWEEN.Easing.Quartic.Out).onUpdate((newUpdate) => {
|
|
2890
|
-
obj.setLineHeight(newUpdate.altitude);
|
|
2891
|
-
});
|
|
2892
|
-
controller.start = () => {
|
|
2893
|
-
tween.start();
|
|
2894
|
-
};
|
|
2895
|
-
controller.clear = () => {
|
|
2896
|
-
tween.stop().to({ altitude }, 1600).startFromCurrentValues();
|
|
2897
|
-
};
|
|
2898
|
-
return controller;
|
|
2899
|
-
};
|
|
2900
|
-
var createHighlighExtrudeObjectController = (obj, { color }) => {
|
|
2901
|
-
const controller = { start: () => {
|
|
2902
|
-
}, clear: () => {
|
|
2903
|
-
} };
|
|
2904
|
-
if (obj?.type !== "ExtrudePolygon" || _5.isNil(obj?.object3d?.material?.color) || _5.isNil(color))
|
|
2905
|
-
return controller;
|
|
2906
|
-
controller.start = () => {
|
|
2907
|
-
obj.object3d.material.color = new Color2(color);
|
|
2908
|
-
};
|
|
2909
|
-
controller.clear = () => {
|
|
2910
|
-
const objectDefaultColor = _5.get(obj, "properties.defaultColor");
|
|
2911
|
-
obj.object3d.material.color = new Color2(objectDefaultColor);
|
|
2912
|
-
};
|
|
2913
|
-
return controller;
|
|
2914
|
-
};
|
|
2915
|
-
|
|
2916
2486
|
// src/IndoorMap/camera/CameraManager.ts
|
|
2917
2487
|
import { Extent } from "maptalks";
|
|
2918
2488
|
|
|
@@ -3057,75 +2627,382 @@ var CameraManager = class {
|
|
|
3057
2627
|
if (this.map && Object.keys(value).length !== 0) {
|
|
3058
2628
|
this.map.setView(value);
|
|
3059
2629
|
}
|
|
3060
|
-
};
|
|
3061
|
-
animateTo = (view, options = {}, step) => {
|
|
3062
|
-
this.map.animateTo(view, options, step);
|
|
3063
|
-
};
|
|
3064
|
-
setMaxExtent(extent) {
|
|
3065
|
-
return this.map.setMaxExtent(extent);
|
|
2630
|
+
};
|
|
2631
|
+
animateTo = (view, options = {}, step) => {
|
|
2632
|
+
this.map.animateTo(view, options, step);
|
|
2633
|
+
};
|
|
2634
|
+
setMaxExtent(extent) {
|
|
2635
|
+
return this.map.setMaxExtent(extent);
|
|
2636
|
+
}
|
|
2637
|
+
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
2638
|
+
const [minX, minY, maxX, maxY] = index_default(
|
|
2639
|
+
scale(bboxPolygon(index_default(feature2)), scaleFactor)
|
|
2640
|
+
);
|
|
2641
|
+
return new Extent(minX, minY, maxX, maxY);
|
|
2642
|
+
};
|
|
2643
|
+
getExtentZoom = (extent, options = {
|
|
2644
|
+
isFraction: false,
|
|
2645
|
+
padding: {
|
|
2646
|
+
paddingLeft: 0,
|
|
2647
|
+
paddingRight: 0,
|
|
2648
|
+
paddingTop: 0,
|
|
2649
|
+
paddingBottom: 0
|
|
2650
|
+
}
|
|
2651
|
+
}) => {
|
|
2652
|
+
const { isFraction = false, padding } = options;
|
|
2653
|
+
return this.map.getFitZoom(extent, isFraction, padding);
|
|
2654
|
+
};
|
|
2655
|
+
set maxZoom(value) {
|
|
2656
|
+
this.map.setMaxZoom(value);
|
|
2657
|
+
const spatialReference = {
|
|
2658
|
+
projection: "EPSG:3857",
|
|
2659
|
+
resolutions: (function() {
|
|
2660
|
+
const resolutions = [];
|
|
2661
|
+
const d = 2 * 6378137 * Math.PI;
|
|
2662
|
+
for (let i = 0; i < value; i++) {
|
|
2663
|
+
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
2664
|
+
}
|
|
2665
|
+
return resolutions;
|
|
2666
|
+
})()
|
|
2667
|
+
};
|
|
2668
|
+
this.map.setSpatialReference(spatialReference);
|
|
2669
|
+
}
|
|
2670
|
+
set minZoom(value) {
|
|
2671
|
+
this.map.setMinZoom(value);
|
|
2672
|
+
}
|
|
2673
|
+
};
|
|
2674
|
+
|
|
2675
|
+
// src/IndoorMap/renderer/RendererManager.ts
|
|
2676
|
+
import { min, compact as compact2, isFunction } from "lodash-es";
|
|
2677
|
+
import { center as turfCenter2 } from "@turf/center";
|
|
2678
|
+
import * as THREE3 from "three";
|
|
2679
|
+
|
|
2680
|
+
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
2681
|
+
import * as maptalks4 from "maptalks-gl";
|
|
2682
|
+
import * as THREE from "three";
|
|
2683
|
+
import { BaseObject as BaseObject5 } from "maptalks.three";
|
|
2684
|
+
import turfBuffer2 from "@turf/buffer";
|
|
2685
|
+
import { cleanCoords } from "@turf/clean-coords";
|
|
2686
|
+
import { polygonToLine } from "@turf/polygon-to-line";
|
|
2687
|
+
import { nearestPointOnLine } from "@turf/nearest-point-on-line";
|
|
2688
|
+
import { length } from "@turf/length";
|
|
2689
|
+
import { along } from "@turf/along";
|
|
2690
|
+
import { pointToLineDistance } from "@turf/point-to-line-distance";
|
|
2691
|
+
|
|
2692
|
+
// src/IndoorMap/renderer/3d/objects/GroundLabel.ts
|
|
2693
|
+
import * as maptalks3 from "maptalks-gl";
|
|
2694
|
+
import { BaseObject as BaseObject4 } from "maptalks.three";
|
|
2695
|
+
import {
|
|
2696
|
+
Texture,
|
|
2697
|
+
MeshPhongMaterial,
|
|
2698
|
+
PlaneGeometry
|
|
2699
|
+
} from "three";
|
|
2700
|
+
import { largestRect } from "d3plus-shape";
|
|
2701
|
+
import { max, merge, isNumber as isNumber2, isArray, range } from "lodash-es";
|
|
2702
|
+
var OPTIONS3 = {
|
|
2703
|
+
// Allowing click through and prevent interaction
|
|
2704
|
+
interactive: false,
|
|
2705
|
+
altitude: 0
|
|
2706
|
+
};
|
|
2707
|
+
var defaultFlatLabelOptions = {
|
|
2708
|
+
fontSize: 14,
|
|
2709
|
+
fontFamily: "Manrope",
|
|
2710
|
+
fontWeight: 600,
|
|
2711
|
+
margin: 0,
|
|
2712
|
+
scaleMin: 0.5,
|
|
2713
|
+
lineHeight: 1.05,
|
|
2714
|
+
scaleStep: 0.05,
|
|
2715
|
+
textAlign: "center",
|
|
2716
|
+
textBaseline: "middle",
|
|
2717
|
+
fillStyle: "#000"
|
|
2718
|
+
};
|
|
2719
|
+
var defaultRectAngleToCalc = range(-90, 92, 2);
|
|
2720
|
+
var getMaterial = (text, flatLabelOptions) => {
|
|
2721
|
+
const options = merge({}, defaultFlatLabelOptions, flatLabelOptions);
|
|
2722
|
+
const {
|
|
2723
|
+
fontSize: initialFontSize,
|
|
2724
|
+
fontFamily,
|
|
2725
|
+
fontWeight,
|
|
2726
|
+
margin,
|
|
2727
|
+
scaleMin,
|
|
2728
|
+
scaleStep,
|
|
2729
|
+
fillStyle,
|
|
2730
|
+
lineHeight,
|
|
2731
|
+
textAlign,
|
|
2732
|
+
strokeStyle,
|
|
2733
|
+
lineWidth,
|
|
2734
|
+
textBaseline
|
|
2735
|
+
} = options;
|
|
2736
|
+
const pixelMultiplier = 4;
|
|
2737
|
+
const SIZE = 100 * pixelMultiplier;
|
|
2738
|
+
const fontSize = initialFontSize * (pixelMultiplier * 1.25);
|
|
2739
|
+
const canvas = document.createElement("canvas");
|
|
2740
|
+
canvas.width = canvas.height = SIZE;
|
|
2741
|
+
const ctx = canvas.getContext("2d");
|
|
2742
|
+
ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", Arial`;
|
|
2743
|
+
ctx.textAlign = textAlign;
|
|
2744
|
+
ctx.textBaseline = textBaseline;
|
|
2745
|
+
ctx.fillStyle = fillStyle;
|
|
2746
|
+
ctx.strokeStyle = strokeStyle;
|
|
2747
|
+
ctx.lineWidth = lineWidth;
|
|
2748
|
+
const wrapText = (ctx2, text2, maxWidth) => {
|
|
2749
|
+
const words = text2.trim().split(/\s+/);
|
|
2750
|
+
if (words.length <= 1) return [text2];
|
|
2751
|
+
const lines = [];
|
|
2752
|
+
const MAX_LINES = 3;
|
|
2753
|
+
let currentLine = words[0];
|
|
2754
|
+
for (let i = 1; i < words.length; i++) {
|
|
2755
|
+
const lineToMeasure = currentLine + " " + words[i];
|
|
2756
|
+
if (ctx2.measureText(lineToMeasure).width > maxWidth) {
|
|
2757
|
+
lines.push(currentLine);
|
|
2758
|
+
currentLine = words[i];
|
|
2759
|
+
} else {
|
|
2760
|
+
currentLine = lineToMeasure;
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
lines.push(currentLine);
|
|
2764
|
+
return lines.slice(0, MAX_LINES);
|
|
2765
|
+
};
|
|
2766
|
+
const hasManualBreaks = text.includes("\n");
|
|
2767
|
+
let texts;
|
|
2768
|
+
if (hasManualBreaks) {
|
|
2769
|
+
texts = text.split(/\n/g);
|
|
2770
|
+
} else {
|
|
2771
|
+
const maxWidth = SIZE - 2 * margin;
|
|
2772
|
+
texts = wrapText(ctx, text, maxWidth);
|
|
2773
|
+
}
|
|
2774
|
+
let textWidth = max(texts.map((text2) => ctx.measureText(text2).width));
|
|
2775
|
+
let scale3 = 1;
|
|
2776
|
+
while (scale3 > 0 && textWidth + 2 * margin > SIZE) {
|
|
2777
|
+
scale3 -= scaleStep;
|
|
2778
|
+
ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
|
|
2779
|
+
textWidth = max(texts.map((text2) => ctx.measureText(text2).width));
|
|
2780
|
+
}
|
|
2781
|
+
const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
|
|
2782
|
+
if (scale3 > scaleMin) {
|
|
2783
|
+
const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
|
|
2784
|
+
const startY = center2.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
|
|
2785
|
+
texts.forEach((text2, index) => {
|
|
2786
|
+
const yOffset = startY + index * (fontSize * scale3 * lineHeight);
|
|
2787
|
+
if (strokeStyle && lineWidth) {
|
|
2788
|
+
ctx.strokeText(text2, center2.x, yOffset);
|
|
2789
|
+
}
|
|
2790
|
+
ctx.fillText(text2, center2.x, yOffset);
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
const texture = new Texture(canvas);
|
|
2794
|
+
texture.needsUpdate = true;
|
|
2795
|
+
const material = new MeshPhongMaterial({
|
|
2796
|
+
map: texture,
|
|
2797
|
+
transparent: true,
|
|
2798
|
+
// @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
|
|
2799
|
+
alphaTest: 0.3
|
|
2800
|
+
});
|
|
2801
|
+
return material;
|
|
2802
|
+
};
|
|
2803
|
+
var GroundLabel = class extends BaseObject4 {
|
|
2804
|
+
#angle = 0;
|
|
2805
|
+
#bearing = 0;
|
|
2806
|
+
#text = "";
|
|
2807
|
+
#offsetX = 0;
|
|
2808
|
+
#offsetY = 0;
|
|
2809
|
+
#originalPosition = null;
|
|
2810
|
+
#layer = null;
|
|
2811
|
+
constructor(bound, text, options, layer) {
|
|
2812
|
+
options = maptalks3.Util.extend({}, OPTIONS3, options, {
|
|
2813
|
+
layer,
|
|
2814
|
+
coordinate: bound
|
|
2815
|
+
});
|
|
2816
|
+
const {
|
|
2817
|
+
altitude = 0,
|
|
2818
|
+
bottomHeight = 0,
|
|
2819
|
+
fontSize,
|
|
2820
|
+
fillStyle,
|
|
2821
|
+
textAlign,
|
|
2822
|
+
fontFamily,
|
|
2823
|
+
textBaseline,
|
|
2824
|
+
strokeStyle,
|
|
2825
|
+
lineWidth,
|
|
2826
|
+
angle = defaultRectAngleToCalc,
|
|
2827
|
+
maxFontScale,
|
|
2828
|
+
offsetX = 0,
|
|
2829
|
+
offsetY = 0,
|
|
2830
|
+
...properties
|
|
2831
|
+
} = options;
|
|
2832
|
+
super();
|
|
2833
|
+
this._initOptions(options);
|
|
2834
|
+
this.properties = properties;
|
|
2835
|
+
this.#offsetX = offsetX;
|
|
2836
|
+
this.#offsetY = offsetY;
|
|
2837
|
+
this.#layer = layer;
|
|
2838
|
+
const material = getMaterial(text, {
|
|
2839
|
+
fillStyle,
|
|
2840
|
+
fontSize,
|
|
2841
|
+
textAlign,
|
|
2842
|
+
textBaseline,
|
|
2843
|
+
fontFamily,
|
|
2844
|
+
strokeStyle,
|
|
2845
|
+
lineWidth
|
|
2846
|
+
});
|
|
2847
|
+
const rectAngles = isArray(angle) ? angle : [angle];
|
|
2848
|
+
material.needsUpdate = true;
|
|
2849
|
+
const rect = largestRect(bound, {
|
|
2850
|
+
cache: true,
|
|
2851
|
+
/**
|
|
2852
|
+
* Black magic here:
|
|
2853
|
+
* For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
|
|
2854
|
+
* So we remove -90 and 90 from choices, and use -85 & 85 instead.
|
|
2855
|
+
*/
|
|
2856
|
+
angle: rectAngles
|
|
2857
|
+
});
|
|
2858
|
+
const { cx, cy, width, angle: calculatedAngle } = rect;
|
|
2859
|
+
this.#text = text;
|
|
2860
|
+
this.#angle = calculatedAngle;
|
|
2861
|
+
const geometry = new PlaneGeometry(1, 1);
|
|
2862
|
+
this._createMesh(geometry, material);
|
|
2863
|
+
const z = layer.altitudeToVector3(altitude + bottomHeight, altitude + bottomHeight).x;
|
|
2864
|
+
const basePosition = layer.coordinateToVector3([cx, cy], z);
|
|
2865
|
+
this.#originalPosition = basePosition.clone();
|
|
2866
|
+
const finalPosition = this.#calculateFinalPosition(basePosition);
|
|
2867
|
+
const scale3 = width / 6456122659e-13;
|
|
2868
|
+
const finalScale = maxFontScale && scale3 > maxFontScale ? maxFontScale : scale3;
|
|
2869
|
+
this.getObject3d().scale.set(finalScale, finalScale, finalScale);
|
|
2870
|
+
this.getObject3d().position.copy(finalPosition);
|
|
2871
|
+
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
2872
|
+
}
|
|
2873
|
+
#calculateFinalPosition(basePosition) {
|
|
2874
|
+
if (this.#offsetX === 0 && this.#offsetY === 0) {
|
|
2875
|
+
return basePosition;
|
|
2876
|
+
}
|
|
2877
|
+
const offsetCoordinate = [this.#offsetX, this.#offsetY];
|
|
2878
|
+
const z = this.#layer.altitudeToVector3(0, 0).x;
|
|
2879
|
+
const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
|
|
2880
|
+
const zeroVector = this.#layer.coordinateToVector3([0, 0], z);
|
|
2881
|
+
const worldOffsetX = offsetVector.x - zeroVector.x;
|
|
2882
|
+
const worldOffsetY = offsetVector.y - zeroVector.y;
|
|
2883
|
+
return {
|
|
2884
|
+
x: basePosition.x + worldOffsetX,
|
|
2885
|
+
y: basePosition.y + worldOffsetY,
|
|
2886
|
+
z: basePosition.z
|
|
2887
|
+
};
|
|
2888
|
+
}
|
|
2889
|
+
#updatePosition() {
|
|
2890
|
+
if (this.#originalPosition && this.#layer) {
|
|
2891
|
+
const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
|
|
2892
|
+
this.getObject3d().position.copy(finalPosition);
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
set bearing(value) {
|
|
2896
|
+
this.#bearing = value;
|
|
2897
|
+
const degree = this.#angle + this.#bearing;
|
|
2898
|
+
const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
|
|
2899
|
+
this.getObject3d().rotation.z = Math.PI / 180 * angle;
|
|
2900
|
+
}
|
|
2901
|
+
get angle() {
|
|
2902
|
+
return this.#angle;
|
|
2903
|
+
}
|
|
2904
|
+
get currentAngle() {
|
|
2905
|
+
return this.#angle;
|
|
2906
|
+
}
|
|
2907
|
+
get text() {
|
|
2908
|
+
return this.#text;
|
|
2909
|
+
}
|
|
2910
|
+
get offsetX() {
|
|
2911
|
+
return this.#offsetX;
|
|
2912
|
+
}
|
|
2913
|
+
get offsetY() {
|
|
2914
|
+
return this.#offsetY;
|
|
2915
|
+
}
|
|
2916
|
+
get offset() {
|
|
2917
|
+
return { x: this.#offsetX, y: this.#offsetY };
|
|
2918
|
+
}
|
|
2919
|
+
set offsetX(value) {
|
|
2920
|
+
if (isNumber2(value)) {
|
|
2921
|
+
this.#offsetX = value;
|
|
2922
|
+
this.#updatePosition();
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
set offsetY(value) {
|
|
2926
|
+
if (isNumber2(value)) {
|
|
2927
|
+
this.#offsetY = value;
|
|
2928
|
+
this.#updatePosition();
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
set angle(newAngle) {
|
|
2932
|
+
if (isNumber2(newAngle)) {
|
|
2933
|
+
this.#angle = newAngle;
|
|
2934
|
+
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
setOffset(offsetX, offsetY) {
|
|
2938
|
+
if (isNumber2(offsetX) && isNumber2(offsetY)) {
|
|
2939
|
+
this.#offsetX = offsetX;
|
|
2940
|
+
this.#offsetY = offsetY;
|
|
2941
|
+
this.#updatePosition();
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
addOffset(deltaX, deltaY) {
|
|
2945
|
+
if (isNumber2(deltaX) && isNumber2(deltaY)) {
|
|
2946
|
+
this.#offsetX += deltaX;
|
|
2947
|
+
this.#offsetY += deltaY;
|
|
2948
|
+
this.#updatePosition();
|
|
2949
|
+
}
|
|
3066
2950
|
}
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
);
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
2951
|
+
resetOffset() {
|
|
2952
|
+
this.#offsetX = 0;
|
|
2953
|
+
this.#offsetY = 0;
|
|
2954
|
+
this.#updatePosition();
|
|
2955
|
+
}
|
|
2956
|
+
moveToPosition(targetX, targetY) {
|
|
2957
|
+
if (this.#originalPosition && this.#layer) {
|
|
2958
|
+
const currentCenter = this.#layer.vector3ToCoordinate(
|
|
2959
|
+
this.#originalPosition
|
|
2960
|
+
);
|
|
2961
|
+
this.#offsetX = targetX - currentCenter.x;
|
|
2962
|
+
this.#offsetY = targetY - currentCenter.y;
|
|
2963
|
+
this.#updatePosition();
|
|
3080
2964
|
}
|
|
3081
|
-
}
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
for (let i = 0; i < value; i++) {
|
|
3093
|
-
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
3094
|
-
}
|
|
3095
|
-
return resolutions;
|
|
3096
|
-
})()
|
|
2965
|
+
}
|
|
2966
|
+
updateText(newText, options = {}) {
|
|
2967
|
+
this.#text = newText;
|
|
2968
|
+
const materialOptions = {
|
|
2969
|
+
fillStyle: options.fillStyle || this.properties.fillStyle,
|
|
2970
|
+
fontSize: options.fontSize || this.properties.fontSize,
|
|
2971
|
+
textAlign: options.textAlign || this.properties.textAlign,
|
|
2972
|
+
textBaseline: options.textBaseline || this.properties.textBaseline,
|
|
2973
|
+
fontFamily: options.fontFamily || this.properties.fontFamily,
|
|
2974
|
+
strokeStyle: options.strokeStyle || this.properties.strokeStyle,
|
|
2975
|
+
lineWidth: options.lineWidth || this.properties.lineWidth
|
|
3097
2976
|
};
|
|
3098
|
-
|
|
2977
|
+
const newMaterial = getMaterial(newText, materialOptions);
|
|
2978
|
+
this.getObject3d().material = newMaterial;
|
|
2979
|
+
newMaterial.needsUpdate = true;
|
|
3099
2980
|
}
|
|
3100
|
-
|
|
3101
|
-
this.
|
|
2981
|
+
_animation() {
|
|
2982
|
+
const map = this.getMap();
|
|
2983
|
+
if (!map) return;
|
|
2984
|
+
const bearing = map.getBearing();
|
|
2985
|
+
this.bearing = bearing;
|
|
2986
|
+
}
|
|
2987
|
+
// Add bottomHeight to altitude as final altitude position
|
|
2988
|
+
setAltitude(altitude) {
|
|
2989
|
+
const bottomHeight = this.options.bottomHeight ?? 0;
|
|
2990
|
+
return super.setAltitude(altitude + bottomHeight);
|
|
3102
2991
|
}
|
|
3103
2992
|
};
|
|
3104
2993
|
|
|
3105
|
-
// src/IndoorMap/renderer/RendererManager.ts
|
|
3106
|
-
import _isFunction from "lodash/isFunction";
|
|
3107
|
-
import _min from "lodash/min";
|
|
3108
|
-
import { center as turfCenter2 } from "@turf/center";
|
|
3109
|
-
import * as THREE3 from "three";
|
|
3110
|
-
|
|
3111
|
-
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3112
|
-
import * as maptalks4 from "maptalks-gl";
|
|
3113
|
-
import * as THREE from "three";
|
|
3114
|
-
import { BaseObject as BaseObject5 } from "maptalks.three";
|
|
3115
|
-
import turfBuffer2 from "@turf/buffer";
|
|
3116
|
-
|
|
3117
2994
|
// src/IndoorMap/renderer/3d/element3DRendererOptions.ts
|
|
3118
2995
|
var element3DRendererOptions = {
|
|
3119
2996
|
unit: {
|
|
3120
|
-
default: { color: "#ffffff", height:
|
|
2997
|
+
default: { color: "#ffffff", height: 0.2 },
|
|
3121
2998
|
byCategory: {
|
|
3122
2999
|
walkway: { color: "#cccccc", height: 0.1 },
|
|
3123
3000
|
terrace: { color: "#cccccc", height: 0.1 },
|
|
3124
3001
|
unenclosedarea: { color: "#cccccc", height: 0.2 },
|
|
3125
3002
|
nonpublic: { color: "#999999", height: 0.3 },
|
|
3126
3003
|
escalator: { height: 0.2 },
|
|
3127
|
-
parking: { height: 0.1 },
|
|
3128
|
-
room: { color: "#ffffff", height:
|
|
3004
|
+
parking: { color: "#999999", height: 0.1 },
|
|
3005
|
+
room: { color: "#ffffff", height: 0.5, bottomHeight: 0.12 }
|
|
3129
3006
|
}
|
|
3130
3007
|
},
|
|
3131
3008
|
kiosk: {
|
|
@@ -3135,35 +3012,37 @@ var element3DRendererOptions = {
|
|
|
3135
3012
|
default: { color: "#ffffff", height: 0.5 },
|
|
3136
3013
|
byCategory: {
|
|
3137
3014
|
water: { color: "#ACD7EC", height: 0.1 },
|
|
3138
|
-
vegetation: { color: "#91C499", height: 0.5 }
|
|
3015
|
+
vegetation: { color: "#91C499", height: 0.5 },
|
|
3016
|
+
wall: { color: "#787878", topColor: "#ffffff", height: 4.2, width: 1 }
|
|
3139
3017
|
}
|
|
3140
3018
|
}
|
|
3141
3019
|
};
|
|
3142
3020
|
|
|
3143
|
-
// src/IndoorMap/renderer/3d/
|
|
3021
|
+
// src/IndoorMap/renderer/3d/utils/get3DRendererOption.ts
|
|
3144
3022
|
var DEFAULT_POLYGON_OPTION = {
|
|
3145
3023
|
color: "#FFFFFF",
|
|
3146
3024
|
offset: 0,
|
|
3147
3025
|
altitude: 0
|
|
3148
3026
|
};
|
|
3149
|
-
var
|
|
3150
|
-
var MULTIORDINAL_HEIGHT_METER = 9;
|
|
3151
|
-
var getGeometryOption = (feature2, options) => {
|
|
3027
|
+
var get3DRendererOption = (featureType, category, options) => {
|
|
3152
3028
|
try {
|
|
3153
|
-
const option = options[
|
|
3154
|
-
const category = feature2.properties.category;
|
|
3029
|
+
const option = options[featureType] ?? element3DRendererOptions[featureType];
|
|
3155
3030
|
return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION;
|
|
3156
3031
|
} catch (err) {
|
|
3157
|
-
console.log(err.message, { options,
|
|
3032
|
+
console.log(err.message, { options, featureType, category });
|
|
3158
3033
|
}
|
|
3159
3034
|
};
|
|
3035
|
+
|
|
3036
|
+
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3037
|
+
import lineSplit from "@turf/line-split";
|
|
3038
|
+
var HEIGHT_METER = 4;
|
|
3039
|
+
var MULTIORDINAL_HEIGHT_METER = 9;
|
|
3160
3040
|
var Element3DRenderer = class extends EventTarget {
|
|
3161
3041
|
options;
|
|
3162
3042
|
map;
|
|
3163
3043
|
gltfLayer;
|
|
3164
3044
|
threeLayer;
|
|
3165
3045
|
scene;
|
|
3166
|
-
// private dracoLoader: DRACOLoader
|
|
3167
3046
|
lineMaterial;
|
|
3168
3047
|
materialByColorMap;
|
|
3169
3048
|
// Renderer is Ready
|
|
@@ -3202,7 +3081,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3202
3081
|
bottomHeight: bottomHeightOptions,
|
|
3203
3082
|
color: colorOptions,
|
|
3204
3083
|
...options
|
|
3205
|
-
} =
|
|
3084
|
+
} = get3DRendererOption(feature2.feature_type, feature2.properties.category, this.options);
|
|
3206
3085
|
const _this = this;
|
|
3207
3086
|
const createPolygon = (geometry, feature3) => {
|
|
3208
3087
|
try {
|
|
@@ -3242,6 +3121,20 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3242
3121
|
return [];
|
|
3243
3122
|
}
|
|
3244
3123
|
};
|
|
3124
|
+
const createLineString = (geometry, feature3) => {
|
|
3125
|
+
try {
|
|
3126
|
+
const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#000000";
|
|
3127
|
+
const material = this.getOrCreateMaterialByColor(color);
|
|
3128
|
+
const extrudedLine = this.threeLayer.toExtrudeLine(
|
|
3129
|
+
new maptalks4.LineString(geometry.coordinates),
|
|
3130
|
+
{ height: heightOptions, ...options },
|
|
3131
|
+
material
|
|
3132
|
+
);
|
|
3133
|
+
return [extrudedLine];
|
|
3134
|
+
} catch (err) {
|
|
3135
|
+
return [];
|
|
3136
|
+
}
|
|
3137
|
+
};
|
|
3245
3138
|
try {
|
|
3246
3139
|
switch (feature2.geometry.type) {
|
|
3247
3140
|
case "MultiPolygon": {
|
|
@@ -3261,11 +3154,80 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3261
3154
|
this.threeLayer.addMesh(meshes);
|
|
3262
3155
|
return meshes;
|
|
3263
3156
|
}
|
|
3157
|
+
case "LineString": {
|
|
3158
|
+
const { coordinates } = feature2.geometry;
|
|
3159
|
+
if (!coordinates) return [];
|
|
3160
|
+
const meshes = createLineString(feature2.geometry, feature2);
|
|
3161
|
+
this.threeLayer.addMesh(meshes);
|
|
3162
|
+
return meshes;
|
|
3163
|
+
}
|
|
3264
3164
|
}
|
|
3265
3165
|
} catch (err) {
|
|
3266
3166
|
console.log(`error createGeometry`, err, { feature: feature2, options });
|
|
3267
3167
|
}
|
|
3268
3168
|
};
|
|
3169
|
+
createRoomWall(unit, openings = []) {
|
|
3170
|
+
const polygons = unit.geometry.type === "Polygon" ? [unit.geometry.coordinates] : unit.geometry.coordinates;
|
|
3171
|
+
return polygons.map((plg) => {
|
|
3172
|
+
return plg.map((ring) => {
|
|
3173
|
+
const roomWall = cleanCoords(polygonToLine(polygon([ring])));
|
|
3174
|
+
if (openings.length === 0) {
|
|
3175
|
+
const color = "#ababab";
|
|
3176
|
+
const material = this.getOrCreateMaterialByColor(color);
|
|
3177
|
+
const extrudedWall = this.threeLayer.toExtrudeLine(
|
|
3178
|
+
new maptalks4.LineString(roomWall.geometry.coordinates),
|
|
3179
|
+
{ height: 4, width: 1 },
|
|
3180
|
+
material
|
|
3181
|
+
);
|
|
3182
|
+
return extrudedWall;
|
|
3183
|
+
}
|
|
3184
|
+
let openingPoints = [];
|
|
3185
|
+
openings.forEach((opening) => {
|
|
3186
|
+
const doorCoords = opening?.geometry?.coordinates;
|
|
3187
|
+
const p0 = point(doorCoords[0]);
|
|
3188
|
+
const p1 = point(doorCoords[doorCoords.length - 1]);
|
|
3189
|
+
const s0 = nearestPointOnLine(roomWall, p0, { units: "meters" });
|
|
3190
|
+
const s1 = nearestPointOnLine(roomWall, p1, { units: "meters" });
|
|
3191
|
+
const d0 = s0.properties.dist;
|
|
3192
|
+
const d1 = s1.properties.dist;
|
|
3193
|
+
if (d0 > 1 || d1 > 1) {
|
|
3194
|
+
} else {
|
|
3195
|
+
openingPoints = openingPoints.concat([s0.geometry.coordinates, s1.geometry.coordinates]);
|
|
3196
|
+
}
|
|
3197
|
+
});
|
|
3198
|
+
try {
|
|
3199
|
+
const split = lineSplit(roomWall, multiPoint(openingPoints));
|
|
3200
|
+
const wallsOnly = split.features.filter((seg) => {
|
|
3201
|
+
const mid = along(seg, length(seg, { units: "meters" }) / 2, { units: "meters" });
|
|
3202
|
+
for (const opening of openings) {
|
|
3203
|
+
const dist = pointToLineDistance(mid, opening, { units: "meters" });
|
|
3204
|
+
if (dist < 0.05) return false;
|
|
3205
|
+
}
|
|
3206
|
+
return true;
|
|
3207
|
+
});
|
|
3208
|
+
const wallMeshes = wallsOnly.map((feature2, i) => {
|
|
3209
|
+
const color = "#ababab";
|
|
3210
|
+
const material = this.getOrCreateMaterialByColor(color);
|
|
3211
|
+
const extrudedLine = this.threeLayer.toExtrudeLine(
|
|
3212
|
+
new maptalks4.LineString(feature2.geometry.coordinates),
|
|
3213
|
+
{ height: 3, width: 0.4, id: unit.id },
|
|
3214
|
+
material
|
|
3215
|
+
);
|
|
3216
|
+
extrudedLine.getObject3d().userData = {
|
|
3217
|
+
unitId: unit.id,
|
|
3218
|
+
coords: feature2.geometry.coordinates
|
|
3219
|
+
};
|
|
3220
|
+
return extrudedLine;
|
|
3221
|
+
}).flat();
|
|
3222
|
+
this.threeLayer.addMesh(wallMeshes);
|
|
3223
|
+
return wallMeshes;
|
|
3224
|
+
} catch (e) {
|
|
3225
|
+
console.log(e.message, { unit, roomWall });
|
|
3226
|
+
return [];
|
|
3227
|
+
}
|
|
3228
|
+
}).flat();
|
|
3229
|
+
}).flat();
|
|
3230
|
+
}
|
|
3269
3231
|
async createEscalator(f, coordinate, options) {
|
|
3270
3232
|
const model = {
|
|
3271
3233
|
url: "https://cdn.venue.in.th/static/glb/escalator.glb",
|
|
@@ -3285,14 +3247,24 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3285
3247
|
escalatorMarker.addTo(this.gltfLayer);
|
|
3286
3248
|
return escalatorMarker;
|
|
3287
3249
|
}
|
|
3288
|
-
|
|
3289
|
-
|
|
3250
|
+
// Note: Move to another renderer and keep this file on Geometry only?
|
|
3251
|
+
createGroundLabel(f, unit) {
|
|
3252
|
+
const text = f.properties.name;
|
|
3253
|
+
const bound = f.geometry.coordinates[0];
|
|
3254
|
+
const { height: unitHeight } = get3DRendererOption("unit", unit.properties.category, this.options);
|
|
3255
|
+
const options = { bottomHeight: unitHeight + 5e-3 };
|
|
3256
|
+
const groundLabel = new GroundLabel(bound, text, options, this.threeLayer);
|
|
3257
|
+
this.threeLayer.addMesh(groundLabel);
|
|
3258
|
+
return groundLabel;
|
|
3259
|
+
}
|
|
3260
|
+
async createModel3d(f) {
|
|
3261
|
+
const marker = new maptalks4.GLTFMarker(f.properties.center, {
|
|
3290
3262
|
symbol: {
|
|
3291
|
-
url:
|
|
3263
|
+
url: f.properties.model
|
|
3292
3264
|
}
|
|
3293
3265
|
});
|
|
3294
|
-
|
|
3295
|
-
return
|
|
3266
|
+
marker.addTo(this.gltfLayer);
|
|
3267
|
+
return marker;
|
|
3296
3268
|
}
|
|
3297
3269
|
async createBuilding(coordinate, ordinal) {
|
|
3298
3270
|
return Promise.resolve(null);
|
|
@@ -3323,7 +3295,8 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3323
3295
|
return null;
|
|
3324
3296
|
}
|
|
3325
3297
|
switch (element.type) {
|
|
3326
|
-
case "ExtrudePolygon":
|
|
3298
|
+
case "ExtrudePolygon":
|
|
3299
|
+
case "ExtrudeLine": {
|
|
3327
3300
|
const mesh = element.getObject3d();
|
|
3328
3301
|
const originalMaterial = mesh.material;
|
|
3329
3302
|
const highlightMaterial = this.getOrCreateMaterialByColor("#ff0000");
|
|
@@ -3404,7 +3377,7 @@ var getGeometryProperties = (feature2) => ({
|
|
|
3404
3377
|
category: feature2.properties.category,
|
|
3405
3378
|
name: feature2.properties.name?.en
|
|
3406
3379
|
});
|
|
3407
|
-
var
|
|
3380
|
+
var getGeometryOption = (feature2, options) => {
|
|
3408
3381
|
try {
|
|
3409
3382
|
const option = options[feature2.feature_type] ?? element2DRendererOptions[feature2.feature_type];
|
|
3410
3383
|
const category = feature2.properties.category;
|
|
@@ -3431,7 +3404,7 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3431
3404
|
}
|
|
3432
3405
|
createGeometry = (imdfFeature) => {
|
|
3433
3406
|
const feature2 = getGeometryProperties(imdfFeature);
|
|
3434
|
-
const { symbol, ...options } =
|
|
3407
|
+
const { symbol, ...options } = getGeometryOption(imdfFeature, this.options);
|
|
3435
3408
|
const altitude = feature2.properties.ordinal * 10;
|
|
3436
3409
|
const geometry = maptalks5.Geometry.fromJSON({
|
|
3437
3410
|
feature: feature2,
|
|
@@ -3450,11 +3423,16 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3450
3423
|
return geometry;
|
|
3451
3424
|
}
|
|
3452
3425
|
};
|
|
3426
|
+
createRoomWall(unit, openings) {
|
|
3427
|
+
return null;
|
|
3428
|
+
}
|
|
3453
3429
|
async createEscalator(f, coordinates) {
|
|
3454
3430
|
return Promise.resolve(null);
|
|
3455
3431
|
}
|
|
3456
|
-
|
|
3457
|
-
|
|
3432
|
+
createGroundLabel(f, unit) {
|
|
3433
|
+
const text = f.properties.name;
|
|
3434
|
+
const bound = f.geometry.coordinates[0];
|
|
3435
|
+
return null;
|
|
3458
3436
|
}
|
|
3459
3437
|
async createBuilding(coordinate, ordinal) {
|
|
3460
3438
|
return Promise.resolve(null);
|
|
@@ -3819,6 +3797,479 @@ var angleBetweenLineStrings = (line1, line2) => {
|
|
|
3819
3797
|
return Math.atan2(dy, dx);
|
|
3820
3798
|
};
|
|
3821
3799
|
|
|
3800
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/util.js
|
|
3801
|
+
var epsilon = 11102230246251565e-32;
|
|
3802
|
+
var splitter = 134217729;
|
|
3803
|
+
var resulterrbound = (3 + 8 * epsilon) * epsilon;
|
|
3804
|
+
function sum(elen, e, flen, f, h) {
|
|
3805
|
+
let Q, Qnew, hh, bvirt;
|
|
3806
|
+
let enow = e[0];
|
|
3807
|
+
let fnow = f[0];
|
|
3808
|
+
let eindex = 0;
|
|
3809
|
+
let findex = 0;
|
|
3810
|
+
if (fnow > enow === fnow > -enow) {
|
|
3811
|
+
Q = enow;
|
|
3812
|
+
enow = e[++eindex];
|
|
3813
|
+
} else {
|
|
3814
|
+
Q = fnow;
|
|
3815
|
+
fnow = f[++findex];
|
|
3816
|
+
}
|
|
3817
|
+
let hindex = 0;
|
|
3818
|
+
if (eindex < elen && findex < flen) {
|
|
3819
|
+
if (fnow > enow === fnow > -enow) {
|
|
3820
|
+
Qnew = enow + Q;
|
|
3821
|
+
hh = Q - (Qnew - enow);
|
|
3822
|
+
enow = e[++eindex];
|
|
3823
|
+
} else {
|
|
3824
|
+
Qnew = fnow + Q;
|
|
3825
|
+
hh = Q - (Qnew - fnow);
|
|
3826
|
+
fnow = f[++findex];
|
|
3827
|
+
}
|
|
3828
|
+
Q = Qnew;
|
|
3829
|
+
if (hh !== 0) {
|
|
3830
|
+
h[hindex++] = hh;
|
|
3831
|
+
}
|
|
3832
|
+
while (eindex < elen && findex < flen) {
|
|
3833
|
+
if (fnow > enow === fnow > -enow) {
|
|
3834
|
+
Qnew = Q + enow;
|
|
3835
|
+
bvirt = Qnew - Q;
|
|
3836
|
+
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3837
|
+
enow = e[++eindex];
|
|
3838
|
+
} else {
|
|
3839
|
+
Qnew = Q + fnow;
|
|
3840
|
+
bvirt = Qnew - Q;
|
|
3841
|
+
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3842
|
+
fnow = f[++findex];
|
|
3843
|
+
}
|
|
3844
|
+
Q = Qnew;
|
|
3845
|
+
if (hh !== 0) {
|
|
3846
|
+
h[hindex++] = hh;
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
while (eindex < elen) {
|
|
3851
|
+
Qnew = Q + enow;
|
|
3852
|
+
bvirt = Qnew - Q;
|
|
3853
|
+
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3854
|
+
enow = e[++eindex];
|
|
3855
|
+
Q = Qnew;
|
|
3856
|
+
if (hh !== 0) {
|
|
3857
|
+
h[hindex++] = hh;
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
while (findex < flen) {
|
|
3861
|
+
Qnew = Q + fnow;
|
|
3862
|
+
bvirt = Qnew - Q;
|
|
3863
|
+
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3864
|
+
fnow = f[++findex];
|
|
3865
|
+
Q = Qnew;
|
|
3866
|
+
if (hh !== 0) {
|
|
3867
|
+
h[hindex++] = hh;
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
if (Q !== 0 || hindex === 0) {
|
|
3871
|
+
h[hindex++] = Q;
|
|
3872
|
+
}
|
|
3873
|
+
return hindex;
|
|
3874
|
+
}
|
|
3875
|
+
function estimate(elen, e) {
|
|
3876
|
+
let Q = e[0];
|
|
3877
|
+
for (let i = 1; i < elen; i++) Q += e[i];
|
|
3878
|
+
return Q;
|
|
3879
|
+
}
|
|
3880
|
+
function vec(n) {
|
|
3881
|
+
return new Float64Array(n);
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient2d.js
|
|
3885
|
+
var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
|
|
3886
|
+
var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
|
|
3887
|
+
var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
|
|
3888
|
+
var B = vec(4);
|
|
3889
|
+
var C1 = vec(8);
|
|
3890
|
+
var C2 = vec(12);
|
|
3891
|
+
var D = vec(16);
|
|
3892
|
+
var u = vec(4);
|
|
3893
|
+
function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
|
|
3894
|
+
let acxtail, acytail, bcxtail, bcytail;
|
|
3895
|
+
let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u32;
|
|
3896
|
+
const acx = ax - cx;
|
|
3897
|
+
const bcx = bx - cx;
|
|
3898
|
+
const acy = ay - cy;
|
|
3899
|
+
const bcy = by - cy;
|
|
3900
|
+
s1 = acx * bcy;
|
|
3901
|
+
c = splitter * acx;
|
|
3902
|
+
ahi = c - (c - acx);
|
|
3903
|
+
alo = acx - ahi;
|
|
3904
|
+
c = splitter * bcy;
|
|
3905
|
+
bhi = c - (c - bcy);
|
|
3906
|
+
blo = bcy - bhi;
|
|
3907
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3908
|
+
t1 = acy * bcx;
|
|
3909
|
+
c = splitter * acy;
|
|
3910
|
+
ahi = c - (c - acy);
|
|
3911
|
+
alo = acy - ahi;
|
|
3912
|
+
c = splitter * bcx;
|
|
3913
|
+
bhi = c - (c - bcx);
|
|
3914
|
+
blo = bcx - bhi;
|
|
3915
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3916
|
+
_i = s0 - t0;
|
|
3917
|
+
bvirt = s0 - _i;
|
|
3918
|
+
B[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
3919
|
+
_j = s1 + _i;
|
|
3920
|
+
bvirt = _j - s1;
|
|
3921
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
3922
|
+
_i = _0 - t1;
|
|
3923
|
+
bvirt = _0 - _i;
|
|
3924
|
+
B[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
3925
|
+
u32 = _j + _i;
|
|
3926
|
+
bvirt = u32 - _j;
|
|
3927
|
+
B[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
3928
|
+
B[3] = u32;
|
|
3929
|
+
let det = estimate(4, B);
|
|
3930
|
+
let errbound = ccwerrboundB * detsum;
|
|
3931
|
+
if (det >= errbound || -det >= errbound) {
|
|
3932
|
+
return det;
|
|
3933
|
+
}
|
|
3934
|
+
bvirt = ax - acx;
|
|
3935
|
+
acxtail = ax - (acx + bvirt) + (bvirt - cx);
|
|
3936
|
+
bvirt = bx - bcx;
|
|
3937
|
+
bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
|
|
3938
|
+
bvirt = ay - acy;
|
|
3939
|
+
acytail = ay - (acy + bvirt) + (bvirt - cy);
|
|
3940
|
+
bvirt = by - bcy;
|
|
3941
|
+
bcytail = by - (bcy + bvirt) + (bvirt - cy);
|
|
3942
|
+
if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
|
|
3943
|
+
return det;
|
|
3944
|
+
}
|
|
3945
|
+
errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
|
|
3946
|
+
det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
|
|
3947
|
+
if (det >= errbound || -det >= errbound) return det;
|
|
3948
|
+
s1 = acxtail * bcy;
|
|
3949
|
+
c = splitter * acxtail;
|
|
3950
|
+
ahi = c - (c - acxtail);
|
|
3951
|
+
alo = acxtail - ahi;
|
|
3952
|
+
c = splitter * bcy;
|
|
3953
|
+
bhi = c - (c - bcy);
|
|
3954
|
+
blo = bcy - bhi;
|
|
3955
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3956
|
+
t1 = acytail * bcx;
|
|
3957
|
+
c = splitter * acytail;
|
|
3958
|
+
ahi = c - (c - acytail);
|
|
3959
|
+
alo = acytail - ahi;
|
|
3960
|
+
c = splitter * bcx;
|
|
3961
|
+
bhi = c - (c - bcx);
|
|
3962
|
+
blo = bcx - bhi;
|
|
3963
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3964
|
+
_i = s0 - t0;
|
|
3965
|
+
bvirt = s0 - _i;
|
|
3966
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
3967
|
+
_j = s1 + _i;
|
|
3968
|
+
bvirt = _j - s1;
|
|
3969
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
3970
|
+
_i = _0 - t1;
|
|
3971
|
+
bvirt = _0 - _i;
|
|
3972
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
3973
|
+
u32 = _j + _i;
|
|
3974
|
+
bvirt = u32 - _j;
|
|
3975
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
3976
|
+
u[3] = u32;
|
|
3977
|
+
const C1len = sum(4, B, 4, u, C1);
|
|
3978
|
+
s1 = acx * bcytail;
|
|
3979
|
+
c = splitter * acx;
|
|
3980
|
+
ahi = c - (c - acx);
|
|
3981
|
+
alo = acx - ahi;
|
|
3982
|
+
c = splitter * bcytail;
|
|
3983
|
+
bhi = c - (c - bcytail);
|
|
3984
|
+
blo = bcytail - bhi;
|
|
3985
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3986
|
+
t1 = acy * bcxtail;
|
|
3987
|
+
c = splitter * acy;
|
|
3988
|
+
ahi = c - (c - acy);
|
|
3989
|
+
alo = acy - ahi;
|
|
3990
|
+
c = splitter * bcxtail;
|
|
3991
|
+
bhi = c - (c - bcxtail);
|
|
3992
|
+
blo = bcxtail - bhi;
|
|
3993
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3994
|
+
_i = s0 - t0;
|
|
3995
|
+
bvirt = s0 - _i;
|
|
3996
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
3997
|
+
_j = s1 + _i;
|
|
3998
|
+
bvirt = _j - s1;
|
|
3999
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4000
|
+
_i = _0 - t1;
|
|
4001
|
+
bvirt = _0 - _i;
|
|
4002
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4003
|
+
u32 = _j + _i;
|
|
4004
|
+
bvirt = u32 - _j;
|
|
4005
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4006
|
+
u[3] = u32;
|
|
4007
|
+
const C2len = sum(C1len, C1, 4, u, C2);
|
|
4008
|
+
s1 = acxtail * bcytail;
|
|
4009
|
+
c = splitter * acxtail;
|
|
4010
|
+
ahi = c - (c - acxtail);
|
|
4011
|
+
alo = acxtail - ahi;
|
|
4012
|
+
c = splitter * bcytail;
|
|
4013
|
+
bhi = c - (c - bcytail);
|
|
4014
|
+
blo = bcytail - bhi;
|
|
4015
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4016
|
+
t1 = acytail * bcxtail;
|
|
4017
|
+
c = splitter * acytail;
|
|
4018
|
+
ahi = c - (c - acytail);
|
|
4019
|
+
alo = acytail - ahi;
|
|
4020
|
+
c = splitter * bcxtail;
|
|
4021
|
+
bhi = c - (c - bcxtail);
|
|
4022
|
+
blo = bcxtail - bhi;
|
|
4023
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4024
|
+
_i = s0 - t0;
|
|
4025
|
+
bvirt = s0 - _i;
|
|
4026
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4027
|
+
_j = s1 + _i;
|
|
4028
|
+
bvirt = _j - s1;
|
|
4029
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4030
|
+
_i = _0 - t1;
|
|
4031
|
+
bvirt = _0 - _i;
|
|
4032
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4033
|
+
u32 = _j + _i;
|
|
4034
|
+
bvirt = u32 - _j;
|
|
4035
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4036
|
+
u[3] = u32;
|
|
4037
|
+
const Dlen = sum(C2len, C2, 4, u, D);
|
|
4038
|
+
return D[Dlen - 1];
|
|
4039
|
+
}
|
|
4040
|
+
function orient2d(ax, ay, bx, by, cx, cy) {
|
|
4041
|
+
const detleft = (ay - cy) * (bx - cx);
|
|
4042
|
+
const detright = (ax - cx) * (by - cy);
|
|
4043
|
+
const det = detleft - detright;
|
|
4044
|
+
const detsum = Math.abs(detleft + detright);
|
|
4045
|
+
if (Math.abs(det) >= ccwerrboundA * detsum) return det;
|
|
4046
|
+
return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
|
|
4047
|
+
}
|
|
4048
|
+
|
|
4049
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient3d.js
|
|
4050
|
+
var o3derrboundA = (7 + 56 * epsilon) * epsilon;
|
|
4051
|
+
var o3derrboundB = (3 + 28 * epsilon) * epsilon;
|
|
4052
|
+
var o3derrboundC = (26 + 288 * epsilon) * epsilon * epsilon;
|
|
4053
|
+
var bc = vec(4);
|
|
4054
|
+
var ca = vec(4);
|
|
4055
|
+
var ab = vec(4);
|
|
4056
|
+
var at_b = vec(4);
|
|
4057
|
+
var at_c = vec(4);
|
|
4058
|
+
var bt_c = vec(4);
|
|
4059
|
+
var bt_a = vec(4);
|
|
4060
|
+
var ct_a = vec(4);
|
|
4061
|
+
var ct_b = vec(4);
|
|
4062
|
+
var bct = vec(8);
|
|
4063
|
+
var cat = vec(8);
|
|
4064
|
+
var abt = vec(8);
|
|
4065
|
+
var u2 = vec(4);
|
|
4066
|
+
var _8 = vec(8);
|
|
4067
|
+
var _8b = vec(8);
|
|
4068
|
+
var _16 = vec(8);
|
|
4069
|
+
var _12 = vec(12);
|
|
4070
|
+
var fin = vec(192);
|
|
4071
|
+
var fin2 = vec(192);
|
|
4072
|
+
|
|
4073
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/incircle.js
|
|
4074
|
+
var iccerrboundA = (10 + 96 * epsilon) * epsilon;
|
|
4075
|
+
var iccerrboundB = (4 + 48 * epsilon) * epsilon;
|
|
4076
|
+
var iccerrboundC = (44 + 576 * epsilon) * epsilon * epsilon;
|
|
4077
|
+
var bc2 = vec(4);
|
|
4078
|
+
var ca2 = vec(4);
|
|
4079
|
+
var ab2 = vec(4);
|
|
4080
|
+
var aa = vec(4);
|
|
4081
|
+
var bb = vec(4);
|
|
4082
|
+
var cc = vec(4);
|
|
4083
|
+
var u3 = vec(4);
|
|
4084
|
+
var v = vec(4);
|
|
4085
|
+
var axtbc = vec(8);
|
|
4086
|
+
var aytbc = vec(8);
|
|
4087
|
+
var bxtca = vec(8);
|
|
4088
|
+
var bytca = vec(8);
|
|
4089
|
+
var cxtab = vec(8);
|
|
4090
|
+
var cytab = vec(8);
|
|
4091
|
+
var abt2 = vec(8);
|
|
4092
|
+
var bct2 = vec(8);
|
|
4093
|
+
var cat2 = vec(8);
|
|
4094
|
+
var abtt = vec(4);
|
|
4095
|
+
var bctt = vec(4);
|
|
4096
|
+
var catt = vec(4);
|
|
4097
|
+
var _82 = vec(8);
|
|
4098
|
+
var _162 = vec(16);
|
|
4099
|
+
var _16b = vec(16);
|
|
4100
|
+
var _16c = vec(16);
|
|
4101
|
+
var _32 = vec(32);
|
|
4102
|
+
var _32b = vec(32);
|
|
4103
|
+
var _48 = vec(48);
|
|
4104
|
+
var _64 = vec(64);
|
|
4105
|
+
var fin3 = vec(1152);
|
|
4106
|
+
var fin22 = vec(1152);
|
|
4107
|
+
|
|
4108
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/insphere.js
|
|
4109
|
+
var isperrboundA = (16 + 224 * epsilon) * epsilon;
|
|
4110
|
+
var isperrboundB = (5 + 72 * epsilon) * epsilon;
|
|
4111
|
+
var isperrboundC = (71 + 1408 * epsilon) * epsilon * epsilon;
|
|
4112
|
+
var ab3 = vec(4);
|
|
4113
|
+
var bc3 = vec(4);
|
|
4114
|
+
var cd = vec(4);
|
|
4115
|
+
var de = vec(4);
|
|
4116
|
+
var ea = vec(4);
|
|
4117
|
+
var ac = vec(4);
|
|
4118
|
+
var bd = vec(4);
|
|
4119
|
+
var ce = vec(4);
|
|
4120
|
+
var da = vec(4);
|
|
4121
|
+
var eb = vec(4);
|
|
4122
|
+
var abc = vec(24);
|
|
4123
|
+
var bcd = vec(24);
|
|
4124
|
+
var cde = vec(24);
|
|
4125
|
+
var dea = vec(24);
|
|
4126
|
+
var eab = vec(24);
|
|
4127
|
+
var abd = vec(24);
|
|
4128
|
+
var bce = vec(24);
|
|
4129
|
+
var cda = vec(24);
|
|
4130
|
+
var deb = vec(24);
|
|
4131
|
+
var eac = vec(24);
|
|
4132
|
+
var adet = vec(1152);
|
|
4133
|
+
var bdet = vec(1152);
|
|
4134
|
+
var cdet = vec(1152);
|
|
4135
|
+
var ddet = vec(1152);
|
|
4136
|
+
var edet = vec(1152);
|
|
4137
|
+
var abdet = vec(2304);
|
|
4138
|
+
var cddet = vec(2304);
|
|
4139
|
+
var cdedet = vec(3456);
|
|
4140
|
+
var deter = vec(5760);
|
|
4141
|
+
var _83 = vec(8);
|
|
4142
|
+
var _8b2 = vec(8);
|
|
4143
|
+
var _8c = vec(8);
|
|
4144
|
+
var _163 = vec(16);
|
|
4145
|
+
var _24 = vec(24);
|
|
4146
|
+
var _482 = vec(48);
|
|
4147
|
+
var _48b = vec(48);
|
|
4148
|
+
var _96 = vec(96);
|
|
4149
|
+
var _192 = vec(192);
|
|
4150
|
+
var _384x = vec(384);
|
|
4151
|
+
var _384y = vec(384);
|
|
4152
|
+
var _384z = vec(384);
|
|
4153
|
+
var _768 = vec(768);
|
|
4154
|
+
var xdet = vec(96);
|
|
4155
|
+
var ydet = vec(96);
|
|
4156
|
+
var zdet = vec(96);
|
|
4157
|
+
var fin4 = vec(1152);
|
|
4158
|
+
|
|
4159
|
+
// ../../node_modules/point-in-polygon-hao/dist/esm/index.js
|
|
4160
|
+
function pointInPolygon(p, polygon2) {
|
|
4161
|
+
var i;
|
|
4162
|
+
var ii;
|
|
4163
|
+
var k = 0;
|
|
4164
|
+
var f;
|
|
4165
|
+
var u1;
|
|
4166
|
+
var v1;
|
|
4167
|
+
var u22;
|
|
4168
|
+
var v2;
|
|
4169
|
+
var currentP;
|
|
4170
|
+
var nextP;
|
|
4171
|
+
var x = p[0];
|
|
4172
|
+
var y = p[1];
|
|
4173
|
+
var numContours = polygon2.length;
|
|
4174
|
+
for (i = 0; i < numContours; i++) {
|
|
4175
|
+
ii = 0;
|
|
4176
|
+
var contour = polygon2[i];
|
|
4177
|
+
var contourLen = contour.length - 1;
|
|
4178
|
+
currentP = contour[0];
|
|
4179
|
+
if (currentP[0] !== contour[contourLen][0] && currentP[1] !== contour[contourLen][1]) {
|
|
4180
|
+
throw new Error("First and last coordinates in a ring must be the same");
|
|
4181
|
+
}
|
|
4182
|
+
u1 = currentP[0] - x;
|
|
4183
|
+
v1 = currentP[1] - y;
|
|
4184
|
+
for (ii; ii < contourLen; ii++) {
|
|
4185
|
+
nextP = contour[ii + 1];
|
|
4186
|
+
u22 = nextP[0] - x;
|
|
4187
|
+
v2 = nextP[1] - y;
|
|
4188
|
+
if (v1 === 0 && v2 === 0) {
|
|
4189
|
+
if (u22 <= 0 && u1 >= 0 || u1 <= 0 && u22 >= 0) {
|
|
4190
|
+
return 0;
|
|
4191
|
+
}
|
|
4192
|
+
} else if (v2 >= 0 && v1 <= 0 || v2 <= 0 && v1 >= 0) {
|
|
4193
|
+
f = orient2d(u1, u22, v1, v2, 0, 0);
|
|
4194
|
+
if (f === 0) {
|
|
4195
|
+
return 0;
|
|
4196
|
+
}
|
|
4197
|
+
if (f > 0 && v2 > 0 && v1 <= 0 || f < 0 && v2 <= 0 && v1 > 0) {
|
|
4198
|
+
k++;
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
currentP = nextP;
|
|
4202
|
+
v1 = v2;
|
|
4203
|
+
u1 = u22;
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4206
|
+
if (k % 2 === 0) {
|
|
4207
|
+
return false;
|
|
4208
|
+
}
|
|
4209
|
+
return true;
|
|
4210
|
+
}
|
|
4211
|
+
|
|
4212
|
+
// ../../node_modules/@turf/invariant/dist/esm/index.js
|
|
4213
|
+
function getCoord(coord) {
|
|
4214
|
+
if (!coord) {
|
|
4215
|
+
throw new Error("coord is required");
|
|
4216
|
+
}
|
|
4217
|
+
if (!Array.isArray(coord)) {
|
|
4218
|
+
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
4219
|
+
return [...coord.geometry.coordinates];
|
|
4220
|
+
}
|
|
4221
|
+
if (coord.type === "Point") {
|
|
4222
|
+
return [...coord.coordinates];
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
4226
|
+
return [...coord];
|
|
4227
|
+
}
|
|
4228
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4229
|
+
}
|
|
4230
|
+
function getGeom(geojson) {
|
|
4231
|
+
if (geojson.type === "Feature") {
|
|
4232
|
+
return geojson.geometry;
|
|
4233
|
+
}
|
|
4234
|
+
return geojson;
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4237
|
+
// ../../node_modules/@turf/boolean-point-in-polygon/dist/esm/index.js
|
|
4238
|
+
function booleanPointInPolygon(point2, polygon2, options = {}) {
|
|
4239
|
+
if (!point2) {
|
|
4240
|
+
throw new Error("point is required");
|
|
4241
|
+
}
|
|
4242
|
+
if (!polygon2) {
|
|
4243
|
+
throw new Error("polygon is required");
|
|
4244
|
+
}
|
|
4245
|
+
const pt = getCoord(point2);
|
|
4246
|
+
const geom = getGeom(polygon2);
|
|
4247
|
+
const type = geom.type;
|
|
4248
|
+
const bbox2 = polygon2.bbox;
|
|
4249
|
+
let polys = geom.coordinates;
|
|
4250
|
+
if (bbox2 && inBBox(pt, bbox2) === false) {
|
|
4251
|
+
return false;
|
|
4252
|
+
}
|
|
4253
|
+
if (type === "Polygon") {
|
|
4254
|
+
polys = [polys];
|
|
4255
|
+
}
|
|
4256
|
+
let result = false;
|
|
4257
|
+
for (var i = 0; i < polys.length; ++i) {
|
|
4258
|
+
const polyResult = pointInPolygon(pt, polys[i]);
|
|
4259
|
+
if (polyResult === 0) return options.ignoreBoundary ? false : true;
|
|
4260
|
+
else if (polyResult) result = true;
|
|
4261
|
+
}
|
|
4262
|
+
return result;
|
|
4263
|
+
}
|
|
4264
|
+
function inBBox(pt, bbox2) {
|
|
4265
|
+
return bbox2[0] <= pt[0] && bbox2[1] <= pt[1] && bbox2[2] >= pt[0] && bbox2[3] >= pt[1];
|
|
4266
|
+
}
|
|
4267
|
+
|
|
4268
|
+
// src/IndoorMap/renderer/utils/findUnitOnPoint.ts
|
|
4269
|
+
var findUnitOnPoint = (units, point2) => {
|
|
4270
|
+
return units.find((unit) => booleanPointInPolygon(point2, polygon(unit.geometry.coordinates)));
|
|
4271
|
+
};
|
|
4272
|
+
|
|
3822
4273
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3823
4274
|
function delay(ms) {
|
|
3824
4275
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -3854,6 +4305,38 @@ var RendererManager = class extends EventTarget {
|
|
|
3854
4305
|
const groupLayer = this.map.getLayer("group");
|
|
3855
4306
|
const threeLayer = groupLayer.getLayer("three");
|
|
3856
4307
|
threeLayer.prepareToDraw = function(gl, scene, camera) {
|
|
4308
|
+
function findBadMeshes(scene2) {
|
|
4309
|
+
const bad = [];
|
|
4310
|
+
scene2.traverse((obj) => {
|
|
4311
|
+
if (!obj?.isMesh) return;
|
|
4312
|
+
const geom = obj.geometry;
|
|
4313
|
+
const pos = geom?.attributes?.position?.array;
|
|
4314
|
+
if (!pos || pos.length === 0) return;
|
|
4315
|
+
for (let i = 0; i < pos.length; i++) {
|
|
4316
|
+
const v2 = pos[i];
|
|
4317
|
+
if (!Number.isFinite(v2)) {
|
|
4318
|
+
bad.push({ mesh: obj, index: i, value: v2 });
|
|
4319
|
+
break;
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4322
|
+
});
|
|
4323
|
+
if (bad.length) {
|
|
4324
|
+
console.group(`\u274C Found ${bad.length} meshes with invalid positions`);
|
|
4325
|
+
for (const b of bad) {
|
|
4326
|
+
console.log({
|
|
4327
|
+
name: b.mesh.name,
|
|
4328
|
+
userData: b.mesh.userData,
|
|
4329
|
+
uuid: b.mesh.uuid,
|
|
4330
|
+
badIndex: b.index,
|
|
4331
|
+
badValue: b.value
|
|
4332
|
+
});
|
|
4333
|
+
}
|
|
4334
|
+
console.groupEnd();
|
|
4335
|
+
} else {
|
|
4336
|
+
console.log("\u2705 No invalid meshes found");
|
|
4337
|
+
}
|
|
4338
|
+
return bad;
|
|
4339
|
+
}
|
|
3857
4340
|
const ambientLight = new THREE3.AmbientLight(16777215, 0.3);
|
|
3858
4341
|
scene.add(ambientLight);
|
|
3859
4342
|
const dirColor = 16777215;
|
|
@@ -3868,6 +4351,9 @@ var RendererManager = class extends EventTarget {
|
|
|
3868
4351
|
options.onRendererReady();
|
|
3869
4352
|
}
|
|
3870
4353
|
_this.#createElements();
|
|
4354
|
+
setTimeout(() => {
|
|
4355
|
+
findBadMeshes(scene);
|
|
4356
|
+
}, 3e3);
|
|
3871
4357
|
};
|
|
3872
4358
|
} else {
|
|
3873
4359
|
this.elementRenderer = new Element2DRenderer(map, options.elements);
|
|
@@ -3879,11 +4365,10 @@ var RendererManager = class extends EventTarget {
|
|
|
3879
4365
|
this.#onClickElement = func;
|
|
3880
4366
|
}
|
|
3881
4367
|
handleClickElement = (e) => {
|
|
3882
|
-
console.log(`handleClickElement`, this.#isClicked);
|
|
3883
4368
|
if (this.#isClicked) return;
|
|
3884
4369
|
this.#isClicked = true;
|
|
3885
4370
|
const onClickElement = this.#onClickElement;
|
|
3886
|
-
if (!
|
|
4371
|
+
if (!isFunction(onClickElement)) return;
|
|
3887
4372
|
this.#onClickElement(e);
|
|
3888
4373
|
this.#isClicked = false;
|
|
3889
4374
|
};
|
|
@@ -3910,6 +4395,9 @@ var RendererManager = class extends EventTarget {
|
|
|
3910
4395
|
const levels = await this.#dataClient.filterByType("level", {
|
|
3911
4396
|
populate: true
|
|
3912
4397
|
});
|
|
4398
|
+
const openings = await this.#dataClient.filterByType("opening", {
|
|
4399
|
+
populate: true
|
|
4400
|
+
});
|
|
3913
4401
|
const relationships = await this.#dataClient.filterByType("relationship");
|
|
3914
4402
|
const fixtures = await this.#dataClient.filterByType("fixture", { populate: true });
|
|
3915
4403
|
fixtures.forEach((fixture) => {
|
|
@@ -3923,7 +4411,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3923
4411
|
populate: true
|
|
3924
4412
|
});
|
|
3925
4413
|
units.filter(
|
|
3926
|
-
(
|
|
4414
|
+
(u4) => !["opentobelow", "escalator", "room"].includes(u4.properties.category)
|
|
3927
4415
|
).forEach((unit) => {
|
|
3928
4416
|
const element = this.elementRenderer.createGeometry(unit);
|
|
3929
4417
|
if (element) {
|
|
@@ -3931,6 +4419,22 @@ var RendererManager = class extends EventTarget {
|
|
|
3931
4419
|
this.addElementsToManager(unit.id, _elements, unit.properties.level.properties.ordinal);
|
|
3932
4420
|
}
|
|
3933
4421
|
});
|
|
4422
|
+
units.filter((u4) => u4.properties.category === "room").forEach((unit) => {
|
|
4423
|
+
const openingRelationships = relationships.filter((r) => r.properties.origin?.id === unit.id || r.properties.destination?.id === unit.id);
|
|
4424
|
+
const roomOpenings = compact2(openingRelationships.map((rel) => {
|
|
4425
|
+
const openingId = rel?.properties.intermediary[0].id;
|
|
4426
|
+
return openings.find((o) => o.id === openingId);
|
|
4427
|
+
}));
|
|
4428
|
+
const innerElements = this.elementRenderer.createGeometry(unit);
|
|
4429
|
+
const wallElements = this.elementRenderer.createRoomWall(unit, roomOpenings);
|
|
4430
|
+
if (innerElements || wallElements) {
|
|
4431
|
+
const _innerElements = Array.isArray(innerElements) ? innerElements : [innerElements];
|
|
4432
|
+
const _wallElements = Array.isArray(wallElements) ? wallElements : [wallElements];
|
|
4433
|
+
const _elements = [..._innerElements, ..._wallElements];
|
|
4434
|
+
const ordinal = unit.properties.level.properties.ordinal;
|
|
4435
|
+
this.addElementsToManager(unit.id, _elements, ordinal);
|
|
4436
|
+
}
|
|
4437
|
+
});
|
|
3934
4438
|
const kiosks = await this.#dataClient.filterByType("kiosk", {
|
|
3935
4439
|
populate: true
|
|
3936
4440
|
});
|
|
@@ -3941,7 +4445,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3941
4445
|
this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal);
|
|
3942
4446
|
}
|
|
3943
4447
|
});
|
|
3944
|
-
const escalators = units.filter((
|
|
4448
|
+
const escalators = units.filter((u4) => u4.properties.category === "escalator");
|
|
3945
4449
|
for (const escalator of escalators) {
|
|
3946
4450
|
try {
|
|
3947
4451
|
const escalatorRelationships = relationships.filter((r) => (r.properties?.intermediary || []).some((inter) => inter.id === escalator.id));
|
|
@@ -3973,6 +4477,22 @@ var RendererManager = class extends EventTarget {
|
|
|
3973
4477
|
console.warn(`cannot create escalator`, err.message);
|
|
3974
4478
|
}
|
|
3975
4479
|
}
|
|
4480
|
+
const groundLabels = await this.#dataClient.filterByType("label");
|
|
4481
|
+
for (const label of groundLabels) {
|
|
4482
|
+
const center2 = turfCenter2(polygon(label.geometry.coordinates)).geometry.coordinates;
|
|
4483
|
+
const unit = findUnitOnPoint(units, center2);
|
|
4484
|
+
const element = this.elementRenderer.createGroundLabel(label, unit);
|
|
4485
|
+
if (element) {
|
|
4486
|
+
const _elements = Array.isArray(element) ? element : [element];
|
|
4487
|
+
this.addElementsToManager(label.id, _elements, label.properties.ordinal);
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
if (this.options.type === "3D") {
|
|
4491
|
+
const model3ds = await this.#dataClient.filterByType("model3d");
|
|
4492
|
+
for (const model3d of model3ds) {
|
|
4493
|
+
this.elementRenderer.createModel3d(model3d);
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
3976
4496
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
3977
4497
|
this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
|
|
3978
4498
|
}
|
|
@@ -3987,7 +4507,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3987
4507
|
this.markerRenderer.showMarkers(markers, ordinal - baseOrdinal);
|
|
3988
4508
|
}
|
|
3989
4509
|
} else {
|
|
3990
|
-
const baseOrdinal = Array.isArray(targetOrdinal) ?
|
|
4510
|
+
const baseOrdinal = Array.isArray(targetOrdinal) ? min(targetOrdinal) : targetOrdinal;
|
|
3991
4511
|
for (const [ordinal, elements] of this.elementsByOrdinal) {
|
|
3992
4512
|
const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
|
|
3993
4513
|
if (inOrdinal) {
|
|
@@ -4014,13 +4534,15 @@ var RendererManager = class extends EventTarget {
|
|
|
4014
4534
|
const elements = elemIds.map((id) => this.elementsMap.get(id)).flat();
|
|
4015
4535
|
elements.forEach((element) => {
|
|
4016
4536
|
const controller = this.elementRenderer.createHighlightController(element);
|
|
4017
|
-
controller.start
|
|
4018
|
-
|
|
4537
|
+
if (controller && isFunction(controller.start)) {
|
|
4538
|
+
controller.start();
|
|
4539
|
+
this.highlightControllers.push(controller);
|
|
4540
|
+
}
|
|
4019
4541
|
});
|
|
4020
4542
|
};
|
|
4021
4543
|
clearHighlightElements = () => {
|
|
4022
4544
|
this.highlightControllers.forEach((controller) => {
|
|
4023
|
-
if (
|
|
4545
|
+
if (isFunction(controller?.clear)) controller.clear();
|
|
4024
4546
|
});
|
|
4025
4547
|
};
|
|
4026
4548
|
/**
|
|
@@ -4062,8 +4584,23 @@ var INITIAL_ZOOM = 18.5;
|
|
|
4062
4584
|
var CLICK_TOLERANCE = 20;
|
|
4063
4585
|
var defaultOptions = {
|
|
4064
4586
|
pixelRatio: 1,
|
|
4587
|
+
interactions: true,
|
|
4065
4588
|
locale: DEFAULT_LOCALE
|
|
4066
4589
|
};
|
|
4590
|
+
var parseMaptalksOptions = (options) => {
|
|
4591
|
+
return {
|
|
4592
|
+
centerCross: options.centerCross ?? false,
|
|
4593
|
+
...options.interactions === false ? {
|
|
4594
|
+
draggable: false,
|
|
4595
|
+
dragPan: false,
|
|
4596
|
+
dragRotate: false,
|
|
4597
|
+
dragPitch: false,
|
|
4598
|
+
scrollWheelZoom: false,
|
|
4599
|
+
touchZoom: false,
|
|
4600
|
+
doubleClickZoom: false
|
|
4601
|
+
} : {}
|
|
4602
|
+
};
|
|
4603
|
+
};
|
|
4067
4604
|
var IndoorMap = class extends EventTarget {
|
|
4068
4605
|
options;
|
|
4069
4606
|
//TODO: refac functions; let them do only 1 thing in a function
|
|
@@ -4082,7 +4619,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4082
4619
|
#billboardObjects = [];
|
|
4083
4620
|
#spriteMarkerObjects = [];
|
|
4084
4621
|
#mapDecorations = [];
|
|
4085
|
-
#groundLabels = [];
|
|
4086
4622
|
#groundObjects = [];
|
|
4087
4623
|
#navigationGeometries = {};
|
|
4088
4624
|
#venueObjects = [];
|
|
@@ -4117,14 +4653,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
4117
4653
|
};
|
|
4118
4654
|
constructor(elementId, options) {
|
|
4119
4655
|
super();
|
|
4120
|
-
const combinedOptions =
|
|
4121
|
-
this.options =
|
|
4656
|
+
const combinedOptions = _5.merge({}, defaultOptions, options);
|
|
4657
|
+
this.options = combinedOptions;
|
|
4122
4658
|
const {
|
|
4123
4659
|
onMapReady,
|
|
4124
4660
|
onMapLoading,
|
|
4125
4661
|
pixelRatio,
|
|
4126
4662
|
locale
|
|
4127
4663
|
} = combinedOptions;
|
|
4664
|
+
const maptalksOptions = parseMaptalksOptions(combinedOptions);
|
|
4128
4665
|
this.map = new Map2(elementId, {
|
|
4129
4666
|
attribution: false,
|
|
4130
4667
|
// Temporart set, not really default view
|
|
@@ -4132,7 +4669,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4132
4669
|
center: INITIAL_CENTER,
|
|
4133
4670
|
zoom: INITIAL_ZOOM,
|
|
4134
4671
|
clickTimeThreshold: 600,
|
|
4135
|
-
|
|
4672
|
+
...maptalksOptions,
|
|
4136
4673
|
baseLayer: new TileLayer("base", {
|
|
4137
4674
|
urlTemplate: "https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
|
|
4138
4675
|
subdomains: ["a", "b", "c", "d"],
|
|
@@ -4145,7 +4682,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4145
4682
|
layers: []
|
|
4146
4683
|
});
|
|
4147
4684
|
const groupLayer = new GroupGLLayer("group", [], {}).addTo(this.map);
|
|
4148
|
-
const threeLayer = new
|
|
4685
|
+
const threeLayer = new ThreeLayer5("three", {
|
|
4149
4686
|
forceRenderOnMoving: true,
|
|
4150
4687
|
forceRenderOnRotating: true
|
|
4151
4688
|
});
|
|
@@ -4162,6 +4699,12 @@ var IndoorMap = class extends EventTarget {
|
|
|
4162
4699
|
this.map.on("click", this.handleMapClick);
|
|
4163
4700
|
this.dataClient = options.dataClient;
|
|
4164
4701
|
}
|
|
4702
|
+
setOptions(options) {
|
|
4703
|
+
const combinedOptions = _5.merge({}, defaultOptions, options);
|
|
4704
|
+
this.options = combinedOptions;
|
|
4705
|
+
const maptalksOptions = parseMaptalksOptions(combinedOptions);
|
|
4706
|
+
this.map.setOptions(maptalksOptions);
|
|
4707
|
+
}
|
|
4165
4708
|
set dataClient(value) {
|
|
4166
4709
|
this.#dataClient = value;
|
|
4167
4710
|
if (!this.options.camera?.defaultView?.center) {
|
|
@@ -4182,7 +4725,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4182
4725
|
handleMapClick = ({ coordinate }) => {
|
|
4183
4726
|
const { x, y } = coordinate;
|
|
4184
4727
|
console.log(
|
|
4185
|
-
`[Coordinates]: x: ${
|
|
4728
|
+
`[Coordinates]: x: ${_5.round(x, 8)} y: ${_5.round(
|
|
4186
4729
|
y,
|
|
4187
4730
|
8
|
|
4188
4731
|
)}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`
|
|
@@ -4240,9 +4783,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4240
4783
|
set mapDecorations(value) {
|
|
4241
4784
|
this.#mapDecorations = value;
|
|
4242
4785
|
}
|
|
4243
|
-
set groundLabels(value) {
|
|
4244
|
-
this.#groundLabels = value;
|
|
4245
|
-
}
|
|
4246
4786
|
set pixelRatio(value) {
|
|
4247
4787
|
this.map.setDevicePixelRatio(value);
|
|
4248
4788
|
}
|
|
@@ -4271,44 +4811,36 @@ var IndoorMap = class extends EventTarget {
|
|
|
4271
4811
|
if (this.#isClicked) return;
|
|
4272
4812
|
this.#isClicked = true;
|
|
4273
4813
|
const onClickElement = this.#onClickElement;
|
|
4274
|
-
if (!
|
|
4814
|
+
if (!_5.isFunction(onClickElement)) return;
|
|
4275
4815
|
this.#onClickElement(e);
|
|
4276
4816
|
this.#isClicked = false;
|
|
4277
4817
|
};
|
|
4278
4818
|
async #legacy_createElements() {
|
|
4279
4819
|
const {
|
|
4280
4820
|
// 2D
|
|
4281
|
-
createVenue,
|
|
4282
4821
|
createOpening,
|
|
4283
4822
|
createSection,
|
|
4284
|
-
createFixture,
|
|
4285
|
-
createOccupant,
|
|
4286
4823
|
createDecoration,
|
|
4287
4824
|
// 3D
|
|
4288
|
-
create3DFootprint,
|
|
4289
|
-
create3DGroundLabel,
|
|
4290
4825
|
create3DBillboard,
|
|
4291
|
-
createExtrudedUnit,
|
|
4292
4826
|
create3DAmenityMarker,
|
|
4293
|
-
|
|
4294
|
-
create3DOpeningMarker,
|
|
4295
|
-
createOccupantGroundLabel
|
|
4827
|
+
create3DOpeningMarker
|
|
4296
4828
|
} = this.#styler;
|
|
4297
4829
|
let elements = {};
|
|
4298
4830
|
let object3ds = [];
|
|
4299
4831
|
for (const feature2 of this.#features) {
|
|
4300
4832
|
try {
|
|
4301
4833
|
const { feature_type: featureType, properties, id } = feature2;
|
|
4302
|
-
const layerName =
|
|
4834
|
+
const layerName = _5.get(
|
|
4303
4835
|
LAYER_FEATURE_TYPE_OBJ,
|
|
4304
4836
|
featureType,
|
|
4305
4837
|
featureType
|
|
4306
4838
|
);
|
|
4307
4839
|
const layer = this.map.getLayer(layerName);
|
|
4308
4840
|
let geometry;
|
|
4309
|
-
const category =
|
|
4310
|
-
const extrudeConfig =
|
|
4311
|
-
const textMarkerType =
|
|
4841
|
+
const category = _5.get(feature2, "properties.category");
|
|
4842
|
+
const extrudeConfig = _5.get(this.#mapConfig, "extrude");
|
|
4843
|
+
const textMarkerType = _5.get(
|
|
4312
4844
|
this.#mapConfig,
|
|
4313
4845
|
"text_marker_type",
|
|
4314
4846
|
"ui-marker"
|
|
@@ -4370,16 +4902,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4370
4902
|
console.warn(`Cannot create ${feature2.id}: ${err.message}`);
|
|
4371
4903
|
}
|
|
4372
4904
|
}
|
|
4373
|
-
this.#groundLabels.forEach((label) => {
|
|
4374
|
-
const text = label.properties.name;
|
|
4375
|
-
try {
|
|
4376
|
-
const groundLabel = create3DGroundLabel(label, this.threeLayer);
|
|
4377
|
-
object3ds.push(groundLabel);
|
|
4378
|
-
this.#groundObjects.push(groundLabel);
|
|
4379
|
-
} catch (error) {
|
|
4380
|
-
console.log("error creating ground label for ", text);
|
|
4381
|
-
}
|
|
4382
|
-
});
|
|
4383
4905
|
this.#mapDecorations.forEach((decoration) => {
|
|
4384
4906
|
const { id, geometry, properties } = decoration;
|
|
4385
4907
|
const geometryType = decoration?.geometry?.type;
|
|
@@ -4461,186 +4983,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4461
4983
|
clearAnimations() {
|
|
4462
4984
|
this.#animationsToRun = [];
|
|
4463
4985
|
}
|
|
4464
|
-
/**
|
|
4465
|
-
* Hilighting Elements
|
|
4466
|
-
* ========================================= */
|
|
4467
|
-
// TODO: To consider if we should use setter `set hilightElementIds` instead?
|
|
4468
|
-
setHighlightElementIds(targetElementIds, options = {}) {
|
|
4469
|
-
const highlight3DOptions = _6.merge(
|
|
4470
|
-
{},
|
|
4471
|
-
DEFAULT_HIGHLIGHT_OPTIONS,
|
|
4472
|
-
_6.get(options, "highlight3DOptions", {})
|
|
4473
|
-
);
|
|
4474
|
-
const highlight2DOptions = _6.merge(
|
|
4475
|
-
{},
|
|
4476
|
-
DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,
|
|
4477
|
-
_6.get(options, "highlight2DOptions", {})
|
|
4478
|
-
);
|
|
4479
|
-
this.setHighlightedObject(targetElementIds, highlight3DOptions);
|
|
4480
|
-
return this.setHighlight2DElementIds(targetElementIds, highlight2DOptions);
|
|
4481
|
-
}
|
|
4482
|
-
setHighlight2DElementIds(targetElementIds, options = {}) {
|
|
4483
|
-
const { defaultMarker, symbolSet } = _6.merge(
|
|
4484
|
-
{},
|
|
4485
|
-
DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,
|
|
4486
|
-
options
|
|
4487
|
-
);
|
|
4488
|
-
const {
|
|
4489
|
-
createMarker,
|
|
4490
|
-
createHighlightOccupantMarker,
|
|
4491
|
-
getElementSymbol,
|
|
4492
|
-
getHilighPolygonalSymbol,
|
|
4493
|
-
getHighlightMarkerSymbol
|
|
4494
|
-
} = this.#styler;
|
|
4495
|
-
const extrudeConfig = _6.get(this.#mapConfig, "extrude");
|
|
4496
|
-
const elementToHilights = targetElementIds.map(
|
|
4497
|
-
(elemId) => this.#elements[elemId] || this.#elements[`${LAST_USER_LOCATION_ELEMENT_ID_PREFIX}${elemId}`]
|
|
4498
|
-
).filter((elem) => elem);
|
|
4499
|
-
elementToHilights.forEach((elem) => {
|
|
4500
|
-
const { feature: feature2, geometry } = elem;
|
|
4501
|
-
if (!geometry || !feature2) return;
|
|
4502
|
-
const hilightLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
4503
|
-
if (!hilightLayer) return;
|
|
4504
|
-
const defaultSymbol = getHilighPolygonalSymbol(geometry.type);
|
|
4505
|
-
const definedSymbol = symbolSet ? getElementSymbol(symbolSet) : null;
|
|
4506
|
-
const symbol = _6.isEmpty(definedSymbol) ? defaultSymbol : definedSymbol;
|
|
4507
|
-
switch (geometry.type) {
|
|
4508
|
-
case "MultiPolygon":
|
|
4509
|
-
case "Polygon": {
|
|
4510
|
-
geometry?.updateSymbol(symbol);
|
|
4511
|
-
break;
|
|
4512
|
-
}
|
|
4513
|
-
default:
|
|
4514
|
-
break;
|
|
4515
|
-
}
|
|
4516
|
-
switch (feature2.feature_type) {
|
|
4517
|
-
case "amenity":
|
|
4518
|
-
const highlightedAmenityMarker = definedSymbol || getHighlightMarkerSymbol();
|
|
4519
|
-
geometry?.updateSymbol(highlightedAmenityMarker);
|
|
4520
|
-
break;
|
|
4521
|
-
case "occupant": {
|
|
4522
|
-
switch (feature2.properties.category) {
|
|
4523
|
-
case "currencyexchange":
|
|
4524
|
-
case "donationcenter":
|
|
4525
|
-
case "postoffice":
|
|
4526
|
-
const highlightedAmenityMarker2 = definedSymbol || getHighlightMarkerSymbol();
|
|
4527
|
-
geometry?.updateSymbol(highlightedAmenityMarker2);
|
|
4528
|
-
break;
|
|
4529
|
-
default:
|
|
4530
|
-
if (feature2.properties.render_type === "Logo") {
|
|
4531
|
-
this.hideGeometryByElementId(feature2.id);
|
|
4532
|
-
}
|
|
4533
|
-
createHighlightOccupantMarker(feature2, {
|
|
4534
|
-
extrudeConfig,
|
|
4535
|
-
symbol: definedSymbol
|
|
4536
|
-
}).on("click", this.handleClickElement).addTo(hilightLayer);
|
|
4537
|
-
break;
|
|
4538
|
-
}
|
|
4539
|
-
break;
|
|
4540
|
-
}
|
|
4541
|
-
case "opening":
|
|
4542
|
-
break;
|
|
4543
|
-
default:
|
|
4544
|
-
if (defaultMarker) createMarker(feature2).addTo(hilightLayer);
|
|
4545
|
-
break;
|
|
4546
|
-
}
|
|
4547
|
-
});
|
|
4548
|
-
this.#highlightElementIds = targetElementIds;
|
|
4549
|
-
if (elementToHilights.length === 0) return;
|
|
4550
|
-
return featureCollection(
|
|
4551
|
-
elementToHilights.map(({ feature: feature2 }) => {
|
|
4552
|
-
const { geometry } = feature2;
|
|
4553
|
-
if (feature2.feature_type === "occupant")
|
|
4554
|
-
return feature(feature2?.properties?.anchor?.geometry);
|
|
4555
|
-
return feature(geometry);
|
|
4556
|
-
})
|
|
4557
|
-
);
|
|
4558
|
-
}
|
|
4559
|
-
clearHighlightElements() {
|
|
4560
|
-
this.#clearAllElementOnLayerByName(HIGHLIGHT_LAYER_NAME);
|
|
4561
|
-
_6(this.#highlightElementIds).map((elemId) => this.#elements[elemId]?.geometry).compact().forEach((geometry) => {
|
|
4562
|
-
if (geometry instanceof ui3.UIMarker) return;
|
|
4563
|
-
if (geometry instanceof Marker2) {
|
|
4564
|
-
this.showGeometryByElementId(geometry.properties.id);
|
|
4565
|
-
return;
|
|
4566
|
-
}
|
|
4567
|
-
try {
|
|
4568
|
-
const defaultSymbol = geometry.options.defaultSymbol;
|
|
4569
|
-
geometry.updateSymbol(defaultSymbol);
|
|
4570
|
-
} catch (err) {
|
|
4571
|
-
console.log(
|
|
4572
|
-
`error cannot return to defaultSymbol, check if "defaultSymbol" exists in element creation function`
|
|
4573
|
-
);
|
|
4574
|
-
}
|
|
4575
|
-
});
|
|
4576
|
-
this.#highlightElementIds = [];
|
|
4577
|
-
}
|
|
4578
|
-
setHighlightedObject(targetObjectIds, options = {}) {
|
|
4579
|
-
const { symbolSet } = _6.merge({}, DEFAULT_HIGHLIGHT_OPTIONS, options);
|
|
4580
|
-
const {
|
|
4581
|
-
getElementSymbol,
|
|
4582
|
-
getHilighPolygonalSymbol,
|
|
4583
|
-
createHighlight2DAmenityMarkerFrom3DMarker
|
|
4584
|
-
} = this.#styler;
|
|
4585
|
-
const objects = this.threeLayer?.getBaseObjects();
|
|
4586
|
-
const objectsToHighlight = objects.filter(
|
|
4587
|
-
({ properties }) => targetObjectIds.includes(properties?.id)
|
|
4588
|
-
);
|
|
4589
|
-
const defaultSymbol = getHilighPolygonalSymbol("Polygon");
|
|
4590
|
-
const targetSymbol = symbolSet ? getElementSymbol(symbolSet) : null;
|
|
4591
|
-
const { polygonFill: color } = _6.isEmpty(targetSymbol) ? defaultSymbol : targetSymbol;
|
|
4592
|
-
const amenityHighlightMode = _6.get(
|
|
4593
|
-
this.#mapConfig,
|
|
4594
|
-
"amenity_highlight_mode",
|
|
4595
|
-
""
|
|
4596
|
-
);
|
|
4597
|
-
objectsToHighlight.forEach((obj) => {
|
|
4598
|
-
if (obj.type === "ExtrudePolygon") {
|
|
4599
|
-
const newController = createHighlighExtrudeObjectController(obj, {
|
|
4600
|
-
color
|
|
4601
|
-
});
|
|
4602
|
-
newController.start();
|
|
4603
|
-
this.#highlightObjectControllers.push(newController);
|
|
4604
|
-
}
|
|
4605
|
-
if (obj instanceof SpriteMarker) {
|
|
4606
|
-
if (amenityHighlightMode === "2DMarker") {
|
|
4607
|
-
const hilight2DLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
4608
|
-
const extrudeConfig = _6.get(this.#mapConfig, "extrude");
|
|
4609
|
-
obj.hide();
|
|
4610
|
-
const { properties: featureProperties } = obj;
|
|
4611
|
-
createHighlight2DAmenityMarkerFrom3DMarker(
|
|
4612
|
-
featureProperties,
|
|
4613
|
-
extrudeConfig
|
|
4614
|
-
).on("click", this.handleClickElement).addTo(hilight2DLayer);
|
|
4615
|
-
} else {
|
|
4616
|
-
obj.highlight();
|
|
4617
|
-
}
|
|
4618
|
-
}
|
|
4619
|
-
if (obj instanceof Billboard) {
|
|
4620
|
-
const newController = createHighlighBillboardController(obj);
|
|
4621
|
-
newController.start();
|
|
4622
|
-
this.#highlightObjectControllers.push(newController);
|
|
4623
|
-
}
|
|
4624
|
-
});
|
|
4625
|
-
this.#highlightObjectIds = targetObjectIds;
|
|
4626
|
-
}
|
|
4627
|
-
clearHighlightObject() {
|
|
4628
|
-
this.#highlightObjectControllers.forEach((controller) => {
|
|
4629
|
-
if (_6.isFunction(controller?.clear)) controller.clear();
|
|
4630
|
-
});
|
|
4631
|
-
this.#highlightObjectIds.forEach((objIds) => {
|
|
4632
|
-
const objects = this.threeLayer?.getBaseObjects();
|
|
4633
|
-
const objectToResetHighlight = objects.find(
|
|
4634
|
-
({ properties }) => objIds.includes(properties?.id)
|
|
4635
|
-
);
|
|
4636
|
-
if (objectToResetHighlight instanceof SpriteMarker) {
|
|
4637
|
-
objectToResetHighlight.show();
|
|
4638
|
-
objectToResetHighlight.removeHighlight();
|
|
4639
|
-
}
|
|
4640
|
-
});
|
|
4641
|
-
this.#highlightObjectControllers = [];
|
|
4642
|
-
this.#highlightObjectIds = [];
|
|
4643
|
-
}
|
|
4644
4986
|
/**
|
|
4645
4987
|
* User Location
|
|
4646
4988
|
****************************/
|
|
@@ -4665,15 +5007,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
4665
5007
|
}
|
|
4666
5008
|
}
|
|
4667
5009
|
updateUserLocationSymbolByLocale(locale) {
|
|
4668
|
-
const userLocationGeometry =
|
|
5010
|
+
const userLocationGeometry = _5.get(
|
|
4669
5011
|
this.#elements,
|
|
4670
5012
|
`${USER_LOCATION_ELEMENT_ID}.geometry`
|
|
4671
5013
|
);
|
|
4672
5014
|
if (!userLocationGeometry) return;
|
|
4673
5015
|
const currentSymbol = userLocationGeometry.getSymbol();
|
|
4674
5016
|
const localeSymbolToUpdate = currentSymbol.map((symbol) => {
|
|
4675
|
-
const localeSymbol =
|
|
4676
|
-
if (!
|
|
5017
|
+
const localeSymbol = _5.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || _5.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
|
|
5018
|
+
if (!_5.isPlainObject(localeSymbol)) return symbol;
|
|
4677
5019
|
return {
|
|
4678
5020
|
...symbol,
|
|
4679
5021
|
...localeSymbol
|
|
@@ -4747,14 +5089,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4747
5089
|
* END of User Location
|
|
4748
5090
|
****************************/
|
|
4749
5091
|
showGeometryByElementId = (elementId) => {
|
|
4750
|
-
const geometry =
|
|
5092
|
+
const geometry = _5.get(
|
|
4751
5093
|
this.#elements,
|
|
4752
5094
|
`${elementId}.geometry`
|
|
4753
5095
|
);
|
|
4754
5096
|
if (geometry) geometry.show();
|
|
4755
5097
|
};
|
|
4756
5098
|
hideGeometryByElementId = (elementId) => {
|
|
4757
|
-
const geometry =
|
|
5099
|
+
const geometry = _5.get(this.#elements, `${elementId}.geometry`);
|
|
4758
5100
|
if (geometry) geometry.hide();
|
|
4759
5101
|
};
|
|
4760
5102
|
setSpriteMarkersOpacity = (opacity = 1) => {
|
|
@@ -4801,13 +5143,13 @@ var IndoorMap = class extends EventTarget {
|
|
|
4801
5143
|
const line = lineStrings[i];
|
|
4802
5144
|
const coords = line.geometry.coordinates;
|
|
4803
5145
|
const prevLine = lineStrings[i - 1];
|
|
4804
|
-
const firstCoord =
|
|
5146
|
+
const firstCoord = _5.first(coords);
|
|
4805
5147
|
const isFirstLine = i === 0;
|
|
4806
5148
|
if (isFirstLine) {
|
|
4807
5149
|
accLine.push(...coords);
|
|
4808
5150
|
continue;
|
|
4809
5151
|
}
|
|
4810
|
-
const prevLastCoord =
|
|
5152
|
+
const prevLastCoord = _5.last(prevLine.geometry.coordinates);
|
|
4811
5153
|
const isNearby = turfDistance(point(firstCoord), point(prevLastCoord)) < distance;
|
|
4812
5154
|
if (!isNearby) {
|
|
4813
5155
|
const remainingLines = lineStrings.slice(i);
|
|
@@ -4828,8 +5170,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
4828
5170
|
create3DStepPath
|
|
4829
5171
|
} = this.#styler;
|
|
4830
5172
|
const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
4831
|
-
const linesByOrdinal =
|
|
4832
|
-
const joinedLines =
|
|
5173
|
+
const linesByOrdinal = _5(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
|
|
5174
|
+
const joinedLines = _5(linesByOrdinal).reduce((acc, lines, key) => {
|
|
4833
5175
|
const joined = this.combineNearbyLineStrings(lines, {
|
|
4834
5176
|
properties: { ordinal: +key }
|
|
4835
5177
|
});
|
|
@@ -4857,14 +5199,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4857
5199
|
stepElement = createOriginMarker(stepGeometry).addTo(routeMarkerLayer);
|
|
4858
5200
|
break;
|
|
4859
5201
|
case "destination-marker":
|
|
4860
|
-
const extrudeConfig =
|
|
5202
|
+
const extrudeConfig = _5.get(this.#mapConfig, "extrude");
|
|
4861
5203
|
if (destinationFeature.feature_type === "occupant") {
|
|
4862
|
-
const stepId =
|
|
5204
|
+
const stepId = _5.get(stepGeometry, "id");
|
|
4863
5205
|
const normalizedDestinationFeature = {
|
|
4864
5206
|
...destinationFeature,
|
|
4865
5207
|
id: stepId
|
|
4866
5208
|
};
|
|
4867
|
-
const logoUrl =
|
|
5209
|
+
const logoUrl = _5.get(
|
|
4868
5210
|
normalizedDestinationFeature,
|
|
4869
5211
|
"properties.logo.url"
|
|
4870
5212
|
);
|
|
@@ -4909,15 +5251,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
4909
5251
|
const routeMarkerLayer = this.map.getLayer(
|
|
4910
5252
|
HIGHLIGHT_LAYER_NAME
|
|
4911
5253
|
);
|
|
4912
|
-
const originMarkerGeometry =
|
|
5254
|
+
const originMarkerGeometry = _5.get(
|
|
4913
5255
|
this.#elements,
|
|
4914
5256
|
`${ORIGIN_MARKER_ID}.geometry`
|
|
4915
5257
|
);
|
|
4916
|
-
const destinationMarkerGeometry =
|
|
5258
|
+
const destinationMarkerGeometry = _5.get(
|
|
4917
5259
|
this.#elements,
|
|
4918
5260
|
`${DESTINATION_MARKER_ID}.geometry`
|
|
4919
5261
|
);
|
|
4920
|
-
const geometriesToRemove =
|
|
5262
|
+
const geometriesToRemove = _5.compact([
|
|
4921
5263
|
originMarkerGeometry,
|
|
4922
5264
|
destinationMarkerGeometry
|
|
4923
5265
|
]);
|
|
@@ -4928,7 +5270,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4928
5270
|
(obj) => !(obj instanceof NavigationPath)
|
|
4929
5271
|
);
|
|
4930
5272
|
const objects = this.#navigationGeometries || {};
|
|
4931
|
-
|
|
5273
|
+
_5.forEach(objects, (obj) => {
|
|
4932
5274
|
if (!obj) return;
|
|
4933
5275
|
this.#navigationGeometries[obj.properties.id] = null;
|
|
4934
5276
|
obj.remove();
|
|
@@ -4965,7 +5307,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4965
5307
|
}
|
|
4966
5308
|
if (this.threeLayer) {
|
|
4967
5309
|
const currentView = this.camera.getView();
|
|
4968
|
-
const objectOpacity =
|
|
5310
|
+
const objectOpacity = _5.clamp(38 - 2 * currentView.zoom, 0, 1);
|
|
4969
5311
|
this.#objects.forEach((object) => {
|
|
4970
5312
|
object.getObject3d().traverse((child) => {
|
|
4971
5313
|
if (child.isMesh) child.material.opacity = objectOpacity;
|
|
@@ -4975,7 +5317,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4975
5317
|
});
|
|
4976
5318
|
if (this.#billboardObjects) {
|
|
4977
5319
|
this.#billboardObjects.forEach((object) => {
|
|
4978
|
-
const objectScale =
|
|
5320
|
+
const objectScale = _5.clamp(
|
|
4979
5321
|
20 - 1 * currentView.zoom,
|
|
4980
5322
|
1,
|
|
4981
5323
|
1.05
|
|
@@ -4984,7 +5326,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4984
5326
|
});
|
|
4985
5327
|
}
|
|
4986
5328
|
if (this.#isLayersFadingOnZoom) {
|
|
4987
|
-
const layerOpacity =
|
|
5329
|
+
const layerOpacity = _5.clamp(1 - objectOpacity, 0, 1);
|
|
4988
5330
|
LAYERS.forEach((layerKey) => {
|
|
4989
5331
|
const layer = this.map.getLayer(layerKey);
|
|
4990
5332
|
if (layer) layer.setOpacity(layerOpacity);
|
|
@@ -4998,23 +5340,17 @@ var IndoorMap = class extends EventTarget {
|
|
|
4998
5340
|
child.visible = this.showVenueObject && objectOpacity > 0.4;
|
|
4999
5341
|
});
|
|
5000
5342
|
});
|
|
5001
|
-
this.#groundObjects.forEach((gLabel) => {
|
|
5002
|
-
gLabel.bearing = currBearing;
|
|
5003
|
-
});
|
|
5004
5343
|
}
|
|
5005
5344
|
this.#animationsToRun.forEach(({ callback }) => callback(this));
|
|
5006
|
-
|
|
5345
|
+
TWEEN.update();
|
|
5007
5346
|
requestAnimationFrame(this.render.bind(this));
|
|
5008
5347
|
}
|
|
5009
5348
|
};
|
|
5010
5349
|
export {
|
|
5011
5350
|
ALL_FEATURE_TYPES,
|
|
5012
|
-
ALWAYS_VISIBLE_FEATURE_TYPES,
|
|
5013
5351
|
BASE_LAYER_NAME,
|
|
5014
5352
|
DEFAULT_BASE_URL,
|
|
5015
|
-
DEFAULT_HIGHLIGHT_OPTIONS,
|
|
5016
5353
|
DEFAULT_LOCALE,
|
|
5017
|
-
DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,
|
|
5018
5354
|
DESTINATION_MARKER_ID,
|
|
5019
5355
|
GEOJSON_FEATURE_TYPES,
|
|
5020
5356
|
HIGHLIGHT_LAYER_NAME,
|
|
@@ -5031,6 +5367,7 @@ export {
|
|
|
5031
5367
|
occupant_helper_exports as OccupantHelpers,
|
|
5032
5368
|
POI_MARKER_LAYER_NAME,
|
|
5033
5369
|
QueryObserver2 as QueryObserver,
|
|
5370
|
+
TextSpriteMarker,
|
|
5034
5371
|
USER_LOCATION_ELEMENT_ID,
|
|
5035
5372
|
USER_LOCATION_LAYER_NAME,
|
|
5036
5373
|
VENUE_EVENTS,
|