venue-js 1.2.0-next.12 → 1.2.0-next.14
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 +27 -41
- package/dist/index.d.ts +27 -41
- package/dist/index.js +1120 -618
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1114 -614
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48,7 +48,9 @@ __export(index_exports, {
|
|
|
48
48
|
ORIGIN_MARKER_ID: () => ORIGIN_MARKER_ID,
|
|
49
49
|
OccupantHelpers: () => occupant_helper_exports,
|
|
50
50
|
POI_MARKER_LAYER_NAME: () => POI_MARKER_LAYER_NAME,
|
|
51
|
+
PulsingMarker: () => PulsingMarker,
|
|
51
52
|
QueryObserver: () => import_query_core2.QueryObserver,
|
|
53
|
+
TextSpriteMarker: () => TextSpriteMarker,
|
|
52
54
|
USER_LOCATION_ELEMENT_ID: () => USER_LOCATION_ELEMENT_ID,
|
|
53
55
|
USER_LOCATION_LAYER_NAME: () => USER_LOCATION_LAYER_NAME,
|
|
54
56
|
VENUE_EVENTS: () => VENUE_EVENTS,
|
|
@@ -292,16 +294,16 @@ function isValidLinearRingCoordinates(ring) {
|
|
|
292
294
|
}
|
|
293
295
|
return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
|
|
294
296
|
}
|
|
295
|
-
var isValidPolygonCoordinates = (
|
|
296
|
-
if (Array.isArray(
|
|
297
|
-
return isValidLinearRingCoordinates(
|
|
297
|
+
var isValidPolygonCoordinates = (polygon2) => {
|
|
298
|
+
if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
|
|
299
|
+
return isValidLinearRingCoordinates(polygon2);
|
|
298
300
|
}
|
|
299
|
-
if (Array.isArray(
|
|
300
|
-
if (!isValidLinearRingCoordinates(
|
|
301
|
+
if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
|
|
302
|
+
if (!isValidLinearRingCoordinates(polygon2[0])) {
|
|
301
303
|
return false;
|
|
302
304
|
}
|
|
303
|
-
for (let i = 1; i <
|
|
304
|
-
if (!isValidLinearRingCoordinates(
|
|
305
|
+
for (let i = 1; i < polygon2.length; i++) {
|
|
306
|
+
if (!isValidLinearRingCoordinates(polygon2[i])) {
|
|
305
307
|
return false;
|
|
306
308
|
}
|
|
307
309
|
}
|
|
@@ -344,7 +346,7 @@ var isValidPoint = (geometry) => {
|
|
|
344
346
|
function isInFilter(filter) {
|
|
345
347
|
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
346
348
|
}
|
|
347
|
-
var someIntersect = (a, b) => a.some((
|
|
349
|
+
var someIntersect = (a, b) => a.some((v2) => b.includes(v2));
|
|
348
350
|
function matchFilter(value, filter) {
|
|
349
351
|
if (Array.isArray(value)) {
|
|
350
352
|
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
@@ -821,6 +823,28 @@ function point(coordinates, properties, options = {}) {
|
|
|
821
823
|
};
|
|
822
824
|
return feature(geom, properties, options);
|
|
823
825
|
}
|
|
826
|
+
function polygon(coordinates, properties, options = {}) {
|
|
827
|
+
for (const ring of coordinates) {
|
|
828
|
+
if (ring.length < 4) {
|
|
829
|
+
throw new Error(
|
|
830
|
+
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
834
|
+
throw new Error("First and last Position are not equivalent.");
|
|
835
|
+
}
|
|
836
|
+
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
837
|
+
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
838
|
+
throw new Error("First and last Position are not equivalent.");
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
const geom = {
|
|
843
|
+
type: "Polygon",
|
|
844
|
+
coordinates
|
|
845
|
+
};
|
|
846
|
+
return feature(geom, properties, options);
|
|
847
|
+
}
|
|
824
848
|
function lineString(coordinates, properties, options = {}) {
|
|
825
849
|
if (coordinates.length < 2) {
|
|
826
850
|
throw new Error("coordinates must be an array of two or more positions");
|
|
@@ -928,10 +952,10 @@ var VENUE_EVENTS = {
|
|
|
928
952
|
|
|
929
953
|
// src/IndoorMap/utils/createElements.js
|
|
930
954
|
var import_lodash4 = __toESM(require("lodash"));
|
|
931
|
-
var
|
|
955
|
+
var import_maptalks4 = require("maptalks");
|
|
932
956
|
var import_center2 = __toESM(require("@turf/center"));
|
|
933
957
|
var import_buffer = __toESM(require("@turf/buffer"));
|
|
934
|
-
var
|
|
958
|
+
var import_three4 = require("three");
|
|
935
959
|
var import_GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader.js");
|
|
936
960
|
|
|
937
961
|
// src/IndoorMap/object3d/Billboard.js
|
|
@@ -964,7 +988,7 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
964
988
|
this._initOptions(options);
|
|
965
989
|
const {
|
|
966
990
|
altitude = OPTIONS.altitude,
|
|
967
|
-
scale:
|
|
991
|
+
scale: scale3 = OPTIONS.scale,
|
|
968
992
|
alphaTest = OPTIONS.alphaTest,
|
|
969
993
|
legColor = OPTIONS.legColor,
|
|
970
994
|
showLeg = OPTIONS.showLeg
|
|
@@ -998,8 +1022,8 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
998
1022
|
const sprite = new import_three.Sprite(material);
|
|
999
1023
|
sprite.material.sizeAttenuation = false;
|
|
1000
1024
|
sprite.scale.set(
|
|
1001
|
-
|
|
1002
|
-
|
|
1025
|
+
scale3 * naturalWidth / divider,
|
|
1026
|
+
scale3 * naturalHeight / divider,
|
|
1003
1027
|
1
|
|
1004
1028
|
);
|
|
1005
1029
|
this.getObject3d().add(sprite);
|
|
@@ -1008,7 +1032,7 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
1008
1032
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
1009
1033
|
import_lodash.default.set(this.properties, "default.position", position);
|
|
1010
1034
|
import_lodash.default.set(this.properties, "default.altitude", altitude);
|
|
1011
|
-
import_lodash.default.set(this.properties, "default.scale",
|
|
1035
|
+
import_lodash.default.set(this.properties, "default.scale", scale3);
|
|
1012
1036
|
this.getObject3d().position.copy(position);
|
|
1013
1037
|
}
|
|
1014
1038
|
setLineHeight(altitude) {
|
|
@@ -1021,383 +1045,93 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
1021
1045
|
}
|
|
1022
1046
|
};
|
|
1023
1047
|
|
|
1024
|
-
// src/IndoorMap/object3d/
|
|
1025
|
-
var maptalks2 = __toESM(require("maptalks"));
|
|
1048
|
+
// src/IndoorMap/object3d/SpriteMarker.ts
|
|
1026
1049
|
var import_maptalks2 = require("maptalks.three");
|
|
1027
1050
|
var import_three2 = require("three");
|
|
1028
|
-
var
|
|
1029
|
-
var
|
|
1030
|
-
var
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
lineHeight: 1.05,
|
|
1042
|
-
scaleStep: 0.05,
|
|
1043
|
-
textAlign: "center",
|
|
1044
|
-
textBaseline: "middle",
|
|
1045
|
-
fillStyle: "#000"
|
|
1046
|
-
};
|
|
1047
|
-
var defaultRectAngleToCalc = (0, import_lodash_es.range)(-90, 92, 2);
|
|
1048
|
-
var getMaterial = (text, flatLabelOptions) => {
|
|
1049
|
-
const options = (0, import_lodash_es.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
|
|
1050
|
-
const {
|
|
1051
|
-
fontSize: initialFontSize,
|
|
1052
|
-
fontFamily,
|
|
1053
|
-
fontWeight,
|
|
1054
|
-
margin,
|
|
1055
|
-
scaleMin,
|
|
1056
|
-
scaleStep,
|
|
1057
|
-
fillStyle,
|
|
1058
|
-
lineHeight,
|
|
1059
|
-
textAlign,
|
|
1060
|
-
strokeStyle,
|
|
1061
|
-
lineWidth,
|
|
1062
|
-
textBaseline
|
|
1063
|
-
} = options;
|
|
1064
|
-
const pixelMultiplier = 4;
|
|
1065
|
-
const SIZE = 100 * pixelMultiplier;
|
|
1066
|
-
const fontSize = initialFontSize * (pixelMultiplier * 1.25);
|
|
1067
|
-
const canvas = document.createElement("canvas");
|
|
1068
|
-
canvas.width = canvas.height = SIZE;
|
|
1069
|
-
const ctx = canvas.getContext("2d");
|
|
1070
|
-
ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", Arial`;
|
|
1071
|
-
ctx.textAlign = textAlign;
|
|
1072
|
-
ctx.textBaseline = textBaseline;
|
|
1073
|
-
ctx.fillStyle = fillStyle;
|
|
1074
|
-
ctx.strokeStyle = strokeStyle;
|
|
1075
|
-
ctx.lineWidth = lineWidth;
|
|
1076
|
-
const wrapText = (ctx2, text2, maxWidth) => {
|
|
1077
|
-
const words = text2.trim().split(/\s+/);
|
|
1078
|
-
if (words.length <= 1) return [text2];
|
|
1079
|
-
const lines = [];
|
|
1080
|
-
const MAX_LINES = 3;
|
|
1081
|
-
let currentLine = words[0];
|
|
1082
|
-
for (let i = 1; i < words.length; i++) {
|
|
1083
|
-
const lineToMeasure = currentLine + " " + words[i];
|
|
1084
|
-
if (ctx2.measureText(lineToMeasure).width > maxWidth) {
|
|
1085
|
-
lines.push(currentLine);
|
|
1086
|
-
currentLine = words[i];
|
|
1087
|
-
} else {
|
|
1088
|
-
currentLine = lineToMeasure;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
lines.push(currentLine);
|
|
1092
|
-
return lines.slice(0, MAX_LINES);
|
|
1093
|
-
};
|
|
1094
|
-
const hasManualBreaks = text.includes("\n");
|
|
1095
|
-
let texts;
|
|
1096
|
-
if (hasManualBreaks) {
|
|
1097
|
-
texts = text.split(/\n/g);
|
|
1098
|
-
} else {
|
|
1099
|
-
const maxWidth = SIZE - 2 * margin;
|
|
1100
|
-
texts = wrapText(ctx, text, maxWidth);
|
|
1101
|
-
}
|
|
1102
|
-
let textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
1103
|
-
let scale2 = 1;
|
|
1104
|
-
while (scale2 > 0 && textWidth + 2 * margin > SIZE) {
|
|
1105
|
-
scale2 -= scaleStep;
|
|
1106
|
-
ctx.font = `${fontWeight} ${scale2 * fontSize}px "${fontFamily}", Arial`;
|
|
1107
|
-
textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
1108
|
-
}
|
|
1109
|
-
const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
|
|
1110
|
-
if (scale2 > scaleMin) {
|
|
1111
|
-
const totalHeight = texts.length * (fontSize * scale2 * lineHeight);
|
|
1112
|
-
const startY = center2.y - totalHeight / 2 + fontSize * scale2 * lineHeight * 0.5;
|
|
1113
|
-
texts.forEach((text2, index) => {
|
|
1114
|
-
const yOffset = startY + index * (fontSize * scale2 * lineHeight);
|
|
1115
|
-
if (strokeStyle && lineWidth) {
|
|
1116
|
-
ctx.strokeText(text2, center2.x, yOffset);
|
|
1117
|
-
}
|
|
1118
|
-
ctx.fillText(text2, center2.x, yOffset);
|
|
1119
|
-
});
|
|
1051
|
+
var import_lodash2 = __toESM(require("lodash"));
|
|
1052
|
+
var DEFAULT_SCALE = 0.05;
|
|
1053
|
+
var DEFAULT_ALTITUDE = 0;
|
|
1054
|
+
var DEFAULT_ALPHATEST = 0.3;
|
|
1055
|
+
var DEFAULT_OPTIONS = {
|
|
1056
|
+
scale: DEFAULT_SCALE,
|
|
1057
|
+
altitude: DEFAULT_ALTITUDE,
|
|
1058
|
+
alphaTest: DEFAULT_ALPHATEST,
|
|
1059
|
+
highlight: {
|
|
1060
|
+
options: {
|
|
1061
|
+
scale: DEFAULT_SCALE * 1.25
|
|
1062
|
+
},
|
|
1063
|
+
material: null
|
|
1120
1064
|
}
|
|
1121
|
-
const texture = new import_three2.Texture(canvas);
|
|
1122
|
-
texture.needsUpdate = true;
|
|
1123
|
-
const material = new import_three2.MeshPhongMaterial({
|
|
1124
|
-
map: texture,
|
|
1125
|
-
transparent: true,
|
|
1126
|
-
// @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
|
|
1127
|
-
alphaTest: 0.3
|
|
1128
|
-
});
|
|
1129
|
-
return material;
|
|
1130
1065
|
};
|
|
1131
|
-
var
|
|
1132
|
-
#
|
|
1133
|
-
#
|
|
1134
|
-
|
|
1135
|
-
#offsetX = 0;
|
|
1136
|
-
#offsetY = 0;
|
|
1137
|
-
#originalPosition = null;
|
|
1138
|
-
#layer = null;
|
|
1139
|
-
constructor(bound, options, layer) {
|
|
1140
|
-
options = maptalks2.Util.extend({}, OPTIONS2, options, {
|
|
1141
|
-
layer,
|
|
1142
|
-
coordinate: bound
|
|
1143
|
-
});
|
|
1144
|
-
const {
|
|
1145
|
-
altitude,
|
|
1146
|
-
text,
|
|
1147
|
-
fontSize,
|
|
1148
|
-
fillStyle,
|
|
1149
|
-
textAlign,
|
|
1150
|
-
fontFamily,
|
|
1151
|
-
textBaseline,
|
|
1152
|
-
strokeStyle,
|
|
1153
|
-
lineWidth,
|
|
1154
|
-
angle = defaultRectAngleToCalc,
|
|
1155
|
-
maxFontScale,
|
|
1156
|
-
offsetX = 0,
|
|
1157
|
-
offsetY = 0,
|
|
1158
|
-
...properties
|
|
1159
|
-
} = options;
|
|
1066
|
+
var SpriteMarker = class extends import_maptalks2.BaseObject {
|
|
1067
|
+
#default = null;
|
|
1068
|
+
#highlight = null;
|
|
1069
|
+
constructor(coordinate, options, material, layer, properties) {
|
|
1160
1070
|
super();
|
|
1161
1071
|
this._initOptions(options);
|
|
1162
|
-
this.
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
*/
|
|
1184
|
-
angle: rectAngles
|
|
1185
|
-
});
|
|
1186
|
-
const { cx, cy, width, angle: calculatedAngle } = rect;
|
|
1187
|
-
this.#text = text;
|
|
1188
|
-
this.#angle = calculatedAngle;
|
|
1189
|
-
const geometry = new import_three2.PlaneGeometry(1, 1);
|
|
1190
|
-
this._createMesh(geometry, material);
|
|
1191
|
-
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
1192
|
-
const basePosition = layer.coordinateToVector3({ x: cx, y: cy }, z);
|
|
1193
|
-
this.#originalPosition = basePosition.clone();
|
|
1194
|
-
const finalPosition = this.#calculateFinalPosition(basePosition);
|
|
1195
|
-
const scale2 = width / 6456122659e-13;
|
|
1196
|
-
const finalScale = maxFontScale && scale2 > maxFontScale ? maxFontScale : scale2;
|
|
1197
|
-
this.getObject3d().scale.set(finalScale, finalScale, finalScale);
|
|
1198
|
-
this.getObject3d().position.copy(finalPosition);
|
|
1199
|
-
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
1200
|
-
}
|
|
1201
|
-
#calculateFinalPosition(basePosition) {
|
|
1202
|
-
if (this.#offsetX === 0 && this.#offsetY === 0) {
|
|
1203
|
-
return basePosition;
|
|
1204
|
-
}
|
|
1205
|
-
const offsetCoordinate = {
|
|
1206
|
-
x: this.#offsetX,
|
|
1207
|
-
y: this.#offsetY
|
|
1208
|
-
};
|
|
1209
|
-
const z = this.#layer.altitudeToVector3(0, 0).x;
|
|
1210
|
-
const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
|
|
1211
|
-
const zeroVector = this.#layer.coordinateToVector3({ x: 0, y: 0 }, z);
|
|
1212
|
-
const worldOffsetX = offsetVector.x - zeroVector.x;
|
|
1213
|
-
const worldOffsetY = offsetVector.y - zeroVector.y;
|
|
1214
|
-
return {
|
|
1215
|
-
x: basePosition.x + worldOffsetX,
|
|
1216
|
-
y: basePosition.y + worldOffsetY,
|
|
1217
|
-
z: basePosition.z
|
|
1218
|
-
};
|
|
1072
|
+
this._createGroup();
|
|
1073
|
+
const {
|
|
1074
|
+
altitude = DEFAULT_OPTIONS.altitude,
|
|
1075
|
+
scale: scale3 = DEFAULT_OPTIONS.scale,
|
|
1076
|
+
highlight = DEFAULT_OPTIONS.highlight,
|
|
1077
|
+
alphaTest = DEFAULT_OPTIONS.alphaTest
|
|
1078
|
+
} = options;
|
|
1079
|
+
this.properties = { ...properties };
|
|
1080
|
+
const modifiedAltitude = altitude + 2;
|
|
1081
|
+
this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
|
|
1082
|
+
this.#highlight = import_lodash2.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
1083
|
+
if (material && material instanceof import_three2.SpriteMaterial)
|
|
1084
|
+
material.alphaTest = alphaTest;
|
|
1085
|
+
const sprite = new import_three2.Sprite(material);
|
|
1086
|
+
sprite.scale.set(scale3, scale3, scale3);
|
|
1087
|
+
const obj3d = this.getObject3d();
|
|
1088
|
+
obj3d.add(sprite);
|
|
1089
|
+
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
1090
|
+
const position = layer.coordinateToVector3(coordinate, z);
|
|
1091
|
+
import_lodash2.default.set(this.properties, "default.position", position);
|
|
1092
|
+
this.getObject3d().position.copy(position);
|
|
1219
1093
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
this.getObject3d().
|
|
1094
|
+
// Different objects need to implement their own methods
|
|
1095
|
+
setSymbol(material) {
|
|
1096
|
+
if (material && material instanceof import_three2.SpriteMaterial) {
|
|
1097
|
+
const sprite = this.getObject3d().children[0];
|
|
1098
|
+
if (!sprite) return this;
|
|
1099
|
+
sprite.material = material;
|
|
1100
|
+
sprite.material.needsUpdate = true;
|
|
1224
1101
|
}
|
|
1102
|
+
return this;
|
|
1225
1103
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
this
|
|
1104
|
+
setScale(scaleX, scaleY = scaleX, scaleZ = scaleX) {
|
|
1105
|
+
const sprite = this.getObject3d().children[0];
|
|
1106
|
+
if (!sprite) return this;
|
|
1107
|
+
sprite.scale.set(scaleX, scaleY, scaleZ);
|
|
1108
|
+
return this;
|
|
1231
1109
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1110
|
+
// Different objects need to implement their own methods
|
|
1111
|
+
getSymbol() {
|
|
1112
|
+
return this.getObject3d()?.children[0]?.material;
|
|
1234
1113
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1114
|
+
highlight() {
|
|
1115
|
+
const { material, options } = this.#highlight;
|
|
1116
|
+
if (material) this.setSymbol(material);
|
|
1117
|
+
if (options.scale) this.setScale(options.scale);
|
|
1118
|
+
if (options.altitude) this.setAltitude(options.altitude);
|
|
1119
|
+
return this;
|
|
1237
1120
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
get offsetY() {
|
|
1245
|
-
return this.#offsetY;
|
|
1246
|
-
}
|
|
1247
|
-
get offset() {
|
|
1248
|
-
return { x: this.#offsetX, y: this.#offsetY };
|
|
1249
|
-
}
|
|
1250
|
-
set offsetX(value) {
|
|
1251
|
-
if ((0, import_lodash_es.isNumber)(value)) {
|
|
1252
|
-
this.#offsetX = value;
|
|
1253
|
-
this.#updatePosition();
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
set offsetY(value) {
|
|
1257
|
-
if ((0, import_lodash_es.isNumber)(value)) {
|
|
1258
|
-
this.#offsetY = value;
|
|
1259
|
-
this.#updatePosition();
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
set angle(newAngle) {
|
|
1263
|
-
if ((0, import_lodash_es.isNumber)(newAngle)) {
|
|
1264
|
-
this.#angle = newAngle;
|
|
1265
|
-
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
setOffset(offsetX, offsetY) {
|
|
1269
|
-
if ((0, import_lodash_es.isNumber)(offsetX) && (0, import_lodash_es.isNumber)(offsetY)) {
|
|
1270
|
-
this.#offsetX = offsetX;
|
|
1271
|
-
this.#offsetY = offsetY;
|
|
1272
|
-
this.#updatePosition();
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
addOffset(deltaX, deltaY) {
|
|
1276
|
-
if ((0, import_lodash_es.isNumber)(deltaX) && (0, import_lodash_es.isNumber)(deltaY)) {
|
|
1277
|
-
this.#offsetX += deltaX;
|
|
1278
|
-
this.#offsetY += deltaY;
|
|
1279
|
-
this.#updatePosition();
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
resetOffset() {
|
|
1283
|
-
this.#offsetX = 0;
|
|
1284
|
-
this.#offsetY = 0;
|
|
1285
|
-
this.#updatePosition();
|
|
1286
|
-
}
|
|
1287
|
-
moveToPosition(targetX, targetY) {
|
|
1288
|
-
if (this.#originalPosition && this.#layer) {
|
|
1289
|
-
const currentCenter = this.#layer.vector3ToCoordinate(
|
|
1290
|
-
this.#originalPosition
|
|
1291
|
-
);
|
|
1292
|
-
this.#offsetX = targetX - currentCenter.x;
|
|
1293
|
-
this.#offsetY = targetY - currentCenter.y;
|
|
1294
|
-
this.#updatePosition();
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
updateText(newText, options = {}) {
|
|
1298
|
-
this.#text = newText;
|
|
1299
|
-
const materialOptions = {
|
|
1300
|
-
fillStyle: options.fillStyle || this.properties.fillStyle,
|
|
1301
|
-
fontSize: options.fontSize || this.properties.fontSize,
|
|
1302
|
-
textAlign: options.textAlign || this.properties.textAlign,
|
|
1303
|
-
textBaseline: options.textBaseline || this.properties.textBaseline,
|
|
1304
|
-
fontFamily: options.fontFamily || this.properties.fontFamily,
|
|
1305
|
-
strokeStyle: options.strokeStyle || this.properties.strokeStyle,
|
|
1306
|
-
lineWidth: options.lineWidth || this.properties.lineWidth
|
|
1307
|
-
};
|
|
1308
|
-
const newMaterial = getMaterial(newText, materialOptions);
|
|
1309
|
-
this.getObject3d().material = newMaterial;
|
|
1310
|
-
newMaterial.needsUpdate = true;
|
|
1121
|
+
removeHighlight() {
|
|
1122
|
+
const { material, options } = this.#default;
|
|
1123
|
+
if (material) this.setSymbol(material);
|
|
1124
|
+
if (options.scale) this.setScale(options.scale);
|
|
1125
|
+
if (options.altitude) this.setAltitude(options.altitude);
|
|
1126
|
+
return this;
|
|
1311
1127
|
}
|
|
1312
1128
|
};
|
|
1313
1129
|
|
|
1314
|
-
// src/IndoorMap/object3d/
|
|
1130
|
+
// src/IndoorMap/object3d/NavigationPath.ts
|
|
1131
|
+
var maptalks2 = __toESM(require("maptalks"));
|
|
1315
1132
|
var import_maptalks3 = require("maptalks.three");
|
|
1316
1133
|
var import_three3 = require("three");
|
|
1317
|
-
var
|
|
1318
|
-
var DEFAULT_SCALE = 0.05;
|
|
1319
|
-
var DEFAULT_ALTITUDE = 0;
|
|
1320
|
-
var DEFAULT_ALPHATEST = 0.3;
|
|
1321
|
-
var DEFAULT_OPTIONS = {
|
|
1322
|
-
scale: DEFAULT_SCALE,
|
|
1323
|
-
altitude: DEFAULT_ALTITUDE,
|
|
1324
|
-
alphaTest: DEFAULT_ALPHATEST,
|
|
1325
|
-
highlight: {
|
|
1326
|
-
options: {
|
|
1327
|
-
scale: DEFAULT_SCALE * 1.25
|
|
1328
|
-
},
|
|
1329
|
-
material: null
|
|
1330
|
-
}
|
|
1331
|
-
};
|
|
1332
|
-
var SpriteMarker = class extends import_maptalks3.BaseObject {
|
|
1333
|
-
#default = null;
|
|
1334
|
-
#highlight = null;
|
|
1335
|
-
constructor(coordinate, options, material, layer, properties) {
|
|
1336
|
-
super();
|
|
1337
|
-
this._initOptions(options);
|
|
1338
|
-
this._createGroup();
|
|
1339
|
-
const {
|
|
1340
|
-
altitude = DEFAULT_OPTIONS.altitude,
|
|
1341
|
-
scale: scale2 = DEFAULT_OPTIONS.scale,
|
|
1342
|
-
highlight = DEFAULT_OPTIONS.highlight,
|
|
1343
|
-
alphaTest = DEFAULT_OPTIONS.alphaTest
|
|
1344
|
-
} = options;
|
|
1345
|
-
this.properties = { ...properties };
|
|
1346
|
-
const modifiedAltitude = altitude + 2;
|
|
1347
|
-
this.#default = { options: { scale: scale2, altitude: modifiedAltitude }, material };
|
|
1348
|
-
this.#highlight = import_lodash2.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
1349
|
-
if (material && material instanceof import_three3.SpriteMaterial)
|
|
1350
|
-
material.alphaTest = alphaTest;
|
|
1351
|
-
const sprite = new import_three3.Sprite(material);
|
|
1352
|
-
sprite.scale.set(scale2, scale2, scale2);
|
|
1353
|
-
const obj3d = this.getObject3d();
|
|
1354
|
-
obj3d.add(sprite);
|
|
1355
|
-
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
1356
|
-
const position = layer.coordinateToVector3(coordinate, z);
|
|
1357
|
-
import_lodash2.default.set(this.properties, "default.position", position);
|
|
1358
|
-
this.getObject3d().position.copy(position);
|
|
1359
|
-
}
|
|
1360
|
-
// Different objects need to implement their own methods
|
|
1361
|
-
setSymbol(material) {
|
|
1362
|
-
if (material && material instanceof import_three3.SpriteMaterial) {
|
|
1363
|
-
const sprite = this.getObject3d().children[0];
|
|
1364
|
-
if (!sprite) return this;
|
|
1365
|
-
sprite.material = material;
|
|
1366
|
-
sprite.material.needsUpdate = true;
|
|
1367
|
-
}
|
|
1368
|
-
return this;
|
|
1369
|
-
}
|
|
1370
|
-
setScale(scaleX, scaleY = scaleX, scaleZ = scaleX) {
|
|
1371
|
-
const sprite = this.getObject3d().children[0];
|
|
1372
|
-
if (!sprite) return this;
|
|
1373
|
-
sprite.scale.set(scaleX, scaleY, scaleZ);
|
|
1374
|
-
return this;
|
|
1375
|
-
}
|
|
1376
|
-
// Different objects need to implement their own methods
|
|
1377
|
-
getSymbol() {
|
|
1378
|
-
return this.getObject3d()?.children[0]?.material;
|
|
1379
|
-
}
|
|
1380
|
-
highlight() {
|
|
1381
|
-
const { material, options } = this.#highlight;
|
|
1382
|
-
if (material) this.setSymbol(material);
|
|
1383
|
-
if (options.scale) this.setScale(options.scale);
|
|
1384
|
-
if (options.altitude) this.setAltitude(options.altitude);
|
|
1385
|
-
return this;
|
|
1386
|
-
}
|
|
1387
|
-
removeHighlight() {
|
|
1388
|
-
const { material, options } = this.#default;
|
|
1389
|
-
if (material) this.setSymbol(material);
|
|
1390
|
-
if (options.scale) this.setScale(options.scale);
|
|
1391
|
-
if (options.altitude) this.setAltitude(options.altitude);
|
|
1392
|
-
return this;
|
|
1393
|
-
}
|
|
1394
|
-
};
|
|
1395
|
-
|
|
1396
|
-
// src/IndoorMap/object3d/NavigationPath.ts
|
|
1397
|
-
var maptalks3 = __toESM(require("maptalks"));
|
|
1398
|
-
var import_maptalks4 = require("maptalks.three");
|
|
1399
|
-
var import_three4 = require("three");
|
|
1400
|
-
var OPTIONS3 = {
|
|
1134
|
+
var OPTIONS2 = {
|
|
1401
1135
|
altitude: 0
|
|
1402
1136
|
};
|
|
1403
1137
|
var DEFAULT_LINE_OPTION = {
|
|
@@ -1409,18 +1143,18 @@ var DEFAULT_LINE_EFFECT_OPTION = {
|
|
|
1409
1143
|
opacity: 1
|
|
1410
1144
|
};
|
|
1411
1145
|
var ENABLE_ANIMATED_PATH = true;
|
|
1412
|
-
var NavigationPath = class extends
|
|
1146
|
+
var NavigationPath = class extends import_maptalks3.BaseObject {
|
|
1413
1147
|
constructor(feature2, layer, properties, options, lineOptions = DEFAULT_LINE_OPTION, outlineOption = DEFAULT_LINE_EFFECT_OPTION) {
|
|
1414
|
-
options =
|
|
1148
|
+
options = maptalks2.Util.extend({}, OPTIONS2, options, {
|
|
1415
1149
|
layer
|
|
1416
1150
|
});
|
|
1417
1151
|
super();
|
|
1418
1152
|
this._initOptions(options);
|
|
1419
|
-
const { altitude =
|
|
1153
|
+
const { altitude = OPTIONS2.altitude } = options;
|
|
1420
1154
|
this.properties = { ...properties };
|
|
1421
1155
|
this._createGroup();
|
|
1422
1156
|
const { color: lineColor, opacity: lineOpacity } = lineOptions || DEFAULT_LINE_OPTION;
|
|
1423
|
-
const staticMaterial = new
|
|
1157
|
+
const staticMaterial = new import_three3.MeshBasicMaterial({
|
|
1424
1158
|
transparent: true,
|
|
1425
1159
|
color: lineColor || "#fff",
|
|
1426
1160
|
opacity: lineOpacity || 1,
|
|
@@ -1428,12 +1162,12 @@ var NavigationPath = class extends import_maptalks4.BaseObject {
|
|
|
1428
1162
|
});
|
|
1429
1163
|
const uniforms = {
|
|
1430
1164
|
time: { value: 0 },
|
|
1431
|
-
color: { value: new
|
|
1165
|
+
color: { value: new import_three3.Color(lineColor || "#fff") },
|
|
1432
1166
|
opacity: { value: lineOpacity || 1 }
|
|
1433
1167
|
};
|
|
1434
1168
|
this._uniforms = uniforms;
|
|
1435
1169
|
this._t = 0;
|
|
1436
|
-
const animatedMaterial = new
|
|
1170
|
+
const animatedMaterial = new import_three3.ShaderMaterial({
|
|
1437
1171
|
uniforms,
|
|
1438
1172
|
transparent: true,
|
|
1439
1173
|
depthWrite: false,
|
|
@@ -1456,7 +1190,7 @@ var NavigationPath = class extends import_maptalks4.BaseObject {
|
|
|
1456
1190
|
}
|
|
1457
1191
|
`
|
|
1458
1192
|
});
|
|
1459
|
-
const pathGeometry =
|
|
1193
|
+
const pathGeometry = maptalks2.GeoJSON.toGeometry(feature2);
|
|
1460
1194
|
const line = layer.toPath(
|
|
1461
1195
|
pathGeometry,
|
|
1462
1196
|
{
|
|
@@ -1467,7 +1201,7 @@ var NavigationPath = class extends import_maptalks4.BaseObject {
|
|
|
1467
1201
|
ENABLE_ANIMATED_PATH ? animatedMaterial : staticMaterial
|
|
1468
1202
|
);
|
|
1469
1203
|
const { color: outlineColor, opacity: outlineOpacity } = outlineOption || {};
|
|
1470
|
-
const outlineMaterial = new
|
|
1204
|
+
const outlineMaterial = new import_three3.MeshBasicMaterial({
|
|
1471
1205
|
transparent: true,
|
|
1472
1206
|
color: outlineColor || "#fff",
|
|
1473
1207
|
opacity: outlineOpacity || 1
|
|
@@ -1514,8 +1248,8 @@ var createPolygonFromLineString = (geometry) => {
|
|
|
1514
1248
|
const right = (0, import_line_offset.default)(line, -0.3, { units: "meters" });
|
|
1515
1249
|
const leftCoords = left.geometry.coordinates;
|
|
1516
1250
|
const rightCoords = right.geometry.coordinates.reverse();
|
|
1517
|
-
const
|
|
1518
|
-
return [
|
|
1251
|
+
const polygon2 = [...leftCoords, ...rightCoords, leftCoords[0]];
|
|
1252
|
+
return [polygon2];
|
|
1519
1253
|
};
|
|
1520
1254
|
|
|
1521
1255
|
// src/IndoorMap/utils/svg.ts
|
|
@@ -1549,14 +1283,14 @@ var createSVGPathFromMarkerSymbol = (style) => {
|
|
|
1549
1283
|
markerFill,
|
|
1550
1284
|
markerPath
|
|
1551
1285
|
} = style;
|
|
1552
|
-
const
|
|
1553
|
-
return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${
|
|
1286
|
+
const scale3 = markerWidth / 24;
|
|
1287
|
+
return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale3})" fill="${markerFill}"/>`;
|
|
1554
1288
|
};
|
|
1555
1289
|
|
|
1556
1290
|
// src/IndoorMap/utils/createElements.js
|
|
1557
1291
|
var GeometryType = {
|
|
1558
|
-
Polygon:
|
|
1559
|
-
MultiPolygon:
|
|
1292
|
+
Polygon: import_maptalks4.Polygon,
|
|
1293
|
+
MultiPolygon: import_maptalks4.MultiPolygon
|
|
1560
1294
|
};
|
|
1561
1295
|
var ORDINAL_HEIGHT = 0;
|
|
1562
1296
|
var VENUE_Z_INDEX = 0;
|
|
@@ -1691,8 +1425,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
|
|
|
1691
1425
|
if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
|
|
1692
1426
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1693
1427
|
if (geometry.type === "LineString") {
|
|
1694
|
-
const
|
|
1695
|
-
return new GeometryType["Polygon"](
|
|
1428
|
+
const polygon2 = createPolygonFromLineString(geometry);
|
|
1429
|
+
return new GeometryType["Polygon"](polygon2, {
|
|
1696
1430
|
properties: {
|
|
1697
1431
|
altitude: getAltitude(properties)
|
|
1698
1432
|
},
|
|
@@ -1760,7 +1494,7 @@ var createPrincipalOpening = (feature2, style, options = {}) => {
|
|
|
1760
1494
|
const symbolStyle = { ...style };
|
|
1761
1495
|
if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
|
|
1762
1496
|
try {
|
|
1763
|
-
return new
|
|
1497
|
+
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1764
1498
|
properties: {
|
|
1765
1499
|
altitude: getAltitude(properties)
|
|
1766
1500
|
},
|
|
@@ -1777,7 +1511,7 @@ var createEmergencyExitOpening = (feature2, style, options = {}) => {
|
|
|
1777
1511
|
const symbolStyle = { ...style };
|
|
1778
1512
|
if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
|
|
1779
1513
|
try {
|
|
1780
|
-
return new
|
|
1514
|
+
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1781
1515
|
properties: {
|
|
1782
1516
|
altitude: getAltitude(properties)
|
|
1783
1517
|
},
|
|
@@ -1794,7 +1528,7 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
|
|
|
1794
1528
|
const symbolStyle = { ...style };
|
|
1795
1529
|
if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
|
|
1796
1530
|
try {
|
|
1797
|
-
return new
|
|
1531
|
+
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1798
1532
|
properties: {
|
|
1799
1533
|
id,
|
|
1800
1534
|
feature_type: "opening",
|
|
@@ -1882,7 +1616,7 @@ var getFeatureMarkerConfig = (feature2, mapConfig = {}) => {
|
|
|
1882
1616
|
};
|
|
1883
1617
|
};
|
|
1884
1618
|
var createSpriteMaterialByLabelSymbol = (labelSymbol = []) => {
|
|
1885
|
-
const material = new
|
|
1619
|
+
const material = new import_three4.SpriteMaterial();
|
|
1886
1620
|
try {
|
|
1887
1621
|
const [base, icon] = labelSymbol;
|
|
1888
1622
|
const { markerWidth: baseWidth = 24 } = base;
|
|
@@ -1891,7 +1625,7 @@ var createSpriteMaterialByLabelSymbol = (labelSymbol = []) => {
|
|
|
1891
1625
|
const baseSVG = createSVGPathFromMarkerSymbol(base);
|
|
1892
1626
|
const iconSVG = createSVGPathFromMarkerSymbol(icon);
|
|
1893
1627
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${viewBoxDimension}" height="${viewBoxDimension}">${baseSVG}${iconSVG}</svg>`;
|
|
1894
|
-
const textureLoader = new
|
|
1628
|
+
const textureLoader = new import_three4.TextureLoader();
|
|
1895
1629
|
const scaleFactor = 200 / 24;
|
|
1896
1630
|
svgToPng(svg, scaleFactor).then((png) => {
|
|
1897
1631
|
const texture = textureLoader.load(png, () => {
|
|
@@ -2048,7 +1782,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2048
1782
|
switch (renderType) {
|
|
2049
1783
|
case "Logo":
|
|
2050
1784
|
import_lodash4.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
2051
|
-
return new
|
|
1785
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2052
1786
|
properties: {
|
|
2053
1787
|
altitude: getAltitude(properties) + markerHeight,
|
|
2054
1788
|
...baseProperties
|
|
@@ -2056,7 +1790,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2056
1790
|
symbol: priorityLabelSymbol
|
|
2057
1791
|
});
|
|
2058
1792
|
case "Logo + Name":
|
|
2059
|
-
return new
|
|
1793
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2060
1794
|
properties: {
|
|
2061
1795
|
name: occupantName.en,
|
|
2062
1796
|
altitude: getAltitude(properties) + markerHeight,
|
|
@@ -2076,7 +1810,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2076
1810
|
}
|
|
2077
1811
|
});
|
|
2078
1812
|
case "None":
|
|
2079
|
-
return new
|
|
1813
|
+
return new import_maptalks4.ui.UIMarker(coordinates, {
|
|
2080
1814
|
properties: { ...baseProperties },
|
|
2081
1815
|
content: createStyledUIMarkerElement({
|
|
2082
1816
|
style: { display: "none" },
|
|
@@ -2087,7 +1821,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2087
1821
|
case "Name":
|
|
2088
1822
|
default:
|
|
2089
1823
|
if (textMarkerType === "marker") {
|
|
2090
|
-
return new
|
|
1824
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2091
1825
|
properties: {
|
|
2092
1826
|
name: occupantName.en,
|
|
2093
1827
|
altitude: getAltitude(properties) + markerHeight,
|
|
@@ -2117,7 +1851,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2117
1851
|
`occupant-${import_lodash4.default.toLower(renderType)}-${renderPriority}`
|
|
2118
1852
|
);
|
|
2119
1853
|
const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol };
|
|
2120
|
-
return new
|
|
1854
|
+
return new import_maptalks4.ui.UIMarker(coordinates, {
|
|
2121
1855
|
properties: { ...baseProperties },
|
|
2122
1856
|
content: createStyledUIMarkerElement({
|
|
2123
1857
|
style,
|
|
@@ -2194,7 +1928,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2194
1928
|
const { geometry, properties } = feature2;
|
|
2195
1929
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2196
1930
|
const markerSymbol = getElementSymbol("pin-marker");
|
|
2197
|
-
return new
|
|
1931
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2198
1932
|
properties: {
|
|
2199
1933
|
altitude: getAltitude(properties)
|
|
2200
1934
|
},
|
|
@@ -2209,7 +1943,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2209
1943
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2210
1944
|
const markerSymbol = getElementSymbol("origin-marker");
|
|
2211
1945
|
try {
|
|
2212
|
-
return new
|
|
1946
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2213
1947
|
properties: {
|
|
2214
1948
|
altitude: getAltitude(properties)
|
|
2215
1949
|
},
|
|
@@ -2231,7 +1965,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2231
1965
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2232
1966
|
const symbol = getElementSymbol("pin-marker");
|
|
2233
1967
|
try {
|
|
2234
|
-
return new
|
|
1968
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2235
1969
|
properties: {
|
|
2236
1970
|
altitude: getAltitude(properties) + markerHeight
|
|
2237
1971
|
},
|
|
@@ -2256,7 +1990,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2256
1990
|
"highlighted-logo-marker"
|
|
2257
1991
|
);
|
|
2258
1992
|
try {
|
|
2259
|
-
return new
|
|
1993
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2260
1994
|
properties: {
|
|
2261
1995
|
altitude: getAltitude(properties) + markerHeight
|
|
2262
1996
|
},
|
|
@@ -2272,7 +2006,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2272
2006
|
const { geometry, properties } = feature2;
|
|
2273
2007
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2274
2008
|
const symbolStyle = getElementSymbol("user-location") || {};
|
|
2275
|
-
const marker = new
|
|
2009
|
+
const marker = new import_maptalks4.Marker(coordinates, {
|
|
2276
2010
|
properties: {
|
|
2277
2011
|
altitude: getAltitude(properties),
|
|
2278
2012
|
ordinal: properties.ordinal !== null ? properties.ordinal : null
|
|
@@ -2301,7 +2035,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2301
2035
|
const coordinates = getCenterFromGeometry(geometry);
|
|
2302
2036
|
const symbolStyle = getElementSymbol("last-user-location") || {};
|
|
2303
2037
|
const options = getElementOptions("last-user-location") || {};
|
|
2304
|
-
const marker = new
|
|
2038
|
+
const marker = new import_maptalks4.Marker(coordinates, {
|
|
2305
2039
|
properties: {
|
|
2306
2040
|
...options,
|
|
2307
2041
|
altitude: getAltitude(properties),
|
|
@@ -2333,14 +2067,14 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2333
2067
|
const coordinates = import_lodash4.default.get(geometry, "coordinates");
|
|
2334
2068
|
const logoUrl = import_lodash4.default.get(properties, "logo.url");
|
|
2335
2069
|
if (markerSymbol) {
|
|
2336
|
-
return new
|
|
2070
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2337
2071
|
properties: markerProperties,
|
|
2338
2072
|
symbol: markerSymbol
|
|
2339
2073
|
});
|
|
2340
2074
|
}
|
|
2341
2075
|
if (!logoUrl) {
|
|
2342
2076
|
const symbol = getElementSymbol("pin-marker");
|
|
2343
|
-
return new
|
|
2077
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2344
2078
|
properties: markerProperties,
|
|
2345
2079
|
symbol
|
|
2346
2080
|
});
|
|
@@ -2348,7 +2082,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2348
2082
|
const labelSymbol = getLabelSymbol("highlight-occupant-logo");
|
|
2349
2083
|
const priorityMarkerSymbol = import_lodash4.default.last(labelSymbol) || {};
|
|
2350
2084
|
import_lodash4.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
2351
|
-
return new
|
|
2085
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2352
2086
|
properties: markerProperties,
|
|
2353
2087
|
symbol: labelSymbol
|
|
2354
2088
|
});
|
|
@@ -2365,7 +2099,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2365
2099
|
const kioskHeight = import_lodash4.default.get(kioskConfig, "height", 0);
|
|
2366
2100
|
const markerHeight = unitHeight + kioskHeight;
|
|
2367
2101
|
const symbol = getElementSymbol("highlight-amenity-marker");
|
|
2368
|
-
return new
|
|
2102
|
+
return new import_maptalks4.Marker(coordinates, {
|
|
2369
2103
|
properties: {
|
|
2370
2104
|
...feature2,
|
|
2371
2105
|
altitude: markerHeight
|
|
@@ -2442,24 +2176,24 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2442
2176
|
switch (geometry.type) {
|
|
2443
2177
|
case "Point":
|
|
2444
2178
|
return [
|
|
2445
|
-
geometry?.getCoordinates ? geometry?.getCoordinates() : new
|
|
2179
|
+
geometry?.getCoordinates ? geometry?.getCoordinates() : new import_maptalks4.Coordinate(geometry.coordinates)
|
|
2446
2180
|
];
|
|
2447
2181
|
case "Polygon":
|
|
2448
2182
|
return [
|
|
2449
|
-
geometry?.getCenter ? geometry?.getCenter() : new
|
|
2183
|
+
geometry?.getCenter ? geometry?.getCenter() : new import_maptalks4.Polygon(geometry.coordinates).getCenter()
|
|
2450
2184
|
];
|
|
2451
2185
|
case "MultiPolygon":
|
|
2452
2186
|
return [
|
|
2453
|
-
geometry?.getCenter ? geometry?.getCenter() : new
|
|
2187
|
+
geometry?.getCenter ? geometry?.getCenter() : new import_maptalks4.MultiPolygon(geometry.coordinates).getCenter()
|
|
2454
2188
|
];
|
|
2455
2189
|
case "LineString":
|
|
2456
2190
|
default:
|
|
2457
|
-
return geometry?.getCoordinates ? geometry?.getCoordinates() : new
|
|
2191
|
+
return geometry?.getCoordinates ? geometry?.getCoordinates() : new import_maptalks4.LineString(geometry.coordinates).getCoordinates();
|
|
2458
2192
|
}
|
|
2459
2193
|
}).flatten().value();
|
|
2460
2194
|
const stepPathLineSymbol = getElementSymbol("navigation-path");
|
|
2461
2195
|
const startPathSymbolMarker = getElementSymbol("navigation-path-start");
|
|
2462
|
-
const line = new
|
|
2196
|
+
const line = new import_maptalks4.LineString(mergedCoordinates, {
|
|
2463
2197
|
smoothness: 0.5,
|
|
2464
2198
|
symbol: [...stepPathLineSymbol, startPathSymbolMarker]
|
|
2465
2199
|
});
|
|
@@ -2500,13 +2234,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2500
2234
|
};
|
|
2501
2235
|
switch (type) {
|
|
2502
2236
|
case "Polygon":
|
|
2503
|
-
return new
|
|
2237
|
+
return new import_maptalks4.Polygon(coordinates, formattedProperties);
|
|
2504
2238
|
case "MultiPolygon":
|
|
2505
|
-
return new
|
|
2239
|
+
return new import_maptalks4.MultiPolygon(coordinates, formattedProperties);
|
|
2506
2240
|
case "LineString":
|
|
2507
|
-
return new
|
|
2241
|
+
return new import_maptalks4.LineString(coordinates, formattedProperties);
|
|
2508
2242
|
case "MultiLineString":
|
|
2509
|
-
return new
|
|
2243
|
+
return new import_maptalks4.MultiLineString(coordinates, formattedProperties);
|
|
2510
2244
|
default:
|
|
2511
2245
|
return null;
|
|
2512
2246
|
}
|
|
@@ -2531,7 +2265,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2531
2265
|
} else {
|
|
2532
2266
|
const color = footprintProperties.defaultColor;
|
|
2533
2267
|
if (color === "transparent") return;
|
|
2534
|
-
const material = new
|
|
2268
|
+
const material = new import_three4.MeshLambertMaterial({
|
|
2535
2269
|
color,
|
|
2536
2270
|
transparent: true
|
|
2537
2271
|
});
|
|
@@ -2547,68 +2281,12 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2547
2281
|
}
|
|
2548
2282
|
return objects;
|
|
2549
2283
|
},
|
|
2550
|
-
create3DGroundLabel: (label, threeLayer) => {
|
|
2551
|
-
const text = label.properties.name;
|
|
2552
|
-
const bound = label.geometry.coordinates[0];
|
|
2553
|
-
if (import_lodash4.default.isNil(bound)) throw new Error("Invalid coordinates");
|
|
2554
|
-
const groundLabelSymbol = getElementSymbol("ground-label");
|
|
2555
|
-
const featureSymbol = import_lodash4.default.get(label, "properties", {});
|
|
2556
|
-
const groundLabelOptions = import_lodash4.default.merge(
|
|
2557
|
-
{},
|
|
2558
|
-
{ text },
|
|
2559
|
-
groundLabelSymbol,
|
|
2560
|
-
featureSymbol
|
|
2561
|
-
);
|
|
2562
|
-
return new GroundLabel(bound, groundLabelOptions, threeLayer);
|
|
2563
|
-
},
|
|
2564
|
-
createOccupantGroundLabel: (feature2, location, mapConfig, threeLayer) => {
|
|
2565
|
-
const text = feature2.properties.name.en;
|
|
2566
|
-
const bound = location.geometry.coordinates[0];
|
|
2567
|
-
if (import_lodash4.default.isNil(bound)) throw new Error("Invalid coordinates");
|
|
2568
|
-
const groundLabelSymbol = getElementSymbol("occupant-flat-label");
|
|
2569
|
-
const groundLabelOptions = getElementOptions("occupant-flat-label");
|
|
2570
|
-
const baseAltitude = getAltitude(location.properties);
|
|
2571
|
-
const extrudeHeight = import_lodash4.default.get(
|
|
2572
|
-
mapConfig,
|
|
2573
|
-
"extrudeConfig.unit.room.height",
|
|
2574
|
-
0
|
|
2575
|
-
);
|
|
2576
|
-
const totalAltitude = baseAltitude + extrudeHeight + 0.05;
|
|
2577
|
-
const customAngle = import_lodash4.default.get(feature2, "properties.style.angle");
|
|
2578
|
-
const offsetX = import_lodash4.default.get(feature2, "properties.style.offsetX", 0);
|
|
2579
|
-
const offsetY = import_lodash4.default.get(feature2, "properties.style.offsetY", 0);
|
|
2580
|
-
const featureSymbol = {
|
|
2581
|
-
name: text,
|
|
2582
|
-
ordinal: location.properties.ordinal,
|
|
2583
|
-
venue_id: feature2.properties.venue_id
|
|
2584
|
-
};
|
|
2585
|
-
const mergedGroundLabelOptions = import_lodash4.default.merge(
|
|
2586
|
-
{},
|
|
2587
|
-
{ text },
|
|
2588
|
-
groundLabelSymbol,
|
|
2589
|
-
groundLabelOptions,
|
|
2590
|
-
featureSymbol,
|
|
2591
|
-
{
|
|
2592
|
-
altitude: totalAltitude,
|
|
2593
|
-
offsetX,
|
|
2594
|
-
offsetY,
|
|
2595
|
-
// set custom angle
|
|
2596
|
-
...!import_lodash4.default.isNil(customAngle) ? { angle: customAngle } : {}
|
|
2597
|
-
}
|
|
2598
|
-
);
|
|
2599
|
-
const groundLabel = new GroundLabel(
|
|
2600
|
-
bound,
|
|
2601
|
-
mergedGroundLabelOptions,
|
|
2602
|
-
threeLayer
|
|
2603
|
-
);
|
|
2604
|
-
return groundLabel;
|
|
2605
|
-
},
|
|
2606
2284
|
create3DBillboard: (billboard, threeLayer) => {
|
|
2607
2285
|
const { id, feature_type, properties } = billboard;
|
|
2608
2286
|
const {
|
|
2609
2287
|
logo,
|
|
2610
2288
|
altitude,
|
|
2611
|
-
scale:
|
|
2289
|
+
scale: scale3,
|
|
2612
2290
|
alphaTest,
|
|
2613
2291
|
legColor,
|
|
2614
2292
|
showLeg,
|
|
@@ -2622,7 +2300,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2622
2300
|
};
|
|
2623
2301
|
const options = {
|
|
2624
2302
|
altitude,
|
|
2625
|
-
scale:
|
|
2303
|
+
scale: scale3,
|
|
2626
2304
|
alphaTest,
|
|
2627
2305
|
legColor,
|
|
2628
2306
|
showLeg,
|
|
@@ -2756,15 +2434,15 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2756
2434
|
};
|
|
2757
2435
|
const color = unitProperty.defaultColor;
|
|
2758
2436
|
if (color === "transparent") return;
|
|
2759
|
-
const material = new
|
|
2437
|
+
const material = new import_three4.MeshLambertMaterial({
|
|
2760
2438
|
color,
|
|
2761
2439
|
transparent: true
|
|
2762
2440
|
});
|
|
2763
2441
|
if (unit.geometry.type === "LineString") {
|
|
2764
|
-
const
|
|
2442
|
+
const polygon2 = createPolygonFromLineString(unit.geometry);
|
|
2765
2443
|
const geometry = {
|
|
2766
2444
|
type: "Polygon",
|
|
2767
|
-
coordinates:
|
|
2445
|
+
coordinates: polygon2
|
|
2768
2446
|
};
|
|
2769
2447
|
return createExtrudePolygon(
|
|
2770
2448
|
geometry,
|
|
@@ -2866,9 +2544,9 @@ var getRelatedLocationsByAmenity = (feature2) => {
|
|
|
2866
2544
|
var getRelatedLocationIdsByFeature = (feature2) => {
|
|
2867
2545
|
switch (feature2?.feature_type) {
|
|
2868
2546
|
case "amenity":
|
|
2869
|
-
return getRelatedLocationsByAmenity(feature2).map((
|
|
2547
|
+
return getRelatedLocationsByAmenity(feature2).map((v2) => v2?.id);
|
|
2870
2548
|
case "occupant":
|
|
2871
|
-
return getRelatedLocationsByOccupant(feature2).map((
|
|
2549
|
+
return getRelatedLocationsByOccupant(feature2).map((v2) => v2?.id);
|
|
2872
2550
|
default:
|
|
2873
2551
|
return [];
|
|
2874
2552
|
}
|
|
@@ -2914,7 +2592,7 @@ var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
|
|
|
2914
2592
|
};
|
|
2915
2593
|
|
|
2916
2594
|
// src/IndoorMap/camera/CameraManager.ts
|
|
2917
|
-
var
|
|
2595
|
+
var import_maptalks5 = require("maptalks");
|
|
2918
2596
|
|
|
2919
2597
|
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
2920
2598
|
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
@@ -3012,108 +2690,406 @@ function coordEach(geojson, callback, excludeWrapCoord) {
|
|
|
3012
2690
|
}
|
|
3013
2691
|
}
|
|
3014
2692
|
}
|
|
3015
|
-
}
|
|
3016
|
-
|
|
3017
|
-
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
3018
|
-
function bbox(geojson, options = {}) {
|
|
3019
|
-
if (geojson.bbox != null && true !== options.recompute) {
|
|
3020
|
-
return geojson.bbox;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
2696
|
+
function bbox(geojson, options = {}) {
|
|
2697
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
2698
|
+
return geojson.bbox;
|
|
2699
|
+
}
|
|
2700
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
2701
|
+
coordEach(geojson, (coord) => {
|
|
2702
|
+
if (result[0] > coord[0]) {
|
|
2703
|
+
result[0] = coord[0];
|
|
2704
|
+
}
|
|
2705
|
+
if (result[1] > coord[1]) {
|
|
2706
|
+
result[1] = coord[1];
|
|
2707
|
+
}
|
|
2708
|
+
if (result[2] < coord[0]) {
|
|
2709
|
+
result[2] = coord[0];
|
|
2710
|
+
}
|
|
2711
|
+
if (result[3] < coord[1]) {
|
|
2712
|
+
result[3] = coord[1];
|
|
2713
|
+
}
|
|
2714
|
+
});
|
|
2715
|
+
return result;
|
|
2716
|
+
}
|
|
2717
|
+
var index_default = bbox;
|
|
2718
|
+
|
|
2719
|
+
// src/IndoorMap/camera/CameraManager.ts
|
|
2720
|
+
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
2721
|
+
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
2722
|
+
var CameraManager = class {
|
|
2723
|
+
map;
|
|
2724
|
+
constructor(map, options) {
|
|
2725
|
+
this.map = map;
|
|
2726
|
+
if (options?.defaultView) {
|
|
2727
|
+
this.setView(options?.defaultView);
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
/** Public methods */
|
|
2731
|
+
getView = () => {
|
|
2732
|
+
return this.map.getView();
|
|
2733
|
+
};
|
|
2734
|
+
setView = (value) => {
|
|
2735
|
+
if (this.map && Object.keys(value).length !== 0) {
|
|
2736
|
+
this.map.setView(value);
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
animateTo = (view, options = {}, step) => {
|
|
2740
|
+
this.map.animateTo(view, options, step);
|
|
2741
|
+
};
|
|
2742
|
+
setMaxExtent(extent) {
|
|
2743
|
+
return this.map.setMaxExtent(extent);
|
|
2744
|
+
}
|
|
2745
|
+
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
2746
|
+
const [minX, minY, maxX, maxY] = index_default(
|
|
2747
|
+
(0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
|
|
2748
|
+
);
|
|
2749
|
+
return new import_maptalks5.Extent(minX, minY, maxX, maxY);
|
|
2750
|
+
};
|
|
2751
|
+
getExtentZoom = (extent, options = {
|
|
2752
|
+
isFraction: false,
|
|
2753
|
+
padding: {
|
|
2754
|
+
paddingLeft: 0,
|
|
2755
|
+
paddingRight: 0,
|
|
2756
|
+
paddingTop: 0,
|
|
2757
|
+
paddingBottom: 0
|
|
2758
|
+
}
|
|
2759
|
+
}) => {
|
|
2760
|
+
const { isFraction = false, padding } = options;
|
|
2761
|
+
return this.map.getFitZoom(extent, isFraction, padding);
|
|
2762
|
+
};
|
|
2763
|
+
set maxZoom(value) {
|
|
2764
|
+
this.map.setMaxZoom(value);
|
|
2765
|
+
const spatialReference = {
|
|
2766
|
+
projection: "EPSG:3857",
|
|
2767
|
+
resolutions: (function() {
|
|
2768
|
+
const resolutions = [];
|
|
2769
|
+
const d = 2 * 6378137 * Math.PI;
|
|
2770
|
+
for (let i = 0; i < value; i++) {
|
|
2771
|
+
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
2772
|
+
}
|
|
2773
|
+
return resolutions;
|
|
2774
|
+
})()
|
|
2775
|
+
};
|
|
2776
|
+
this.map.setSpatialReference(spatialReference);
|
|
2777
|
+
}
|
|
2778
|
+
set minZoom(value) {
|
|
2779
|
+
this.map.setMinZoom(value);
|
|
2780
|
+
}
|
|
2781
|
+
};
|
|
2782
|
+
|
|
2783
|
+
// src/IndoorMap/renderer/RendererManager.ts
|
|
2784
|
+
var import_isFunction = __toESM(require("lodash/isFunction"));
|
|
2785
|
+
var import_min = __toESM(require("lodash/min"));
|
|
2786
|
+
var import_center3 = require("@turf/center");
|
|
2787
|
+
var THREE3 = __toESM(require("three"));
|
|
2788
|
+
|
|
2789
|
+
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
2790
|
+
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
2791
|
+
var THREE = __toESM(require("three"));
|
|
2792
|
+
var import_maptalks7 = require("maptalks.three");
|
|
2793
|
+
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
2794
|
+
|
|
2795
|
+
// src/IndoorMap/renderer/3d/objects/GroundLabel.ts
|
|
2796
|
+
var maptalks3 = __toESM(require("maptalks-gl"));
|
|
2797
|
+
var import_maptalks6 = require("maptalks.three");
|
|
2798
|
+
var import_three5 = require("three");
|
|
2799
|
+
var import_d3plus_shape = require("d3plus-shape");
|
|
2800
|
+
var import_lodash_es = require("lodash-es");
|
|
2801
|
+
var OPTIONS3 = {
|
|
2802
|
+
// Allowing click through and prevent interaction
|
|
2803
|
+
interactive: false,
|
|
2804
|
+
altitude: 0
|
|
2805
|
+
};
|
|
2806
|
+
var defaultFlatLabelOptions = {
|
|
2807
|
+
fontSize: 14,
|
|
2808
|
+
fontFamily: "Manrope",
|
|
2809
|
+
fontWeight: 600,
|
|
2810
|
+
margin: 0,
|
|
2811
|
+
scaleMin: 0.5,
|
|
2812
|
+
lineHeight: 1.05,
|
|
2813
|
+
scaleStep: 0.05,
|
|
2814
|
+
textAlign: "center",
|
|
2815
|
+
textBaseline: "middle",
|
|
2816
|
+
fillStyle: "#000"
|
|
2817
|
+
};
|
|
2818
|
+
var defaultRectAngleToCalc = (0, import_lodash_es.range)(-90, 92, 2);
|
|
2819
|
+
var getMaterial = (text, flatLabelOptions) => {
|
|
2820
|
+
const options = (0, import_lodash_es.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
|
|
2821
|
+
const {
|
|
2822
|
+
fontSize: initialFontSize,
|
|
2823
|
+
fontFamily,
|
|
2824
|
+
fontWeight,
|
|
2825
|
+
margin,
|
|
2826
|
+
scaleMin,
|
|
2827
|
+
scaleStep,
|
|
2828
|
+
fillStyle,
|
|
2829
|
+
lineHeight,
|
|
2830
|
+
textAlign,
|
|
2831
|
+
strokeStyle,
|
|
2832
|
+
lineWidth,
|
|
2833
|
+
textBaseline
|
|
2834
|
+
} = options;
|
|
2835
|
+
const pixelMultiplier = 4;
|
|
2836
|
+
const SIZE = 100 * pixelMultiplier;
|
|
2837
|
+
const fontSize = initialFontSize * (pixelMultiplier * 1.25);
|
|
2838
|
+
const canvas = document.createElement("canvas");
|
|
2839
|
+
canvas.width = canvas.height = SIZE;
|
|
2840
|
+
const ctx = canvas.getContext("2d");
|
|
2841
|
+
ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", Arial`;
|
|
2842
|
+
ctx.textAlign = textAlign;
|
|
2843
|
+
ctx.textBaseline = textBaseline;
|
|
2844
|
+
ctx.fillStyle = fillStyle;
|
|
2845
|
+
ctx.strokeStyle = strokeStyle;
|
|
2846
|
+
ctx.lineWidth = lineWidth;
|
|
2847
|
+
const wrapText = (ctx2, text2, maxWidth) => {
|
|
2848
|
+
const words = text2.trim().split(/\s+/);
|
|
2849
|
+
if (words.length <= 1) return [text2];
|
|
2850
|
+
const lines = [];
|
|
2851
|
+
const MAX_LINES = 3;
|
|
2852
|
+
let currentLine = words[0];
|
|
2853
|
+
for (let i = 1; i < words.length; i++) {
|
|
2854
|
+
const lineToMeasure = currentLine + " " + words[i];
|
|
2855
|
+
if (ctx2.measureText(lineToMeasure).width > maxWidth) {
|
|
2856
|
+
lines.push(currentLine);
|
|
2857
|
+
currentLine = words[i];
|
|
2858
|
+
} else {
|
|
2859
|
+
currentLine = lineToMeasure;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
lines.push(currentLine);
|
|
2863
|
+
return lines.slice(0, MAX_LINES);
|
|
2864
|
+
};
|
|
2865
|
+
const hasManualBreaks = text.includes("\n");
|
|
2866
|
+
let texts;
|
|
2867
|
+
if (hasManualBreaks) {
|
|
2868
|
+
texts = text.split(/\n/g);
|
|
2869
|
+
} else {
|
|
2870
|
+
const maxWidth = SIZE - 2 * margin;
|
|
2871
|
+
texts = wrapText(ctx, text, maxWidth);
|
|
2872
|
+
}
|
|
2873
|
+
let textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
2874
|
+
let scale3 = 1;
|
|
2875
|
+
while (scale3 > 0 && textWidth + 2 * margin > SIZE) {
|
|
2876
|
+
scale3 -= scaleStep;
|
|
2877
|
+
ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
|
|
2878
|
+
textWidth = (0, import_lodash_es.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
2879
|
+
}
|
|
2880
|
+
const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
|
|
2881
|
+
if (scale3 > scaleMin) {
|
|
2882
|
+
const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
|
|
2883
|
+
const startY = center2.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
|
|
2884
|
+
texts.forEach((text2, index) => {
|
|
2885
|
+
const yOffset = startY + index * (fontSize * scale3 * lineHeight);
|
|
2886
|
+
if (strokeStyle && lineWidth) {
|
|
2887
|
+
ctx.strokeText(text2, center2.x, yOffset);
|
|
2888
|
+
}
|
|
2889
|
+
ctx.fillText(text2, center2.x, yOffset);
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
const texture = new import_three5.Texture(canvas);
|
|
2893
|
+
texture.needsUpdate = true;
|
|
2894
|
+
const material = new import_three5.MeshPhongMaterial({
|
|
2895
|
+
map: texture,
|
|
2896
|
+
transparent: true,
|
|
2897
|
+
// @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest
|
|
2898
|
+
alphaTest: 0.3
|
|
2899
|
+
});
|
|
2900
|
+
return material;
|
|
2901
|
+
};
|
|
2902
|
+
var GroundLabel = class extends import_maptalks6.BaseObject {
|
|
2903
|
+
#angle = 0;
|
|
2904
|
+
#bearing = 0;
|
|
2905
|
+
#text = "";
|
|
2906
|
+
#offsetX = 0;
|
|
2907
|
+
#offsetY = 0;
|
|
2908
|
+
#originalPosition = null;
|
|
2909
|
+
#layer = null;
|
|
2910
|
+
constructor(bound, text, options, layer) {
|
|
2911
|
+
options = maptalks3.Util.extend({}, OPTIONS3, options, {
|
|
2912
|
+
layer,
|
|
2913
|
+
coordinate: bound
|
|
2914
|
+
});
|
|
2915
|
+
const {
|
|
2916
|
+
altitude = 0,
|
|
2917
|
+
bottomHeight = 0,
|
|
2918
|
+
fontSize,
|
|
2919
|
+
fillStyle,
|
|
2920
|
+
textAlign,
|
|
2921
|
+
fontFamily,
|
|
2922
|
+
textBaseline,
|
|
2923
|
+
strokeStyle,
|
|
2924
|
+
lineWidth,
|
|
2925
|
+
angle = defaultRectAngleToCalc,
|
|
2926
|
+
maxFontScale,
|
|
2927
|
+
offsetX = 0,
|
|
2928
|
+
offsetY = 0,
|
|
2929
|
+
...properties
|
|
2930
|
+
} = options;
|
|
2931
|
+
super();
|
|
2932
|
+
this._initOptions(options);
|
|
2933
|
+
this.properties = properties;
|
|
2934
|
+
this.#offsetX = offsetX;
|
|
2935
|
+
this.#offsetY = offsetY;
|
|
2936
|
+
this.#layer = layer;
|
|
2937
|
+
const material = getMaterial(text, {
|
|
2938
|
+
fillStyle,
|
|
2939
|
+
fontSize,
|
|
2940
|
+
textAlign,
|
|
2941
|
+
textBaseline,
|
|
2942
|
+
fontFamily,
|
|
2943
|
+
strokeStyle,
|
|
2944
|
+
lineWidth
|
|
2945
|
+
});
|
|
2946
|
+
const rectAngles = (0, import_lodash_es.isArray)(angle) ? angle : [angle];
|
|
2947
|
+
material.needsUpdate = true;
|
|
2948
|
+
const rect = (0, import_d3plus_shape.largestRect)(bound, {
|
|
2949
|
+
cache: true,
|
|
2950
|
+
/**
|
|
2951
|
+
* Black magic here:
|
|
2952
|
+
* For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.
|
|
2953
|
+
* So we remove -90 and 90 from choices, and use -85 & 85 instead.
|
|
2954
|
+
*/
|
|
2955
|
+
angle: rectAngles
|
|
2956
|
+
});
|
|
2957
|
+
const { cx, cy, width, angle: calculatedAngle } = rect;
|
|
2958
|
+
this.#text = text;
|
|
2959
|
+
this.#angle = calculatedAngle;
|
|
2960
|
+
const geometry = new import_three5.PlaneGeometry(1, 1);
|
|
2961
|
+
this._createMesh(geometry, material);
|
|
2962
|
+
const z = layer.altitudeToVector3(altitude + bottomHeight, altitude + bottomHeight).x;
|
|
2963
|
+
const basePosition = layer.coordinateToVector3([cx, cy], z);
|
|
2964
|
+
this.#originalPosition = basePosition.clone();
|
|
2965
|
+
const finalPosition = this.#calculateFinalPosition(basePosition);
|
|
2966
|
+
const scale3 = width / 6456122659e-13;
|
|
2967
|
+
const finalScale = maxFontScale && scale3 > maxFontScale ? maxFontScale : scale3;
|
|
2968
|
+
this.getObject3d().scale.set(finalScale, finalScale, finalScale);
|
|
2969
|
+
this.getObject3d().position.copy(finalPosition);
|
|
2970
|
+
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
2971
|
+
}
|
|
2972
|
+
#calculateFinalPosition(basePosition) {
|
|
2973
|
+
if (this.#offsetX === 0 && this.#offsetY === 0) {
|
|
2974
|
+
return basePosition;
|
|
2975
|
+
}
|
|
2976
|
+
const offsetCoordinate = [this.#offsetX, this.#offsetY];
|
|
2977
|
+
const z = this.#layer.altitudeToVector3(0, 0).x;
|
|
2978
|
+
const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z);
|
|
2979
|
+
const zeroVector = this.#layer.coordinateToVector3([0, 0], z);
|
|
2980
|
+
const worldOffsetX = offsetVector.x - zeroVector.x;
|
|
2981
|
+
const worldOffsetY = offsetVector.y - zeroVector.y;
|
|
2982
|
+
return {
|
|
2983
|
+
x: basePosition.x + worldOffsetX,
|
|
2984
|
+
y: basePosition.y + worldOffsetY,
|
|
2985
|
+
z: basePosition.z
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2988
|
+
#updatePosition() {
|
|
2989
|
+
if (this.#originalPosition && this.#layer) {
|
|
2990
|
+
const finalPosition = this.#calculateFinalPosition(this.#originalPosition);
|
|
2991
|
+
this.getObject3d().position.copy(finalPosition);
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
set bearing(value) {
|
|
2995
|
+
this.#bearing = value;
|
|
2996
|
+
const degree = this.#angle + this.#bearing;
|
|
2997
|
+
const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle;
|
|
2998
|
+
this.getObject3d().rotation.z = Math.PI / 180 * angle;
|
|
2999
|
+
}
|
|
3000
|
+
get angle() {
|
|
3001
|
+
return this.#angle;
|
|
3002
|
+
}
|
|
3003
|
+
get currentAngle() {
|
|
3004
|
+
return this.#angle;
|
|
3021
3005
|
}
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3006
|
+
get text() {
|
|
3007
|
+
return this.#text;
|
|
3008
|
+
}
|
|
3009
|
+
get offsetX() {
|
|
3010
|
+
return this.#offsetX;
|
|
3011
|
+
}
|
|
3012
|
+
get offsetY() {
|
|
3013
|
+
return this.#offsetY;
|
|
3014
|
+
}
|
|
3015
|
+
get offset() {
|
|
3016
|
+
return { x: this.#offsetX, y: this.#offsetY };
|
|
3017
|
+
}
|
|
3018
|
+
set offsetX(value) {
|
|
3019
|
+
if ((0, import_lodash_es.isNumber)(value)) {
|
|
3020
|
+
this.#offsetX = value;
|
|
3021
|
+
this.#updatePosition();
|
|
3029
3022
|
}
|
|
3030
|
-
|
|
3031
|
-
|
|
3023
|
+
}
|
|
3024
|
+
set offsetY(value) {
|
|
3025
|
+
if ((0, import_lodash_es.isNumber)(value)) {
|
|
3026
|
+
this.#offsetY = value;
|
|
3027
|
+
this.#updatePosition();
|
|
3032
3028
|
}
|
|
3033
|
-
|
|
3034
|
-
|
|
3029
|
+
}
|
|
3030
|
+
set angle(newAngle) {
|
|
3031
|
+
if ((0, import_lodash_es.isNumber)(newAngle)) {
|
|
3032
|
+
this.#angle = newAngle;
|
|
3033
|
+
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
3035
3034
|
}
|
|
3036
|
-
}
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
3043
|
-
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
3044
|
-
var CameraManager = class {
|
|
3045
|
-
map;
|
|
3046
|
-
constructor(map, options) {
|
|
3047
|
-
this.map = map;
|
|
3048
|
-
if (options?.defaultView) {
|
|
3049
|
-
this.setView(options?.defaultView);
|
|
3035
|
+
}
|
|
3036
|
+
setOffset(offsetX, offsetY) {
|
|
3037
|
+
if ((0, import_lodash_es.isNumber)(offsetX) && (0, import_lodash_es.isNumber)(offsetY)) {
|
|
3038
|
+
this.#offsetX = offsetX;
|
|
3039
|
+
this.#offsetY = offsetY;
|
|
3040
|
+
this.#updatePosition();
|
|
3050
3041
|
}
|
|
3051
3042
|
}
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
if (this.map && Object.keys(value).length !== 0) {
|
|
3058
|
-
this.map.setView(value);
|
|
3043
|
+
addOffset(deltaX, deltaY) {
|
|
3044
|
+
if ((0, import_lodash_es.isNumber)(deltaX) && (0, import_lodash_es.isNumber)(deltaY)) {
|
|
3045
|
+
this.#offsetX += deltaX;
|
|
3046
|
+
this.#offsetY += deltaY;
|
|
3047
|
+
this.#updatePosition();
|
|
3059
3048
|
}
|
|
3060
|
-
};
|
|
3061
|
-
animateTo = (view, options = {}, step) => {
|
|
3062
|
-
this.map.animateTo(view, options, step);
|
|
3063
|
-
};
|
|
3064
|
-
setMaxExtent(extent) {
|
|
3065
|
-
return this.map.setMaxExtent(extent);
|
|
3066
3049
|
}
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
);
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3050
|
+
resetOffset() {
|
|
3051
|
+
this.#offsetX = 0;
|
|
3052
|
+
this.#offsetY = 0;
|
|
3053
|
+
this.#updatePosition();
|
|
3054
|
+
}
|
|
3055
|
+
moveToPosition(targetX, targetY) {
|
|
3056
|
+
if (this.#originalPosition && this.#layer) {
|
|
3057
|
+
const currentCenter = this.#layer.vector3ToCoordinate(
|
|
3058
|
+
this.#originalPosition
|
|
3059
|
+
);
|
|
3060
|
+
this.#offsetX = targetX - currentCenter.x;
|
|
3061
|
+
this.#offsetY = targetY - currentCenter.y;
|
|
3062
|
+
this.#updatePosition();
|
|
3080
3063
|
}
|
|
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
|
-
})()
|
|
3064
|
+
}
|
|
3065
|
+
updateText(newText, options = {}) {
|
|
3066
|
+
this.#text = newText;
|
|
3067
|
+
const materialOptions = {
|
|
3068
|
+
fillStyle: options.fillStyle || this.properties.fillStyle,
|
|
3069
|
+
fontSize: options.fontSize || this.properties.fontSize,
|
|
3070
|
+
textAlign: options.textAlign || this.properties.textAlign,
|
|
3071
|
+
textBaseline: options.textBaseline || this.properties.textBaseline,
|
|
3072
|
+
fontFamily: options.fontFamily || this.properties.fontFamily,
|
|
3073
|
+
strokeStyle: options.strokeStyle || this.properties.strokeStyle,
|
|
3074
|
+
lineWidth: options.lineWidth || this.properties.lineWidth
|
|
3097
3075
|
};
|
|
3098
|
-
|
|
3076
|
+
const newMaterial = getMaterial(newText, materialOptions);
|
|
3077
|
+
this.getObject3d().material = newMaterial;
|
|
3078
|
+
newMaterial.needsUpdate = true;
|
|
3099
3079
|
}
|
|
3100
|
-
|
|
3101
|
-
this.
|
|
3080
|
+
_animation() {
|
|
3081
|
+
const map = this.getMap();
|
|
3082
|
+
if (!map) return;
|
|
3083
|
+
const bearing = map.getBearing();
|
|
3084
|
+
this.bearing = bearing;
|
|
3085
|
+
}
|
|
3086
|
+
// Add bottomHeight to altitude as final altitude position
|
|
3087
|
+
setAltitude(altitude) {
|
|
3088
|
+
const bottomHeight = this.options.bottomHeight ?? 0;
|
|
3089
|
+
return super.setAltitude(altitude + bottomHeight);
|
|
3102
3090
|
}
|
|
3103
3091
|
};
|
|
3104
3092
|
|
|
3105
|
-
// src/IndoorMap/renderer/RendererManager.ts
|
|
3106
|
-
var import_isFunction = __toESM(require("lodash/isFunction"));
|
|
3107
|
-
var import_min = __toESM(require("lodash/min"));
|
|
3108
|
-
var import_center3 = require("@turf/center");
|
|
3109
|
-
var THREE3 = __toESM(require("three"));
|
|
3110
|
-
|
|
3111
|
-
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3112
|
-
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
3113
|
-
var THREE = __toESM(require("three"));
|
|
3114
|
-
var import_maptalks7 = require("maptalks.three");
|
|
3115
|
-
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
3116
|
-
|
|
3117
3093
|
// src/IndoorMap/renderer/3d/element3DRendererOptions.ts
|
|
3118
3094
|
var element3DRendererOptions = {
|
|
3119
3095
|
unit: {
|
|
@@ -3141,30 +3117,30 @@ var element3DRendererOptions = {
|
|
|
3141
3117
|
}
|
|
3142
3118
|
};
|
|
3143
3119
|
|
|
3144
|
-
// src/IndoorMap/renderer/3d/
|
|
3120
|
+
// src/IndoorMap/renderer/3d/utils/get3DRendererOption.ts
|
|
3145
3121
|
var DEFAULT_POLYGON_OPTION = {
|
|
3146
3122
|
color: "#FFFFFF",
|
|
3147
3123
|
offset: 0,
|
|
3148
3124
|
altitude: 0
|
|
3149
3125
|
};
|
|
3150
|
-
var
|
|
3151
|
-
var MULTIORDINAL_HEIGHT_METER = 9;
|
|
3152
|
-
var getGeometryOption = (feature2, options) => {
|
|
3126
|
+
var get3DRendererOption = (featureType, category, options) => {
|
|
3153
3127
|
try {
|
|
3154
|
-
const option = options[
|
|
3155
|
-
const category = feature2.properties.category;
|
|
3128
|
+
const option = options[featureType] ?? element3DRendererOptions[featureType];
|
|
3156
3129
|
return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION;
|
|
3157
3130
|
} catch (err) {
|
|
3158
|
-
console.log(err.message, { options,
|
|
3131
|
+
console.log(err.message, { options, featureType, category });
|
|
3159
3132
|
}
|
|
3160
3133
|
};
|
|
3134
|
+
|
|
3135
|
+
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3136
|
+
var HEIGHT_METER = 4;
|
|
3137
|
+
var MULTIORDINAL_HEIGHT_METER = 9;
|
|
3161
3138
|
var Element3DRenderer = class extends EventTarget {
|
|
3162
3139
|
options;
|
|
3163
3140
|
map;
|
|
3164
3141
|
gltfLayer;
|
|
3165
3142
|
threeLayer;
|
|
3166
3143
|
scene;
|
|
3167
|
-
// private dracoLoader: DRACOLoader
|
|
3168
3144
|
lineMaterial;
|
|
3169
3145
|
materialByColorMap;
|
|
3170
3146
|
// Renderer is Ready
|
|
@@ -3203,7 +3179,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3203
3179
|
bottomHeight: bottomHeightOptions,
|
|
3204
3180
|
color: colorOptions,
|
|
3205
3181
|
...options
|
|
3206
|
-
} =
|
|
3182
|
+
} = get3DRendererOption(feature2.feature_type, feature2.properties.category, this.options);
|
|
3207
3183
|
const _this = this;
|
|
3208
3184
|
const createPolygon = (geometry, feature3) => {
|
|
3209
3185
|
try {
|
|
@@ -3307,6 +3283,16 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3307
3283
|
escalatorMarker.addTo(this.gltfLayer);
|
|
3308
3284
|
return escalatorMarker;
|
|
3309
3285
|
}
|
|
3286
|
+
// Note: Move to another renderer and keep this file on Geometry only?
|
|
3287
|
+
createGroundLabel(f, unit) {
|
|
3288
|
+
const text = f.properties.name;
|
|
3289
|
+
const bound = f.geometry.coordinates[0];
|
|
3290
|
+
const { height: unitHeight } = get3DRendererOption("unit", unit.properties.category, this.options);
|
|
3291
|
+
const options = { bottomHeight: unitHeight + 5e-3 };
|
|
3292
|
+
const groundLabel = new GroundLabel(bound, text, options, this.threeLayer);
|
|
3293
|
+
this.threeLayer.addMesh(groundLabel);
|
|
3294
|
+
return groundLabel;
|
|
3295
|
+
}
|
|
3310
3296
|
async createTree(coordinate, ordinal) {
|
|
3311
3297
|
const treeMarker = new maptalks4.GLTFMarker(coordinate, {
|
|
3312
3298
|
symbol: {
|
|
@@ -3427,7 +3413,7 @@ var getGeometryProperties = (feature2) => ({
|
|
|
3427
3413
|
category: feature2.properties.category,
|
|
3428
3414
|
name: feature2.properties.name?.en
|
|
3429
3415
|
});
|
|
3430
|
-
var
|
|
3416
|
+
var getGeometryOption = (feature2, options) => {
|
|
3431
3417
|
try {
|
|
3432
3418
|
const option = options[feature2.feature_type] ?? element2DRendererOptions[feature2.feature_type];
|
|
3433
3419
|
const category = feature2.properties.category;
|
|
@@ -3454,7 +3440,7 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3454
3440
|
}
|
|
3455
3441
|
createGeometry = (imdfFeature) => {
|
|
3456
3442
|
const feature2 = getGeometryProperties(imdfFeature);
|
|
3457
|
-
const { symbol, ...options } =
|
|
3443
|
+
const { symbol, ...options } = getGeometryOption(imdfFeature, this.options);
|
|
3458
3444
|
const altitude = feature2.properties.ordinal * 10;
|
|
3459
3445
|
const geometry = maptalks5.Geometry.fromJSON({
|
|
3460
3446
|
feature: feature2,
|
|
@@ -3476,6 +3462,11 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3476
3462
|
async createEscalator(f, coordinates) {
|
|
3477
3463
|
return Promise.resolve(null);
|
|
3478
3464
|
}
|
|
3465
|
+
createGroundLabel(f, unit) {
|
|
3466
|
+
const text = f.properties.name;
|
|
3467
|
+
const bound = f.geometry.coordinates[0];
|
|
3468
|
+
return null;
|
|
3469
|
+
}
|
|
3479
3470
|
async createTree(coordinates) {
|
|
3480
3471
|
return Promise.resolve(null);
|
|
3481
3472
|
}
|
|
@@ -3842,6 +3833,479 @@ var angleBetweenLineStrings = (line1, line2) => {
|
|
|
3842
3833
|
return Math.atan2(dy, dx);
|
|
3843
3834
|
};
|
|
3844
3835
|
|
|
3836
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/util.js
|
|
3837
|
+
var epsilon = 11102230246251565e-32;
|
|
3838
|
+
var splitter = 134217729;
|
|
3839
|
+
var resulterrbound = (3 + 8 * epsilon) * epsilon;
|
|
3840
|
+
function sum(elen, e, flen, f, h) {
|
|
3841
|
+
let Q, Qnew, hh, bvirt;
|
|
3842
|
+
let enow = e[0];
|
|
3843
|
+
let fnow = f[0];
|
|
3844
|
+
let eindex = 0;
|
|
3845
|
+
let findex = 0;
|
|
3846
|
+
if (fnow > enow === fnow > -enow) {
|
|
3847
|
+
Q = enow;
|
|
3848
|
+
enow = e[++eindex];
|
|
3849
|
+
} else {
|
|
3850
|
+
Q = fnow;
|
|
3851
|
+
fnow = f[++findex];
|
|
3852
|
+
}
|
|
3853
|
+
let hindex = 0;
|
|
3854
|
+
if (eindex < elen && findex < flen) {
|
|
3855
|
+
if (fnow > enow === fnow > -enow) {
|
|
3856
|
+
Qnew = enow + Q;
|
|
3857
|
+
hh = Q - (Qnew - enow);
|
|
3858
|
+
enow = e[++eindex];
|
|
3859
|
+
} else {
|
|
3860
|
+
Qnew = fnow + Q;
|
|
3861
|
+
hh = Q - (Qnew - fnow);
|
|
3862
|
+
fnow = f[++findex];
|
|
3863
|
+
}
|
|
3864
|
+
Q = Qnew;
|
|
3865
|
+
if (hh !== 0) {
|
|
3866
|
+
h[hindex++] = hh;
|
|
3867
|
+
}
|
|
3868
|
+
while (eindex < elen && findex < flen) {
|
|
3869
|
+
if (fnow > enow === fnow > -enow) {
|
|
3870
|
+
Qnew = Q + enow;
|
|
3871
|
+
bvirt = Qnew - Q;
|
|
3872
|
+
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3873
|
+
enow = e[++eindex];
|
|
3874
|
+
} else {
|
|
3875
|
+
Qnew = Q + fnow;
|
|
3876
|
+
bvirt = Qnew - Q;
|
|
3877
|
+
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3878
|
+
fnow = f[++findex];
|
|
3879
|
+
}
|
|
3880
|
+
Q = Qnew;
|
|
3881
|
+
if (hh !== 0) {
|
|
3882
|
+
h[hindex++] = hh;
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
while (eindex < elen) {
|
|
3887
|
+
Qnew = Q + enow;
|
|
3888
|
+
bvirt = Qnew - Q;
|
|
3889
|
+
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3890
|
+
enow = e[++eindex];
|
|
3891
|
+
Q = Qnew;
|
|
3892
|
+
if (hh !== 0) {
|
|
3893
|
+
h[hindex++] = hh;
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
while (findex < flen) {
|
|
3897
|
+
Qnew = Q + fnow;
|
|
3898
|
+
bvirt = Qnew - Q;
|
|
3899
|
+
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3900
|
+
fnow = f[++findex];
|
|
3901
|
+
Q = Qnew;
|
|
3902
|
+
if (hh !== 0) {
|
|
3903
|
+
h[hindex++] = hh;
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
3906
|
+
if (Q !== 0 || hindex === 0) {
|
|
3907
|
+
h[hindex++] = Q;
|
|
3908
|
+
}
|
|
3909
|
+
return hindex;
|
|
3910
|
+
}
|
|
3911
|
+
function estimate(elen, e) {
|
|
3912
|
+
let Q = e[0];
|
|
3913
|
+
for (let i = 1; i < elen; i++) Q += e[i];
|
|
3914
|
+
return Q;
|
|
3915
|
+
}
|
|
3916
|
+
function vec(n) {
|
|
3917
|
+
return new Float64Array(n);
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3920
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient2d.js
|
|
3921
|
+
var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
|
|
3922
|
+
var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
|
|
3923
|
+
var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
|
|
3924
|
+
var B = vec(4);
|
|
3925
|
+
var C1 = vec(8);
|
|
3926
|
+
var C2 = vec(12);
|
|
3927
|
+
var D = vec(16);
|
|
3928
|
+
var u = vec(4);
|
|
3929
|
+
function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
|
|
3930
|
+
let acxtail, acytail, bcxtail, bcytail;
|
|
3931
|
+
let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u32;
|
|
3932
|
+
const acx = ax - cx;
|
|
3933
|
+
const bcx = bx - cx;
|
|
3934
|
+
const acy = ay - cy;
|
|
3935
|
+
const bcy = by - cy;
|
|
3936
|
+
s1 = acx * bcy;
|
|
3937
|
+
c = splitter * acx;
|
|
3938
|
+
ahi = c - (c - acx);
|
|
3939
|
+
alo = acx - ahi;
|
|
3940
|
+
c = splitter * bcy;
|
|
3941
|
+
bhi = c - (c - bcy);
|
|
3942
|
+
blo = bcy - bhi;
|
|
3943
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3944
|
+
t1 = acy * bcx;
|
|
3945
|
+
c = splitter * acy;
|
|
3946
|
+
ahi = c - (c - acy);
|
|
3947
|
+
alo = acy - ahi;
|
|
3948
|
+
c = splitter * bcx;
|
|
3949
|
+
bhi = c - (c - bcx);
|
|
3950
|
+
blo = bcx - bhi;
|
|
3951
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3952
|
+
_i = s0 - t0;
|
|
3953
|
+
bvirt = s0 - _i;
|
|
3954
|
+
B[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
3955
|
+
_j = s1 + _i;
|
|
3956
|
+
bvirt = _j - s1;
|
|
3957
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
3958
|
+
_i = _0 - t1;
|
|
3959
|
+
bvirt = _0 - _i;
|
|
3960
|
+
B[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
3961
|
+
u32 = _j + _i;
|
|
3962
|
+
bvirt = u32 - _j;
|
|
3963
|
+
B[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
3964
|
+
B[3] = u32;
|
|
3965
|
+
let det = estimate(4, B);
|
|
3966
|
+
let errbound = ccwerrboundB * detsum;
|
|
3967
|
+
if (det >= errbound || -det >= errbound) {
|
|
3968
|
+
return det;
|
|
3969
|
+
}
|
|
3970
|
+
bvirt = ax - acx;
|
|
3971
|
+
acxtail = ax - (acx + bvirt) + (bvirt - cx);
|
|
3972
|
+
bvirt = bx - bcx;
|
|
3973
|
+
bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
|
|
3974
|
+
bvirt = ay - acy;
|
|
3975
|
+
acytail = ay - (acy + bvirt) + (bvirt - cy);
|
|
3976
|
+
bvirt = by - bcy;
|
|
3977
|
+
bcytail = by - (bcy + bvirt) + (bvirt - cy);
|
|
3978
|
+
if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
|
|
3979
|
+
return det;
|
|
3980
|
+
}
|
|
3981
|
+
errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
|
|
3982
|
+
det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
|
|
3983
|
+
if (det >= errbound || -det >= errbound) return det;
|
|
3984
|
+
s1 = acxtail * bcy;
|
|
3985
|
+
c = splitter * acxtail;
|
|
3986
|
+
ahi = c - (c - acxtail);
|
|
3987
|
+
alo = acxtail - ahi;
|
|
3988
|
+
c = splitter * bcy;
|
|
3989
|
+
bhi = c - (c - bcy);
|
|
3990
|
+
blo = bcy - bhi;
|
|
3991
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3992
|
+
t1 = acytail * bcx;
|
|
3993
|
+
c = splitter * acytail;
|
|
3994
|
+
ahi = c - (c - acytail);
|
|
3995
|
+
alo = acytail - ahi;
|
|
3996
|
+
c = splitter * bcx;
|
|
3997
|
+
bhi = c - (c - bcx);
|
|
3998
|
+
blo = bcx - bhi;
|
|
3999
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4000
|
+
_i = s0 - t0;
|
|
4001
|
+
bvirt = s0 - _i;
|
|
4002
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4003
|
+
_j = s1 + _i;
|
|
4004
|
+
bvirt = _j - s1;
|
|
4005
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4006
|
+
_i = _0 - t1;
|
|
4007
|
+
bvirt = _0 - _i;
|
|
4008
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4009
|
+
u32 = _j + _i;
|
|
4010
|
+
bvirt = u32 - _j;
|
|
4011
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4012
|
+
u[3] = u32;
|
|
4013
|
+
const C1len = sum(4, B, 4, u, C1);
|
|
4014
|
+
s1 = acx * bcytail;
|
|
4015
|
+
c = splitter * acx;
|
|
4016
|
+
ahi = c - (c - acx);
|
|
4017
|
+
alo = acx - ahi;
|
|
4018
|
+
c = splitter * bcytail;
|
|
4019
|
+
bhi = c - (c - bcytail);
|
|
4020
|
+
blo = bcytail - bhi;
|
|
4021
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4022
|
+
t1 = acy * bcxtail;
|
|
4023
|
+
c = splitter * acy;
|
|
4024
|
+
ahi = c - (c - acy);
|
|
4025
|
+
alo = acy - ahi;
|
|
4026
|
+
c = splitter * bcxtail;
|
|
4027
|
+
bhi = c - (c - bcxtail);
|
|
4028
|
+
blo = bcxtail - bhi;
|
|
4029
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4030
|
+
_i = s0 - t0;
|
|
4031
|
+
bvirt = s0 - _i;
|
|
4032
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4033
|
+
_j = s1 + _i;
|
|
4034
|
+
bvirt = _j - s1;
|
|
4035
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4036
|
+
_i = _0 - t1;
|
|
4037
|
+
bvirt = _0 - _i;
|
|
4038
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4039
|
+
u32 = _j + _i;
|
|
4040
|
+
bvirt = u32 - _j;
|
|
4041
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4042
|
+
u[3] = u32;
|
|
4043
|
+
const C2len = sum(C1len, C1, 4, u, C2);
|
|
4044
|
+
s1 = acxtail * bcytail;
|
|
4045
|
+
c = splitter * acxtail;
|
|
4046
|
+
ahi = c - (c - acxtail);
|
|
4047
|
+
alo = acxtail - ahi;
|
|
4048
|
+
c = splitter * bcytail;
|
|
4049
|
+
bhi = c - (c - bcytail);
|
|
4050
|
+
blo = bcytail - bhi;
|
|
4051
|
+
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4052
|
+
t1 = acytail * bcxtail;
|
|
4053
|
+
c = splitter * acytail;
|
|
4054
|
+
ahi = c - (c - acytail);
|
|
4055
|
+
alo = acytail - ahi;
|
|
4056
|
+
c = splitter * bcxtail;
|
|
4057
|
+
bhi = c - (c - bcxtail);
|
|
4058
|
+
blo = bcxtail - bhi;
|
|
4059
|
+
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4060
|
+
_i = s0 - t0;
|
|
4061
|
+
bvirt = s0 - _i;
|
|
4062
|
+
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4063
|
+
_j = s1 + _i;
|
|
4064
|
+
bvirt = _j - s1;
|
|
4065
|
+
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4066
|
+
_i = _0 - t1;
|
|
4067
|
+
bvirt = _0 - _i;
|
|
4068
|
+
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4069
|
+
u32 = _j + _i;
|
|
4070
|
+
bvirt = u32 - _j;
|
|
4071
|
+
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4072
|
+
u[3] = u32;
|
|
4073
|
+
const Dlen = sum(C2len, C2, 4, u, D);
|
|
4074
|
+
return D[Dlen - 1];
|
|
4075
|
+
}
|
|
4076
|
+
function orient2d(ax, ay, bx, by, cx, cy) {
|
|
4077
|
+
const detleft = (ay - cy) * (bx - cx);
|
|
4078
|
+
const detright = (ax - cx) * (by - cy);
|
|
4079
|
+
const det = detleft - detright;
|
|
4080
|
+
const detsum = Math.abs(detleft + detright);
|
|
4081
|
+
if (Math.abs(det) >= ccwerrboundA * detsum) return det;
|
|
4082
|
+
return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient3d.js
|
|
4086
|
+
var o3derrboundA = (7 + 56 * epsilon) * epsilon;
|
|
4087
|
+
var o3derrboundB = (3 + 28 * epsilon) * epsilon;
|
|
4088
|
+
var o3derrboundC = (26 + 288 * epsilon) * epsilon * epsilon;
|
|
4089
|
+
var bc = vec(4);
|
|
4090
|
+
var ca = vec(4);
|
|
4091
|
+
var ab = vec(4);
|
|
4092
|
+
var at_b = vec(4);
|
|
4093
|
+
var at_c = vec(4);
|
|
4094
|
+
var bt_c = vec(4);
|
|
4095
|
+
var bt_a = vec(4);
|
|
4096
|
+
var ct_a = vec(4);
|
|
4097
|
+
var ct_b = vec(4);
|
|
4098
|
+
var bct = vec(8);
|
|
4099
|
+
var cat = vec(8);
|
|
4100
|
+
var abt = vec(8);
|
|
4101
|
+
var u2 = vec(4);
|
|
4102
|
+
var _8 = vec(8);
|
|
4103
|
+
var _8b = vec(8);
|
|
4104
|
+
var _16 = vec(8);
|
|
4105
|
+
var _12 = vec(12);
|
|
4106
|
+
var fin = vec(192);
|
|
4107
|
+
var fin2 = vec(192);
|
|
4108
|
+
|
|
4109
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/incircle.js
|
|
4110
|
+
var iccerrboundA = (10 + 96 * epsilon) * epsilon;
|
|
4111
|
+
var iccerrboundB = (4 + 48 * epsilon) * epsilon;
|
|
4112
|
+
var iccerrboundC = (44 + 576 * epsilon) * epsilon * epsilon;
|
|
4113
|
+
var bc2 = vec(4);
|
|
4114
|
+
var ca2 = vec(4);
|
|
4115
|
+
var ab2 = vec(4);
|
|
4116
|
+
var aa = vec(4);
|
|
4117
|
+
var bb = vec(4);
|
|
4118
|
+
var cc = vec(4);
|
|
4119
|
+
var u3 = vec(4);
|
|
4120
|
+
var v = vec(4);
|
|
4121
|
+
var axtbc = vec(8);
|
|
4122
|
+
var aytbc = vec(8);
|
|
4123
|
+
var bxtca = vec(8);
|
|
4124
|
+
var bytca = vec(8);
|
|
4125
|
+
var cxtab = vec(8);
|
|
4126
|
+
var cytab = vec(8);
|
|
4127
|
+
var abt2 = vec(8);
|
|
4128
|
+
var bct2 = vec(8);
|
|
4129
|
+
var cat2 = vec(8);
|
|
4130
|
+
var abtt = vec(4);
|
|
4131
|
+
var bctt = vec(4);
|
|
4132
|
+
var catt = vec(4);
|
|
4133
|
+
var _82 = vec(8);
|
|
4134
|
+
var _162 = vec(16);
|
|
4135
|
+
var _16b = vec(16);
|
|
4136
|
+
var _16c = vec(16);
|
|
4137
|
+
var _32 = vec(32);
|
|
4138
|
+
var _32b = vec(32);
|
|
4139
|
+
var _48 = vec(48);
|
|
4140
|
+
var _64 = vec(64);
|
|
4141
|
+
var fin3 = vec(1152);
|
|
4142
|
+
var fin22 = vec(1152);
|
|
4143
|
+
|
|
4144
|
+
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/insphere.js
|
|
4145
|
+
var isperrboundA = (16 + 224 * epsilon) * epsilon;
|
|
4146
|
+
var isperrboundB = (5 + 72 * epsilon) * epsilon;
|
|
4147
|
+
var isperrboundC = (71 + 1408 * epsilon) * epsilon * epsilon;
|
|
4148
|
+
var ab3 = vec(4);
|
|
4149
|
+
var bc3 = vec(4);
|
|
4150
|
+
var cd = vec(4);
|
|
4151
|
+
var de = vec(4);
|
|
4152
|
+
var ea = vec(4);
|
|
4153
|
+
var ac = vec(4);
|
|
4154
|
+
var bd = vec(4);
|
|
4155
|
+
var ce = vec(4);
|
|
4156
|
+
var da = vec(4);
|
|
4157
|
+
var eb = vec(4);
|
|
4158
|
+
var abc = vec(24);
|
|
4159
|
+
var bcd = vec(24);
|
|
4160
|
+
var cde = vec(24);
|
|
4161
|
+
var dea = vec(24);
|
|
4162
|
+
var eab = vec(24);
|
|
4163
|
+
var abd = vec(24);
|
|
4164
|
+
var bce = vec(24);
|
|
4165
|
+
var cda = vec(24);
|
|
4166
|
+
var deb = vec(24);
|
|
4167
|
+
var eac = vec(24);
|
|
4168
|
+
var adet = vec(1152);
|
|
4169
|
+
var bdet = vec(1152);
|
|
4170
|
+
var cdet = vec(1152);
|
|
4171
|
+
var ddet = vec(1152);
|
|
4172
|
+
var edet = vec(1152);
|
|
4173
|
+
var abdet = vec(2304);
|
|
4174
|
+
var cddet = vec(2304);
|
|
4175
|
+
var cdedet = vec(3456);
|
|
4176
|
+
var deter = vec(5760);
|
|
4177
|
+
var _83 = vec(8);
|
|
4178
|
+
var _8b2 = vec(8);
|
|
4179
|
+
var _8c = vec(8);
|
|
4180
|
+
var _163 = vec(16);
|
|
4181
|
+
var _24 = vec(24);
|
|
4182
|
+
var _482 = vec(48);
|
|
4183
|
+
var _48b = vec(48);
|
|
4184
|
+
var _96 = vec(96);
|
|
4185
|
+
var _192 = vec(192);
|
|
4186
|
+
var _384x = vec(384);
|
|
4187
|
+
var _384y = vec(384);
|
|
4188
|
+
var _384z = vec(384);
|
|
4189
|
+
var _768 = vec(768);
|
|
4190
|
+
var xdet = vec(96);
|
|
4191
|
+
var ydet = vec(96);
|
|
4192
|
+
var zdet = vec(96);
|
|
4193
|
+
var fin4 = vec(1152);
|
|
4194
|
+
|
|
4195
|
+
// ../../node_modules/point-in-polygon-hao/dist/esm/index.js
|
|
4196
|
+
function pointInPolygon(p, polygon2) {
|
|
4197
|
+
var i;
|
|
4198
|
+
var ii;
|
|
4199
|
+
var k = 0;
|
|
4200
|
+
var f;
|
|
4201
|
+
var u1;
|
|
4202
|
+
var v1;
|
|
4203
|
+
var u22;
|
|
4204
|
+
var v2;
|
|
4205
|
+
var currentP;
|
|
4206
|
+
var nextP;
|
|
4207
|
+
var x = p[0];
|
|
4208
|
+
var y = p[1];
|
|
4209
|
+
var numContours = polygon2.length;
|
|
4210
|
+
for (i = 0; i < numContours; i++) {
|
|
4211
|
+
ii = 0;
|
|
4212
|
+
var contour = polygon2[i];
|
|
4213
|
+
var contourLen = contour.length - 1;
|
|
4214
|
+
currentP = contour[0];
|
|
4215
|
+
if (currentP[0] !== contour[contourLen][0] && currentP[1] !== contour[contourLen][1]) {
|
|
4216
|
+
throw new Error("First and last coordinates in a ring must be the same");
|
|
4217
|
+
}
|
|
4218
|
+
u1 = currentP[0] - x;
|
|
4219
|
+
v1 = currentP[1] - y;
|
|
4220
|
+
for (ii; ii < contourLen; ii++) {
|
|
4221
|
+
nextP = contour[ii + 1];
|
|
4222
|
+
u22 = nextP[0] - x;
|
|
4223
|
+
v2 = nextP[1] - y;
|
|
4224
|
+
if (v1 === 0 && v2 === 0) {
|
|
4225
|
+
if (u22 <= 0 && u1 >= 0 || u1 <= 0 && u22 >= 0) {
|
|
4226
|
+
return 0;
|
|
4227
|
+
}
|
|
4228
|
+
} else if (v2 >= 0 && v1 <= 0 || v2 <= 0 && v1 >= 0) {
|
|
4229
|
+
f = orient2d(u1, u22, v1, v2, 0, 0);
|
|
4230
|
+
if (f === 0) {
|
|
4231
|
+
return 0;
|
|
4232
|
+
}
|
|
4233
|
+
if (f > 0 && v2 > 0 && v1 <= 0 || f < 0 && v2 <= 0 && v1 > 0) {
|
|
4234
|
+
k++;
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
currentP = nextP;
|
|
4238
|
+
v1 = v2;
|
|
4239
|
+
u1 = u22;
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
if (k % 2 === 0) {
|
|
4243
|
+
return false;
|
|
4244
|
+
}
|
|
4245
|
+
return true;
|
|
4246
|
+
}
|
|
4247
|
+
|
|
4248
|
+
// ../../node_modules/@turf/invariant/dist/esm/index.js
|
|
4249
|
+
function getCoord(coord) {
|
|
4250
|
+
if (!coord) {
|
|
4251
|
+
throw new Error("coord is required");
|
|
4252
|
+
}
|
|
4253
|
+
if (!Array.isArray(coord)) {
|
|
4254
|
+
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
4255
|
+
return [...coord.geometry.coordinates];
|
|
4256
|
+
}
|
|
4257
|
+
if (coord.type === "Point") {
|
|
4258
|
+
return [...coord.coordinates];
|
|
4259
|
+
}
|
|
4260
|
+
}
|
|
4261
|
+
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
4262
|
+
return [...coord];
|
|
4263
|
+
}
|
|
4264
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4265
|
+
}
|
|
4266
|
+
function getGeom(geojson) {
|
|
4267
|
+
if (geojson.type === "Feature") {
|
|
4268
|
+
return geojson.geometry;
|
|
4269
|
+
}
|
|
4270
|
+
return geojson;
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4273
|
+
// ../../node_modules/@turf/boolean-point-in-polygon/dist/esm/index.js
|
|
4274
|
+
function booleanPointInPolygon(point2, polygon2, options = {}) {
|
|
4275
|
+
if (!point2) {
|
|
4276
|
+
throw new Error("point is required");
|
|
4277
|
+
}
|
|
4278
|
+
if (!polygon2) {
|
|
4279
|
+
throw new Error("polygon is required");
|
|
4280
|
+
}
|
|
4281
|
+
const pt = getCoord(point2);
|
|
4282
|
+
const geom = getGeom(polygon2);
|
|
4283
|
+
const type = geom.type;
|
|
4284
|
+
const bbox2 = polygon2.bbox;
|
|
4285
|
+
let polys = geom.coordinates;
|
|
4286
|
+
if (bbox2 && inBBox(pt, bbox2) === false) {
|
|
4287
|
+
return false;
|
|
4288
|
+
}
|
|
4289
|
+
if (type === "Polygon") {
|
|
4290
|
+
polys = [polys];
|
|
4291
|
+
}
|
|
4292
|
+
let result = false;
|
|
4293
|
+
for (var i = 0; i < polys.length; ++i) {
|
|
4294
|
+
const polyResult = pointInPolygon(pt, polys[i]);
|
|
4295
|
+
if (polyResult === 0) return options.ignoreBoundary ? false : true;
|
|
4296
|
+
else if (polyResult) result = true;
|
|
4297
|
+
}
|
|
4298
|
+
return result;
|
|
4299
|
+
}
|
|
4300
|
+
function inBBox(pt, bbox2) {
|
|
4301
|
+
return bbox2[0] <= pt[0] && bbox2[1] <= pt[1] && bbox2[2] >= pt[0] && bbox2[3] >= pt[1];
|
|
4302
|
+
}
|
|
4303
|
+
|
|
4304
|
+
// src/IndoorMap/renderer/utils/findUnitOnPoint.ts
|
|
4305
|
+
var findUnitOnPoint = (units, point2) => {
|
|
4306
|
+
return units.find((unit) => booleanPointInPolygon(point2, polygon(unit.geometry.coordinates)));
|
|
4307
|
+
};
|
|
4308
|
+
|
|
3845
4309
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3846
4310
|
function delay(ms) {
|
|
3847
4311
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -3945,7 +4409,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3945
4409
|
populate: true
|
|
3946
4410
|
});
|
|
3947
4411
|
units.filter(
|
|
3948
|
-
(
|
|
4412
|
+
(u4) => !["opentobelow", "escalator"].includes(u4.properties.category)
|
|
3949
4413
|
).forEach((unit) => {
|
|
3950
4414
|
const element = this.elementRenderer.createGeometry(unit);
|
|
3951
4415
|
if (element) {
|
|
@@ -3963,7 +4427,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3963
4427
|
this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal);
|
|
3964
4428
|
}
|
|
3965
4429
|
});
|
|
3966
|
-
const escalators = units.filter((
|
|
4430
|
+
const escalators = units.filter((u4) => u4.properties.category === "escalator");
|
|
3967
4431
|
for (const escalator of escalators) {
|
|
3968
4432
|
try {
|
|
3969
4433
|
const escalatorRelationships = relationships.filter((r) => (r.properties?.intermediary || []).some((inter) => inter.id === escalator.id));
|
|
@@ -3995,6 +4459,17 @@ var RendererManager = class extends EventTarget {
|
|
|
3995
4459
|
console.warn(`cannot create escalator`, err.message);
|
|
3996
4460
|
}
|
|
3997
4461
|
}
|
|
4462
|
+
const groundLabels = await this.#dataClient.filterByType("label");
|
|
4463
|
+
for (const label of groundLabels) {
|
|
4464
|
+
const center2 = (0, import_center3.center)(polygon(label.geometry.coordinates)).geometry.coordinates;
|
|
4465
|
+
const unit = findUnitOnPoint(units, center2);
|
|
4466
|
+
const element = this.elementRenderer.createGroundLabel(label, unit);
|
|
4467
|
+
console.log({ element });
|
|
4468
|
+
if (element) {
|
|
4469
|
+
const _elements = Array.isArray(element) ? element : [element];
|
|
4470
|
+
this.addElementsToManager(label.id, _elements, label.properties.ordinal);
|
|
4471
|
+
}
|
|
4472
|
+
}
|
|
3998
4473
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
3999
4474
|
this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
|
|
4000
4475
|
}
|
|
@@ -4036,8 +4511,10 @@ var RendererManager = class extends EventTarget {
|
|
|
4036
4511
|
const elements = elemIds.map((id) => this.elementsMap.get(id)).flat();
|
|
4037
4512
|
elements.forEach((element) => {
|
|
4038
4513
|
const controller = this.elementRenderer.createHighlightController(element);
|
|
4039
|
-
controller.start
|
|
4040
|
-
|
|
4514
|
+
if (controller && (0, import_isFunction.default)(controller.start)) {
|
|
4515
|
+
controller.start();
|
|
4516
|
+
this.highlightControllers.push(controller);
|
|
4517
|
+
}
|
|
4041
4518
|
});
|
|
4042
4519
|
};
|
|
4043
4520
|
clearHighlightElements = () => {
|
|
@@ -4087,6 +4564,20 @@ var defaultOptions = {
|
|
|
4087
4564
|
interactions: true,
|
|
4088
4565
|
locale: DEFAULT_LOCALE
|
|
4089
4566
|
};
|
|
4567
|
+
var parseMaptalksOptions = (options) => {
|
|
4568
|
+
return {
|
|
4569
|
+
centerCross: options.centerCross ?? false,
|
|
4570
|
+
...options.interactions === false ? {
|
|
4571
|
+
draggable: false,
|
|
4572
|
+
dragPan: false,
|
|
4573
|
+
dragRotate: false,
|
|
4574
|
+
dragPitch: false,
|
|
4575
|
+
scrollWheelZoom: false,
|
|
4576
|
+
touchZoom: false,
|
|
4577
|
+
doubleClickZoom: false
|
|
4578
|
+
} : {}
|
|
4579
|
+
};
|
|
4580
|
+
};
|
|
4090
4581
|
var IndoorMap = class extends EventTarget {
|
|
4091
4582
|
options;
|
|
4092
4583
|
//TODO: refac functions; let them do only 1 thing in a function
|
|
@@ -4105,7 +4596,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4105
4596
|
#billboardObjects = [];
|
|
4106
4597
|
#spriteMarkerObjects = [];
|
|
4107
4598
|
#mapDecorations = [];
|
|
4108
|
-
#groundLabels = [];
|
|
4109
4599
|
#groundObjects = [];
|
|
4110
4600
|
#navigationGeometries = {};
|
|
4111
4601
|
#venueObjects = [];
|
|
@@ -4141,13 +4631,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4141
4631
|
constructor(elementId, options) {
|
|
4142
4632
|
super();
|
|
4143
4633
|
const combinedOptions = import_lodash6.default.merge({}, defaultOptions, options);
|
|
4144
|
-
this.options =
|
|
4634
|
+
this.options = combinedOptions;
|
|
4145
4635
|
const {
|
|
4146
4636
|
onMapReady,
|
|
4147
4637
|
onMapLoading,
|
|
4148
4638
|
pixelRatio,
|
|
4149
4639
|
locale
|
|
4150
4640
|
} = combinedOptions;
|
|
4641
|
+
const maptalksOptions = parseMaptalksOptions(combinedOptions);
|
|
4151
4642
|
this.map = new import_maptalks_gl.Map(elementId, {
|
|
4152
4643
|
attribution: false,
|
|
4153
4644
|
// Temporart set, not really default view
|
|
@@ -4155,16 +4646,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4155
4646
|
center: INITIAL_CENTER,
|
|
4156
4647
|
zoom: INITIAL_ZOOM,
|
|
4157
4648
|
clickTimeThreshold: 600,
|
|
4158
|
-
|
|
4159
|
-
...options.interactions === false ? {
|
|
4160
|
-
draggable: false,
|
|
4161
|
-
dragPan: false,
|
|
4162
|
-
dragRotate: false,
|
|
4163
|
-
dragPitch: false,
|
|
4164
|
-
scrollWheelZoom: false,
|
|
4165
|
-
touchZoom: false,
|
|
4166
|
-
doubleClickZoom: false
|
|
4167
|
-
} : {},
|
|
4649
|
+
...maptalksOptions,
|
|
4168
4650
|
baseLayer: new import_maptalks_gl.TileLayer("base", {
|
|
4169
4651
|
urlTemplate: "https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
|
|
4170
4652
|
subdomains: ["a", "b", "c", "d"],
|
|
@@ -4194,6 +4676,12 @@ var IndoorMap = class extends EventTarget {
|
|
|
4194
4676
|
this.map.on("click", this.handleMapClick);
|
|
4195
4677
|
this.dataClient = options.dataClient;
|
|
4196
4678
|
}
|
|
4679
|
+
setOptions(options) {
|
|
4680
|
+
const combinedOptions = import_lodash6.default.merge({}, defaultOptions, options);
|
|
4681
|
+
this.options = combinedOptions;
|
|
4682
|
+
const maptalksOptions = parseMaptalksOptions(combinedOptions);
|
|
4683
|
+
this.map.setOptions(maptalksOptions);
|
|
4684
|
+
}
|
|
4197
4685
|
set dataClient(value) {
|
|
4198
4686
|
this.#dataClient = value;
|
|
4199
4687
|
if (!this.options.camera?.defaultView?.center) {
|
|
@@ -4272,9 +4760,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4272
4760
|
set mapDecorations(value) {
|
|
4273
4761
|
this.#mapDecorations = value;
|
|
4274
4762
|
}
|
|
4275
|
-
set groundLabels(value) {
|
|
4276
|
-
this.#groundLabels = value;
|
|
4277
|
-
}
|
|
4278
4763
|
set pixelRatio(value) {
|
|
4279
4764
|
this.map.setDevicePixelRatio(value);
|
|
4280
4765
|
}
|
|
@@ -4318,13 +4803,11 @@ var IndoorMap = class extends EventTarget {
|
|
|
4318
4803
|
createDecoration,
|
|
4319
4804
|
// 3D
|
|
4320
4805
|
create3DFootprint,
|
|
4321
|
-
create3DGroundLabel,
|
|
4322
4806
|
create3DBillboard,
|
|
4323
4807
|
createExtrudedUnit,
|
|
4324
4808
|
create3DAmenityMarker,
|
|
4325
4809
|
create3DOccupantAmenityMarker,
|
|
4326
|
-
create3DOpeningMarker
|
|
4327
|
-
createOccupantGroundLabel
|
|
4810
|
+
create3DOpeningMarker
|
|
4328
4811
|
} = this.#styler;
|
|
4329
4812
|
let elements = {};
|
|
4330
4813
|
let object3ds = [];
|
|
@@ -4402,16 +4885,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4402
4885
|
console.warn(`Cannot create ${feature2.id}: ${err.message}`);
|
|
4403
4886
|
}
|
|
4404
4887
|
}
|
|
4405
|
-
this.#groundLabels.forEach((label) => {
|
|
4406
|
-
const text = label.properties.name;
|
|
4407
|
-
try {
|
|
4408
|
-
const groundLabel = create3DGroundLabel(label, this.threeLayer);
|
|
4409
|
-
object3ds.push(groundLabel);
|
|
4410
|
-
this.#groundObjects.push(groundLabel);
|
|
4411
|
-
} catch (error) {
|
|
4412
|
-
console.log("error creating ground label for ", text);
|
|
4413
|
-
}
|
|
4414
|
-
});
|
|
4415
4888
|
this.#mapDecorations.forEach((decoration) => {
|
|
4416
4889
|
const { id, geometry, properties } = decoration;
|
|
4417
4890
|
const geometryType = decoration?.geometry?.type;
|
|
@@ -4850,15 +5323,42 @@ var IndoorMap = class extends EventTarget {
|
|
|
4850
5323
|
child.visible = this.showVenueObject && objectOpacity > 0.4;
|
|
4851
5324
|
});
|
|
4852
5325
|
});
|
|
4853
|
-
this.#groundObjects.forEach((gLabel) => {
|
|
4854
|
-
gLabel.bearing = currBearing;
|
|
4855
|
-
});
|
|
4856
5326
|
}
|
|
4857
5327
|
this.#animationsToRun.forEach(({ callback }) => callback(this));
|
|
4858
5328
|
import_tween.default.update();
|
|
4859
5329
|
requestAnimationFrame(this.render.bind(this));
|
|
4860
5330
|
}
|
|
4861
5331
|
};
|
|
5332
|
+
|
|
5333
|
+
// src/IndoorMap/renderer/3d/objects/PulsingMarker.ts
|
|
5334
|
+
var maptalks8 = __toESM(require("maptalks-gl"));
|
|
5335
|
+
var import_maptalks11 = require("maptalks.three");
|
|
5336
|
+
var THREE4 = __toESM(require("three"));
|
|
5337
|
+
var OPTIONS5 = {
|
|
5338
|
+
radius: 100,
|
|
5339
|
+
altitude: 0
|
|
5340
|
+
};
|
|
5341
|
+
var PulsingMarker = class extends import_maptalks11.BaseObject {
|
|
5342
|
+
constructor(coordinate, options, material, layer) {
|
|
5343
|
+
options = maptalks8.Util.extend({}, OPTIONS5, options, { layer, coordinate });
|
|
5344
|
+
super();
|
|
5345
|
+
this._initOptions(options);
|
|
5346
|
+
const { altitude, radius } = options;
|
|
5347
|
+
const r = layer.distanceToVector3(radius, radius).x;
|
|
5348
|
+
const geometry = new THREE4.CircleGeometry(r, 50);
|
|
5349
|
+
this._createMesh(geometry, material);
|
|
5350
|
+
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
5351
|
+
const position = layer.coordinateToVector3(coordinate, z);
|
|
5352
|
+
this.getObject3d().position.copy(position);
|
|
5353
|
+
this._scale = 1;
|
|
5354
|
+
}
|
|
5355
|
+
// test animation
|
|
5356
|
+
_animation() {
|
|
5357
|
+
this._scale = this._scale > 1 ? 0 : this._scale;
|
|
5358
|
+
this._scale += 0.02;
|
|
5359
|
+
this.getObject3d().scale.set(this._scale, this._scale, this._scale);
|
|
5360
|
+
}
|
|
5361
|
+
};
|
|
4862
5362
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4863
5363
|
0 && (module.exports = {
|
|
4864
5364
|
ALL_FEATURE_TYPES,
|
|
@@ -4880,7 +5380,9 @@ var IndoorMap = class extends EventTarget {
|
|
|
4880
5380
|
ORIGIN_MARKER_ID,
|
|
4881
5381
|
OccupantHelpers,
|
|
4882
5382
|
POI_MARKER_LAYER_NAME,
|
|
5383
|
+
PulsingMarker,
|
|
4883
5384
|
QueryObserver,
|
|
5385
|
+
TextSpriteMarker,
|
|
4884
5386
|
USER_LOCATION_ELEMENT_ID,
|
|
4885
5387
|
USER_LOCATION_LAYER_NAME,
|
|
4886
5388
|
VENUE_EVENTS,
|