bruce-cesium 3.4.7 → 3.4.9
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/README.md +31 -0
- package/dist/bruce-cesium.es5.js +1073 -1057
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +1073 -1057
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/entity-render-engine.js +3 -3
- package/dist/lib/rendering/entity-render-engine.js.map +1 -1
- package/dist/lib/rendering/render-managers/common/point-clustering.js +3 -3
- package/dist/lib/rendering/render-managers/common/point-clustering.js.map +1 -1
- package/dist/lib/rendering/render-managers/data-source/data-source-static-kml-manager.js +42 -26
- package/dist/lib/rendering/render-managers/data-source/data-source-static-kml-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
- package/dist/lib/rendering/visuals-register.js +1 -1
- package/dist/lib/rendering/visuals-register.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/package.json +77 -77
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -81,463 +81,878 @@
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
var TIME_LAG = 300;
|
|
85
|
+
var POSITION_CHECK_TIMER = 950;
|
|
86
|
+
var DEFAULT_GROUNDED_HEIGHT = 300;
|
|
87
|
+
var MINIMUM_VIEW_AREA_SIZE_DEGREES = 0.01;
|
|
88
|
+
var NET_STEP_PERCENT = 5;
|
|
89
|
+
var BORDER_STEPS = 3;
|
|
90
|
+
var ESearchStatus;
|
|
91
|
+
(function (ESearchStatus) {
|
|
92
|
+
ESearchStatus[ESearchStatus["LocationFound"] = 1] = "LocationFound";
|
|
93
|
+
ESearchStatus[ESearchStatus["LocationChanged"] = 2] = "LocationChanged";
|
|
94
|
+
ESearchStatus[ESearchStatus["LocationMissing"] = 3] = "LocationMissing";
|
|
95
|
+
})(ESearchStatus || (ESearchStatus = {}));
|
|
84
96
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @param value
|
|
88
|
-
* @param defaultNum default is 0.
|
|
97
|
+
* @param viewer
|
|
98
|
+
* @param center the previously calculated center of the view area. This is in degrees.
|
|
89
99
|
* @returns
|
|
90
100
|
*/
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
(function (MeasureUtils) {
|
|
103
|
-
/**
|
|
104
|
-
* Returns the total distance in meters between an array of points.
|
|
105
|
-
* This distance is NOT following the terrain.
|
|
106
|
-
* @param posses
|
|
107
|
-
* @returns
|
|
108
|
-
*/
|
|
109
|
-
function MeasurePolyline(params) {
|
|
110
|
-
var posses = params.posses;
|
|
111
|
-
if (posses.length < 2) {
|
|
112
|
-
return {
|
|
113
|
-
totalLength: 0
|
|
114
|
-
};
|
|
101
|
+
function netScanViewForBoundaries(viewer, center) {
|
|
102
|
+
var maxLong = -2 * Math.PI;
|
|
103
|
+
var minLong = 2 * Math.PI;
|
|
104
|
+
var maxLat = -2 * Math.PI;
|
|
105
|
+
var minLat = 2 * Math.PI;
|
|
106
|
+
var found = 0;
|
|
107
|
+
var updateMinMax = function (lon, lat) {
|
|
108
|
+
// Check to see if given lon/lat (in radians) are within valid range.
|
|
109
|
+
if (lon < -Math.PI || lon > Math.PI || lat < -Math.PI / 2 || lat > Math.PI / 2) {
|
|
110
|
+
return;
|
|
115
111
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
112
|
+
maxLong = Math.max(maxLong, lon);
|
|
113
|
+
maxLat = Math.max(maxLat, lat);
|
|
114
|
+
minLong = Math.min(minLong, lon);
|
|
115
|
+
minLat = Math.min(minLat, lat);
|
|
116
|
+
};
|
|
117
|
+
var updateMinMaxForPoint = function (stepX, stepY) {
|
|
118
|
+
var x = Math.round(0 + (viewer.container.clientWidth / 100) * (stepX * NET_STEP_PERCENT));
|
|
119
|
+
var y = Math.round(0 + (viewer.container.clientHeight / 100) * (stepY * NET_STEP_PERCENT));
|
|
120
|
+
var winPos = new Cesium.Cartesian2(x, y);
|
|
121
|
+
try {
|
|
122
|
+
var intersection = getAdjustedGroundIntersectionOfCameraRay(viewer, winPos);
|
|
123
|
+
if (intersection) {
|
|
124
|
+
var point = Cesium.Cartographic.fromCartesian(intersection, viewer.scene.globe.ellipsoid);
|
|
125
|
+
updateMinMax(point.longitude, point.latitude);
|
|
126
|
+
found++;
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
MeasureUtils.MeasurePolyline = MeasurePolyline;
|
|
135
|
-
function MeasurePolygon(params) {
|
|
136
|
-
var posses = params.posses;
|
|
137
|
-
posses = [].concat(posses);
|
|
138
|
-
if (!bruceModels.Cartes.IsRing3Closed(posses)) {
|
|
139
|
-
posses.push(posses[0].clone());
|
|
129
|
+
catch (e) {
|
|
130
|
+
console.error(e);
|
|
140
131
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
132
|
+
};
|
|
133
|
+
// Outer circle.
|
|
134
|
+
updateMinMaxForPoint(BORDER_STEPS, BORDER_STEPS);
|
|
135
|
+
updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS, BORDER_STEPS);
|
|
136
|
+
updateMinMaxForPoint(BORDER_STEPS, (100 / NET_STEP_PERCENT) - BORDER_STEPS);
|
|
137
|
+
updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS, (100 / NET_STEP_PERCENT) - BORDER_STEPS);
|
|
138
|
+
// Inner circle.
|
|
139
|
+
updateMinMaxForPoint(BORDER_STEPS * 2, BORDER_STEPS * 2);
|
|
140
|
+
updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS * 2, BORDER_STEPS * 2);
|
|
141
|
+
updateMinMaxForPoint(BORDER_STEPS * 2, (100 / NET_STEP_PERCENT) - BORDER_STEPS * 2);
|
|
142
|
+
updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS * 2, (100 / NET_STEP_PERCENT) - BORDER_STEPS * 2);
|
|
143
|
+
// If we failed to find intersections and a center-point was provided, then we can use that to make some guesses.
|
|
144
|
+
// This happens if terrain is hidden, and there's nothing to intersect with.
|
|
145
|
+
if (center && found <= 0) {
|
|
146
|
+
updateMinMax(Cesium.Math.toRadians(center.longitude), Cesium.Math.toRadians(center.latitude));
|
|
147
|
+
found += 1;
|
|
148
|
+
// We'll use the camera height as an indicator on size of the rect.
|
|
149
|
+
var size = viewer.camera.positionCartographic.height;
|
|
150
|
+
var pitch = viewer.camera.pitch;
|
|
151
|
+
var distance = size / Math.tan(pitch);
|
|
152
|
+
var p1 = _offsetPoint({
|
|
153
|
+
altitude: center.altitude,
|
|
154
|
+
latitude: center.latitude,
|
|
155
|
+
longitude: center.longitude
|
|
156
|
+
}, distance, 45);
|
|
157
|
+
var p2 = _offsetPoint({
|
|
158
|
+
altitude: center.altitude,
|
|
159
|
+
latitude: center.latitude,
|
|
160
|
+
longitude: center.longitude
|
|
161
|
+
}, -distance, 45);
|
|
162
|
+
if (p1 === null || p1 === void 0 ? void 0 : p1.latitude) {
|
|
163
|
+
updateMinMax(Cesium.Math.toRadians(p1.longitude), Cesium.Math.toRadians(p1.latitude));
|
|
146
164
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
for (var i = 0; i < indices.length; i += 3) {
|
|
150
|
-
var vector1 = posses[indices[i]];
|
|
151
|
-
var vector2 = posses[indices[i + 1]];
|
|
152
|
-
var vector3 = posses[indices[i + 2]];
|
|
153
|
-
var vectorC = Cesium.Cartesian3.subtract(vector2, vector1, new Cesium.Cartesian3());
|
|
154
|
-
var vectorD = Cesium.Cartesian3.subtract(vector3, vector1, new Cesium.Cartesian3());
|
|
155
|
-
var areaVector = Cesium.Cartesian3.cross(vectorC, vectorD, new Cesium.Cartesian3());
|
|
156
|
-
area += Cesium.Cartesian3.magnitude(areaVector) / 2.0;
|
|
165
|
+
if (p2 === null || p2 === void 0 ? void 0 : p2.latitude) {
|
|
166
|
+
updateMinMax(Cesium.Math.toRadians(p2.longitude), Cesium.Math.toRadians(p2.latitude));
|
|
157
167
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
}
|
|
169
|
+
if (found > 0) {
|
|
170
|
+
var viewRect = {
|
|
171
|
+
east: maxLong,
|
|
172
|
+
west: minLong,
|
|
173
|
+
north: maxLat,
|
|
174
|
+
south: minLat
|
|
164
175
|
};
|
|
176
|
+
return viewRect;
|
|
165
177
|
}
|
|
166
|
-
|
|
167
|
-
})(exports.MeasureUtils || (exports.MeasureUtils = {}));
|
|
168
|
-
|
|
169
|
-
var C3 = [Cesium.Cartesian3][0];
|
|
170
|
-
function getT(t, alpha, p0, p1) {
|
|
171
|
-
var d = C3.subtract(p1, p0, new C3);
|
|
172
|
-
var a = C3.dot(d, d);
|
|
173
|
-
var b = Math.pow(a, alpha * 0.5);
|
|
174
|
-
return b + t;
|
|
178
|
+
return null;
|
|
175
179
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var
|
|
186
|
-
var
|
|
187
|
-
var
|
|
188
|
-
var
|
|
189
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Moves a given point by a given distance towards a heading.
|
|
182
|
+
* @param point in degrees.
|
|
183
|
+
* @param distance in meters.
|
|
184
|
+
* @param heading in degrees.
|
|
185
|
+
* @returns
|
|
186
|
+
*/
|
|
187
|
+
function _offsetPoint(point, distance, heading) {
|
|
188
|
+
// Radius of earth.
|
|
189
|
+
var radius = 6371e3;
|
|
190
|
+
var δ = distance / radius;
|
|
191
|
+
var θ = Cesium.Math.toRadians(heading);
|
|
192
|
+
var φ1 = Cesium.Math.toRadians(point.latitude);
|
|
193
|
+
var λ1 = Cesium.Math.toRadians(point.longitude);
|
|
194
|
+
var sinφ2 = Math.sin(φ1) * Math.cos(δ) + Math.cos(φ1) * Math.sin(δ) * Math.cos(θ);
|
|
195
|
+
var φ2 = Math.asin(sinφ2);
|
|
196
|
+
var y = Math.sin(θ) * Math.sin(δ) * Math.cos(φ1);
|
|
197
|
+
var x = Math.cos(δ) - Math.sin(φ1) * sinφ2;
|
|
198
|
+
var λ2 = λ1 + Math.atan2(y, x);
|
|
199
|
+
return {
|
|
200
|
+
altitude: point.altitude,
|
|
201
|
+
latitude: Cesium.Math.toDegrees(φ2),
|
|
202
|
+
longitude: Cesium.Math.toDegrees(λ2)
|
|
203
|
+
};
|
|
190
204
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
for (var i = 0; i < positions.length - 1; i++) {
|
|
218
|
-
var length_1 = Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
|
219
|
-
if (length_1 + currentDistance >= distance) {
|
|
220
|
-
var carto1 = Cesium.Cartographic.fromCartesian(positions[i]);
|
|
221
|
-
var carto2 = Cesium.Cartographic.fromCartesian(positions[i + 1]);
|
|
222
|
-
var geodesic = new Cesium.EllipsoidGeodesic(carto1, carto2, viewer.scene.globe.ellipsoid);
|
|
223
|
-
//const position = geodesic.interpolateUsingSurfaceDistance(distance - currentDistance);
|
|
224
|
-
var position = geodesic.interpolateUsingFraction((distance - currentDistance) / length_1);
|
|
225
|
-
var height = (carto1.height + carto2.height) / 2;
|
|
226
|
-
return {
|
|
227
|
-
point: Cesium.Cartesian3.fromRadians(position.longitude, position.latitude, height)
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
currentDistance += length_1;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
point: positions.length ? positions[positions.length - 1] : null
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
DrawingUtils.PointAcrossPolyline = PointAcrossPolyline;
|
|
240
|
-
/**
|
|
241
|
-
* Returns terrain height from current viewer's provider.
|
|
242
|
-
* On error or flat terrain, it will return 0.
|
|
243
|
-
* If an error occurred it will be attached to the result.
|
|
244
|
-
* @param pos3d
|
|
245
|
-
* @param viewer
|
|
246
|
-
* @returns
|
|
247
|
-
*/
|
|
248
|
-
function GetTerrainHeight(params) {
|
|
249
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
250
|
-
var pos3d, viewer, sample, height, e_1;
|
|
251
|
-
return __generator(this, function (_a) {
|
|
252
|
-
switch (_a.label) {
|
|
253
|
-
case 0:
|
|
254
|
-
pos3d = params.pos3d, viewer = params.viewer;
|
|
255
|
-
_a.label = 1;
|
|
256
|
-
case 1:
|
|
257
|
-
_a.trys.push([1, 3, , 4]);
|
|
258
|
-
// If the terrain provider is not ready let's not ping it.
|
|
259
|
-
if (!viewer.terrainProvider || viewer.terrainProvider["ready"] == false) {
|
|
260
|
-
return [2 /*return*/, {
|
|
261
|
-
height: 0,
|
|
262
|
-
error: "Terrain provider not ready."
|
|
263
|
-
}];
|
|
264
|
-
}
|
|
265
|
-
if (viewer.scene.terrainProvider instanceof Cesium.EllipsoidTerrainProvider) {
|
|
266
|
-
return [2 /*return*/, {
|
|
267
|
-
height: 0
|
|
268
|
-
}];
|
|
269
|
-
}
|
|
270
|
-
return [4 /*yield*/, Cesium.sampleTerrainMostDetailed(viewer.scene.terrainProvider, [Cesium.Cartographic.fromCartesian(pos3d)])];
|
|
271
|
-
case 2:
|
|
272
|
-
sample = _a.sent();
|
|
273
|
-
height = (sample === null || sample === void 0 ? void 0 : sample.length) ? sample[0].height : null;
|
|
274
|
-
if (isNaN(height)) {
|
|
275
|
-
return [2 /*return*/, {
|
|
276
|
-
height: 0,
|
|
277
|
-
error: "NaN"
|
|
278
|
-
}];
|
|
279
|
-
}
|
|
280
|
-
return [2 /*return*/, {
|
|
281
|
-
height: height
|
|
282
|
-
}];
|
|
283
|
-
case 3:
|
|
284
|
-
e_1 = _a.sent();
|
|
285
|
-
return [2 /*return*/, {
|
|
286
|
-
height: 0,
|
|
287
|
-
error: e_1
|
|
288
|
-
}];
|
|
289
|
-
case 4: return [2 /*return*/];
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
});
|
|
205
|
+
/**
|
|
206
|
+
* @param pos3d
|
|
207
|
+
* @param distance in meters
|
|
208
|
+
* @param heading in degrees
|
|
209
|
+
* @returns
|
|
210
|
+
*/
|
|
211
|
+
function _offsetPos3d(pos3d, distance, heading) {
|
|
212
|
+
var carto = Cesium.Cartographic.fromCartesian(pos3d);
|
|
213
|
+
var newCarto = _offsetPoint({
|
|
214
|
+
altitude: carto.height,
|
|
215
|
+
latitude: Cesium.Math.toDegrees(carto.latitude),
|
|
216
|
+
longitude: Cesium.Math.toDegrees(carto.longitude)
|
|
217
|
+
}, distance, heading);
|
|
218
|
+
return Cesium.Cartesian3.fromDegrees(newCarto.longitude, newCarto.latitude, newCarto.altitude);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Returns the intersection of the camera ray with the ground.
|
|
222
|
+
* @param viewer
|
|
223
|
+
* @param screenPos
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
function getAdjustedGroundIntersectionOfCameraRay(viewer, screenPos) {
|
|
227
|
+
var ray = viewer.camera.getPickRay(screenPos);
|
|
228
|
+
var intersection = ray ? viewer.scene.globe.pick(ray, viewer.scene) : null;
|
|
229
|
+
if (intersection) {
|
|
230
|
+
return intersection;
|
|
293
231
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (heightRef == Cesium.HeightReference.NONE) {
|
|
311
|
-
// Turn absolute into clamped.
|
|
312
|
-
if (desiredHeightRef == Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
313
|
-
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, 0);
|
|
314
|
-
}
|
|
315
|
-
// Turn absolute into relative (remove terrain height).
|
|
316
|
-
else if (desiredHeightRef == Cesium.HeightReference.RELATIVE_TO_GROUND) {
|
|
317
|
-
var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto), 0);
|
|
318
|
-
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height - terrainHeight);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
else if (heightRef == Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
322
|
-
var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto), 0);
|
|
323
|
-
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, terrainHeight);
|
|
324
|
-
}
|
|
325
|
-
else if (heightRef == Cesium.HeightReference.RELATIVE_TO_GROUND) {
|
|
326
|
-
// Turn relative into absolute (add terrain height).
|
|
327
|
-
if (desiredHeightRef == Cesium.HeightReference.NONE) {
|
|
328
|
-
var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto), 0);
|
|
329
|
-
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height + terrainHeight);
|
|
330
|
-
}
|
|
331
|
-
// Turn relative into clamped.
|
|
332
|
-
else if (desiredHeightRef == Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
333
|
-
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, 0);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return pos3d;
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Returns the intersection of the camera ray with the ground.
|
|
236
|
+
* If no intersection is found, then a "guess" is made based on the camera angle and height.
|
|
237
|
+
* The guess is made at the center of the view! It ignores the screenPos.
|
|
238
|
+
* @param viewer
|
|
239
|
+
* @param screenPos
|
|
240
|
+
* @returns
|
|
241
|
+
*/
|
|
242
|
+
function getGroundCenterOfCameraRay(viewer, screenPos) {
|
|
243
|
+
var _a, _b;
|
|
244
|
+
var ray = viewer.camera.getPickRay(screenPos);
|
|
245
|
+
var intersection = ray ? viewer.scene.globe.pick(ray, viewer.scene) : null;
|
|
246
|
+
if (intersection) {
|
|
247
|
+
return intersection;
|
|
337
248
|
}
|
|
338
|
-
|
|
249
|
+
// The fallback will be to "guess" where the intersection might be.
|
|
250
|
+
// This happens if terrain is hidden, and there's nothing to intersect with.
|
|
251
|
+
// We will use the camera angle + camera height.
|
|
252
|
+
// Eg: if camera is looking straight down and is 100 meters above the ground, then the intersection will be 100 meters below the camera.
|
|
253
|
+
var cameraHeight = viewer.camera.positionCartographic.height;
|
|
254
|
+
if (!isNaN(cameraHeight) && cameraHeight != null && ((_b = (_a = viewer.camera) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.clone)) {
|
|
255
|
+
var cameraPos3d = viewer.camera.position.clone();
|
|
256
|
+
var pitch = viewer.camera.pitch;
|
|
257
|
+
var distance = cameraHeight / Math.tan(pitch);
|
|
258
|
+
return _offsetPos3d(cameraPos3d, -distance, Cesium.Math.toDegrees(viewer.camera.heading));
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
function areBoundsEqual(a, b) {
|
|
263
|
+
return a.north == b.north && a.south == b.south && a.east == b.east && a.west == b.west;
|
|
264
|
+
}
|
|
265
|
+
function arePosEqual(a, b) {
|
|
266
|
+
return a.latitude == b.latitude && a.longitude == b.longitude;
|
|
267
|
+
}
|
|
268
|
+
(function (CesiumViewMonitor) {
|
|
339
269
|
/**
|
|
340
|
-
*
|
|
341
|
-
* @param viewer
|
|
342
|
-
* @param cursor
|
|
343
|
-
* @returns
|
|
270
|
+
* Monitors and emits events when the Cesium view changes.
|
|
344
271
|
*/
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
272
|
+
var Monitor = /** @class */ (function () {
|
|
273
|
+
function Monitor(viewer) {
|
|
274
|
+
var _this = this;
|
|
275
|
+
this.target = null;
|
|
276
|
+
this.bounds = null;
|
|
277
|
+
this.disposed = false;
|
|
278
|
+
this.updatedEvent = null;
|
|
279
|
+
this.entity = null;
|
|
280
|
+
this.updating = false;
|
|
281
|
+
this.viewer = viewer;
|
|
282
|
+
this.tryEmitUpdate();
|
|
283
|
+
this.checkInterval = setInterval(function () {
|
|
284
|
+
_this.updateQueue();
|
|
285
|
+
}, POSITION_CHECK_TIMER);
|
|
286
|
+
}
|
|
287
|
+
Object.defineProperty(Monitor.prototype, "Disposed", {
|
|
288
|
+
get: function () {
|
|
289
|
+
return this.disposed;
|
|
290
|
+
},
|
|
291
|
+
enumerable: false,
|
|
292
|
+
configurable: true
|
|
293
|
+
});
|
|
294
|
+
Monitor.prototype.createEntity = function () {
|
|
295
|
+
var _this = this;
|
|
296
|
+
if (this.entity) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
this.entity = this.viewer.entities.add({
|
|
300
|
+
position: new Cesium.CallbackProperty(function () {
|
|
301
|
+
return _this.target ? Cesium.Cartesian3.fromDegrees(_this.target.longitude, _this.target.latitude) : null;
|
|
302
|
+
}, false),
|
|
303
|
+
point: {
|
|
304
|
+
pixelSize: 8,
|
|
305
|
+
color: Cesium.Color.ORANGE,
|
|
306
|
+
heightReference: Cesium.HeightReference.NONE
|
|
307
|
+
},
|
|
308
|
+
rectangle: {
|
|
309
|
+
coordinates: new Cesium.CallbackProperty(function () {
|
|
310
|
+
return _this.bounds ? Cesium.Rectangle.fromDegrees(_this.bounds.west, _this.bounds.south, _this.bounds.east, _this.bounds.north) : null;
|
|
311
|
+
}, false),
|
|
312
|
+
material: Cesium.Color.fromCssColorString('#ff0000').withAlpha(0.4),
|
|
313
|
+
zIndex: 1,
|
|
314
|
+
heightReference: Cesium.HeightReference.NONE
|
|
366
315
|
}
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
Monitor.prototype.destroyEntity = function () {
|
|
319
|
+
if (this.entity && this.viewer.entities.contains(this.entity)) {
|
|
320
|
+
this.viewer.entities.remove(this.entity);
|
|
367
321
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
pos3d = scene.pickPosition(cursor);
|
|
322
|
+
this.entity = null;
|
|
323
|
+
};
|
|
324
|
+
Monitor.prototype.Updated = function () {
|
|
325
|
+
if (!this.updatedEvent) {
|
|
326
|
+
this.updatedEvent = new bruceModels.BruceEvent();
|
|
374
327
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
328
|
+
return this.updatedEvent;
|
|
329
|
+
};
|
|
330
|
+
Monitor.prototype.GetBounds = function () {
|
|
331
|
+
return this.bounds;
|
|
332
|
+
};
|
|
333
|
+
Monitor.prototype.GetTarget = function () {
|
|
334
|
+
return this.target;
|
|
335
|
+
};
|
|
336
|
+
Monitor.prototype.DoUpdate = function () {
|
|
337
|
+
this.tryEmitUpdate();
|
|
338
|
+
};
|
|
339
|
+
Monitor.prototype.Dispose = function () {
|
|
340
|
+
if (this.disposed) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
this.disposed = true;
|
|
344
|
+
clearInterval(this.checkInterval);
|
|
345
|
+
this.destroyEntity();
|
|
346
|
+
};
|
|
347
|
+
Monitor.prototype.tryDoUpdate = function () {
|
|
348
|
+
var _a;
|
|
349
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
350
|
+
var viewRect, center, camera, terrData, cameraPosition, terrHeight, viewRectRad, windowPosition, intersection, point, viewRectRad, centerLong, centerLat;
|
|
351
|
+
return __generator(this, function (_b) {
|
|
352
|
+
switch (_b.label) {
|
|
353
|
+
case 0:
|
|
354
|
+
if (!this.viewer || this.viewer.isDestroyed()) {
|
|
355
|
+
this.Dispose();
|
|
356
|
+
return [2 /*return*/, ESearchStatus.LocationMissing];
|
|
357
|
+
}
|
|
358
|
+
viewRect = null;
|
|
359
|
+
center = null;
|
|
360
|
+
camera = this.viewer.camera;
|
|
361
|
+
return [4 /*yield*/, exports.DrawingUtils.GetTerrainHeight({
|
|
362
|
+
pos3d: camera.position,
|
|
363
|
+
viewer: this.viewer
|
|
364
|
+
})];
|
|
365
|
+
case 1:
|
|
366
|
+
terrData = _b.sent();
|
|
367
|
+
cameraPosition = this.viewer.camera.positionCartographic;
|
|
368
|
+
terrHeight = terrData.error ? cameraPosition.height + DEFAULT_GROUNDED_HEIGHT : terrData.height;
|
|
369
|
+
// We are almost at the ground, screw horizon, just load around.
|
|
370
|
+
if (terrHeight && ((cameraPosition.height - terrHeight) < DEFAULT_GROUNDED_HEIGHT)) {
|
|
371
|
+
// View area calculation.
|
|
372
|
+
viewRect = {};
|
|
373
|
+
viewRectRad = netScanViewForBoundaries(this.viewer);
|
|
374
|
+
if (viewRectRad &&
|
|
375
|
+
viewRectRad.east &&
|
|
376
|
+
viewRectRad.west &&
|
|
377
|
+
viewRectRad.north &&
|
|
378
|
+
viewRectRad.south) {
|
|
379
|
+
viewRect.east = Cesium.Math.toDegrees(Math.max(viewRectRad.east, cameraPosition.longitude));
|
|
380
|
+
viewRect.west = Cesium.Math.toDegrees(Math.min(viewRectRad.west, cameraPosition.longitude));
|
|
381
|
+
viewRect.south = Cesium.Math.toDegrees(Math.min(viewRectRad.south, cameraPosition.latitude));
|
|
382
|
+
viewRect.north = Cesium.Math.toDegrees(Math.max(viewRectRad.north, cameraPosition.latitude));
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
viewRect.east = cameraPosition.longitude;
|
|
386
|
+
viewRect.west = cameraPosition.longitude;
|
|
387
|
+
viewRect.south = cameraPosition.latitude;
|
|
388
|
+
viewRect.north = cameraPosition.latitude;
|
|
389
|
+
}
|
|
390
|
+
center = {};
|
|
391
|
+
center.latitude = Cesium.Math.toDegrees(camera.positionCartographic.latitude);
|
|
392
|
+
center.longitude = Cesium.Math.toDegrees(camera.positionCartographic.longitude);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
windowPosition = new Cesium.Cartesian2(this.viewer.container.clientWidth / 2, this.viewer.container.clientHeight / 2);
|
|
396
|
+
intersection = getGroundCenterOfCameraRay(this.viewer, windowPosition);
|
|
397
|
+
point = null;
|
|
398
|
+
if (intersection) {
|
|
399
|
+
point = Cesium.Cartographic.fromCartesian(intersection, this.viewer.scene.globe.ellipsoid);
|
|
400
|
+
}
|
|
401
|
+
if (point) {
|
|
402
|
+
center = {};
|
|
403
|
+
center.latitude = Cesium.Math.toDegrees(point.latitude);
|
|
404
|
+
center.longitude = Cesium.Math.toDegrees(point.longitude);
|
|
405
|
+
viewRectRad = netScanViewForBoundaries(this.viewer, center);
|
|
406
|
+
if (viewRectRad) {
|
|
407
|
+
viewRect = {};
|
|
408
|
+
viewRect.east = Cesium.Math.toDegrees(viewRectRad.east);
|
|
409
|
+
viewRect.west = Cesium.Math.toDegrees(viewRectRad.west);
|
|
410
|
+
viewRect.south = Cesium.Math.toDegrees(viewRectRad.south);
|
|
411
|
+
viewRect.north = Cesium.Math.toDegrees(viewRectRad.north);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
// Minimal field of view.
|
|
416
|
+
if (viewRect) {
|
|
417
|
+
centerLong = (viewRect.east + viewRect.west) / 2;
|
|
418
|
+
centerLat = (viewRect.north + viewRect.south) / 2;
|
|
419
|
+
viewRect.east = Math.max(viewRect.east, centerLong + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
|
|
420
|
+
viewRect.west = Math.min(viewRect.west, centerLong - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
|
|
421
|
+
viewRect.south = Math.min(viewRect.south, centerLat - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
|
|
422
|
+
viewRect.north = Math.max(viewRect.north, centerLat + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
|
|
423
|
+
viewRect.alt = (_a = this.viewer.scene.camera.positionCartographic) === null || _a === void 0 ? void 0 : _a.height;
|
|
424
|
+
}
|
|
425
|
+
if (center && viewRect) {
|
|
426
|
+
if ((!this.target || (this.target && !arePosEqual(this.target, center))) ||
|
|
427
|
+
(!this.bounds || (this.bounds && !areBoundsEqual(this.bounds, viewRect)))) {
|
|
428
|
+
this.target = center;
|
|
429
|
+
this.bounds = viewRect;
|
|
430
|
+
return [2 /*return*/, ESearchStatus.LocationChanged];
|
|
431
|
+
}
|
|
432
|
+
return [2 /*return*/, ESearchStatus.LocationFound];
|
|
433
|
+
}
|
|
434
|
+
return [2 /*return*/, ESearchStatus.LocationMissing];
|
|
398
435
|
}
|
|
399
|
-
|
|
400
|
-
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
Monitor.prototype.tryEmitUpdate = function () {
|
|
440
|
+
var _a;
|
|
441
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
442
|
+
var searchResult, interest, e_1;
|
|
443
|
+
return __generator(this, function (_b) {
|
|
444
|
+
switch (_b.label) {
|
|
445
|
+
case 0:
|
|
446
|
+
if (this.updating) {
|
|
447
|
+
return [2 /*return*/];
|
|
448
|
+
}
|
|
449
|
+
this.updating = true;
|
|
450
|
+
_b.label = 1;
|
|
451
|
+
case 1:
|
|
452
|
+
_b.trys.push([1, 3, , 4]);
|
|
453
|
+
return [4 /*yield*/, this.tryDoUpdate()];
|
|
454
|
+
case 2:
|
|
455
|
+
searchResult = _b.sent();
|
|
456
|
+
if (searchResult == ESearchStatus.LocationChanged) {
|
|
457
|
+
interest = {
|
|
458
|
+
bounds: this.bounds,
|
|
459
|
+
target: this.target
|
|
460
|
+
};
|
|
461
|
+
// this.createEntity();
|
|
462
|
+
(_a = this.updatedEvent) === null || _a === void 0 ? void 0 : _a.Trigger(interest);
|
|
463
|
+
}
|
|
464
|
+
else if (searchResult == ESearchStatus.LocationMissing) {
|
|
465
|
+
this.updateQueue();
|
|
466
|
+
}
|
|
467
|
+
return [3 /*break*/, 4];
|
|
468
|
+
case 3:
|
|
469
|
+
e_1 = _b.sent();
|
|
470
|
+
console.error(e_1);
|
|
471
|
+
this.updateQueue();
|
|
472
|
+
return [3 /*break*/, 4];
|
|
473
|
+
case 4:
|
|
474
|
+
this.updating = false;
|
|
475
|
+
return [2 /*return*/];
|
|
401
476
|
}
|
|
402
|
-
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
Monitor.prototype.queuePosition = function (lag) {
|
|
481
|
+
var _this = this;
|
|
482
|
+
if (this.pendingTimeout) {
|
|
483
|
+
clearTimeout(this.pendingTimeout);
|
|
403
484
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
};
|
|
409
|
-
cacheTimestamp = Date.now();
|
|
410
|
-
cachedCameraState = {
|
|
411
|
-
position: camera.positionWC.clone(),
|
|
412
|
-
direction: camera.directionWC.clone()
|
|
413
|
-
};
|
|
414
|
-
return pos3d;
|
|
485
|
+
this.pendingTimeout = setTimeout(function () {
|
|
486
|
+
if (!_this.disposed) {
|
|
487
|
+
_this.tryEmitUpdate();
|
|
488
|
+
}
|
|
489
|
+
}, lag);
|
|
415
490
|
};
|
|
416
|
-
|
|
491
|
+
Monitor.prototype.updateQueue = function () {
|
|
492
|
+
this.queuePosition(TIME_LAG);
|
|
493
|
+
};
|
|
494
|
+
return Monitor;
|
|
495
|
+
}());
|
|
496
|
+
CesiumViewMonitor.Monitor = Monitor;
|
|
497
|
+
})(exports.CesiumViewMonitor || (exports.CesiumViewMonitor = {}));
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Ensures a number is returned from a given value.
|
|
501
|
+
* If given value cannot be parsed it will return defaultNum.
|
|
502
|
+
* @param value
|
|
503
|
+
* @param defaultNum default is 0.
|
|
504
|
+
* @returns
|
|
505
|
+
*/
|
|
506
|
+
function EnsureNumber(value, defaultNum) {
|
|
507
|
+
if (!defaultNum) {
|
|
508
|
+
defaultNum = 0;
|
|
509
|
+
}
|
|
510
|
+
value = Number(value);
|
|
511
|
+
if (isNaN(value)) {
|
|
512
|
+
return defaultNum;
|
|
513
|
+
}
|
|
514
|
+
return value;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
(function (MeasureUtils) {
|
|
417
518
|
/**
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
* @param
|
|
421
|
-
* @param closed: true if this is a closed shape. Eg: polygon.
|
|
519
|
+
* Returns the total distance in meters between an array of points.
|
|
520
|
+
* This distance is NOT following the terrain.
|
|
521
|
+
* @param posses
|
|
422
522
|
* @returns
|
|
423
523
|
*/
|
|
424
|
-
function
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
points.push(C3.subtract(points[points.length - 1], points[points.length - 2], new C3));
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
points.unshift(points[points.length - 1]);
|
|
434
|
-
points.unshift(points[points.length - 2]);
|
|
435
|
-
points.push(points[2]);
|
|
524
|
+
function MeasurePolyline(params) {
|
|
525
|
+
var posses = params.posses;
|
|
526
|
+
if (posses.length < 2) {
|
|
527
|
+
return {
|
|
528
|
+
totalLength: 0
|
|
529
|
+
};
|
|
436
530
|
}
|
|
437
|
-
var
|
|
438
|
-
var
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
531
|
+
var totalLength = 0;
|
|
532
|
+
var pos1 = null;
|
|
533
|
+
var pos2 = null;
|
|
534
|
+
for (var i = 0; i < posses.length; i++) {
|
|
535
|
+
if (pos1 == null) {
|
|
536
|
+
pos1 = posses[i];
|
|
537
|
+
}
|
|
538
|
+
else if (pos2 == null) {
|
|
539
|
+
pos2 = posses[i];
|
|
540
|
+
totalLength += Cesium.Cartesian3.distance(pos1, pos2);
|
|
541
|
+
pos1 = pos2;
|
|
542
|
+
pos2 = null;
|
|
442
543
|
}
|
|
443
|
-
};
|
|
444
|
-
for (var i = 0; i < points.length - 3; i++) {
|
|
445
|
-
_loop_1(i);
|
|
446
544
|
}
|
|
447
|
-
return
|
|
545
|
+
return {
|
|
546
|
+
totalLength: totalLength
|
|
547
|
+
};
|
|
448
548
|
}
|
|
449
|
-
|
|
549
|
+
MeasureUtils.MeasurePolyline = MeasurePolyline;
|
|
550
|
+
function MeasurePolygon(params) {
|
|
551
|
+
var posses = params.posses;
|
|
552
|
+
posses = [].concat(posses);
|
|
553
|
+
if (!bruceModels.Cartes.IsRing3Closed(posses)) {
|
|
554
|
+
posses.push(posses[0].clone());
|
|
555
|
+
}
|
|
556
|
+
if (posses.length < 3) {
|
|
557
|
+
return {
|
|
558
|
+
area: 0,
|
|
559
|
+
perimeter: 0
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
var area = 0;
|
|
563
|
+
var indices = Cesium.PolygonPipeline.triangulate(posses, []);
|
|
564
|
+
for (var i = 0; i < indices.length; i += 3) {
|
|
565
|
+
var vector1 = posses[indices[i]];
|
|
566
|
+
var vector2 = posses[indices[i + 1]];
|
|
567
|
+
var vector3 = posses[indices[i + 2]];
|
|
568
|
+
var vectorC = Cesium.Cartesian3.subtract(vector2, vector1, new Cesium.Cartesian3());
|
|
569
|
+
var vectorD = Cesium.Cartesian3.subtract(vector3, vector1, new Cesium.Cartesian3());
|
|
570
|
+
var areaVector = Cesium.Cartesian3.cross(vectorC, vectorD, new Cesium.Cartesian3());
|
|
571
|
+
area += Cesium.Cartesian3.magnitude(areaVector) / 2.0;
|
|
572
|
+
}
|
|
573
|
+
var perimeter = MeasurePolyline({
|
|
574
|
+
posses: posses
|
|
575
|
+
}).totalLength;
|
|
576
|
+
return {
|
|
577
|
+
area: area,
|
|
578
|
+
perimeter: perimeter
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
MeasureUtils.MeasurePolygon = MeasurePolygon;
|
|
582
|
+
})(exports.MeasureUtils || (exports.MeasureUtils = {}));
|
|
583
|
+
|
|
584
|
+
var C3 = [Cesium.Cartesian3][0];
|
|
585
|
+
function getT(t, alpha, p0, p1) {
|
|
586
|
+
var d = C3.subtract(p1, p0, new C3);
|
|
587
|
+
var a = C3.dot(d, d);
|
|
588
|
+
var b = Math.pow(a, alpha * 0.5);
|
|
589
|
+
return b + t;
|
|
590
|
+
}
|
|
591
|
+
function catmullRom(p0, p1, p2, p3, t) {
|
|
592
|
+
var t0 = 0;
|
|
593
|
+
var t1 = getT(t0, 0.5, p0, p1);
|
|
594
|
+
var t2 = getT(t1, 0.5, p1, p2);
|
|
595
|
+
var t3 = getT(t2, 0.5, p2, p3);
|
|
596
|
+
t = Cesium.Math.lerp(t1, t2, t);
|
|
597
|
+
var _a = [function (l, r) { return C3.add(l, r, new C3); }, function (l, r) { return C3.multiplyByScalar(l, r, new C3); }], add = _a[0], mul = _a[1];
|
|
598
|
+
var A1 = add(mul(p0, (t1 - t) / (t1 - t0)), mul(p1, (t - t0) / (t1 - t0)));
|
|
599
|
+
var A2 = add(mul(p1, (t2 - t) / (t2 - t1)), mul(p2, (t - t1) / (t2 - t1)));
|
|
600
|
+
var A3 = add(mul(p2, (t3 - t) / (t3 - t2)), mul(p3, (t - t2) / (t3 - t2)));
|
|
601
|
+
var B1 = add(mul(A1, (t2 - t) / (t2 - t0)), mul(A2, (t - t0) / (t2 - t0)));
|
|
602
|
+
var B2 = add(mul(A2, (t3 - t) / (t3 - t1)), mul(A3, (t - t1) / (t3 - t1)));
|
|
603
|
+
var C = add(mul(B1, (t2 - t) / (t2 - t1)), mul(B2, (t - t1) / (t2 - t1)));
|
|
604
|
+
return C;
|
|
605
|
+
}
|
|
606
|
+
(function (DrawingUtils) {
|
|
607
|
+
/**
|
|
608
|
+
* Returns the point across a polyline at a given distance.
|
|
609
|
+
* If the distance exceeds the length of the line, the point will be placed at the end of the line.
|
|
610
|
+
* @param viewer
|
|
611
|
+
* @param positions
|
|
612
|
+
* @param distance
|
|
613
|
+
* @returns
|
|
614
|
+
*/
|
|
615
|
+
function PointAcrossPolyline(params) {
|
|
616
|
+
var viewer = params.viewer, positions = params.posses, distance = params.distance;
|
|
617
|
+
if (distance <= 0 && positions.length > 0) {
|
|
618
|
+
return {
|
|
619
|
+
point: positions[0]
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
else if (positions.length > 1) {
|
|
623
|
+
var currentDistance = 0;
|
|
624
|
+
var totalLength = exports.MeasureUtils.MeasurePolyline({
|
|
625
|
+
posses: positions,
|
|
626
|
+
}).totalLength;
|
|
627
|
+
if (distance > totalLength) {
|
|
628
|
+
return {
|
|
629
|
+
point: positions[positions.length - 1]
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
for (var i = 0; i < positions.length - 1; i++) {
|
|
633
|
+
var length_1 = Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
|
634
|
+
if (length_1 + currentDistance >= distance) {
|
|
635
|
+
var carto1 = Cesium.Cartographic.fromCartesian(positions[i]);
|
|
636
|
+
var carto2 = Cesium.Cartographic.fromCartesian(positions[i + 1]);
|
|
637
|
+
var geodesic = new Cesium.EllipsoidGeodesic(carto1, carto2, viewer.scene.globe.ellipsoid);
|
|
638
|
+
//const position = geodesic.interpolateUsingSurfaceDistance(distance - currentDistance);
|
|
639
|
+
var position = geodesic.interpolateUsingFraction((distance - currentDistance) / length_1);
|
|
640
|
+
var height = (carto1.height + carto2.height) / 2;
|
|
641
|
+
return {
|
|
642
|
+
point: Cesium.Cartesian3.fromRadians(position.longitude, position.latitude, height)
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
currentDistance += length_1;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return {
|
|
651
|
+
point: positions.length ? positions[positions.length - 1] : null
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
DrawingUtils.PointAcrossPolyline = PointAcrossPolyline;
|
|
450
655
|
/**
|
|
656
|
+
* Returns terrain height from current viewer's provider.
|
|
657
|
+
* On error or flat terrain, it will return 0.
|
|
658
|
+
* If an error occurred it will be attached to the result.
|
|
451
659
|
* @param pos3d
|
|
452
|
-
* @param
|
|
660
|
+
* @param viewer
|
|
661
|
+
* @returns
|
|
453
662
|
*/
|
|
454
|
-
function
|
|
455
|
-
if (minimumHeight === void 0) { minimumHeight = 0; }
|
|
663
|
+
function GetTerrainHeight(params) {
|
|
456
664
|
return __awaiter(this, void 0, void 0, function () {
|
|
457
|
-
var
|
|
665
|
+
var pos3d, viewer, sample, height, e_1;
|
|
458
666
|
return __generator(this, function (_a) {
|
|
459
667
|
switch (_a.label) {
|
|
460
668
|
case 0:
|
|
669
|
+
pos3d = params.pos3d, viewer = params.viewer;
|
|
670
|
+
_a.label = 1;
|
|
671
|
+
case 1:
|
|
672
|
+
_a.trys.push([1, 3, , 4]);
|
|
461
673
|
// If the terrain provider is not ready let's not ping it.
|
|
462
674
|
if (!viewer.terrainProvider || viewer.terrainProvider["ready"] == false) {
|
|
463
|
-
return [2 /*return*/,
|
|
675
|
+
return [2 /*return*/, {
|
|
676
|
+
height: 0,
|
|
677
|
+
error: "Terrain provider not ready."
|
|
678
|
+
}];
|
|
464
679
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
return [
|
|
471
|
-
case 1: return [4 /*yield*/, Cesium.sampleTerrainMostDetailed(viewer.scene.terrainProvider, [terrainCarto])];
|
|
680
|
+
if (viewer.scene.terrainProvider instanceof Cesium.EllipsoidTerrainProvider) {
|
|
681
|
+
return [2 /*return*/, {
|
|
682
|
+
height: 0
|
|
683
|
+
}];
|
|
684
|
+
}
|
|
685
|
+
return [4 /*yield*/, Cesium.sampleTerrainMostDetailed(viewer.scene.terrainProvider, [Cesium.Cartographic.fromCartesian(pos3d)])];
|
|
472
686
|
case 2:
|
|
473
687
|
sample = _a.sent();
|
|
474
|
-
|
|
475
|
-
if (
|
|
476
|
-
|
|
688
|
+
height = (sample === null || sample === void 0 ? void 0 : sample.length) ? sample[0].height : null;
|
|
689
|
+
if (isNaN(height)) {
|
|
690
|
+
return [2 /*return*/, {
|
|
691
|
+
height: 0,
|
|
692
|
+
error: "NaN"
|
|
693
|
+
}];
|
|
477
694
|
}
|
|
478
|
-
|
|
479
|
-
|
|
695
|
+
return [2 /*return*/, {
|
|
696
|
+
height: height
|
|
697
|
+
}];
|
|
698
|
+
case 3:
|
|
699
|
+
e_1 = _a.sent();
|
|
700
|
+
return [2 /*return*/, {
|
|
701
|
+
height: 0,
|
|
702
|
+
error: e_1
|
|
703
|
+
}];
|
|
704
|
+
case 4: return [2 /*return*/];
|
|
480
705
|
}
|
|
481
706
|
});
|
|
482
707
|
});
|
|
483
708
|
}
|
|
484
|
-
DrawingUtils.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
* @param visual
|
|
491
|
-
* @returns
|
|
492
|
-
*/
|
|
493
|
-
function isAlive(viewer, visual) {
|
|
494
|
-
if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
|
|
495
|
-
return false;
|
|
496
|
-
}
|
|
497
|
-
if (visual instanceof Cesium.Entity) {
|
|
498
|
-
return true;
|
|
499
|
-
}
|
|
500
|
-
else if (visual instanceof Cesium.Primitive) {
|
|
501
|
-
return true;
|
|
502
|
-
}
|
|
503
|
-
else if (visual instanceof Cesium.Cesium3DTileFeature) {
|
|
504
|
-
var cTileset = visual === null || visual === void 0 ? void 0 : visual.tileset;
|
|
505
|
-
if (!cTileset) {
|
|
506
|
-
return false;
|
|
709
|
+
DrawingUtils.GetTerrainHeight = GetTerrainHeight;
|
|
710
|
+
function EnsurePosHeight(params) {
|
|
711
|
+
var pos3d = params.pos3d, viewer = params.viewer, desiredHeightRef = params.desiredHeightRef, heightRef = params.heightRef;
|
|
712
|
+
var carto = bruceModels.Cartes.ValidateCartes3(pos3d) ? Cesium.Cartographic.fromCartesian(pos3d) : null;
|
|
713
|
+
if (!(carto === null || carto === void 0 ? void 0 : carto.latitude)) {
|
|
714
|
+
return pos3d;
|
|
507
715
|
}
|
|
508
|
-
if (
|
|
509
|
-
|
|
716
|
+
if (heightRef == null) {
|
|
717
|
+
heightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
510
718
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
719
|
+
if (desiredHeightRef == null) {
|
|
720
|
+
desiredHeightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
721
|
+
}
|
|
722
|
+
if (heightRef == desiredHeightRef) {
|
|
723
|
+
return pos3d;
|
|
724
|
+
}
|
|
725
|
+
if (heightRef == Cesium.HeightReference.NONE) {
|
|
726
|
+
// Turn absolute into clamped.
|
|
727
|
+
if (desiredHeightRef == Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
728
|
+
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, 0);
|
|
729
|
+
}
|
|
730
|
+
// Turn absolute into relative (remove terrain height).
|
|
731
|
+
else if (desiredHeightRef == Cesium.HeightReference.RELATIVE_TO_GROUND) {
|
|
732
|
+
var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto), 0);
|
|
733
|
+
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height - terrainHeight);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
else if (heightRef == Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
737
|
+
var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto), 0);
|
|
738
|
+
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, terrainHeight);
|
|
739
|
+
}
|
|
740
|
+
else if (heightRef == Cesium.HeightReference.RELATIVE_TO_GROUND) {
|
|
741
|
+
// Turn relative into absolute (add terrain height).
|
|
742
|
+
if (desiredHeightRef == Cesium.HeightReference.NONE) {
|
|
743
|
+
var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto), 0);
|
|
744
|
+
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height + terrainHeight);
|
|
745
|
+
}
|
|
746
|
+
// Turn relative into clamped.
|
|
747
|
+
else if (desiredHeightRef == Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
748
|
+
return Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, 0);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
return pos3d;
|
|
539
752
|
}
|
|
540
|
-
|
|
753
|
+
DrawingUtils.EnsurePosHeight = EnsurePosHeight;
|
|
754
|
+
/**
|
|
755
|
+
* Returns an accurate 3d position from a given screen position.
|
|
756
|
+
* @param viewer
|
|
757
|
+
* @param cursor
|
|
758
|
+
* @returns
|
|
759
|
+
*/
|
|
760
|
+
DrawingUtils.GetAccuratePosition = (function () {
|
|
761
|
+
var cachedPick = null;
|
|
762
|
+
var cacheTimestamp = null;
|
|
763
|
+
var cachedCameraState = null;
|
|
764
|
+
return function (viewer, cursor, pickOnly) {
|
|
765
|
+
if (pickOnly === void 0) { pickOnly = false; }
|
|
766
|
+
var scene = viewer.scene;
|
|
767
|
+
var camera = scene.camera;
|
|
768
|
+
// Check if we can use cached position.
|
|
769
|
+
if (cachedPick && cacheTimestamp) {
|
|
770
|
+
var timeElapsed = Date.now() - cacheTimestamp;
|
|
771
|
+
var isWithinCacheDuration = timeElapsed < 3000; // 3 seconds
|
|
772
|
+
var isNearPreviousPick = Cesium.Cartesian2.distanceSquared(cursor, cachedPick.cursor) < 9; // 3 pixels
|
|
773
|
+
var directionDot = Cesium.Cartesian3.dot(camera.directionWC, cachedCameraState.direction);
|
|
774
|
+
var directionLengths = Cesium.Cartesian3.magnitude(camera.directionWC) * Cesium.Cartesian3.magnitude(cachedCameraState.direction);
|
|
775
|
+
var angle = Math.acos(directionDot / directionLengths);
|
|
776
|
+
var hasCameraMoved = Math.abs(camera.positionWC.x - cachedCameraState.position.x) > 2 || // 2 meters
|
|
777
|
+
Math.abs(camera.positionWC.y - cachedCameraState.position.y) > 2 ||
|
|
778
|
+
angle > Cesium.Math.toRadians(5); // 5 degrees
|
|
779
|
+
if (isWithinCacheDuration && isNearPreviousPick && !hasCameraMoved) {
|
|
780
|
+
return cachedPick.position;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
// Actual picking logic
|
|
784
|
+
// https://community.cesium.com/t/scene-pick-returning-point-inside-the-globe/18940/9
|
|
785
|
+
var pos3d = null;
|
|
786
|
+
// Means we can accurately pick right now.
|
|
787
|
+
if (!pickOnly && scene.globe.depthTestAgainstTerrain) {
|
|
788
|
+
pos3d = scene.pickPosition(cursor);
|
|
789
|
+
}
|
|
790
|
+
// Means we cannot guarantee an accurate pick.
|
|
791
|
+
// We want to prioritize pick-position when we can, so we'll try use it and if the result is sus then we'll use some fallbacks.
|
|
792
|
+
else {
|
|
793
|
+
if (!pickOnly) {
|
|
794
|
+
pos3d = scene.pickPosition(cursor);
|
|
795
|
+
}
|
|
796
|
+
if (Cesium.defined(pos3d)) {
|
|
797
|
+
var carto = Cesium.Cartographic.fromCartesian(pos3d);
|
|
798
|
+
if (!Cesium.defined(carto) || carto.height < 0) {
|
|
799
|
+
pos3d = null;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
if (!Cesium.defined(pos3d)) {
|
|
803
|
+
pos3d = null;
|
|
804
|
+
var ray = scene.camera.getPickRay(cursor);
|
|
805
|
+
if (scene.pickPositionSupported) {
|
|
806
|
+
var pickedObject = scene.pick(cursor, 1, 1);
|
|
807
|
+
if (Cesium.defined(pickedObject) &&
|
|
808
|
+
(pickedObject instanceof Cesium.Cesium3DTileFeature ||
|
|
809
|
+
pickedObject.primitive instanceof Cesium.Cesium3DTileset ||
|
|
810
|
+
pickedObject.primitive instanceof Cesium.Model)) {
|
|
811
|
+
pos3d = scene.pickPosition(cursor);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
if (!pickOnly && !Cesium.defined(pos3d)) {
|
|
815
|
+
pos3d = scene.globe.pick(ray, scene);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
// Update cache.
|
|
820
|
+
cachedPick = {
|
|
821
|
+
position: pos3d,
|
|
822
|
+
cursor: cursor.clone()
|
|
823
|
+
};
|
|
824
|
+
cacheTimestamp = Date.now();
|
|
825
|
+
cachedCameraState = {
|
|
826
|
+
position: camera.positionWC.clone(),
|
|
827
|
+
direction: camera.directionWC.clone()
|
|
828
|
+
};
|
|
829
|
+
return pos3d;
|
|
830
|
+
};
|
|
831
|
+
})();
|
|
832
|
+
/**
|
|
833
|
+
* Smooths a given set of points.
|
|
834
|
+
* @param points
|
|
835
|
+
* @param multiplier
|
|
836
|
+
* @param closed: true if this is a closed shape. Eg: polygon.
|
|
837
|
+
* @returns
|
|
838
|
+
*/
|
|
839
|
+
function SmoothPoints(points, multiplier, closed) {
|
|
840
|
+
if (points.length < 4 || multiplier < 2) {
|
|
841
|
+
return points;
|
|
842
|
+
}
|
|
843
|
+
if (!closed) {
|
|
844
|
+
points.unshift(C3.subtract(points[0], points[1], new C3));
|
|
845
|
+
points.push(C3.subtract(points[points.length - 1], points[points.length - 2], new C3));
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
points.unshift(points[points.length - 1]);
|
|
849
|
+
points.unshift(points[points.length - 2]);
|
|
850
|
+
points.push(points[2]);
|
|
851
|
+
}
|
|
852
|
+
var splinePoints = [];
|
|
853
|
+
var _loop_1 = function (i) {
|
|
854
|
+
var _a = [0, 1, 2, 3].map(function (n) { return points[i + n]; }), P0 = _a[0], P1 = _a[1], P2 = _a[2], P3 = _a[3];
|
|
855
|
+
for (var j = 0; j <= multiplier; j++) {
|
|
856
|
+
splinePoints.push(catmullRom(P0, P1, P2, P3, j / multiplier));
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
for (var i = 0; i < points.length - 3; i++) {
|
|
860
|
+
_loop_1(i);
|
|
861
|
+
}
|
|
862
|
+
return splinePoints;
|
|
863
|
+
}
|
|
864
|
+
DrawingUtils.SmoothPoints = SmoothPoints;
|
|
865
|
+
/**
|
|
866
|
+
* @param pos3d
|
|
867
|
+
* @param minimumHeight height relative to ground
|
|
868
|
+
*/
|
|
869
|
+
function RaisePos3d(viewer, pos3d, minimumHeight) {
|
|
870
|
+
if (minimumHeight === void 0) { minimumHeight = 0; }
|
|
871
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
872
|
+
var carto, terrainCarto, sample, terrainHeight;
|
|
873
|
+
return __generator(this, function (_a) {
|
|
874
|
+
switch (_a.label) {
|
|
875
|
+
case 0:
|
|
876
|
+
// If the terrain provider is not ready let's not ping it.
|
|
877
|
+
if (!viewer.terrainProvider || viewer.terrainProvider["ready"] == false) {
|
|
878
|
+
return [2 /*return*/, pos3d];
|
|
879
|
+
}
|
|
880
|
+
carto = Cesium.Cartographic.fromCartesian(pos3d);
|
|
881
|
+
terrainCarto = carto.clone();
|
|
882
|
+
terrainCarto.height = 0;
|
|
883
|
+
if (!(viewer.scene.terrainProvider instanceof Cesium.EllipsoidTerrainProvider)) return [3 /*break*/, 1];
|
|
884
|
+
carto.height = Math.max(carto.height, minimumHeight);
|
|
885
|
+
return [3 /*break*/, 3];
|
|
886
|
+
case 1: return [4 /*yield*/, Cesium.sampleTerrainMostDetailed(viewer.scene.terrainProvider, [terrainCarto])];
|
|
887
|
+
case 2:
|
|
888
|
+
sample = _a.sent();
|
|
889
|
+
terrainHeight = (sample === null || sample === void 0 ? void 0 : sample.length) ? sample[0].height : null;
|
|
890
|
+
if (terrainHeight != null) {
|
|
891
|
+
carto.height = Math.max(carto.height, terrainHeight + minimumHeight);
|
|
892
|
+
}
|
|
893
|
+
_a.label = 3;
|
|
894
|
+
case 3: return [2 /*return*/, Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height)];
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
DrawingUtils.RaisePos3d = RaisePos3d;
|
|
900
|
+
})(exports.DrawingUtils || (exports.DrawingUtils = {}));
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Returns if a given visual can be styled by this utility.
|
|
904
|
+
* @param viewer
|
|
905
|
+
* @param visual
|
|
906
|
+
* @returns
|
|
907
|
+
*/
|
|
908
|
+
function isAlive(viewer, visual) {
|
|
909
|
+
if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
if (visual instanceof Cesium.Entity) {
|
|
913
|
+
return true;
|
|
914
|
+
}
|
|
915
|
+
else if (visual instanceof Cesium.Primitive) {
|
|
916
|
+
return true;
|
|
917
|
+
}
|
|
918
|
+
else if (visual instanceof Cesium.Cesium3DTileFeature) {
|
|
919
|
+
var cTileset = visual === null || visual === void 0 ? void 0 : visual.tileset;
|
|
920
|
+
if (!cTileset) {
|
|
921
|
+
return false;
|
|
922
|
+
}
|
|
923
|
+
if (cTileset.isDestroyed() || !viewer.scene.primitives.contains(cTileset)) {
|
|
924
|
+
return false;
|
|
925
|
+
}
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
return false;
|
|
929
|
+
}
|
|
930
|
+
var _selectColor = Cesium.Color.fromAlpha(Cesium.Color.YELLOW, 0.5);
|
|
931
|
+
var _highlightColor = Cesium.Color.fromCssColorString("#33b1ff").withAlpha(0.5);
|
|
932
|
+
var STORE_COLOR_PREFIX = "_storeColor_";
|
|
933
|
+
function getStoreKey(key) {
|
|
934
|
+
return STORE_COLOR_PREFIX + key;
|
|
935
|
+
}
|
|
936
|
+
var STORE_KEY_STATE_PREFIX = "_storeKeyState_";
|
|
937
|
+
function getStoreStateKey(key) {
|
|
938
|
+
return STORE_KEY_STATE_PREFIX + key;
|
|
939
|
+
}
|
|
940
|
+
var LAST_APPLIED_OPACITY_KEY = "_lastAppliedOpacityKey";
|
|
941
|
+
/**
|
|
942
|
+
* Returns a color property from a graphic.
|
|
943
|
+
* This will turn materials properties into colors before returning them.
|
|
944
|
+
* @param viewer
|
|
945
|
+
* @param prop
|
|
946
|
+
* @returns
|
|
947
|
+
*/
|
|
948
|
+
function getCesiumColorValue(viewer, prop) {
|
|
949
|
+
if (!prop) {
|
|
950
|
+
return Cesium.Color.WHITE;
|
|
951
|
+
}
|
|
952
|
+
if (prop.getValue) {
|
|
953
|
+
prop = prop.getValue(viewer.scene.lastRenderTime);
|
|
954
|
+
}
|
|
955
|
+
if (prop instanceof Cesium.Color) {
|
|
541
956
|
return prop;
|
|
542
957
|
}
|
|
543
958
|
var tmp = prop === null || prop === void 0 ? void 0 : prop.color;
|
|
@@ -3786,14 +4201,14 @@
|
|
|
3786
4201
|
};
|
|
3787
4202
|
res(data);
|
|
3788
4203
|
};
|
|
3789
|
-
image_1.onerror = function () {
|
|
3790
|
-
rej(
|
|
4204
|
+
image_1.onerror = function (e) {
|
|
4205
|
+
rej(e);
|
|
3791
4206
|
};
|
|
3792
4207
|
image_1.src = URL.createObjectURL(blob);
|
|
3793
4208
|
return [3 /*break*/, 4];
|
|
3794
4209
|
case 3:
|
|
3795
4210
|
e_4 = _a.sent();
|
|
3796
|
-
rej(
|
|
4211
|
+
rej(e_4);
|
|
3797
4212
|
return [3 /*break*/, 4];
|
|
3798
4213
|
case 4: return [2 /*return*/];
|
|
3799
4214
|
}
|
|
@@ -6442,7 +6857,7 @@
|
|
|
6442
6857
|
}
|
|
6443
6858
|
// A sub-object can be culled while the siblings are not.
|
|
6444
6859
|
// We only cull things that give us some benefit. For example clamped to ground graphics are expensive to keep rendered.
|
|
6445
|
-
show = show ? !VisualRegisterCuller.IsCulled(viewer, rego, visual) :
|
|
6860
|
+
show = show ? !VisualRegisterCuller.IsCulled(viewer, rego, visual) : false;
|
|
6446
6861
|
if (visual._parentEntity && !ignoreParent) {
|
|
6447
6862
|
updateCEntityShow(viewer, visual._parentEntity, rego, show, false, depth + 1);
|
|
6448
6863
|
}
|
|
@@ -7993,7 +8408,7 @@
|
|
|
7993
8408
|
entityId: id,
|
|
7994
8409
|
menuItemId: this.menuItemId
|
|
7995
8410
|
});
|
|
7996
|
-
if (rego && rego.overrideShow) {
|
|
8411
|
+
if (rego && rego.overrideShow != null) {
|
|
7997
8412
|
rego.overrideShow = null;
|
|
7998
8413
|
entitiesToUpdate.push(id);
|
|
7999
8414
|
}
|
|
@@ -8072,8 +8487,8 @@
|
|
|
8072
8487
|
entityId: entityId,
|
|
8073
8488
|
menuItemId: this_1.menuItemId
|
|
8074
8489
|
});
|
|
8075
|
-
if (rego &&
|
|
8076
|
-
rego.overrideShow =
|
|
8490
|
+
if (rego && rego.overrideShow != false) {
|
|
8491
|
+
rego.overrideShow = false;
|
|
8077
8492
|
entitiesToUpdate.push(entityId);
|
|
8078
8493
|
}
|
|
8079
8494
|
}
|
|
@@ -9043,7 +9458,7 @@
|
|
|
9043
9458
|
entityTypeId: entity.Bruce["EntityType.ID"],
|
|
9044
9459
|
accountId: this.apiGetter.accountId,
|
|
9045
9460
|
tagIds: tagIds ? [].concat(tagIds) : [],
|
|
9046
|
-
overrideShow: wasClustered ?
|
|
9461
|
+
overrideShow: wasClustered ? false : null,
|
|
9047
9462
|
name: cEntity.name,
|
|
9048
9463
|
cdn: this.item.cdnEnabled
|
|
9049
9464
|
};
|
|
@@ -10445,7 +10860,7 @@
|
|
|
10445
10860
|
priority: 0,
|
|
10446
10861
|
entityTypeId: entity.Bruce["EntityType.ID"],
|
|
10447
10862
|
accountId: this.apiGetter.accountId,
|
|
10448
|
-
overrideShow: clustered ?
|
|
10863
|
+
overrideShow: clustered ? false : null,
|
|
10449
10864
|
name: cEntity.name
|
|
10450
10865
|
},
|
|
10451
10866
|
requestRender: false
|
|
@@ -13389,7 +13804,7 @@
|
|
|
13389
13804
|
configurable: true
|
|
13390
13805
|
});
|
|
13391
13806
|
Manager.prototype.Init = function () {
|
|
13392
|
-
var
|
|
13807
|
+
var _this = this;
|
|
13393
13808
|
var files = this.item.KML;
|
|
13394
13809
|
if (!files) {
|
|
13395
13810
|
return;
|
|
@@ -13397,31 +13812,47 @@
|
|
|
13397
13812
|
if (!Array.isArray(files)) {
|
|
13398
13813
|
files = [files];
|
|
13399
13814
|
}
|
|
13400
|
-
|
|
13401
|
-
var file
|
|
13402
|
-
var
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13815
|
+
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
13816
|
+
var api, i, file, fileId, externalURL, fileUrl, source;
|
|
13817
|
+
var _a;
|
|
13818
|
+
return __generator(this, function (_b) {
|
|
13819
|
+
switch (_b.label) {
|
|
13820
|
+
case 0:
|
|
13821
|
+
api = this.apiGetter.getApi();
|
|
13822
|
+
return [4 /*yield*/, api.Loading];
|
|
13823
|
+
case 1:
|
|
13824
|
+
_b.sent();
|
|
13825
|
+
if (this.disposed) {
|
|
13826
|
+
return [2 /*return*/];
|
|
13827
|
+
}
|
|
13828
|
+
for (i = 0; i < files.length; i++) {
|
|
13829
|
+
file = files[i];
|
|
13830
|
+
fileId = (_a = file === null || file === void 0 ? void 0 : file.ClientFile) === null || _a === void 0 ? void 0 : _a.ID;
|
|
13831
|
+
externalURL = file === null || file === void 0 ? void 0 : file.fileUrl;
|
|
13832
|
+
if (!fileId && !externalURL) {
|
|
13833
|
+
continue;
|
|
13834
|
+
}
|
|
13835
|
+
fileUrl = void 0;
|
|
13836
|
+
if (fileId) {
|
|
13837
|
+
fileUrl = bruceModels.ClientFile.GetUrl({
|
|
13838
|
+
api: api,
|
|
13839
|
+
fileId: fileId,
|
|
13840
|
+
viaCdn: true
|
|
13841
|
+
});
|
|
13842
|
+
}
|
|
13843
|
+
else if (externalURL) {
|
|
13844
|
+
fileUrl = externalURL;
|
|
13845
|
+
}
|
|
13846
|
+
source = new Cesium.KmlDataSource();
|
|
13847
|
+
source.load(fileUrl);
|
|
13848
|
+
this.viewer.dataSources.add(source);
|
|
13849
|
+
this.dataSources.push(source);
|
|
13850
|
+
this.viewer.scene.requestRender();
|
|
13851
|
+
}
|
|
13852
|
+
return [2 /*return*/];
|
|
13853
|
+
}
|
|
13854
|
+
});
|
|
13855
|
+
}); })();
|
|
13425
13856
|
};
|
|
13426
13857
|
Manager.prototype.Dispose = function () {
|
|
13427
13858
|
var _a;
|
|
@@ -20917,634 +21348,219 @@
|
|
|
20917
21348
|
imagery = JSON.parse(JSON.stringify(imagery));
|
|
20918
21349
|
for (i = 0; i < imagery.length; i++) {
|
|
20919
21350
|
layer = imagery[i];
|
|
20920
|
-
if (layer.tilesetId == bruceModels.ProjectViewTile.EDefaultImagery.BingMapsAerial) {
|
|
20921
|
-
layer.tilesetId = bruceModels.ProjectViewTile.EDefaultImagery.MapboxSatellite;
|
|
20922
|
-
console.warn("Cesium Ion token not set, using mapbox satellite instead of bing maps aerial.");
|
|
20923
|
-
}
|
|
20924
|
-
else if (layer.tilesetId == bruceModels.ProjectViewTile.EDefaultImagery.BingMapsAerialWithLabels) {
|
|
20925
|
-
layer.tilesetId = bruceModels.ProjectViewTile.EDefaultImagery.MapboxSatellite;
|
|
20926
|
-
console.warn("Cesium Ion token not set, using mapbox satellite instead of bing maps aerial with labels.");
|
|
20927
|
-
}
|
|
20928
|
-
else if (layer.tilesetId == bruceModels.ProjectViewTile.EDefaultImagery.BingMapsRoads) {
|
|
20929
|
-
layer.tilesetId = bruceModels.ProjectViewTile.EDefaultImagery.MapBoxStreets;
|
|
20930
|
-
console.warn("Cesium Ion token not set, using mapbox streets instead of bing maps roads.");
|
|
20931
|
-
}
|
|
20932
|
-
}
|
|
20933
|
-
}
|
|
20934
|
-
}
|
|
20935
|
-
// We don't wait for imageries to load, this does not affect rendering other things.
|
|
20936
|
-
exports.TileRenderEngine.Map.Navigator.Render({
|
|
20937
|
-
apiGetter: params.apiGetter,
|
|
20938
|
-
tiles: imagery,
|
|
20939
|
-
viewer: params.manager.Viewer,
|
|
20940
|
-
});
|
|
20941
|
-
legacyRelationIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.renderedEntityRelations;
|
|
20942
|
-
if (!legacyRelationIds) {
|
|
20943
|
-
legacyRelationIds = [];
|
|
20944
|
-
}
|
|
20945
|
-
relations = bSettings === null || bSettings === void 0 ? void 0 : bSettings.renderedRelations;
|
|
20946
|
-
if (!relations) {
|
|
20947
|
-
relations = [];
|
|
20948
|
-
}
|
|
20949
|
-
viewer.scene.requestRender();
|
|
20950
|
-
curEnabled = params.manager.GetEnabledItemIds();
|
|
20951
|
-
newItemIds = (_5 = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _5 !== void 0 ? _5 : [];
|
|
20952
|
-
for (_i = 0, curEnabled_1 = curEnabled; _i < curEnabled_1.length; _i++) {
|
|
20953
|
-
id = curEnabled_1[_i];
|
|
20954
|
-
shouldRemove = void 0;
|
|
20955
|
-
if (id == RELATION_MENU_ITEM_ID) {
|
|
20956
|
-
rendered = params.manager.GetEnabledItem(id);
|
|
20957
|
-
shouldRemove = false;
|
|
20958
|
-
if (!legacyRelationIds.length && !relations.length) {
|
|
20959
|
-
shouldRemove = true;
|
|
20960
|
-
}
|
|
20961
|
-
// If we're about to render legacy relationships but a non-legacy item is currently enabled then we remove it.
|
|
20962
|
-
else if (legacyRelationIds.length && (rendered === null || rendered === void 0 ? void 0 : rendered.type) != bruceModels.MenuItem.EType.Relations) {
|
|
20963
|
-
shouldRemove = true;
|
|
20964
|
-
}
|
|
20965
|
-
// If we're about to render non-legacy relationships but a legacy item is currently enabled then we remove it.
|
|
20966
|
-
else if (relations.length && (rendered === null || rendered === void 0 ? void 0 : rendered.type) != bruceModels.MenuItem.EType.Relationships) {
|
|
20967
|
-
shouldRemove = true;
|
|
20968
|
-
}
|
|
20969
|
-
}
|
|
20970
|
-
else {
|
|
20971
|
-
shouldRemove = newItemIds.indexOf(id) === -1;
|
|
20972
|
-
}
|
|
20973
|
-
if (shouldRemove) {
|
|
20974
|
-
params.manager.RemoveItemById({
|
|
20975
|
-
menuItemId: id
|
|
20976
|
-
});
|
|
20977
|
-
}
|
|
20978
|
-
}
|
|
20979
|
-
if (!bookmark) return [3 /*break*/, 15];
|
|
20980
|
-
return [4 /*yield*/, exports.MenuItemCreator.RenderBookmarkItems({
|
|
20981
|
-
getters: params.getters,
|
|
20982
|
-
manager: params.manager,
|
|
20983
|
-
view: view,
|
|
20984
|
-
bookmark: bookmark
|
|
20985
|
-
})];
|
|
20986
|
-
case 14:
|
|
20987
|
-
_8.sent();
|
|
20988
|
-
if (!assertIteration$1(params.viewer, iteration)) {
|
|
20989
|
-
return [2 /*return*/];
|
|
20990
|
-
}
|
|
20991
|
-
_8.label = 15;
|
|
20992
|
-
case 15:
|
|
20993
|
-
if (legacyRelationIds.length || relations.length) {
|
|
20994
|
-
if (relations.length) {
|
|
20995
|
-
menuItem = {
|
|
20996
|
-
id: RELATION_MENU_ITEM_ID,
|
|
20997
|
-
Caption: "Entity relations",
|
|
20998
|
-
relations: relations,
|
|
20999
|
-
Type: bruceModels.MenuItem.EType.Relationships
|
|
21000
|
-
};
|
|
21001
|
-
params.manager.RenderItem({
|
|
21002
|
-
getters: params.getters,
|
|
21003
|
-
item: menuItem
|
|
21004
|
-
});
|
|
21005
|
-
}
|
|
21006
|
-
else if (legacyRelationIds.length) {
|
|
21007
|
-
menuItem = {
|
|
21008
|
-
id: RELATION_MENU_ITEM_ID,
|
|
21009
|
-
Caption: "Entity relations",
|
|
21010
|
-
BruceEntity: {
|
|
21011
|
-
EntityIds: legacyRelationIds
|
|
21012
|
-
},
|
|
21013
|
-
Type: bruceModels.MenuItem.EType.Relations
|
|
21014
|
-
};
|
|
21015
|
-
params.manager.RenderItem({
|
|
21016
|
-
getters: params.getters,
|
|
21017
|
-
item: menuItem
|
|
21018
|
-
});
|
|
21019
|
-
}
|
|
21020
|
-
if (!assertIteration$1(params.viewer, iteration)) {
|
|
21021
|
-
return [2 /*return*/];
|
|
21022
|
-
}
|
|
21023
|
-
}
|
|
21024
|
-
gOcclusion = bSettings === null || bSettings === void 0 ? void 0 : bSettings.groundOcclusion;
|
|
21025
|
-
if (gOcclusion == null) {
|
|
21026
|
-
gOcclusion = (_6 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _6 === void 0 ? void 0 : _6.groundOcclusion;
|
|
21027
|
-
}
|
|
21028
|
-
if (gOcclusion == null) {
|
|
21029
|
-
// TODO: Need global default.
|
|
21030
|
-
gOcclusion = true;
|
|
21031
|
-
}
|
|
21032
|
-
scene.globe.depthTestAgainstTerrain = Boolean(gOcclusion);
|
|
21033
|
-
return [2 /*return*/];
|
|
21034
|
-
}
|
|
21035
|
-
});
|
|
21036
|
-
});
|
|
21037
|
-
}
|
|
21038
|
-
(function (ViewRenderEngine) {
|
|
21039
|
-
function Render(params) {
|
|
21040
|
-
var _a;
|
|
21041
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
21042
|
-
var iteration, api, view, _b, bookmark, bookmarkId, _c, version, bWidget;
|
|
21043
|
-
return __generator(this, function (_d) {
|
|
21044
|
-
switch (_d.label) {
|
|
21045
|
-
case 0:
|
|
21046
|
-
if (!params.manager && params.viewer) {
|
|
21047
|
-
params.manager = exports.ViewerUtils.GetManager({
|
|
21048
|
-
viewer: params.viewer,
|
|
21049
|
-
createIfMissing: true
|
|
21050
|
-
});
|
|
21051
|
-
}
|
|
21052
|
-
else if (!params.viewer && params.manager) {
|
|
21053
|
-
params.viewer = params.manager.Viewer;
|
|
21054
|
-
}
|
|
21055
|
-
iteration = newIteration$1(params.viewer);
|
|
21056
|
-
if (!params.getters) {
|
|
21057
|
-
params.getters = bruceModels.ENVIRONMENT.Api();
|
|
21058
|
-
}
|
|
21059
|
-
if (params.apiGetter && !params.getters) {
|
|
21060
|
-
console.warn("ViewRenderEngine.Render(): Please pass getters instead of apiGetter. This is now deprecated due to needing access to other kinds of apis.");
|
|
21061
|
-
}
|
|
21062
|
-
else if (!params.apiGetter) {
|
|
21063
|
-
params.apiGetter = params.getters.GetBruceGetter();
|
|
21064
|
-
}
|
|
21065
|
-
api = params.getters.GetBruceApi();
|
|
21066
|
-
if (!params.view) return [3 /*break*/, 1];
|
|
21067
|
-
_b = params.view;
|
|
21068
|
-
return [3 /*break*/, 3];
|
|
21069
|
-
case 1: return [4 /*yield*/, bruceModels.ProjectView.Get({
|
|
21070
|
-
api: api,
|
|
21071
|
-
viewId: params.viewId
|
|
21072
|
-
})];
|
|
21073
|
-
case 2:
|
|
21074
|
-
_b = (_d.sent()).view;
|
|
21075
|
-
_d.label = 3;
|
|
21076
|
-
case 3:
|
|
21077
|
-
view = _b;
|
|
21078
|
-
bookmark = params.bookmark;
|
|
21079
|
-
if (!!bookmark) return [3 /*break*/, 7];
|
|
21080
|
-
bookmarkId = params.bookmarkId;
|
|
21081
|
-
if (!bookmarkId) {
|
|
21082
|
-
bookmarkId = view.DefaultUISlideID;
|
|
21083
|
-
}
|
|
21084
|
-
if (!bookmarkId) return [3 /*break*/, 5];
|
|
21085
|
-
return [4 /*yield*/, bruceModels.ProjectViewBookmark.Get({
|
|
21086
|
-
api: api,
|
|
21087
|
-
viewId: params.viewId,
|
|
21088
|
-
bookmarkId: bookmarkId
|
|
21089
|
-
})];
|
|
21090
|
-
case 4:
|
|
21091
|
-
_c = (_d.sent()).bookmark;
|
|
21092
|
-
return [3 /*break*/, 6];
|
|
21093
|
-
case 5:
|
|
21094
|
-
_c = null;
|
|
21095
|
-
_d.label = 6;
|
|
21096
|
-
case 6:
|
|
21097
|
-
bookmark = _c;
|
|
21098
|
-
_d.label = 7;
|
|
21099
|
-
case 7:
|
|
21100
|
-
if (!assertIteration$1(params.viewer, iteration)) {
|
|
21101
|
-
return [2 /*return*/];
|
|
21102
|
-
}
|
|
21103
|
-
version = view.DataVersion;
|
|
21104
|
-
if (!(version == 1)) return [3 /*break*/, 9];
|
|
21105
|
-
return [4 /*yield*/, renderLegacyNavigator(iteration, params, bookmark, view)];
|
|
21106
|
-
case 8:
|
|
21107
|
-
_d.sent();
|
|
21108
|
-
return [3 /*break*/, 11];
|
|
21109
|
-
case 9: return [4 /*yield*/, renderNavigator(iteration, params, bookmark, view, params.getters)];
|
|
21110
|
-
case 10:
|
|
21111
|
-
_d.sent();
|
|
21112
|
-
_d.label = 11;
|
|
21113
|
-
case 11:
|
|
21114
|
-
if (!assertIteration$1(params.viewer, iteration)) {
|
|
21115
|
-
return [2 /*return*/];
|
|
21116
|
-
}
|
|
21117
|
-
bWidget = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_BOOKMARKS_WIDGET_KEY];
|
|
21118
|
-
if (bWidget) {
|
|
21119
|
-
bWidget.ViewId = params.viewId ? params.viewId : view === null || view === void 0 ? void 0 : view.ID;
|
|
21120
|
-
bWidget.LastEnabledBookmarkId = params.bookmarkId ? params.bookmarkId : bookmark === null || bookmark === void 0 ? void 0 : bookmark.ID;
|
|
21121
|
-
}
|
|
21122
|
-
return [2 /*return*/];
|
|
21123
|
-
}
|
|
21124
|
-
});
|
|
21125
|
-
});
|
|
21126
|
-
}
|
|
21127
|
-
ViewRenderEngine.Render = Render;
|
|
21128
|
-
})(exports.ViewRenderEngine || (exports.ViewRenderEngine = {}));
|
|
21129
|
-
|
|
21130
|
-
var TIME_LAG = 300;
|
|
21131
|
-
var POSITION_CHECK_TIMER = 950;
|
|
21132
|
-
var DEFAULT_GROUNDED_HEIGHT = 300;
|
|
21133
|
-
var MINIMUM_VIEW_AREA_SIZE_DEGREES = 0.01;
|
|
21134
|
-
var NET_STEP_PERCENT = 5;
|
|
21135
|
-
var BORDER_STEPS = 3;
|
|
21136
|
-
var ESearchStatus;
|
|
21137
|
-
(function (ESearchStatus) {
|
|
21138
|
-
ESearchStatus[ESearchStatus["LocationFound"] = 1] = "LocationFound";
|
|
21139
|
-
ESearchStatus[ESearchStatus["LocationChanged"] = 2] = "LocationChanged";
|
|
21140
|
-
ESearchStatus[ESearchStatus["LocationMissing"] = 3] = "LocationMissing";
|
|
21141
|
-
})(ESearchStatus || (ESearchStatus = {}));
|
|
21142
|
-
/**
|
|
21143
|
-
* @param viewer
|
|
21144
|
-
* @param center the previously calculated center of the view area. This is in degrees.
|
|
21145
|
-
* @returns
|
|
21146
|
-
*/
|
|
21147
|
-
function netScanViewForBoundaries(viewer, center) {
|
|
21148
|
-
var maxLong = -2 * Math.PI;
|
|
21149
|
-
var minLong = 2 * Math.PI;
|
|
21150
|
-
var maxLat = -2 * Math.PI;
|
|
21151
|
-
var minLat = 2 * Math.PI;
|
|
21152
|
-
var found = 0;
|
|
21153
|
-
var updateMinMax = function (lon, lat) {
|
|
21154
|
-
// Check to see if given lon/lat (in radians) are within valid range.
|
|
21155
|
-
if (lon < -Math.PI || lon > Math.PI || lat < -Math.PI / 2 || lat > Math.PI / 2) {
|
|
21156
|
-
return;
|
|
21157
|
-
}
|
|
21158
|
-
maxLong = Math.max(maxLong, lon);
|
|
21159
|
-
maxLat = Math.max(maxLat, lat);
|
|
21160
|
-
minLong = Math.min(minLong, lon);
|
|
21161
|
-
minLat = Math.min(minLat, lat);
|
|
21162
|
-
};
|
|
21163
|
-
var updateMinMaxForPoint = function (stepX, stepY) {
|
|
21164
|
-
var x = Math.round(0 + (viewer.container.clientWidth / 100) * (stepX * NET_STEP_PERCENT));
|
|
21165
|
-
var y = Math.round(0 + (viewer.container.clientHeight / 100) * (stepY * NET_STEP_PERCENT));
|
|
21166
|
-
var winPos = new Cesium.Cartesian2(x, y);
|
|
21167
|
-
try {
|
|
21168
|
-
var intersection = getAdjustedGroundIntersectionOfCameraRay(viewer, winPos);
|
|
21169
|
-
if (intersection) {
|
|
21170
|
-
var point = Cesium.Cartographic.fromCartesian(intersection, viewer.scene.globe.ellipsoid);
|
|
21171
|
-
updateMinMax(point.longitude, point.latitude);
|
|
21172
|
-
found++;
|
|
21173
|
-
}
|
|
21174
|
-
}
|
|
21175
|
-
catch (e) {
|
|
21176
|
-
console.error(e);
|
|
21177
|
-
}
|
|
21178
|
-
};
|
|
21179
|
-
// Outer circle.
|
|
21180
|
-
updateMinMaxForPoint(BORDER_STEPS, BORDER_STEPS);
|
|
21181
|
-
updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS, BORDER_STEPS);
|
|
21182
|
-
updateMinMaxForPoint(BORDER_STEPS, (100 / NET_STEP_PERCENT) - BORDER_STEPS);
|
|
21183
|
-
updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS, (100 / NET_STEP_PERCENT) - BORDER_STEPS);
|
|
21184
|
-
// Inner circle.
|
|
21185
|
-
updateMinMaxForPoint(BORDER_STEPS * 2, BORDER_STEPS * 2);
|
|
21186
|
-
updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS * 2, BORDER_STEPS * 2);
|
|
21187
|
-
updateMinMaxForPoint(BORDER_STEPS * 2, (100 / NET_STEP_PERCENT) - BORDER_STEPS * 2);
|
|
21188
|
-
updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS * 2, (100 / NET_STEP_PERCENT) - BORDER_STEPS * 2);
|
|
21189
|
-
// If we failed to find intersections and a center-point was provided, then we can use that to make some guesses.
|
|
21190
|
-
// This happens if terrain is hidden, and there's nothing to intersect with.
|
|
21191
|
-
if (center && found <= 0) {
|
|
21192
|
-
updateMinMax(Cesium.Math.toRadians(center.longitude), Cesium.Math.toRadians(center.latitude));
|
|
21193
|
-
found += 1;
|
|
21194
|
-
// We'll use the camera height as an indicator on size of the rect.
|
|
21195
|
-
var size = viewer.camera.positionCartographic.height;
|
|
21196
|
-
var pitch = viewer.camera.pitch;
|
|
21197
|
-
var distance = size / Math.tan(pitch);
|
|
21198
|
-
var p1 = _offsetPoint({
|
|
21199
|
-
altitude: center.altitude,
|
|
21200
|
-
latitude: center.latitude,
|
|
21201
|
-
longitude: center.longitude
|
|
21202
|
-
}, distance, 45);
|
|
21203
|
-
var p2 = _offsetPoint({
|
|
21204
|
-
altitude: center.altitude,
|
|
21205
|
-
latitude: center.latitude,
|
|
21206
|
-
longitude: center.longitude
|
|
21207
|
-
}, -distance, 45);
|
|
21208
|
-
if (p1 === null || p1 === void 0 ? void 0 : p1.latitude) {
|
|
21209
|
-
updateMinMax(Cesium.Math.toRadians(p1.longitude), Cesium.Math.toRadians(p1.latitude));
|
|
21210
|
-
}
|
|
21211
|
-
if (p2 === null || p2 === void 0 ? void 0 : p2.latitude) {
|
|
21212
|
-
updateMinMax(Cesium.Math.toRadians(p2.longitude), Cesium.Math.toRadians(p2.latitude));
|
|
21213
|
-
}
|
|
21214
|
-
}
|
|
21215
|
-
if (found > 0) {
|
|
21216
|
-
var viewRect = {
|
|
21217
|
-
east: maxLong,
|
|
21218
|
-
west: minLong,
|
|
21219
|
-
north: maxLat,
|
|
21220
|
-
south: minLat
|
|
21221
|
-
};
|
|
21222
|
-
return viewRect;
|
|
21223
|
-
}
|
|
21224
|
-
return null;
|
|
21225
|
-
}
|
|
21226
|
-
/**
|
|
21227
|
-
* Moves a given point by a given distance towards a heading.
|
|
21228
|
-
* @param point in degrees.
|
|
21229
|
-
* @param distance in meters.
|
|
21230
|
-
* @param heading in degrees.
|
|
21231
|
-
* @returns
|
|
21232
|
-
*/
|
|
21233
|
-
function _offsetPoint(point, distance, heading) {
|
|
21234
|
-
// Radius of earth.
|
|
21235
|
-
var radius = 6371e3;
|
|
21236
|
-
var δ = distance / radius;
|
|
21237
|
-
var θ = Cesium.Math.toRadians(heading);
|
|
21238
|
-
var φ1 = Cesium.Math.toRadians(point.latitude);
|
|
21239
|
-
var λ1 = Cesium.Math.toRadians(point.longitude);
|
|
21240
|
-
var sinφ2 = Math.sin(φ1) * Math.cos(δ) + Math.cos(φ1) * Math.sin(δ) * Math.cos(θ);
|
|
21241
|
-
var φ2 = Math.asin(sinφ2);
|
|
21242
|
-
var y = Math.sin(θ) * Math.sin(δ) * Math.cos(φ1);
|
|
21243
|
-
var x = Math.cos(δ) - Math.sin(φ1) * sinφ2;
|
|
21244
|
-
var λ2 = λ1 + Math.atan2(y, x);
|
|
21245
|
-
return {
|
|
21246
|
-
altitude: point.altitude,
|
|
21247
|
-
latitude: Cesium.Math.toDegrees(φ2),
|
|
21248
|
-
longitude: Cesium.Math.toDegrees(λ2)
|
|
21249
|
-
};
|
|
21250
|
-
}
|
|
21251
|
-
/**
|
|
21252
|
-
* @param pos3d
|
|
21253
|
-
* @param distance in meters
|
|
21254
|
-
* @param heading in degrees
|
|
21255
|
-
* @returns
|
|
21256
|
-
*/
|
|
21257
|
-
function _offsetPos3d(pos3d, distance, heading) {
|
|
21258
|
-
var carto = Cesium.Cartographic.fromCartesian(pos3d);
|
|
21259
|
-
var newCarto = _offsetPoint({
|
|
21260
|
-
altitude: carto.height,
|
|
21261
|
-
latitude: Cesium.Math.toDegrees(carto.latitude),
|
|
21262
|
-
longitude: Cesium.Math.toDegrees(carto.longitude)
|
|
21263
|
-
}, distance, heading);
|
|
21264
|
-
return Cesium.Cartesian3.fromDegrees(newCarto.longitude, newCarto.latitude, newCarto.altitude);
|
|
21265
|
-
}
|
|
21266
|
-
/**
|
|
21267
|
-
* Returns the intersection of the camera ray with the ground.
|
|
21268
|
-
* @param viewer
|
|
21269
|
-
* @param screenPos
|
|
21270
|
-
* @returns
|
|
21271
|
-
*/
|
|
21272
|
-
function getAdjustedGroundIntersectionOfCameraRay(viewer, screenPos) {
|
|
21273
|
-
var ray = viewer.camera.getPickRay(screenPos);
|
|
21274
|
-
var intersection = ray ? viewer.scene.globe.pick(ray, viewer.scene) : null;
|
|
21275
|
-
if (intersection) {
|
|
21276
|
-
return intersection;
|
|
21277
|
-
}
|
|
21278
|
-
return null;
|
|
21279
|
-
}
|
|
21280
|
-
/**
|
|
21281
|
-
* Returns the intersection of the camera ray with the ground.
|
|
21282
|
-
* If no intersection is found, then a "guess" is made based on the camera angle and height.
|
|
21283
|
-
* The guess is made at the center of the view! It ignores the screenPos.
|
|
21284
|
-
* @param viewer
|
|
21285
|
-
* @param screenPos
|
|
21286
|
-
* @returns
|
|
21287
|
-
*/
|
|
21288
|
-
function getGroundCenterOfCameraRay(viewer, screenPos) {
|
|
21289
|
-
var _a, _b;
|
|
21290
|
-
var ray = viewer.camera.getPickRay(screenPos);
|
|
21291
|
-
var intersection = ray ? viewer.scene.globe.pick(ray, viewer.scene) : null;
|
|
21292
|
-
if (intersection) {
|
|
21293
|
-
return intersection;
|
|
21294
|
-
}
|
|
21295
|
-
// The fallback will be to "guess" where the intersection might be.
|
|
21296
|
-
// This happens if terrain is hidden, and there's nothing to intersect with.
|
|
21297
|
-
// We will use the camera angle + camera height.
|
|
21298
|
-
// Eg: if camera is looking straight down and is 100 meters above the ground, then the intersection will be 100 meters below the camera.
|
|
21299
|
-
var cameraHeight = viewer.camera.positionCartographic.height;
|
|
21300
|
-
if (!isNaN(cameraHeight) && cameraHeight != null && ((_b = (_a = viewer.camera) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.clone)) {
|
|
21301
|
-
var cameraPos3d = viewer.camera.position.clone();
|
|
21302
|
-
var pitch = viewer.camera.pitch;
|
|
21303
|
-
var distance = cameraHeight / Math.tan(pitch);
|
|
21304
|
-
return _offsetPos3d(cameraPos3d, -distance, Cesium.Math.toDegrees(viewer.camera.heading));
|
|
21305
|
-
}
|
|
21306
|
-
return null;
|
|
21307
|
-
}
|
|
21308
|
-
function areBoundsEqual(a, b) {
|
|
21309
|
-
return a.north == b.north && a.south == b.south && a.east == b.east && a.west == b.west;
|
|
21310
|
-
}
|
|
21311
|
-
function arePosEqual(a, b) {
|
|
21312
|
-
return a.latitude == b.latitude && a.longitude == b.longitude;
|
|
21313
|
-
}
|
|
21314
|
-
(function (CesiumViewMonitor) {
|
|
21315
|
-
/**
|
|
21316
|
-
* Monitors and emits events when the Cesium view changes.
|
|
21317
|
-
*/
|
|
21318
|
-
var Monitor = /** @class */ (function () {
|
|
21319
|
-
function Monitor(viewer) {
|
|
21320
|
-
var _this = this;
|
|
21321
|
-
this.target = null;
|
|
21322
|
-
this.bounds = null;
|
|
21323
|
-
this.disposed = false;
|
|
21324
|
-
this.updatedEvent = null;
|
|
21325
|
-
this.entity = null;
|
|
21326
|
-
this.updating = false;
|
|
21327
|
-
this.viewer = viewer;
|
|
21328
|
-
this.tryEmitUpdate();
|
|
21329
|
-
this.checkInterval = setInterval(function () {
|
|
21330
|
-
_this.updateQueue();
|
|
21331
|
-
}, POSITION_CHECK_TIMER);
|
|
21332
|
-
}
|
|
21333
|
-
Object.defineProperty(Monitor.prototype, "Disposed", {
|
|
21334
|
-
get: function () {
|
|
21335
|
-
return this.disposed;
|
|
21336
|
-
},
|
|
21337
|
-
enumerable: false,
|
|
21338
|
-
configurable: true
|
|
21339
|
-
});
|
|
21340
|
-
Monitor.prototype.createEntity = function () {
|
|
21341
|
-
var _this = this;
|
|
21342
|
-
if (this.entity) {
|
|
21343
|
-
return;
|
|
21344
|
-
}
|
|
21345
|
-
this.entity = this.viewer.entities.add({
|
|
21346
|
-
position: new Cesium.CallbackProperty(function () {
|
|
21347
|
-
return _this.target ? Cesium.Cartesian3.fromDegrees(_this.target.longitude, _this.target.latitude) : null;
|
|
21348
|
-
}, false),
|
|
21349
|
-
point: {
|
|
21350
|
-
pixelSize: 8,
|
|
21351
|
-
color: Cesium.Color.ORANGE,
|
|
21352
|
-
heightReference: Cesium.HeightReference.NONE
|
|
21353
|
-
},
|
|
21354
|
-
rectangle: {
|
|
21355
|
-
coordinates: new Cesium.CallbackProperty(function () {
|
|
21356
|
-
return _this.bounds ? Cesium.Rectangle.fromDegrees(_this.bounds.west, _this.bounds.south, _this.bounds.east, _this.bounds.north) : null;
|
|
21357
|
-
}, false),
|
|
21358
|
-
material: Cesium.Color.fromCssColorString('#ff0000').withAlpha(0.4),
|
|
21359
|
-
zIndex: 1,
|
|
21360
|
-
heightReference: Cesium.HeightReference.NONE
|
|
21361
|
-
}
|
|
21362
|
-
});
|
|
21363
|
-
};
|
|
21364
|
-
Monitor.prototype.destroyEntity = function () {
|
|
21365
|
-
if (this.entity && this.viewer.entities.contains(this.entity)) {
|
|
21366
|
-
this.viewer.entities.remove(this.entity);
|
|
21367
|
-
}
|
|
21368
|
-
this.entity = null;
|
|
21369
|
-
};
|
|
21370
|
-
Monitor.prototype.Updated = function () {
|
|
21371
|
-
if (!this.updatedEvent) {
|
|
21372
|
-
this.updatedEvent = new bruceModels.BruceEvent();
|
|
21373
|
-
}
|
|
21374
|
-
return this.updatedEvent;
|
|
21375
|
-
};
|
|
21376
|
-
Monitor.prototype.GetBounds = function () {
|
|
21377
|
-
return this.bounds;
|
|
21378
|
-
};
|
|
21379
|
-
Monitor.prototype.GetTarget = function () {
|
|
21380
|
-
return this.target;
|
|
21381
|
-
};
|
|
21382
|
-
Monitor.prototype.DoUpdate = function () {
|
|
21383
|
-
this.tryEmitUpdate();
|
|
21384
|
-
};
|
|
21385
|
-
Monitor.prototype.Dispose = function () {
|
|
21386
|
-
if (this.disposed) {
|
|
21387
|
-
return;
|
|
21388
|
-
}
|
|
21389
|
-
this.disposed = true;
|
|
21390
|
-
clearInterval(this.checkInterval);
|
|
21391
|
-
this.destroyEntity();
|
|
21392
|
-
};
|
|
21393
|
-
Monitor.prototype.tryDoUpdate = function () {
|
|
21394
|
-
var _a;
|
|
21395
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
21396
|
-
var viewRect, center, camera, terrData, cameraPosition, terrHeight, viewRectRad, windowPosition, intersection, point, viewRectRad, centerLong, centerLat;
|
|
21397
|
-
return __generator(this, function (_b) {
|
|
21398
|
-
switch (_b.label) {
|
|
21399
|
-
case 0:
|
|
21400
|
-
if (!this.viewer || this.viewer.isDestroyed()) {
|
|
21401
|
-
this.Dispose();
|
|
21402
|
-
return [2 /*return*/, ESearchStatus.LocationMissing];
|
|
21403
|
-
}
|
|
21404
|
-
viewRect = null;
|
|
21405
|
-
center = null;
|
|
21406
|
-
camera = this.viewer.camera;
|
|
21407
|
-
return [4 /*yield*/, exports.DrawingUtils.GetTerrainHeight({
|
|
21408
|
-
pos3d: camera.position,
|
|
21409
|
-
viewer: this.viewer
|
|
21410
|
-
})];
|
|
21411
|
-
case 1:
|
|
21412
|
-
terrData = _b.sent();
|
|
21413
|
-
cameraPosition = this.viewer.camera.positionCartographic;
|
|
21414
|
-
terrHeight = terrData.error ? cameraPosition.height + DEFAULT_GROUNDED_HEIGHT : terrData.height;
|
|
21415
|
-
// We are almost at the ground, screw horizon, just load around.
|
|
21416
|
-
if (terrHeight && ((cameraPosition.height - terrHeight) < DEFAULT_GROUNDED_HEIGHT)) {
|
|
21417
|
-
// View area calculation.
|
|
21418
|
-
viewRect = {};
|
|
21419
|
-
viewRectRad = netScanViewForBoundaries(this.viewer);
|
|
21420
|
-
if (viewRectRad &&
|
|
21421
|
-
viewRectRad.east &&
|
|
21422
|
-
viewRectRad.west &&
|
|
21423
|
-
viewRectRad.north &&
|
|
21424
|
-
viewRectRad.south) {
|
|
21425
|
-
viewRect.east = Cesium.Math.toDegrees(Math.max(viewRectRad.east, cameraPosition.longitude));
|
|
21426
|
-
viewRect.west = Cesium.Math.toDegrees(Math.min(viewRectRad.west, cameraPosition.longitude));
|
|
21427
|
-
viewRect.south = Cesium.Math.toDegrees(Math.min(viewRectRad.south, cameraPosition.latitude));
|
|
21428
|
-
viewRect.north = Cesium.Math.toDegrees(Math.max(viewRectRad.north, cameraPosition.latitude));
|
|
21429
|
-
}
|
|
21430
|
-
else {
|
|
21431
|
-
viewRect.east = cameraPosition.longitude;
|
|
21432
|
-
viewRect.west = cameraPosition.longitude;
|
|
21433
|
-
viewRect.south = cameraPosition.latitude;
|
|
21434
|
-
viewRect.north = cameraPosition.latitude;
|
|
21435
|
-
}
|
|
21436
|
-
center = {};
|
|
21437
|
-
center.latitude = Cesium.Math.toDegrees(camera.positionCartographic.latitude);
|
|
21438
|
-
center.longitude = Cesium.Math.toDegrees(camera.positionCartographic.longitude);
|
|
21439
|
-
}
|
|
21440
|
-
else {
|
|
21441
|
-
windowPosition = new Cesium.Cartesian2(this.viewer.container.clientWidth / 2, this.viewer.container.clientHeight / 2);
|
|
21442
|
-
intersection = getGroundCenterOfCameraRay(this.viewer, windowPosition);
|
|
21443
|
-
point = null;
|
|
21444
|
-
if (intersection) {
|
|
21445
|
-
point = Cesium.Cartographic.fromCartesian(intersection, this.viewer.scene.globe.ellipsoid);
|
|
21446
|
-
}
|
|
21447
|
-
if (point) {
|
|
21448
|
-
center = {};
|
|
21449
|
-
center.latitude = Cesium.Math.toDegrees(point.latitude);
|
|
21450
|
-
center.longitude = Cesium.Math.toDegrees(point.longitude);
|
|
21451
|
-
viewRectRad = netScanViewForBoundaries(this.viewer, center);
|
|
21452
|
-
if (viewRectRad) {
|
|
21453
|
-
viewRect = {};
|
|
21454
|
-
viewRect.east = Cesium.Math.toDegrees(viewRectRad.east);
|
|
21455
|
-
viewRect.west = Cesium.Math.toDegrees(viewRectRad.west);
|
|
21456
|
-
viewRect.south = Cesium.Math.toDegrees(viewRectRad.south);
|
|
21457
|
-
viewRect.north = Cesium.Math.toDegrees(viewRectRad.north);
|
|
21458
|
-
}
|
|
21459
|
-
}
|
|
21460
|
-
}
|
|
21461
|
-
// Minimal field of view.
|
|
21462
|
-
if (viewRect) {
|
|
21463
|
-
centerLong = (viewRect.east + viewRect.west) / 2;
|
|
21464
|
-
centerLat = (viewRect.north + viewRect.south) / 2;
|
|
21465
|
-
viewRect.east = Math.max(viewRect.east, centerLong + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
|
|
21466
|
-
viewRect.west = Math.min(viewRect.west, centerLong - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
|
|
21467
|
-
viewRect.south = Math.min(viewRect.south, centerLat - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
|
|
21468
|
-
viewRect.north = Math.max(viewRect.north, centerLat + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
|
|
21469
|
-
viewRect.alt = (_a = this.viewer.scene.camera.positionCartographic) === null || _a === void 0 ? void 0 : _a.height;
|
|
21470
|
-
}
|
|
21471
|
-
if (center && viewRect) {
|
|
21472
|
-
if ((!this.target || (this.target && !arePosEqual(this.target, center))) ||
|
|
21473
|
-
(!this.bounds || (this.bounds && !areBoundsEqual(this.bounds, viewRect)))) {
|
|
21474
|
-
this.target = center;
|
|
21475
|
-
this.bounds = viewRect;
|
|
21476
|
-
return [2 /*return*/, ESearchStatus.LocationChanged];
|
|
21351
|
+
if (layer.tilesetId == bruceModels.ProjectViewTile.EDefaultImagery.BingMapsAerial) {
|
|
21352
|
+
layer.tilesetId = bruceModels.ProjectViewTile.EDefaultImagery.MapboxSatellite;
|
|
21353
|
+
console.warn("Cesium Ion token not set, using mapbox satellite instead of bing maps aerial.");
|
|
21354
|
+
}
|
|
21355
|
+
else if (layer.tilesetId == bruceModels.ProjectViewTile.EDefaultImagery.BingMapsAerialWithLabels) {
|
|
21356
|
+
layer.tilesetId = bruceModels.ProjectViewTile.EDefaultImagery.MapboxSatellite;
|
|
21357
|
+
console.warn("Cesium Ion token not set, using mapbox satellite instead of bing maps aerial with labels.");
|
|
21358
|
+
}
|
|
21359
|
+
else if (layer.tilesetId == bruceModels.ProjectViewTile.EDefaultImagery.BingMapsRoads) {
|
|
21360
|
+
layer.tilesetId = bruceModels.ProjectViewTile.EDefaultImagery.MapBoxStreets;
|
|
21361
|
+
console.warn("Cesium Ion token not set, using mapbox streets instead of bing maps roads.");
|
|
21477
21362
|
}
|
|
21478
|
-
return [2 /*return*/, ESearchStatus.LocationFound];
|
|
21479
21363
|
}
|
|
21480
|
-
|
|
21364
|
+
}
|
|
21481
21365
|
}
|
|
21482
|
-
|
|
21483
|
-
|
|
21484
|
-
|
|
21485
|
-
|
|
21486
|
-
|
|
21487
|
-
|
|
21488
|
-
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
21492
|
-
|
|
21493
|
-
|
|
21366
|
+
// We don't wait for imageries to load, this does not affect rendering other things.
|
|
21367
|
+
exports.TileRenderEngine.Map.Navigator.Render({
|
|
21368
|
+
apiGetter: params.apiGetter,
|
|
21369
|
+
tiles: imagery,
|
|
21370
|
+
viewer: params.manager.Viewer,
|
|
21371
|
+
});
|
|
21372
|
+
legacyRelationIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.renderedEntityRelations;
|
|
21373
|
+
if (!legacyRelationIds) {
|
|
21374
|
+
legacyRelationIds = [];
|
|
21375
|
+
}
|
|
21376
|
+
relations = bSettings === null || bSettings === void 0 ? void 0 : bSettings.renderedRelations;
|
|
21377
|
+
if (!relations) {
|
|
21378
|
+
relations = [];
|
|
21379
|
+
}
|
|
21380
|
+
viewer.scene.requestRender();
|
|
21381
|
+
curEnabled = params.manager.GetEnabledItemIds();
|
|
21382
|
+
newItemIds = (_5 = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _5 !== void 0 ? _5 : [];
|
|
21383
|
+
for (_i = 0, curEnabled_1 = curEnabled; _i < curEnabled_1.length; _i++) {
|
|
21384
|
+
id = curEnabled_1[_i];
|
|
21385
|
+
shouldRemove = void 0;
|
|
21386
|
+
if (id == RELATION_MENU_ITEM_ID) {
|
|
21387
|
+
rendered = params.manager.GetEnabledItem(id);
|
|
21388
|
+
shouldRemove = false;
|
|
21389
|
+
if (!legacyRelationIds.length && !relations.length) {
|
|
21390
|
+
shouldRemove = true;
|
|
21494
21391
|
}
|
|
21495
|
-
|
|
21496
|
-
|
|
21497
|
-
|
|
21498
|
-
_b.trys.push([1, 3, , 4]);
|
|
21499
|
-
return [4 /*yield*/, this.tryDoUpdate()];
|
|
21500
|
-
case 2:
|
|
21501
|
-
searchResult = _b.sent();
|
|
21502
|
-
if (searchResult == ESearchStatus.LocationChanged) {
|
|
21503
|
-
interest = {
|
|
21504
|
-
bounds: this.bounds,
|
|
21505
|
-
target: this.target
|
|
21506
|
-
};
|
|
21507
|
-
// this.createEntity();
|
|
21508
|
-
(_a = this.updatedEvent) === null || _a === void 0 ? void 0 : _a.Trigger(interest);
|
|
21392
|
+
// If we're about to render legacy relationships but a non-legacy item is currently enabled then we remove it.
|
|
21393
|
+
else if (legacyRelationIds.length && (rendered === null || rendered === void 0 ? void 0 : rendered.type) != bruceModels.MenuItem.EType.Relations) {
|
|
21394
|
+
shouldRemove = true;
|
|
21509
21395
|
}
|
|
21510
|
-
|
|
21511
|
-
|
|
21396
|
+
// If we're about to render non-legacy relationships but a legacy item is currently enabled then we remove it.
|
|
21397
|
+
else if (relations.length && (rendered === null || rendered === void 0 ? void 0 : rendered.type) != bruceModels.MenuItem.EType.Relationships) {
|
|
21398
|
+
shouldRemove = true;
|
|
21512
21399
|
}
|
|
21513
|
-
|
|
21514
|
-
|
|
21515
|
-
|
|
21516
|
-
|
|
21517
|
-
|
|
21518
|
-
|
|
21519
|
-
|
|
21520
|
-
|
|
21400
|
+
}
|
|
21401
|
+
else {
|
|
21402
|
+
shouldRemove = newItemIds.indexOf(id) === -1;
|
|
21403
|
+
}
|
|
21404
|
+
if (shouldRemove) {
|
|
21405
|
+
params.manager.RemoveItemById({
|
|
21406
|
+
menuItemId: id
|
|
21407
|
+
});
|
|
21408
|
+
}
|
|
21409
|
+
}
|
|
21410
|
+
if (!bookmark) return [3 /*break*/, 15];
|
|
21411
|
+
return [4 /*yield*/, exports.MenuItemCreator.RenderBookmarkItems({
|
|
21412
|
+
getters: params.getters,
|
|
21413
|
+
manager: params.manager,
|
|
21414
|
+
view: view,
|
|
21415
|
+
bookmark: bookmark
|
|
21416
|
+
})];
|
|
21417
|
+
case 14:
|
|
21418
|
+
_8.sent();
|
|
21419
|
+
if (!assertIteration$1(params.viewer, iteration)) {
|
|
21420
|
+
return [2 /*return*/];
|
|
21421
|
+
}
|
|
21422
|
+
_8.label = 15;
|
|
21423
|
+
case 15:
|
|
21424
|
+
if (legacyRelationIds.length || relations.length) {
|
|
21425
|
+
if (relations.length) {
|
|
21426
|
+
menuItem = {
|
|
21427
|
+
id: RELATION_MENU_ITEM_ID,
|
|
21428
|
+
Caption: "Entity relations",
|
|
21429
|
+
relations: relations,
|
|
21430
|
+
Type: bruceModels.MenuItem.EType.Relationships
|
|
21431
|
+
};
|
|
21432
|
+
params.manager.RenderItem({
|
|
21433
|
+
getters: params.getters,
|
|
21434
|
+
item: menuItem
|
|
21435
|
+
});
|
|
21436
|
+
}
|
|
21437
|
+
else if (legacyRelationIds.length) {
|
|
21438
|
+
menuItem = {
|
|
21439
|
+
id: RELATION_MENU_ITEM_ID,
|
|
21440
|
+
Caption: "Entity relations",
|
|
21441
|
+
BruceEntity: {
|
|
21442
|
+
EntityIds: legacyRelationIds
|
|
21443
|
+
},
|
|
21444
|
+
Type: bruceModels.MenuItem.EType.Relations
|
|
21445
|
+
};
|
|
21446
|
+
params.manager.RenderItem({
|
|
21447
|
+
getters: params.getters,
|
|
21448
|
+
item: menuItem
|
|
21449
|
+
});
|
|
21450
|
+
}
|
|
21451
|
+
if (!assertIteration$1(params.viewer, iteration)) {
|
|
21521
21452
|
return [2 /*return*/];
|
|
21453
|
+
}
|
|
21522
21454
|
}
|
|
21523
|
-
|
|
21524
|
-
|
|
21525
|
-
|
|
21526
|
-
|
|
21527
|
-
|
|
21528
|
-
|
|
21529
|
-
|
|
21455
|
+
gOcclusion = bSettings === null || bSettings === void 0 ? void 0 : bSettings.groundOcclusion;
|
|
21456
|
+
if (gOcclusion == null) {
|
|
21457
|
+
gOcclusion = (_6 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _6 === void 0 ? void 0 : _6.groundOcclusion;
|
|
21458
|
+
}
|
|
21459
|
+
if (gOcclusion == null) {
|
|
21460
|
+
// TODO: Need global default.
|
|
21461
|
+
gOcclusion = true;
|
|
21462
|
+
}
|
|
21463
|
+
scene.globe.depthTestAgainstTerrain = Boolean(gOcclusion);
|
|
21464
|
+
return [2 /*return*/];
|
|
21530
21465
|
}
|
|
21531
|
-
|
|
21532
|
-
|
|
21533
|
-
|
|
21466
|
+
});
|
|
21467
|
+
});
|
|
21468
|
+
}
|
|
21469
|
+
(function (ViewRenderEngine) {
|
|
21470
|
+
function Render(params) {
|
|
21471
|
+
var _a;
|
|
21472
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21473
|
+
var iteration, api, view, _b, bookmark, bookmarkId, _c, version, bWidget;
|
|
21474
|
+
return __generator(this, function (_d) {
|
|
21475
|
+
switch (_d.label) {
|
|
21476
|
+
case 0:
|
|
21477
|
+
if (!params.manager && params.viewer) {
|
|
21478
|
+
params.manager = exports.ViewerUtils.GetManager({
|
|
21479
|
+
viewer: params.viewer,
|
|
21480
|
+
createIfMissing: true
|
|
21481
|
+
});
|
|
21482
|
+
}
|
|
21483
|
+
else if (!params.viewer && params.manager) {
|
|
21484
|
+
params.viewer = params.manager.Viewer;
|
|
21485
|
+
}
|
|
21486
|
+
iteration = newIteration$1(params.viewer);
|
|
21487
|
+
if (!params.getters) {
|
|
21488
|
+
params.getters = bruceModels.ENVIRONMENT.Api();
|
|
21489
|
+
}
|
|
21490
|
+
if (params.apiGetter && !params.getters) {
|
|
21491
|
+
console.warn("ViewRenderEngine.Render(): Please pass getters instead of apiGetter. This is now deprecated due to needing access to other kinds of apis.");
|
|
21492
|
+
}
|
|
21493
|
+
else if (!params.apiGetter) {
|
|
21494
|
+
params.apiGetter = params.getters.GetBruceGetter();
|
|
21495
|
+
}
|
|
21496
|
+
api = params.getters.GetBruceApi();
|
|
21497
|
+
if (!params.view) return [3 /*break*/, 1];
|
|
21498
|
+
_b = params.view;
|
|
21499
|
+
return [3 /*break*/, 3];
|
|
21500
|
+
case 1: return [4 /*yield*/, bruceModels.ProjectView.Get({
|
|
21501
|
+
api: api,
|
|
21502
|
+
viewId: params.viewId
|
|
21503
|
+
})];
|
|
21504
|
+
case 2:
|
|
21505
|
+
_b = (_d.sent()).view;
|
|
21506
|
+
_d.label = 3;
|
|
21507
|
+
case 3:
|
|
21508
|
+
view = _b;
|
|
21509
|
+
bookmark = params.bookmark;
|
|
21510
|
+
if (!!bookmark) return [3 /*break*/, 7];
|
|
21511
|
+
bookmarkId = params.bookmarkId;
|
|
21512
|
+
if (!bookmarkId) {
|
|
21513
|
+
bookmarkId = view.DefaultUISlideID;
|
|
21514
|
+
}
|
|
21515
|
+
if (!bookmarkId) return [3 /*break*/, 5];
|
|
21516
|
+
return [4 /*yield*/, bruceModels.ProjectViewBookmark.Get({
|
|
21517
|
+
api: api,
|
|
21518
|
+
viewId: params.viewId,
|
|
21519
|
+
bookmarkId: bookmarkId
|
|
21520
|
+
})];
|
|
21521
|
+
case 4:
|
|
21522
|
+
_c = (_d.sent()).bookmark;
|
|
21523
|
+
return [3 /*break*/, 6];
|
|
21524
|
+
case 5:
|
|
21525
|
+
_c = null;
|
|
21526
|
+
_d.label = 6;
|
|
21527
|
+
case 6:
|
|
21528
|
+
bookmark = _c;
|
|
21529
|
+
_d.label = 7;
|
|
21530
|
+
case 7:
|
|
21531
|
+
if (!assertIteration$1(params.viewer, iteration)) {
|
|
21532
|
+
return [2 /*return*/];
|
|
21533
|
+
}
|
|
21534
|
+
version = view.DataVersion;
|
|
21535
|
+
if (!(version == 1)) return [3 /*break*/, 9];
|
|
21536
|
+
return [4 /*yield*/, renderLegacyNavigator(iteration, params, bookmark, view)];
|
|
21537
|
+
case 8:
|
|
21538
|
+
_d.sent();
|
|
21539
|
+
return [3 /*break*/, 11];
|
|
21540
|
+
case 9: return [4 /*yield*/, renderNavigator(iteration, params, bookmark, view, params.getters)];
|
|
21541
|
+
case 10:
|
|
21542
|
+
_d.sent();
|
|
21543
|
+
_d.label = 11;
|
|
21544
|
+
case 11:
|
|
21545
|
+
if (!assertIteration$1(params.viewer, iteration)) {
|
|
21546
|
+
return [2 /*return*/];
|
|
21547
|
+
}
|
|
21548
|
+
bWidget = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_BOOKMARKS_WIDGET_KEY];
|
|
21549
|
+
if (bWidget) {
|
|
21550
|
+
bWidget.ViewId = params.viewId ? params.viewId : view === null || view === void 0 ? void 0 : view.ID;
|
|
21551
|
+
bWidget.LastEnabledBookmarkId = params.bookmarkId ? params.bookmarkId : bookmark === null || bookmark === void 0 ? void 0 : bookmark.ID;
|
|
21552
|
+
}
|
|
21553
|
+
return [2 /*return*/];
|
|
21534
21554
|
}
|
|
21535
|
-
}
|
|
21536
|
-
};
|
|
21537
|
-
|
|
21538
|
-
|
|
21539
|
-
|
|
21540
|
-
return Monitor;
|
|
21541
|
-
}());
|
|
21542
|
-
CesiumViewMonitor.Monitor = Monitor;
|
|
21543
|
-
})(exports.CesiumViewMonitor || (exports.CesiumViewMonitor = {}));
|
|
21555
|
+
});
|
|
21556
|
+
});
|
|
21557
|
+
}
|
|
21558
|
+
ViewRenderEngine.Render = Render;
|
|
21559
|
+
})(exports.ViewRenderEngine || (exports.ViewRenderEngine = {}));
|
|
21544
21560
|
|
|
21545
|
-
var VERSION
|
|
21561
|
+
var VERSION = "3.4.9";
|
|
21546
21562
|
|
|
21547
|
-
exports.VERSION = VERSION
|
|
21563
|
+
exports.VERSION = VERSION;
|
|
21548
21564
|
exports.CesiumParabola = CesiumParabola;
|
|
21549
21565
|
exports.CESIUM_INSPECTOR_KEY = CESIUM_INSPECTOR_KEY;
|
|
21550
21566
|
exports.Draw3dPolygon = Draw3dPolygon;
|