bruce-cesium 2.2.9 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3079,8 +3079,10 @@
3079
3079
  var FORCE_UPDATE_BATCH_SIZE = 1000;
3080
3080
  var FORCE_UPDATE_BATCH_DELAY = 100;
3081
3081
  var PointClustering = /** @class */ (function () {
3082
- function PointClustering(register, menuItemId) {
3082
+ function PointClustering(register, menuItemId, settings) {
3083
3083
  var _this = this;
3084
+ this.minDistance = 5000;
3085
+ this.minTotalCount = 0;
3084
3086
  this.disposed = false;
3085
3087
  this.registeredEntityIds = new Set();
3086
3088
  // Queue to force update entities.
@@ -3097,6 +3099,14 @@
3097
3099
  _this.doUpdate();
3098
3100
  }, 1000);
3099
3101
  this.listenCamera();
3102
+ if (settings) {
3103
+ if (!isNaN(+settings.minDistance)) {
3104
+ this.minDistance = +settings.minDistance;
3105
+ }
3106
+ if (!isNaN(+settings.minTotalCount)) {
3107
+ this.minTotalCount = +settings.minTotalCount;
3108
+ }
3109
+ }
3100
3110
  }
3101
3111
  PointClustering.prototype.queueForceUpdate = function (entityIds) {
3102
3112
  for (var i = 0; i < entityIds.length; i++) {
@@ -3378,51 +3388,55 @@
3378
3388
  var clusters = [];
3379
3389
  var processedPoints = new Set();
3380
3390
  var cameraPosition = this.viewer.camera.position;
3381
- var MIN_CAMERA_DISTANCE = 5000;
3382
- var processQuad = function (quad) {
3383
- // Distance to quad.
3384
- // TODO: Needs improvement.
3385
- var distanceToQuad = quad.GetDistanceToQuad(cameraPosition);
3386
- // Skip quads that are too close.
3387
- if (distanceToQuad >= MIN_CAMERA_DISTANCE) {
3388
- for (var _i = 0, _a = quad.points; _i < _a.length; _i++) {
3389
- var point = _a[_i];
3390
- // Skip points already processed in previous clusters.
3391
- if (processedPoints.has(point.id)) {
3392
- continue;
3393
- }
3394
- // Skip points closer than MIN_CAMERA_DISTANCE meters to the camera.
3395
- var cartesian3 = Cesium.Cartesian3.fromDegrees(point.lon, point.lat);
3396
- var distanceFromCluster = Cesium.Cartesian3.distance(cartesian3, cameraPosition);
3397
- if (distanceFromCluster <= MIN_CAMERA_DISTANCE) {
3398
- continue;
3399
- }
3400
- var found = [];
3401
- var nearbyPoints = quad.Query(new Circle(point.lon, point.lat, _this.getClusterSpacing(distanceFromCluster)), found);
3402
- if (nearbyPoints.length > 1) {
3403
- var cluster = { center: point, points: [] };
3404
- for (var _b = 0, nearbyPoints_1 = nearbyPoints; _b < nearbyPoints_1.length; _b++) {
3405
- var nearby = nearbyPoints_1[_b];
3406
- if (!processedPoints.has(nearby.id) && !cluster.points.includes(nearby)) {
3407
- cluster.points.push(nearby);
3408
- processedPoints.add(nearby.id);
3409
- _this.currClusteredEntities.add(nearby.id);
3391
+ // Only cluster if total registered points exceeds minTotalCount.
3392
+ var validClusters = [];
3393
+ if (this.registeredEntityIds.size < this.minTotalCount) {
3394
+ var MIN_CAMERA_DISTANCE_1 = this.minDistance;
3395
+ var processQuad_1 = function (quad) {
3396
+ // Distance to quad.
3397
+ // TODO: Needs improvement.
3398
+ var distanceToQuad = quad.GetDistanceToQuad(cameraPosition);
3399
+ // Skip quads that are too close.
3400
+ if (distanceToQuad >= MIN_CAMERA_DISTANCE_1) {
3401
+ for (var _i = 0, _a = quad.points; _i < _a.length; _i++) {
3402
+ var point = _a[_i];
3403
+ // Skip points already processed in previous clusters.
3404
+ if (processedPoints.has(point.id)) {
3405
+ continue;
3406
+ }
3407
+ // Skip points closer than MIN_CAMERA_DISTANCE meters to the camera.
3408
+ var cartesian3 = Cesium.Cartesian3.fromDegrees(point.lon, point.lat);
3409
+ var distanceFromCluster = Cesium.Cartesian3.distance(cartesian3, cameraPosition);
3410
+ if (distanceFromCluster <= MIN_CAMERA_DISTANCE_1) {
3411
+ continue;
3412
+ }
3413
+ var found = [];
3414
+ var nearbyPoints = quad.Query(new Circle(point.lon, point.lat, _this.getClusterSpacing(distanceFromCluster)), found);
3415
+ if (nearbyPoints.length > 1) {
3416
+ var cluster = { center: point, points: [] };
3417
+ for (var _b = 0, nearbyPoints_1 = nearbyPoints; _b < nearbyPoints_1.length; _b++) {
3418
+ var nearby = nearbyPoints_1[_b];
3419
+ if (!processedPoints.has(nearby.id) && !cluster.points.includes(nearby)) {
3420
+ cluster.points.push(nearby);
3421
+ processedPoints.add(nearby.id);
3422
+ _this.currClusteredEntities.add(nearby.id);
3423
+ }
3410
3424
  }
3425
+ clusters.push(cluster);
3411
3426
  }
3412
- clusters.push(cluster);
3413
3427
  }
3414
3428
  }
3415
- }
3416
- if (quad.divided) {
3417
- processQuad(quad.northwest);
3418
- processQuad(quad.northeast);
3419
- processQuad(quad.southwest);
3420
- processQuad(quad.southeast);
3421
- }
3422
- };
3423
- processQuad(this.quadTree);
3424
- // Filter out clusters with only one point.
3425
- var validClusters = clusters.filter(function (cluster) { return cluster.points.length > 1; });
3429
+ if (quad.divided) {
3430
+ processQuad_1(quad.northwest);
3431
+ processQuad_1(quad.northeast);
3432
+ processQuad_1(quad.southwest);
3433
+ processQuad_1(quad.southeast);
3434
+ }
3435
+ };
3436
+ processQuad_1(this.quadTree);
3437
+ // Filter out clusters with only one point.
3438
+ validClusters = clusters.filter(function (cluster) { return cluster.points.length > 1; });
3439
+ }
3426
3440
  // Get the entity IDs that are no longer clustered
3427
3441
  var noLongerClustered = new Set(Array.from(this.prevClusteredEntities).filter(function (id) { return !_this.currClusteredEntities.has(id); }));
3428
3442
  // Update the previous clustered entities ref.
@@ -3573,7 +3587,7 @@
3573
3587
  });
3574
3588
  Manager.prototype.Init = function (params) {
3575
3589
  var _this = this;
3576
- var _a, _b, _c, _d, _e, _f, _g, _h;
3590
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3577
3591
  if (this.disposed) {
3578
3592
  throw (new Error("This item is disposed."));
3579
3593
  }
@@ -3627,12 +3641,12 @@
3627
3641
  return;
3628
3642
  }
3629
3643
  if (this.item.enableClustering) {
3630
- this.clustering = new PointClustering(this.visualsManager, this.item.id);
3644
+ this.clustering = new PointClustering(this.visualsManager, this.item.id, (_h = this.item) === null || _h === void 0 ? void 0 : _h.clustering);
3631
3645
  }
3632
3646
  var api = this.apiGetter.getApi();
3633
3647
  this.getter = this.sharedGetters.GetOrCreateFilterGetter({
3634
3648
  api: api,
3635
- attrFilter: (_h = this.item.BruceEntity.Filter) !== null && _h !== void 0 ? _h : {},
3649
+ attrFilter: (_j = this.item.BruceEntity.Filter) !== null && _j !== void 0 ? _j : {},
3636
3650
  batchSize: BATCH_SIZE,
3637
3651
  typeId: this.item.BruceEntity["EntityType.ID"],
3638
3652
  monitor: this.monitor,
@@ -5511,6 +5525,7 @@
5511
5525
  (function (EntitiesIdsRenderManager) {
5512
5526
  var Manager = /** @class */ (function () {
5513
5527
  function Manager(params) {
5528
+ var _a;
5514
5529
  this.getter = null;
5515
5530
  this.getterSub = null;
5516
5531
  this.disposed = false;
@@ -5522,7 +5537,7 @@
5522
5537
  this.item = item;
5523
5538
  this.visualsManager = visualsManager;
5524
5539
  if (this.item.enableClustering) {
5525
- this.clustering = new PointClustering(visualsManager, this.item.id);
5540
+ this.clustering = new PointClustering(visualsManager, this.item.id, (_a = this.item) === null || _a === void 0 ? void 0 : _a.clustering);
5526
5541
  }
5527
5542
  }
5528
5543
  Object.defineProperty(Manager.prototype, "Disposed", {
@@ -13311,7 +13326,7 @@
13311
13326
  }
13312
13327
  var style = document.createElement("style");
13313
13328
  style.id = this.STYLESHEET_ID;
13314
- style.innerHTML = "\n .NextspaceSearchBar {\n position: absolute;\n z-index: 1;\n top: 10px;\n right: 10px;\n display: flex;\n box-sizing: border-box;\n box-shadow: 0 0 1px rgba(18,22,25,.24),0 18px 36px -4px rgba(18,22,25,.6);\n background: #21272a;\n border-radius: 9px;\n height: 48px;\n padding-left: 2px;\n padding-right: 2px;\n font-family: sans-serif;\n }\n\n .NextspaceSearchBar * {\n box-sizing: border-box;\n }\n\n .NextspaceSearchBar[is-opened=\"true\"] .NextspaceSearchBarContent {\n display: flex;\n overflow: visible;\n width: 260px;\n }\n\n .NextspaceSearchBarToggle {\n align-items: center;\n border-radius: 0;\n border-radius: 9px 0 0 9px;\n color: #fff;\n cursor: pointer;\n display: flex;\n flex-shrink: 0;\n font-size: 18px;\n height: 100%;\n justify-content: center;\n transition: .3s ease;\n width: 46px;\n }\n\n .NextspaceSearchBarToggle >svg {\n transition: .3s ease;\n }\n\n .NextspaceSearchBarToggle >svg:hover {\n -webkit-transform: scale(1.2);\n transform: scale(1.2);\n }\n\n .NextspaceSearchBarContent {\n flex-grow: 0;\n flex-shrink: 0;\n overflow: hidden;\n transition: .3s ease;\n width: 0;\n }\n\n .NextspaceSearchBarContent >input {\n background: transparent;\n border: none;\n color: #fff;\n font-size: 15px;\n height: 100%;\n outline: none;\n padding: 0 8px;\n width: 100%;\n }\n\n .NextspaceSearchBarResults {\n background-color: #21272a;\n border-radius: 0 0 6px 6px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n padding: 12px 8px 8px;\n position: absolute;\n top: calc(100% - 4px);\n width: 100%;\n left: 0;\n z-index: 1;\n }\n\n .NextspaceSearchBarResultsItem {\n align-items: center;\n color: #fff;\n cursor: pointer;\n display: flex;\n height: 30px;\n transition: .3s ease;\n font-size: 13px;\n }\n\n .NextspaceSearchBarResultsItem:hover .NextspaceSearchBarResultsItemIcon {\n -webkit-transform: scale(1.05);\n transform: scale(1.05);\n }\n\n .NextspaceSearchBarResultsItemIcon {\n align-items: center;\n display: flex;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n margin-right: 5px;\n width: 25px;\n }\n\n .NextspaceSearchBarResultsItemTip {\n flex-grow: 1;\n flex-shrink: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 50px;\n font-size: 15px;\n }\n\n .NextspaceSearchBarResultsWarning {\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n font-size: 15px;\n }\n ";
13329
+ style.innerHTML = "\n .NextspaceSearchBar {\n position: absolute;\n z-index: 1;\n top: 10px;\n right: 10px;\n display: flex;\n box-sizing: border-box;\n box-shadow: 0 0 1px rgba(18,22,25,.24),0 18px 36px -4px rgba(18,22,25,.6);\n background: #21272a;\n border-radius: 9px;\n height: 48px;\n padding-left: 2px;\n padding-right: 2px;\n font-family: sans-serif;\n }\n\n .NextspaceSearchBar * {\n box-sizing: border-box;\n }\n\n .NextspaceSearchBar[is-opened=\"true\"] .NextspaceSearchBarContent {\n display: flex;\n width: 260px;\n }\n\n .NextspaceSearchBarToggle {\n align-items: center;\n border-radius: 0;\n border-radius: 9px 0 0 9px;\n color: #fff;\n cursor: pointer;\n display: flex;\n flex-shrink: 0;\n font-size: 18px;\n height: 100%;\n justify-content: center;\n transition: .3s ease;\n width: 46px;\n }\n\n .NextspaceSearchBarToggle >svg {\n transition: .3s ease;\n }\n\n .NextspaceSearchBarToggle >svg:hover {\n -webkit-transform: scale(1.2);\n transform: scale(1.2);\n }\n\n .NextspaceSearchBarContent {\n flex-grow: 0;\n flex-shrink: 0;\n overflow: hidden;\n transition: .3s ease;\n width: 0;\n }\n\n .NextspaceSearchBarContent >input {\n background: transparent;\n border: none;\n color: #fff;\n font-size: 15px;\n height: 100%;\n outline: none;\n padding: 0 8px;\n width: 100%;\n }\n\n .NextspaceSearchBarResults {\n background-color: #21272a;\n border-radius: 0 0 6px 6px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n padding: 12px 8px 8px;\n position: absolute;\n top: calc(100% - 4px);\n width: 100%;\n left: 0;\n z-index: 1;\n }\n\n .NextspaceSearchBarResultsItem {\n align-items: center;\n color: #fff;\n cursor: pointer;\n display: flex;\n height: 30px;\n transition: .3s ease;\n font-size: 13px;\n }\n\n .NextspaceSearchBarResultsItem:hover .NextspaceSearchBarResultsItemIcon {\n -webkit-transform: scale(1.05);\n transform: scale(1.05);\n }\n\n .NextspaceSearchBarResultsItemIcon {\n align-items: center;\n display: flex;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n margin-right: 5px;\n width: 25px;\n }\n\n .NextspaceSearchBarResultsItemTip {\n flex-grow: 1;\n flex-shrink: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 50px;\n font-size: 15px;\n }\n\n .NextspaceSearchBarResultsWarning {\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n font-size: 15px;\n }\n ";
13315
13330
  document.head.appendChild(style);
13316
13331
  };
13317
13332
  WidgetSearchBar.prototype._generateElement = function () {
@@ -14187,7 +14202,7 @@
14187
14202
  ViewerUtils.CreateWidgets = CreateWidgets;
14188
14203
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
14189
14204
 
14190
- var VERSION$1 = "2.2.9";
14205
+ var VERSION$1 = "2.3.1";
14191
14206
 
14192
14207
  exports.VERSION = VERSION$1;
14193
14208
  exports.CesiumViewMonitor = CesiumViewMonitor;