bruce-cesium 4.4.4 → 4.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bruce-cesium.es5.js +4510 -3712
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +4485 -3699
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +5 -1
- package/dist/lib/bruce-cesium.js.map +1 -1
- package/dist/lib/internal/cesium-utils.js +92 -5
- package/dist/lib/internal/cesium-utils.js.map +1 -1
- package/dist/lib/rendering/cesium-animated-property.js +149 -0
- package/dist/lib/rendering/cesium-animated-property.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine-model3d.js +809 -0
- package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-point.js +995 -0
- package/dist/lib/rendering/entity-render-engine-point.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js +756 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-polyline.js +516 -0
- package/dist/lib/rendering/entity-render-engine-polyline.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine.js +62 -2420
- package/dist/lib/rendering/entity-render-engine.js.map +1 -1
- package/dist/lib/rendering/render-managers/data-source/data-source-static-csv-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +15 -0
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/tilesets/tileset-arb-render-manager.js +18 -0
- package/dist/lib/rendering/render-managers/tilesets/tileset-arb-render-manager.js.map +1 -1
- package/dist/lib/utils/view-utils.js +2 -2
- package/dist/lib/utils/view-utils.js.map +1 -1
- package/dist/lib/widgets/common/draw-3d-polyline.js +0 -8
- package/dist/lib/widgets/common/draw-3d-polyline.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +5 -1
- package/dist/types/internal/cesium-utils.d.ts +22 -2
- package/dist/types/rendering/cesium-animated-property.d.ts +21 -0
- package/dist/types/rendering/entity-render-engine-model3d.d.ts +56 -0
- package/dist/types/rendering/entity-render-engine-point.d.ts +73 -0
- package/dist/types/rendering/entity-render-engine-polygon.d.ts +26 -0
- package/dist/types/rendering/entity-render-engine-polyline.d.ts +48 -0
- package/dist/types/rendering/entity-render-engine.d.ts +31 -98
- package/package.json +2 -2
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.EntityRenderEnginePolygon = void 0;
|
|
51
|
+
var bruce_models_1 = require("bruce-models");
|
|
52
|
+
var Cesium = require("cesium");
|
|
53
|
+
var entity_render_engine_1 = require("./entity-render-engine");
|
|
54
|
+
var entity_utils_1 = require("../utils/entity-utils");
|
|
55
|
+
var js_utils_1 = require("../internal/js-utils");
|
|
56
|
+
var cesium_utils_1 = require("../internal/cesium-utils");
|
|
57
|
+
var cesium_entity_styler_1 = require("../utils/cesium-entity-styler");
|
|
58
|
+
var EntityRenderEnginePolygon;
|
|
59
|
+
(function (EntityRenderEnginePolygon) {
|
|
60
|
+
function Render(params) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
var entity = params.entity;
|
|
63
|
+
var pRings = bruce_models_1.Entity.GetValue({
|
|
64
|
+
entity: entity,
|
|
65
|
+
path: ["Bruce", "VectorGeometry", "Polygon"]
|
|
66
|
+
});
|
|
67
|
+
if (pRings == null || !Array.isArray(pRings) || pRings.length <= 0) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
var style = params.style;
|
|
71
|
+
var bFillColor = bruce_models_1.Calculator.GetColor(style.fillColor, entity, params.tags);
|
|
72
|
+
var cFillColor = bFillColor ? (0, cesium_utils_1.ColorToCColor)(bFillColor) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
|
|
73
|
+
var bLineColor = bruce_models_1.Calculator.GetColor(style.lineColor, entity, params.tags);
|
|
74
|
+
var cLineColor = bLineColor ? (0, cesium_utils_1.ColorToCColor)(bLineColor) : Cesium.Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
|
|
75
|
+
var width = style.lineWidth ? bruce_models_1.Calculator.GetNumber(style.lineWidth, entity, params.tags) : null;
|
|
76
|
+
if (width == null) {
|
|
77
|
+
width = 1;
|
|
78
|
+
}
|
|
79
|
+
width = (0, js_utils_1.EnsureNumber)(width);
|
|
80
|
+
if (width < 0.01) {
|
|
81
|
+
width = 0;
|
|
82
|
+
}
|
|
83
|
+
var units = style.lineWidthUnits;
|
|
84
|
+
if (units != "px" && units != "m") {
|
|
85
|
+
units = "m";
|
|
86
|
+
}
|
|
87
|
+
// If both outline and fill is not available then don't render anything.
|
|
88
|
+
if ((width <= 0 || cLineColor.alpha <= 0) &&
|
|
89
|
+
cFillColor.alpha <= 0) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
var heightRef = getHeightRef(style);
|
|
93
|
+
var outerRing = pRings.find(function (x) { return x.Facing == bruce_models_1.Geometry.EPolygonRingType.Boundaries; });
|
|
94
|
+
var points = bruce_models_1.Geometry.ParsePoints(outerRing === null || outerRing === void 0 ? void 0 : outerRing.LinearRing);
|
|
95
|
+
var posses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.altitude)); });
|
|
96
|
+
bruce_models_1.Cartes.CloseRing3(posses);
|
|
97
|
+
var extrusion = getPolygonExtrusion(entity, params.tags, outerRing, posses, heightRef, style);
|
|
98
|
+
posses = extrusion.posses;
|
|
99
|
+
posses = (0, cesium_utils_1.CullDuplicateCPosses)(posses);
|
|
100
|
+
if (posses.length < 4) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
var holeRings = pRings.filter(function (x) { return x.Facing == bruce_models_1.Geometry.EPolygonRingType.Hole; });
|
|
104
|
+
var holePosses = holeRings.map(function (x) {
|
|
105
|
+
var points = bruce_models_1.Geometry.ParsePoints(x.LinearRing);
|
|
106
|
+
var holePosses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.altitude)); });
|
|
107
|
+
holePosses = (0, cesium_utils_1.CullDuplicateCPosses)(holePosses);
|
|
108
|
+
bruce_models_1.Cartes.CloseRing3(holePosses);
|
|
109
|
+
return holePosses;
|
|
110
|
+
}).filter(function (x) { return x.length >= 4; });
|
|
111
|
+
var zIndex = getZIndex(style, entity, params.tags);
|
|
112
|
+
var size = getSizeOfPolygonEntity(entity);
|
|
113
|
+
var classification = Cesium.ClassificationType.TERRAIN;
|
|
114
|
+
if (style.drapeOver == "ALL") {
|
|
115
|
+
classification = Cesium.ClassificationType.BOTH;
|
|
116
|
+
}
|
|
117
|
+
var prepareExistingGraphic = function (cEntity, siblings) {
|
|
118
|
+
if (siblings === void 0) { siblings = 0; }
|
|
119
|
+
// Gather entity in case previous version had sibling graphics we no longer need.
|
|
120
|
+
var parts = entity_utils_1.EntityUtils.GatherEntity({
|
|
121
|
+
entity: cEntity,
|
|
122
|
+
});
|
|
123
|
+
if (parts.length > 1) {
|
|
124
|
+
// We'll cull all except the allowed number of siblings.
|
|
125
|
+
cEntity._siblingGraphics = cEntity._siblingGraphics.slice(0, siblings);
|
|
126
|
+
// We'll remove all that aren't in the allowed (direct) list.
|
|
127
|
+
for (var i = 0; i < parts.length - 1; i++) {
|
|
128
|
+
var part = parts[i];
|
|
129
|
+
if (part && part instanceof Cesium.Entity && params.viewer.entities.contains(part) && !cEntity._siblingGraphics.includes(part)) {
|
|
130
|
+
params.viewer.entities.remove(part);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (cEntity._parentEntity) {
|
|
134
|
+
console.warn("Point.Render: Parent entity was not null. This should not happen.");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var hasOutline = width > 0 && cLineColor;
|
|
139
|
+
var cEntity = null;
|
|
140
|
+
if (!params.rendered || !params.rendered.polygon) {
|
|
141
|
+
cEntity = new Cesium.Entity({
|
|
142
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
143
|
+
polygon: {
|
|
144
|
+
hierarchy: new Cesium.PolygonHierarchy(posses, holePosses.map(function (x) { return new Cesium.PolygonHierarchy(x); })),
|
|
145
|
+
material: cFillColor,
|
|
146
|
+
extrudedHeight: extrusion.value,
|
|
147
|
+
extrudedHeightReference: extrusion.exHeightRef,
|
|
148
|
+
shadows: Cesium.ShadowMode.ENABLED,
|
|
149
|
+
heightReference: heightRef,
|
|
150
|
+
classificationType: classification,
|
|
151
|
+
perPositionHeight: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true,
|
|
152
|
+
zIndex: zIndex,
|
|
153
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance, width <= 0 || !cLineColor || units == "m" ? size : null, true)
|
|
154
|
+
},
|
|
155
|
+
position: entity_utils_1.EntityUtils.GetPos({
|
|
156
|
+
viewer: params.viewer,
|
|
157
|
+
entity: entity,
|
|
158
|
+
recordHeightRef: heightRef,
|
|
159
|
+
returnHeightRef: heightRef,
|
|
160
|
+
allowRendered: false
|
|
161
|
+
}),
|
|
162
|
+
show: true
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Polygons can have more siblings for the related hole graphics.
|
|
167
|
+
// So this is a "good enough" way rather than perfect as it only preserves the outline.
|
|
168
|
+
prepareExistingGraphic(params.rendered, hasOutline ? 1 : 0);
|
|
169
|
+
cEntity = params.rendered;
|
|
170
|
+
// We'll do a number of checks to avoid updating the entity if it's not needed.
|
|
171
|
+
var oldHierarchy = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.polygon.hierarchy);
|
|
172
|
+
var newHierarchy = new Cesium.PolygonHierarchy(posses, holePosses.map(function (x) { return new Cesium.PolygonHierarchy(x); }));
|
|
173
|
+
if (!(0, cesium_utils_1.CompareCPolygonHierarchies)(oldHierarchy, newHierarchy)) {
|
|
174
|
+
cEntity.polygon.hierarchy = new Cesium.ConstantProperty(newHierarchy);
|
|
175
|
+
}
|
|
176
|
+
var oldExtrusion = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.polygon.extrudedHeight);
|
|
177
|
+
if (oldExtrusion != extrusion.value) {
|
|
178
|
+
cEntity.polygon.extrudedHeight = new Cesium.ConstantProperty(extrusion.value);
|
|
179
|
+
}
|
|
180
|
+
var oldExHeightRef = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.polygon.extrudedHeightReference);
|
|
181
|
+
if (oldExHeightRef != extrusion.exHeightRef) {
|
|
182
|
+
cEntity.polygon.extrudedHeightReference = new Cesium.ConstantProperty(extrusion.exHeightRef);
|
|
183
|
+
}
|
|
184
|
+
var oldHeightRef = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.polygon.heightReference);
|
|
185
|
+
if (oldHeightRef != heightRef) {
|
|
186
|
+
cEntity.polygon.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
187
|
+
}
|
|
188
|
+
var oldPerPosHeight = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.polygon.perPositionHeight);
|
|
189
|
+
if (oldPerPosHeight != (heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true)) {
|
|
190
|
+
cEntity.polygon.perPositionHeight = new Cesium.ConstantProperty(heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true);
|
|
191
|
+
}
|
|
192
|
+
var oldPosition = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.position);
|
|
193
|
+
var newPosition = entity_utils_1.EntityUtils.GetPos({
|
|
194
|
+
viewer: params.viewer,
|
|
195
|
+
entity: entity,
|
|
196
|
+
recordHeightRef: heightRef,
|
|
197
|
+
returnHeightRef: heightRef,
|
|
198
|
+
allowRendered: false
|
|
199
|
+
});
|
|
200
|
+
if (newPosition && (!oldPosition || !bruce_models_1.Cartes.IsEqualCartes3(oldPosition, newPosition))) {
|
|
201
|
+
cEntity.position = new Cesium.ConstantPositionProperty(newPosition);
|
|
202
|
+
}
|
|
203
|
+
var oldZIndex = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.polygon.zIndex);
|
|
204
|
+
if (oldZIndex != zIndex) {
|
|
205
|
+
cEntity.polygon.zIndex = new Cesium.ConstantProperty(zIndex);
|
|
206
|
+
}
|
|
207
|
+
cEntity.polygon.distanceDisplayCondition = new Cesium.ConstantProperty(entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance, width <= 0 || !cLineColor || units == "m" ? size : null, true));
|
|
208
|
+
cEntity.polygon.shadows = new Cesium.ConstantProperty(Cesium.ShadowMode.ENABLED);
|
|
209
|
+
cEntity.polygon.classificationType = new Cesium.ConstantProperty(classification);
|
|
210
|
+
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
211
|
+
// WARNING: polygon does not support animation (yet?).
|
|
212
|
+
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
213
|
+
color: cFillColor,
|
|
214
|
+
entity: cEntity,
|
|
215
|
+
viewer: params.viewer,
|
|
216
|
+
override: true,
|
|
217
|
+
requestRender: false
|
|
218
|
+
});
|
|
219
|
+
cEntity.show = true;
|
|
220
|
+
}
|
|
221
|
+
if (hasOutline) {
|
|
222
|
+
var borderHeight = undefined;
|
|
223
|
+
if (heightRef != Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
224
|
+
// Set height to smallest height value from points.
|
|
225
|
+
for (var i = 0; i < points.length; i++) {
|
|
226
|
+
var point = points[i];
|
|
227
|
+
if (!borderHeight || point.altitude < borderHeight) {
|
|
228
|
+
borderHeight = point.altitude;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
var borderPosses = posses.map(function (x) { return x.clone ? x.clone() : __assign({}, x); });
|
|
233
|
+
var cEntityBorder = (_b = (_a = params.rendered) === null || _a === void 0 ? void 0 : _a._siblingGraphics) === null || _b === void 0 ? void 0 : _b[0];
|
|
234
|
+
cEntity._siblingGraphics = [];
|
|
235
|
+
if (!cEntityBorder || ((!cEntityBorder.polyline && units == "px") ||
|
|
236
|
+
(!cEntityBorder.corridor && units == "m"))) {
|
|
237
|
+
cEntityBorder = new Cesium.Entity({
|
|
238
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
239
|
+
polyline: units == "px" ? new Cesium.PolylineGraphics({
|
|
240
|
+
positions: borderPosses,
|
|
241
|
+
material: cLineColor,
|
|
242
|
+
width: width,
|
|
243
|
+
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
244
|
+
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
245
|
+
arcType: Cesium.ArcType.GEODESIC,
|
|
246
|
+
zIndex: zIndex,
|
|
247
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance)
|
|
248
|
+
}) : null,
|
|
249
|
+
corridor: units == "m" ? {
|
|
250
|
+
positions: borderPosses,
|
|
251
|
+
material: cLineColor,
|
|
252
|
+
heightReference: heightRef,
|
|
253
|
+
height: borderHeight,
|
|
254
|
+
width: width,
|
|
255
|
+
fill: true,
|
|
256
|
+
zIndex: zIndex + 1,
|
|
257
|
+
cornerType: Cesium.CornerType.MITERED,
|
|
258
|
+
classificationType: classification,
|
|
259
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
260
|
+
shadows: Cesium.ShadowMode.ENABLED
|
|
261
|
+
} : null,
|
|
262
|
+
show: true
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
if (units == "px") {
|
|
267
|
+
var oldPosses = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.polyline.positions);
|
|
268
|
+
if (!(0, cesium_utils_1.CompareCPosses)(oldPosses, borderPosses)) {
|
|
269
|
+
cEntityBorder.polyline.positions = new Cesium.ConstantProperty(borderPosses);
|
|
270
|
+
}
|
|
271
|
+
var oldWidth = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.polyline.width);
|
|
272
|
+
if (oldWidth != width) {
|
|
273
|
+
cEntityBorder.polyline.width = new Cesium.ConstantProperty(width);
|
|
274
|
+
}
|
|
275
|
+
var oldClampToGround = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.polyline.clampToGround);
|
|
276
|
+
var newClampToGround = heightRef == Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
277
|
+
if (oldClampToGround != newClampToGround) {
|
|
278
|
+
cEntityBorder.polyline.clampToGround = new Cesium.ConstantProperty(newClampToGround);
|
|
279
|
+
}
|
|
280
|
+
var oldZIndex = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.polyline.zIndex);
|
|
281
|
+
if (oldZIndex != zIndex) {
|
|
282
|
+
cEntityBorder.polyline.zIndex = new Cesium.ConstantProperty(zIndex);
|
|
283
|
+
}
|
|
284
|
+
var oldMaterial = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.polyline.material);
|
|
285
|
+
var newMaterial = new Cesium.ColorMaterialProperty(cLineColor);
|
|
286
|
+
if (compareColorMaterials(params.viewer, oldMaterial, newMaterial)) {
|
|
287
|
+
cEntityBorder.polyline.material = newMaterial;
|
|
288
|
+
}
|
|
289
|
+
cEntityBorder.polyline.classificationType = new Cesium.ConstantProperty(Cesium.ClassificationType.TERRAIN);
|
|
290
|
+
cEntityBorder.polyline.distanceDisplayCondition = new Cesium.ConstantProperty(entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
|
|
291
|
+
cEntityBorder.corridor = undefined;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
var oldPosses = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.corridor.positions);
|
|
295
|
+
if (!(0, cesium_utils_1.CompareCPosses)(oldPosses, borderPosses)) {
|
|
296
|
+
cEntityBorder.corridor.positions = new Cesium.ConstantProperty(borderPosses);
|
|
297
|
+
}
|
|
298
|
+
var oldHeightRef = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.corridor.heightReference);
|
|
299
|
+
if (oldHeightRef != heightRef) {
|
|
300
|
+
cEntityBorder.corridor.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
301
|
+
}
|
|
302
|
+
var oldBorderHeight = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.corridor.height);
|
|
303
|
+
if (oldBorderHeight != borderHeight) {
|
|
304
|
+
cEntityBorder.corridor.height = new Cesium.ConstantProperty(borderHeight);
|
|
305
|
+
}
|
|
306
|
+
var oldWidth = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.corridor.width);
|
|
307
|
+
if (oldWidth != width) {
|
|
308
|
+
cEntityBorder.corridor.width = new Cesium.ConstantProperty(width);
|
|
309
|
+
}
|
|
310
|
+
var oldZIndex = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.corridor.zIndex);
|
|
311
|
+
if (oldZIndex != zIndex + 1) {
|
|
312
|
+
cEntityBorder.corridor.zIndex = new Cesium.ConstantProperty(zIndex + 1);
|
|
313
|
+
}
|
|
314
|
+
var oldMaterial = (0, cesium_utils_1.GetCValue)(params.viewer, cEntityBorder.corridor.material);
|
|
315
|
+
var newMaterial = new Cesium.ColorMaterialProperty(cLineColor);
|
|
316
|
+
if (compareColorMaterials(params.viewer, oldMaterial, newMaterial)) {
|
|
317
|
+
cEntityBorder.corridor.material = newMaterial;
|
|
318
|
+
}
|
|
319
|
+
cEntityBorder.corridor.fill = new Cesium.ConstantProperty(true);
|
|
320
|
+
cEntityBorder.corridor.distanceDisplayCondition = new Cesium.ConstantProperty(entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance, width));
|
|
321
|
+
cEntityBorder.polyline = undefined;
|
|
322
|
+
}
|
|
323
|
+
cEntityBorder.show = true;
|
|
324
|
+
}
|
|
325
|
+
cEntityBorder._parentEntity = cEntity;
|
|
326
|
+
cEntity._siblingGraphics.push(cEntityBorder);
|
|
327
|
+
for (var i = 0; i < holePosses.length; i++) {
|
|
328
|
+
var posses_1 = holePosses[i];
|
|
329
|
+
bruce_models_1.Cartes.CloseRing3(posses_1);
|
|
330
|
+
var cEntityHole = new Cesium.Entity({
|
|
331
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
332
|
+
polyline: units == "px" ? new Cesium.PolylineGraphics({
|
|
333
|
+
positions: posses_1,
|
|
334
|
+
material: cLineColor,
|
|
335
|
+
width: width,
|
|
336
|
+
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
337
|
+
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
338
|
+
arcType: Cesium.ArcType.GEODESIC,
|
|
339
|
+
zIndex: zIndex,
|
|
340
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance)
|
|
341
|
+
}) : null,
|
|
342
|
+
corridor: units == "m" ? {
|
|
343
|
+
positions: borderPosses,
|
|
344
|
+
material: cLineColor,
|
|
345
|
+
heightReference: heightRef,
|
|
346
|
+
height: borderHeight,
|
|
347
|
+
width: width,
|
|
348
|
+
fill: true,
|
|
349
|
+
zIndex: zIndex + 1,
|
|
350
|
+
cornerType: Cesium.CornerType.MITERED,
|
|
351
|
+
classificationType: classification,
|
|
352
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
353
|
+
shadows: Cesium.ShadowMode.ENABLED,
|
|
354
|
+
} : null,
|
|
355
|
+
show: true
|
|
356
|
+
});
|
|
357
|
+
cEntity._siblingGraphics.push(cEntityHole);
|
|
358
|
+
cEntityHole._parentEntity = cEntity;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
cEntity._siblingGraphics = [];
|
|
363
|
+
}
|
|
364
|
+
return cEntity;
|
|
365
|
+
}
|
|
366
|
+
EntityRenderEnginePolygon.Render = Render;
|
|
367
|
+
function RenderGroup(params) {
|
|
368
|
+
var _a, _b, _c;
|
|
369
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
370
|
+
var api, cEntities, i, entity, zoomItem, style, _d, tagIds, tags, pStyle, cEntity, name_1;
|
|
371
|
+
return __generator(this, function (_e) {
|
|
372
|
+
switch (_e.label) {
|
|
373
|
+
case 0:
|
|
374
|
+
api = params.apiGetter.getApi();
|
|
375
|
+
cEntities = new Map();
|
|
376
|
+
i = 0;
|
|
377
|
+
_e.label = 1;
|
|
378
|
+
case 1:
|
|
379
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 9];
|
|
380
|
+
entity = params.entities[i];
|
|
381
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
382
|
+
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 3];
|
|
383
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
384
|
+
case 2:
|
|
385
|
+
_d = (_a = (_e.sent())) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
386
|
+
return [3 /*break*/, 4];
|
|
387
|
+
case 3:
|
|
388
|
+
_d = zoomItem.Style;
|
|
389
|
+
_e.label = 4;
|
|
390
|
+
case 4:
|
|
391
|
+
style = _d;
|
|
392
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
393
|
+
tags = [];
|
|
394
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 6];
|
|
395
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
396
|
+
api: api,
|
|
397
|
+
tagIds: tagIds
|
|
398
|
+
})];
|
|
399
|
+
case 5:
|
|
400
|
+
tags = (_e.sent()).tags;
|
|
401
|
+
_e.label = 6;
|
|
402
|
+
case 6:
|
|
403
|
+
pStyle = (_b = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _b !== void 0 ? _b : {};
|
|
404
|
+
cEntity = Render({
|
|
405
|
+
entity: entity,
|
|
406
|
+
style: pStyle,
|
|
407
|
+
tags: tags,
|
|
408
|
+
viewer: params.viewer,
|
|
409
|
+
maxDistance: zoomItem.MaxZoom,
|
|
410
|
+
minDistance: zoomItem.MinZoom,
|
|
411
|
+
// Temporarily disabling re-using graphics for polygons as they have some bugs, and
|
|
412
|
+
// they don't support any animation yet.
|
|
413
|
+
// rendered: null
|
|
414
|
+
rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID)
|
|
415
|
+
});
|
|
416
|
+
if (!cEntity) return [3 /*break*/, 8];
|
|
417
|
+
return [4 /*yield*/, getName(api, entity)];
|
|
418
|
+
case 7:
|
|
419
|
+
name_1 = _e.sent();
|
|
420
|
+
cEntity.name = name_1;
|
|
421
|
+
cEntity._renderGroup = entity_render_engine_1.EntityRenderEngine.GetRenderGroupId(zoomItem);
|
|
422
|
+
cEntities.set(entity.Bruce.ID, cEntity);
|
|
423
|
+
_e.label = 8;
|
|
424
|
+
case 8:
|
|
425
|
+
i++;
|
|
426
|
+
return [3 /*break*/, 1];
|
|
427
|
+
case 9: return [2 /*return*/, cEntities];
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
EntityRenderEnginePolygon.RenderGroup = RenderGroup;
|
|
433
|
+
})(EntityRenderEnginePolygon = exports.EntityRenderEnginePolygon || (exports.EntityRenderEnginePolygon = {}));
|
|
434
|
+
function getName(api, entity) {
|
|
435
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
436
|
+
var typeId, type, name_2, e_1, hideError, error, code;
|
|
437
|
+
return __generator(this, function (_a) {
|
|
438
|
+
switch (_a.label) {
|
|
439
|
+
case 0:
|
|
440
|
+
_a.trys.push([0, 3, , 4]);
|
|
441
|
+
typeId = entity.Bruce["EntityType.ID"];
|
|
442
|
+
type = null;
|
|
443
|
+
if (!typeId) return [3 /*break*/, 2];
|
|
444
|
+
return [4 /*yield*/, bruce_models_1.EntityType.Get({
|
|
445
|
+
api: api,
|
|
446
|
+
entityTypeId: typeId
|
|
447
|
+
})];
|
|
448
|
+
case 1:
|
|
449
|
+
type = (_a.sent()).entityType;
|
|
450
|
+
_a.label = 2;
|
|
451
|
+
case 2:
|
|
452
|
+
if (type) {
|
|
453
|
+
name_2 = bruce_models_1.Entity.CalculateName({
|
|
454
|
+
entity: entity,
|
|
455
|
+
type: type,
|
|
456
|
+
defaultToId: false
|
|
457
|
+
});
|
|
458
|
+
return [2 /*return*/, name_2 ? name_2 : "Unnamed Entity"];
|
|
459
|
+
}
|
|
460
|
+
return [3 /*break*/, 4];
|
|
461
|
+
case 3:
|
|
462
|
+
e_1 = _a.sent();
|
|
463
|
+
hideError = false;
|
|
464
|
+
// TODO: we need a util for extracting code + message rather than writing all this every time.
|
|
465
|
+
if (e_1 && typeof e_1 == "object" && e_1.ERROR) {
|
|
466
|
+
error = e_1.ERROR;
|
|
467
|
+
code = error && typeof error == "object" ? error.Code : "";
|
|
468
|
+
// Avoiding logging a common error.
|
|
469
|
+
// This happens when rendering entities that don't have records.
|
|
470
|
+
hideError = String(code).toLowerCase() == "notfound";
|
|
471
|
+
}
|
|
472
|
+
if (!hideError) {
|
|
473
|
+
console.error(e_1);
|
|
474
|
+
}
|
|
475
|
+
return [3 /*break*/, 4];
|
|
476
|
+
case 4: return [2 /*return*/, "Unknown entity"];
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function getStyle(api, entity, styleId) {
|
|
482
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
483
|
+
var style, e_2, typeId, type, e_3, hideError, error, code;
|
|
484
|
+
return __generator(this, function (_a) {
|
|
485
|
+
switch (_a.label) {
|
|
486
|
+
case 0:
|
|
487
|
+
style = null;
|
|
488
|
+
if (!styleId) return [3 /*break*/, 4];
|
|
489
|
+
_a.label = 1;
|
|
490
|
+
case 1:
|
|
491
|
+
_a.trys.push([1, 3, , 4]);
|
|
492
|
+
return [4 /*yield*/, bruce_models_1.Style.Get({
|
|
493
|
+
api: api,
|
|
494
|
+
styleId: styleId
|
|
495
|
+
})];
|
|
496
|
+
case 2:
|
|
497
|
+
style = (_a.sent()).style;
|
|
498
|
+
return [3 /*break*/, 4];
|
|
499
|
+
case 3:
|
|
500
|
+
e_2 = _a.sent();
|
|
501
|
+
console.error(e_2);
|
|
502
|
+
return [3 /*break*/, 4];
|
|
503
|
+
case 4:
|
|
504
|
+
if (!!style) return [3 /*break*/, 9];
|
|
505
|
+
typeId = entity.Bruce["EntityType.ID"];
|
|
506
|
+
if (!typeId) return [3 /*break*/, 9];
|
|
507
|
+
return [4 /*yield*/, bruce_models_1.EntityType.Get({
|
|
508
|
+
api: api,
|
|
509
|
+
entityTypeId: typeId
|
|
510
|
+
})];
|
|
511
|
+
case 5:
|
|
512
|
+
type = (_a.sent()).entityType;
|
|
513
|
+
if (!type["DisplaySetting.ID"]) return [3 /*break*/, 9];
|
|
514
|
+
_a.label = 6;
|
|
515
|
+
case 6:
|
|
516
|
+
_a.trys.push([6, 8, , 9]);
|
|
517
|
+
return [4 /*yield*/, bruce_models_1.Style.Get({
|
|
518
|
+
api: api,
|
|
519
|
+
styleId: type["DisplaySetting.ID"]
|
|
520
|
+
})];
|
|
521
|
+
case 7:
|
|
522
|
+
style = (_a.sent()).style;
|
|
523
|
+
return [3 /*break*/, 9];
|
|
524
|
+
case 8:
|
|
525
|
+
e_3 = _a.sent();
|
|
526
|
+
hideError = false;
|
|
527
|
+
// TODO: we need a util for extracting code + message rather than writing all this every time.
|
|
528
|
+
if (e_3 && typeof e_3 == "object" && e_3.ERROR) {
|
|
529
|
+
error = e_3.ERROR;
|
|
530
|
+
code = error && typeof error == "object" ? error.Code : "";
|
|
531
|
+
// Avoiding logging a common error.
|
|
532
|
+
// This happens when rendering entities that don't have records.
|
|
533
|
+
hideError = String(code).toLowerCase() == "notfound";
|
|
534
|
+
}
|
|
535
|
+
if (!hideError) {
|
|
536
|
+
console.error(e_3);
|
|
537
|
+
}
|
|
538
|
+
return [3 /*break*/, 9];
|
|
539
|
+
case 9: return [2 /*return*/, style];
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Compares two color materials.
|
|
546
|
+
* Returns if they are equal.
|
|
547
|
+
* @param viewer
|
|
548
|
+
* @param a
|
|
549
|
+
* @param b
|
|
550
|
+
* @returns
|
|
551
|
+
*/
|
|
552
|
+
function compareColorMaterials(viewer, a, b) {
|
|
553
|
+
// Same reference.
|
|
554
|
+
if (a == b) {
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
var colorA = getColor(viewer, a.color);
|
|
558
|
+
var colorB = getColor(viewer, b.color);
|
|
559
|
+
// One is null.
|
|
560
|
+
if (!colorA || !colorB) {
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
// Colors don't match.
|
|
564
|
+
if (colorA.alpha != colorB.alpha || colorA.red != colorB.red || colorA.green != colorB.green || colorA.blue != colorB.blue) {
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
function getColor(viewer, obj) {
|
|
570
|
+
var value = null;
|
|
571
|
+
if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
|
|
572
|
+
var date = viewer.scene.lastRenderTime;
|
|
573
|
+
if (!date) {
|
|
574
|
+
date = viewer.clock.currentTime;
|
|
575
|
+
}
|
|
576
|
+
value = obj.getValue(date);
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
value = obj;
|
|
580
|
+
}
|
|
581
|
+
if (value && value instanceof Cesium.ColorMaterialProperty) {
|
|
582
|
+
value = value.color;
|
|
583
|
+
}
|
|
584
|
+
return value;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Returns an entity's "size" used for distance display condition calcs.
|
|
588
|
+
* This will return the distance in meters between the two boundary corners.
|
|
589
|
+
* @param entity
|
|
590
|
+
*/
|
|
591
|
+
function getSizeOfPolygonEntity(entity) {
|
|
592
|
+
if (!entity) {
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
var hasCalculatedBounds = false;
|
|
596
|
+
var bounds = bruce_models_1.Entity.GetValue({
|
|
597
|
+
entity: entity,
|
|
598
|
+
path: ["Bruce", "Boundaries"]
|
|
599
|
+
});
|
|
600
|
+
var calculateBounds = function () {
|
|
601
|
+
hasCalculatedBounds = true;
|
|
602
|
+
bounds = bruce_models_1.Bounds.FromEntity(entity);
|
|
603
|
+
};
|
|
604
|
+
var checkHasArea = function () {
|
|
605
|
+
return (bounds === null || bounds === void 0 ? void 0 : bounds.minLongitude) != (bounds === null || bounds === void 0 ? void 0 : bounds.maxLongitude) || (bounds === null || bounds === void 0 ? void 0 : bounds.minLatitude) != (bounds === null || bounds === void 0 ? void 0 : bounds.maxLatitude);
|
|
606
|
+
};
|
|
607
|
+
// Create bounds if missing entirely.
|
|
608
|
+
if (!bounds) {
|
|
609
|
+
calculateBounds();
|
|
610
|
+
}
|
|
611
|
+
if (!(bounds === null || bounds === void 0 ? void 0 : bounds.minLatitude)) {
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
614
|
+
// Check for bounds that are a single point.
|
|
615
|
+
if (!checkHasArea()) {
|
|
616
|
+
// Already tried to reconstruct, so we'll just give up.
|
|
617
|
+
if (hasCalculatedBounds) {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
calculateBounds();
|
|
621
|
+
// Check after reconstruction. If still bad then give up.
|
|
622
|
+
if (!(bounds === null || bounds === void 0 ? void 0 : bounds.minLatitude) || !checkHasArea()) {
|
|
623
|
+
return null;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
var minLat = +(bounds === null || bounds === void 0 ? void 0 : bounds.minLatitude);
|
|
627
|
+
var maxLat = +(bounds === null || bounds === void 0 ? void 0 : bounds.maxLatitude);
|
|
628
|
+
var minLon = +(bounds === null || bounds === void 0 ? void 0 : bounds.minLongitude);
|
|
629
|
+
var maxLon = +(bounds === null || bounds === void 0 ? void 0 : bounds.maxLongitude);
|
|
630
|
+
if (isNaN(minLat) || isNaN(maxLat) || isNaN(minLon) || isNaN(maxLon)) {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
var p1 = Cesium.Cartesian3.fromDegrees(minLon, minLat);
|
|
634
|
+
var p2 = Cesium.Cartesian3.fromDegrees(maxLon, maxLat);
|
|
635
|
+
var length = Cesium.Cartesian3.distance(p1, p2);
|
|
636
|
+
if (isNaN(length) || length <= 0) {
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
if (hasCalculatedBounds) {
|
|
640
|
+
// Data not migrated to an internal field.
|
|
641
|
+
// We'll set the change in both places.
|
|
642
|
+
if (entity.boundaries) {
|
|
643
|
+
entity.boundaries = bounds;
|
|
644
|
+
entity.Bruce.Boundaries = bounds;
|
|
645
|
+
}
|
|
646
|
+
// Data migrated to an internal field.
|
|
647
|
+
else {
|
|
648
|
+
entity.Bruce.Boundaries = bounds;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return length;
|
|
652
|
+
}
|
|
653
|
+
function getZIndex(style, entity, tags) {
|
|
654
|
+
var zIndex = (style === null || style === void 0 ? void 0 : style.zIndex) ? +bruce_models_1.Calculator.GetNumber(style === null || style === void 0 ? void 0 : style.zIndex, entity, tags) : 0;
|
|
655
|
+
if (zIndex == null) {
|
|
656
|
+
zIndex = 0;
|
|
657
|
+
}
|
|
658
|
+
return (0, js_utils_1.EnsureNumber)(zIndex);
|
|
659
|
+
}
|
|
660
|
+
function getPolygonStyleExtrusion(pStyle, entity, tags, heightRef) {
|
|
661
|
+
var attrPath = pStyle.extrusionPath;
|
|
662
|
+
if (!pStyle.useExtrusion || !attrPath) {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
try {
|
|
666
|
+
var extrusion = +bruce_models_1.Calculator.GetNumber(attrPath, entity, tags);
|
|
667
|
+
if (!extrusion && extrusion != 0) {
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
/*
|
|
671
|
+
Cesium extrudes in strange way.
|
|
672
|
+
If you want something that is 50 meters above sea, and 5 meters tall,
|
|
673
|
+
You need to extrude by 55 meters, if you extrude by 5 it will extrude from sea and look flat.
|
|
674
|
+
*/
|
|
675
|
+
var height = bruce_models_1.Entity.GetValue({
|
|
676
|
+
entity: entity,
|
|
677
|
+
path: ["Bruce", "Location", "altitude"]
|
|
678
|
+
});
|
|
679
|
+
return heightRef != Cesium.HeightReference.CLAMP_TO_GROUND ? extrusion + height : extrusion;
|
|
680
|
+
}
|
|
681
|
+
catch (e) {
|
|
682
|
+
console.error(e);
|
|
683
|
+
}
|
|
684
|
+
return 0;
|
|
685
|
+
}
|
|
686
|
+
function getPolygonExtrusion(entity, tags, ring, posses, heightRef, pStyle) {
|
|
687
|
+
var data = {
|
|
688
|
+
value: undefined,
|
|
689
|
+
exHeightRef: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
|
690
|
+
posses: null
|
|
691
|
+
};
|
|
692
|
+
// Step 1. Try get using style.
|
|
693
|
+
var extrusion = getPolygonStyleExtrusion(pStyle, entity, tags, heightRef);
|
|
694
|
+
if (extrusion) {
|
|
695
|
+
if (heightRef == Cesium.HeightReference.NONE) {
|
|
696
|
+
// Let's normalize all point heights to be the same (at entity altitude).
|
|
697
|
+
// This let's us have a consistent extrusion height, and be adjustable easier by user.
|
|
698
|
+
var alt_1 = bruce_models_1.Entity.GetValue({
|
|
699
|
+
entity: entity,
|
|
700
|
+
path: ["Bruce", "Location", "altitude"]
|
|
701
|
+
});
|
|
702
|
+
if (!alt_1) {
|
|
703
|
+
alt_1 = 0;
|
|
704
|
+
}
|
|
705
|
+
var points = posses.map(function (x) { return Cesium.Cartographic.fromCartesian(x); });
|
|
706
|
+
points.forEach(function (point) {
|
|
707
|
+
point.height = alt_1;
|
|
708
|
+
});
|
|
709
|
+
posses = points.map(function (x) { return Cesium.Cartesian3.fromRadians((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.height)); });
|
|
710
|
+
}
|
|
711
|
+
data.value = extrusion;
|
|
712
|
+
}
|
|
713
|
+
// Step 2. Try get using geometry data.
|
|
714
|
+
else {
|
|
715
|
+
data.exHeightRef = undefined;
|
|
716
|
+
if (ring.Height && ring.Height > 0) {
|
|
717
|
+
var points = posses.map(function (x) { return Cesium.Cartographic.fromCartesian(x); });
|
|
718
|
+
if (points.length <= 0) {
|
|
719
|
+
data.value = ring.Height;
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
var highest = null;
|
|
723
|
+
for (var i = 0; i < points.length; i++) {
|
|
724
|
+
var pointHeight = points[i].height;
|
|
725
|
+
if (pointHeight > highest || highest === null) {
|
|
726
|
+
highest = pointHeight;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
highest = (highest === null ? 0 : highest) + ring.Height;
|
|
730
|
+
data.value = highest;
|
|
731
|
+
}
|
|
732
|
+
data.exHeightRef = Cesium.HeightReference.NONE;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
data.posses = posses;
|
|
736
|
+
if (data.value != undefined) {
|
|
737
|
+
data.value = (0, js_utils_1.EnsureNumber)(data.value);
|
|
738
|
+
}
|
|
739
|
+
return data;
|
|
740
|
+
}
|
|
741
|
+
function getHeightRef(style, defaultStyle) {
|
|
742
|
+
var _a;
|
|
743
|
+
var heightRef = defaultStyle == null ? Cesium.HeightReference.CLAMP_TO_GROUND : defaultStyle;
|
|
744
|
+
var altOptionId = (_a = style === null || style === void 0 ? void 0 : style.altitudeOption) === null || _a === void 0 ? void 0 : _a.id;
|
|
745
|
+
if (altOptionId == 0) {
|
|
746
|
+
heightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
747
|
+
}
|
|
748
|
+
else if (altOptionId == 1) {
|
|
749
|
+
heightRef = Cesium.HeightReference.NONE;
|
|
750
|
+
}
|
|
751
|
+
else if (altOptionId == 2) {
|
|
752
|
+
heightRef = Cesium.HeightReference.RELATIVE_TO_GROUND;
|
|
753
|
+
}
|
|
754
|
+
return heightRef;
|
|
755
|
+
}
|
|
756
|
+
//# sourceMappingURL=entity-render-engine-polygon.js.map
|