bruce-cesium 4.1.6 → 4.1.8

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.
@@ -1,6 +1,6 @@
1
1
  import { BruceEvent, Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ProjectViewTile, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, Api, EntityRelationType, ENVIRONMENT, EntityHistoricData, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, Camera } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, DistanceDisplayCondition, NearFarScalar, Model, ColorMaterialProperty, Entity, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorBlendMode, HeadingPitchRoll, Transforms, JulianDate, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, BoundingSphere, GeometryInstance, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Quaternion, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, SceneMode, Entity, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, NearFarScalar, Model, ColorMaterialProperty, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorBlendMode, HeadingPitchRoll, Transforms, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, Cesium3DTileset, Matrix4, Matrix3, IonResource, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Quaternion, Intersect } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4030,12 +4030,13 @@ var TERRAIN_HEIGHT_TOLERANCE_LOW_ENTITY_THRESHOLD = 100;
4030
4030
  * @returns
4031
4031
  */
4032
4032
  var getTerrainOffset = function (viewer, pos3d) {
4033
+ var _a;
4033
4034
  if (!viewer.terrainProvider || viewer.terrainProvider["ready"] == false) {
4034
4035
  return null;
4035
4036
  }
4036
- var terrain = ViewUtils.GatherTerrainTile({
4037
+ var terrain = (_a = ViewUtils.GatherTerrainTile({
4037
4038
  viewer: viewer
4038
- }).terrain;
4039
+ })) === null || _a === void 0 ? void 0 : _a.terrain;
4039
4040
  if (!terrain || terrain.tilesetId == ProjectViewTile.EDefaultTerrain.FlatTerrain) {
4040
4041
  return 0;
4041
4042
  }
@@ -4044,8 +4045,8 @@ var getTerrainOffset = function (viewer, pos3d) {
4044
4045
  var keys = Array.from(_terrainCache.Entries());
4045
4046
  var tolerance = viewer.entities.values.length > TERRAIN_HEIGHT_TOLERANCE_LOW_ENTITY_THRESHOLD ? TERRAIN_HEIGHT_TOLERANCE : TERRAIN_HEIGHT_TOLERANCE_LOW_COUNT;
4046
4047
  for (var i = 0; i < keys.length; i++) {
4047
- var _a = keys[i], key_1 = _a[0], offset_1 = _a[1];
4048
- var _b = key_1.split("_"), terrainId2 = _b[0], x = _b[1], y = _b[2], z = _b[3];
4048
+ var _b = keys[i], key_1 = _b[0], offset_1 = _b[1];
4049
+ var _c = key_1.split("_"), terrainId2 = _c[0], x = _c[1], y = _c[2], z = _c[3];
4049
4050
  if (terrainId2 != terrainId) {
4050
4051
  continue;
4051
4052
  }
@@ -4102,13 +4103,13 @@ var adjustPos3d = function (viewer, heightRef, pos3d) {
4102
4103
  return newPos3d;
4103
4104
  };
4104
4105
  function isFlatTerrain(viewer) {
4105
- var _a;
4106
+ var _a, _b;
4106
4107
  if (!viewer) {
4107
4108
  return false;
4108
4109
  }
4109
- return ((_a = ViewUtils.GatherTerrainTile({
4110
+ return ((_b = (_a = ViewUtils.GatherTerrainTile({
4110
4111
  viewer: viewer
4111
- }).terrain) === null || _a === void 0 ? void 0 : _a.tilesetId) == ProjectViewTile.EDefaultTerrain.FlatTerrain;
4112
+ })) === null || _a === void 0 ? void 0 : _a.terrain) === null || _b === void 0 ? void 0 : _b.tilesetId) == ProjectViewTile.EDefaultTerrain.FlatTerrain;
4112
4113
  }
4113
4114
  function getValue(viewer, obj) {
4114
4115
  if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
@@ -4232,12 +4233,12 @@ function computeBoundingSphereFromPositions(positions) {
4232
4233
  return BoundingSphere.fromPoints(positions);
4233
4234
  }
4234
4235
  function shouldCullEntity(viewer, cEntity) {
4235
- var _a, _b, _c;
4236
+ var _a, _b, _c, _d;
4236
4237
  var camera = viewer.scene.camera;
4237
4238
  var boundingSphere;
4238
- var terrainId = (_b = (_a = ViewUtils.GatherTerrainTile({
4239
+ var terrainId = (_c = (_b = (_a = ViewUtils.GatherTerrainTile({
4239
4240
  viewer: viewer
4240
- }).terrain) === null || _a === void 0 ? void 0 : _a.tilesetId) !== null && _b !== void 0 ? _b : ProjectViewTile.EDefaultTerrain.FlatTerrain;
4241
+ })) === null || _a === void 0 ? void 0 : _a.terrain) === null || _b === void 0 ? void 0 : _b.tilesetId) !== null && _c !== void 0 ? _c : ProjectViewTile.EDefaultTerrain.FlatTerrain;
4241
4242
  var cacheKey = terrainId + cEntity.id;
4242
4243
  var cacheData = boundingSphereCache.Get(cacheKey);
4243
4244
  if (cacheData) {
@@ -4245,7 +4246,7 @@ function shouldCullEntity(viewer, cEntity) {
4245
4246
  }
4246
4247
  else {
4247
4248
  var positions = getPositionsFromEntity(viewer, cEntity);
4248
- if ((_c = positions === null || positions === void 0 ? void 0 : positions.positions) === null || _c === void 0 ? void 0 : _c.length) {
4249
+ if ((_d = positions === null || positions === void 0 ? void 0 : positions.positions) === null || _d === void 0 ? void 0 : _d.length) {
4249
4250
  // Sphere calculated from entity positions.
4250
4251
  // We will evaluate the visual now to see if the sphere should be counted, for example 3D models might not be loaded yet.
4251
4252
  var sphere = computeBoundingSphereFromPositions(positions.positions);
@@ -4645,6 +4646,235 @@ function OneTimeError(key, message) {
4645
4646
  }
4646
4647
  }
4647
4648
 
4649
+ /**
4650
+ * Util for simplifying geometry on the fly.
4651
+ */
4652
+ var SimplifyGeometry;
4653
+ (function (SimplifyGeometry) {
4654
+ /**
4655
+ * Returns the total number of points in the geometry.
4656
+ * @param geometry
4657
+ * @returns
4658
+ */
4659
+ function CountPoints(geometry) {
4660
+ var count = 0;
4661
+ var traverse = function (geometry) {
4662
+ if (geometry.MultiGeometry) {
4663
+ for (var i = 0; i < geometry.MultiGeometry.length; i++) {
4664
+ traverse(geometry.MultiGeometry[i]);
4665
+ }
4666
+ }
4667
+ else if (geometry.Polygon) {
4668
+ for (var i = 0; i < geometry.Polygon.length; i++) {
4669
+ var polygon = geometry.Polygon[i];
4670
+ count += Geometry.ParsePoints(polygon.LinearRing).length;
4671
+ }
4672
+ }
4673
+ else if (geometry.LineString) {
4674
+ count += Geometry.ParsePoints(geometry.LineString).length;
4675
+ }
4676
+ else if (geometry.Point) {
4677
+ count += 1;
4678
+ }
4679
+ };
4680
+ traverse(geometry);
4681
+ return count;
4682
+ }
4683
+ SimplifyGeometry.CountPoints = CountPoints;
4684
+ /**
4685
+ * Simplifies input geometry.
4686
+ * This will turn it into GeoJSON, run it through turf, then back to Bruce geometry.
4687
+ * @param geometry
4688
+ */
4689
+ function Simplify(geometry, tolerance) {
4690
+ if (!geometry || tolerance <= 0 || !turf || !turf.simplify) {
4691
+ return geometry;
4692
+ }
4693
+ var geoJson = toGeoJson(geometry);
4694
+ // Union overlapping shapes
4695
+ var combinedFeatures = [];
4696
+ geoJson.features.forEach(function (feature) {
4697
+ var unioned = false;
4698
+ for (var i = 0; i < combinedFeatures.length; i++) {
4699
+ try {
4700
+ var unionResult = turf.union(combinedFeatures[i], feature);
4701
+ if (unionResult) {
4702
+ combinedFeatures[i] = unionResult;
4703
+ unioned = true;
4704
+ break;
4705
+ }
4706
+ }
4707
+ catch (error) {
4708
+ // Ignore the error if union fails, and continue
4709
+ }
4710
+ }
4711
+ if (!unioned) {
4712
+ combinedFeatures.push(feature);
4713
+ }
4714
+ });
4715
+ geoJson = {
4716
+ type: "FeatureCollection",
4717
+ features: combinedFeatures,
4718
+ };
4719
+ // Simplify the combined result.
4720
+ var simplified = turf.simplify(geoJson, { tolerance: tolerance, highQuality: true, mutate: true });
4721
+ return fromGeoJson(simplified);
4722
+ }
4723
+ SimplifyGeometry.Simplify = Simplify;
4724
+ })(SimplifyGeometry || (SimplifyGeometry = {}));
4725
+ /**
4726
+ * Converts Bruce geometry to GeoJSON.
4727
+ * @param geometry
4728
+ * @returns
4729
+ */
4730
+ function toGeoJson(geometry) {
4731
+ var features = [];
4732
+ var excludeAltitude = false;
4733
+ var areCoordinatesEqual = function (coord1, coord2) {
4734
+ return coord1[0] === coord2[0] && coord1[1] === coord2[1] && (coord1[2] === coord2[2] || (coord1.length < 3 && coord2.length < 3));
4735
+ };
4736
+ var removeConsecutiveDuplicates = function (coordinates) {
4737
+ return coordinates.filter(function (coord, index, array) {
4738
+ return index === 0 || !areCoordinatesEqual(coord, array[index - 1]);
4739
+ });
4740
+ };
4741
+ var closePolygonCoordinates = function (coordinates) {
4742
+ if (coordinates.length > 0 && !areCoordinatesEqual(coordinates[0], coordinates[coordinates.length - 1])) {
4743
+ var firstPointCopy = [].concat(coordinates[0]);
4744
+ coordinates.push(firstPointCopy);
4745
+ }
4746
+ return coordinates;
4747
+ };
4748
+ var processGeometry = function (geometry) {
4749
+ var _a, _b;
4750
+ var feature = {
4751
+ type: "Feature",
4752
+ properties: {},
4753
+ geometry: null
4754
+ };
4755
+ if ((_a = geometry.MultiGeometry) === null || _a === void 0 ? void 0 : _a.length) {
4756
+ geometry.MultiGeometry.forEach(function (geo) { return processGeometry(geo); });
4757
+ return;
4758
+ }
4759
+ else if ((_b = geometry.Polygon) === null || _b === void 0 ? void 0 : _b.length) {
4760
+ var sortedPolygons = geometry.Polygon.sort(function (a, b) {
4761
+ return a.Facing === Geometry.EPolygonRingType.Boundaries ? -1 : 1;
4762
+ });
4763
+ var coordinates = sortedPolygons.map(function (polygonRing) {
4764
+ return closePolygonCoordinates(removeConsecutiveDuplicates(polygonRing.LinearRing.split(' ').map(function (coord) {
4765
+ var _a = coord.split(',').map(Number), lon = _a[0], lat = _a[1], alt = _a[2];
4766
+ return [lon, lat, alt !== undefined ? alt : 0];
4767
+ })));
4768
+ });
4769
+ // Check if the polygon has at least 4 points.
4770
+ var isValidPolygon = coordinates.every(function (polygon) { return polygon.length >= 4; });
4771
+ if (!isValidPolygon) {
4772
+ // Perhaps try other geometry instead of returning?
4773
+ return;
4774
+ }
4775
+ feature.geometry = {
4776
+ type: "Polygon",
4777
+ coordinates: coordinates,
4778
+ };
4779
+ }
4780
+ else if (geometry.LineString) {
4781
+ var coordinates = removeConsecutiveDuplicates(geometry.LineString.split(' ').map(function (coord) {
4782
+ var _a = coord.split(',').map(Number), lon = _a[0], lat = _a[1], alt = _a[2];
4783
+ return [lon, lat, alt !== undefined ? alt : 0];
4784
+ }));
4785
+ // Check if the polyline has at least 2 points.
4786
+ if (coordinates.length < 2) {
4787
+ // Perhaps try other geometry instead of returning?
4788
+ return;
4789
+ }
4790
+ feature.geometry = {
4791
+ type: "LineString",
4792
+ coordinates: coordinates,
4793
+ };
4794
+ }
4795
+ else if (geometry.Point) {
4796
+ var _c = geometry.Point.split(',').map(Number), lon = _c[0], lat = _c[1], alt = _c[2];
4797
+ var coordinates = excludeAltitude ? [lon, lat] : [lon, lat, alt !== undefined ? alt : 0];
4798
+ feature.geometry = {
4799
+ type: "Point",
4800
+ coordinates: coordinates,
4801
+ };
4802
+ }
4803
+ if (feature.geometry) {
4804
+ features.push(feature);
4805
+ }
4806
+ };
4807
+ try {
4808
+ processGeometry(geometry);
4809
+ }
4810
+ catch (e) {
4811
+ console.error(e);
4812
+ return null;
4813
+ }
4814
+ var geoJson = {
4815
+ type: "FeatureCollection",
4816
+ features: features,
4817
+ };
4818
+ return geoJson;
4819
+ }
4820
+ /**
4821
+ * Converts GeoJSON to Bruce geometry.
4822
+ * @param geoJson
4823
+ * @returns
4824
+ */
4825
+ function fromGeoJson(geoJson) {
4826
+ if (geoJson.features.length === 0) {
4827
+ return {};
4828
+ }
4829
+ var geometry = {
4830
+ Polygon: [],
4831
+ MultiGeometry: []
4832
+ };
4833
+ if (geoJson.features.length > 1) {
4834
+ geoJson.features.forEach(function (feature) {
4835
+ var featureGeometry = fromGeoJson({
4836
+ type: "FeatureCollection",
4837
+ features: [feature]
4838
+ });
4839
+ geometry.MultiGeometry.push(featureGeometry);
4840
+ });
4841
+ return geometry;
4842
+ }
4843
+ var feature = geoJson.features[0];
4844
+ var _a = feature.geometry, type = _a.type, coordinates = _a.coordinates;
4845
+ switch (type) {
4846
+ case "Polygon":
4847
+ coordinates.forEach(function (polygon, index) {
4848
+ var linearRing = polygon.map(function (coord) { return coord.join(','); }).join(' ');
4849
+ geometry.Polygon.push({
4850
+ LinearRing: linearRing,
4851
+ Facing: index === 0 ? Geometry.EPolygonRingType.Boundaries : Geometry.EPolygonRingType.Hole
4852
+ });
4853
+ });
4854
+ break;
4855
+ case "LineString":
4856
+ geometry.LineString = coordinates.map(function (coord) { return coord.join(','); }).join(' ');
4857
+ break;
4858
+ case "Point":
4859
+ geometry.Point = coordinates.join(',');
4860
+ break;
4861
+ case "MultiPolygon":
4862
+ coordinates.forEach(function (multiPolygon) {
4863
+ var multiPolygonGeometry = { Polygon: [] };
4864
+ multiPolygon.forEach(function (polygon, index) {
4865
+ var linearRing = polygon.map(function (coord) { return coord.join(','); }).join(' ');
4866
+ multiPolygonGeometry.Polygon.push({
4867
+ LinearRing: linearRing,
4868
+ Facing: index === 0 ? Geometry.EPolygonRingType.Boundaries : Geometry.EPolygonRingType.Hole
4869
+ });
4870
+ });
4871
+ geometry.MultiGeometry.push(multiPolygonGeometry);
4872
+ });
4873
+ break;
4874
+ }
4875
+ return geometry;
4876
+ }
4877
+
4648
4878
  function colorToCColor(color) {
4649
4879
  return new Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
4650
4880
  }
@@ -5320,7 +5550,7 @@ var EntityRenderEngine;
5320
5550
  function Render(params) {
5321
5551
  var _a, _b, _c, _d, _e, _f, _g;
5322
5552
  return __awaiter(this, void 0, void 0, function () {
5323
- var groupRenderParams, i, entity, geometry, updated, cEntities, models, multiGeometry, polygons, polylines, points, i, entity, id, zoomItem, displayType, existingRego, newRenderId, oldRenderId, geometry, mParams, mEntities, i, entity, id, cEntity, _loop_1, i, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity;
5553
+ var groupRenderParams, i, entity, geometry, optimized, updated, cEntities, models, multiGeometry, polygons, polylines, points, i, entity, id, zoomItem, displayType, existingRego, newRenderId, oldRenderId, geometry, mParams, mEntities, i, entity, id, cEntity, _loop_1, i, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity;
5324
5554
  return __generator(this, function (_h) {
5325
5555
  switch (_h.label) {
5326
5556
  case 0:
@@ -5339,17 +5569,37 @@ var EntityRenderEngine;
5339
5569
  entity: entity,
5340
5570
  path: ["Bruce", "VectorGeometry"]
5341
5571
  });
5342
- if (((_a = geometry === null || geometry === void 0 ? void 0 : geometry.MultiGeometry) === null || _a === void 0 ? void 0 : _a.length) == 1) {
5343
- // Not migrated to internal, set in both places.
5344
- if (entity.geometry) {
5345
- entity.geometry = __assign(__assign(__assign({}, entity.geometry), geometry.MultiGeometry[0]), { MultiGeometry: [] });
5346
- entity.Bruce.VectorGeometry = entity.geometry;
5572
+ // Optimize geometry if requested.
5573
+ // This will attempt to merge and simplify before rendering.
5574
+ // Note that this modifies the Entity object.
5575
+ if (params.optimizeGeometry) {
5576
+ if (params.optimizeMinPoints == null) {
5577
+ params.optimizeMinPoints = 1000;
5347
5578
  }
5348
- // Migrated to internal, we'll set it there.
5349
- else if (entity.Bruce.VectorGeometry) {
5350
- entity.Bruce.VectorGeometry = __assign(__assign(__assign({}, entity.Bruce.VectorGeometry), geometry.MultiGeometry[0]), { MultiGeometry: [] });
5579
+ if (geometry && SimplifyGeometry.CountPoints(geometry) >= params.optimizeMinPoints) {
5580
+ if (params.optimizeTolerance == null) {
5581
+ params.optimizeTolerance = 0.0005;
5582
+ }
5583
+ optimized = SimplifyGeometry.Simplify(geometry, params.optimizeTolerance);
5584
+ if (optimized) {
5585
+ // Continue on with the rendering using the optimized geometry.
5586
+ geometry = optimized;
5587
+ // Dereference the Entity object now that we have done a destructive operation.
5588
+ entity = Object.assign({}, entity);
5589
+ entity.Bruce = Object.assign({}, entity.Bruce);
5590
+ params.entities[i] = entity;
5591
+ }
5351
5592
  }
5352
5593
  }
5594
+ // We are using the new path.
5595
+ // This ensures we don't have a duplicate.
5596
+ entity.geometry = null;
5597
+ if (((_a = geometry === null || geometry === void 0 ? void 0 : geometry.MultiGeometry) === null || _a === void 0 ? void 0 : _a.length) == 1) {
5598
+ entity.Bruce.VectorGeometry = geometry.MultiGeometry[0];
5599
+ }
5600
+ else {
5601
+ entity.Bruce.VectorGeometry = geometry;
5602
+ }
5353
5603
  }
5354
5604
  updated = new Map();
5355
5605
  cEntities = new Map();
@@ -5461,7 +5711,7 @@ var EntityRenderEngine;
5461
5711
  pParams.entitiesHistoric = params.entitiesHistoric;
5462
5712
  zoomItem = pParams.zoomItems[entity.Bruce.ID];
5463
5713
  for (j = 0; j < geometry.MultiGeometry.length; j++) {
5464
- subEntity = __assign(__assign({}, entity), { geometry: geometry.MultiGeometry[j], Bruce: __assign(__assign({}, entity.Bruce), { ID: ObjectUtils.UId() }) });
5714
+ subEntity = __assign(__assign({}, entity), { geometry: null, Bruce: __assign(__assign({}, entity.Bruce), { ID: ObjectUtils.UId(), VectorGeometry: geometry.MultiGeometry[j] }) });
5465
5715
  pParams.zoomItems[subEntity.Bruce.ID] = zoomItem;
5466
5716
  pParams.entities.push(subEntity);
5467
5717
  }
@@ -11001,7 +11251,7 @@ var EntitiesRenderManager;
11001
11251
  Manager.prototype.renderAsGeojson = function (entities, force) {
11002
11252
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
11003
11253
  return __awaiter(this, void 0, void 0, function () {
11004
- var zoomItem, lods, withLods_1, individuals, style, e_4, entityTypeId, entityType, e_5, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, geojson, notRendered, source, groups, applyStyle, toForceUpdate, register, sEntities, i, cEntity;
11254
+ var zoomItem, lods, withLods_1, individuals, style, e_4, entityTypeId, entityType, e_5, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, i, entity, geometry, optimized, geojson, notRendered, source, groups, applyStyle, toForceUpdate, register, sEntities, i, cEntity;
11005
11255
  var _this = this;
11006
11256
  return __generator(this, function (_o) {
11007
11257
  switch (_o.label) {
@@ -11119,6 +11369,39 @@ var EntitiesRenderManager;
11119
11369
  lineWidthPx = 0;
11120
11370
  }
11121
11371
  lineWidthPx = Math.round(lineWidthPx);
11372
+ // If we are flagged to optimize then we'll run through and simplify each entity's geometry.
11373
+ if (this.item.optimizeGeometry) {
11374
+ for (i = 0; i < entities.length; i++) {
11375
+ entity = entities[i];
11376
+ geometry = Entity$1.GetValue({
11377
+ entity: entity,
11378
+ path: ["Bruce", "VectorGeometry"]
11379
+ });
11380
+ if (geometry) {
11381
+ if (this.item.optimizeMinPoints == null) {
11382
+ this.item.optimizeMinPoints = 1000;
11383
+ }
11384
+ if (SimplifyGeometry.CountPoints(geometry) > this.item.optimizeMinPoints) {
11385
+ if (this.item.optimizeTolerance == null) {
11386
+ this.item.optimizeTolerance = 0.0005;
11387
+ }
11388
+ optimized = SimplifyGeometry.Simplify(geometry, this.item.optimizeTolerance);
11389
+ if (optimized) {
11390
+ // Dereference the Entity object now that we have done a destructive operation.
11391
+ entity = Object.assign({}, entity);
11392
+ entity.Bruce = Object.assign({}, entity.Bruce);
11393
+ entities[i] = entity;
11394
+ // Continue on with the rendering using the optimized geometry.
11395
+ geometry = optimized;
11396
+ }
11397
+ }
11398
+ }
11399
+ // We are using the new path.
11400
+ // This ensures we don't have a duplicate.
11401
+ entity.geometry = null;
11402
+ entity.Bruce.VectorGeometry = geometry;
11403
+ }
11404
+ }
11122
11405
  geojson = Entity$1.ToGeoJson({
11123
11406
  entities: entities,
11124
11407
  includeUserData: false,
@@ -11352,7 +11635,10 @@ var EntitiesRenderManager;
11352
11635
  visualRegister: this.visualsManager,
11353
11636
  zoomControl: this.item.CameraZoomSettings,
11354
11637
  entitiesHistoric: entitiesHistoric,
11355
- force: force
11638
+ force: force,
11639
+ optimizeGeometry: this.item.optimizeGeometry,
11640
+ optimizeMinPoints: this.item.optimizeMinPoints,
11641
+ optimizeTolerance: this.item.optimizeTolerance,
11356
11642
  })];
11357
11643
  case 3:
11358
11644
  _m = _o.sent(), updated = _m.updated, cEntities = _m.entities;
@@ -25323,7 +25609,7 @@ var ViewRenderEngine;
25323
25609
  ViewRenderEngine.Render = Render;
25324
25610
  })(ViewRenderEngine || (ViewRenderEngine = {}));
25325
25611
 
25326
- var VERSION = "4.1.6";
25612
+ var VERSION = "4.1.8";
25327
25613
 
25328
25614
  export { VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline };
25329
25615
  //# sourceMappingURL=bruce-cesium.es5.js.map