bruce-cesium 2.7.4 → 2.7.5

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.
@@ -1764,7 +1764,7 @@
1764
1764
  }
1765
1765
  function getStyle(api, entity, styleId) {
1766
1766
  return __awaiter(this, void 0, void 0, function () {
1767
- var style, e_2, typeId, type, e_3;
1767
+ var style, e_2, typeId, type, e_3, hideError, error, code;
1768
1768
  return __generator(this, function (_a) {
1769
1769
  switch (_a.label) {
1770
1770
  case 0:
@@ -1807,7 +1807,18 @@
1807
1807
  return [3 /*break*/, 9];
1808
1808
  case 8:
1809
1809
  e_3 = _a.sent();
1810
- console.error(e_3);
1810
+ hideError = false;
1811
+ // TODO: we need a util for extracting code + message rather than writing all this every time.
1812
+ if (e_3 && typeof e_3 == "object" && e_3.ERROR) {
1813
+ error = e_3.ERROR;
1814
+ code = error && typeof error == "object" ? error.Code : "";
1815
+ // Avoiding logging a common error.
1816
+ // This happens when rendering entities that don't have records.
1817
+ hideError = String(code).toLowerCase() == "notfound";
1818
+ }
1819
+ if (!hideError) {
1820
+ console.error(e_3);
1821
+ }
1811
1822
  return [3 /*break*/, 9];
1812
1823
  case 9: return [2 /*return*/, style];
1813
1824
  }
@@ -5506,16 +5517,14 @@
5506
5517
  viewer: this.viewer,
5507
5518
  // Unfortunately this searches as an "AND" rather than "OR" which does not meet our needs here.
5508
5519
  // So for multiple tags we'll manually sort on UI end...
5509
- tagIds: tagsToRender.length == 1 ? tagsToRender : [],
5520
+ tagIds: (tagsToRender === null || tagsToRender === void 0 ? void 0 : tagsToRender.length) ? tagsToRender : [],
5510
5521
  debugShowBounds: Boolean(window === null || window === void 0 ? void 0 : window.ENTITIES_RENDER_MANAGER_SHOW_BOUNDS),
5511
5522
  cdn: this.item.cdnEnabled
5512
5523
  });
5513
5524
  var minMax = exports.RenderManager.GetZoomMinMax({
5514
5525
  zoomControl: this.item.CameraZoomSettings
5515
5526
  });
5516
- // Unfortunately this searches as an "AND" rather than "OR" which does not meet our needs here.
5517
- // So for multiple tags we'll manually sort on UI end...
5518
- this.getter.IncludeMenuItem(this.item.id, tagsToRender.length == 1 ? tagsToRender : [], minMax[0], minMax[1]);
5527
+ this.getter.IncludeMenuItem(this.item.id, (tagsToRender === null || tagsToRender === void 0 ? void 0 : tagsToRender.length) ? tagsToRender : [], minMax[0], minMax[1]);
5519
5528
  this.getterSub = this.getter.OnUpdate.Subscribe(function (entities) {
5520
5529
  if (isTagItem) {
5521
5530
  _this.distributeForRender(entities.filter(function (entity) {
@@ -12383,71 +12392,43 @@
12383
12392
  })(exports.ViewRenderEngine || (exports.ViewRenderEngine = {}));
12384
12393
 
12385
12394
  var DEFAULT_SMOOTH_MULTIPLIER = 0;
12386
- function avgDistanceFromPointPair(refPoint, pos1, pos2) {
12387
- var carto1 = Cesium.Cartographic.fromCartesian(refPoint);
12388
- var carto2 = Cesium.Cartographic.fromCartesian(pos1);
12389
- var carto3 = Cesium.Cartographic.fromCartesian(pos2);
12390
- var x1 = carto1.longitude;
12391
- var y1 = carto1.latitude;
12392
- var x2 = carto2.longitude;
12393
- var y2 = carto2.latitude;
12394
- var x3 = carto3.longitude;
12395
- var y3 = carto3.latitude;
12396
- var A = x1 - x2;
12397
- var B = y1 - y2;
12398
- var C = x3 - x2;
12399
- var D = y3 - y2;
12400
- var dot = A * C + B * D;
12401
- var lenSq = C * C + D * D;
12402
- var param = dot / lenSq;
12403
- var xx;
12404
- var yy;
12405
- if (param < 0 || x2 == x3 && y2 == y3) {
12406
- xx = x2;
12407
- yy = y2;
12408
- }
12409
- else if (param > 1) {
12410
- xx = x3;
12411
- yy = y3;
12395
+ function distanceToSegment$1(p, v, w) {
12396
+ var l2 = Cesium.Cartesian3.distanceSquared(v, w);
12397
+ if (l2 === 0) {
12398
+ return Cesium.Cartesian3.distance(p, v);
12412
12399
  }
12413
- else {
12414
- xx = x2 + param * C;
12415
- yy = y2 + param * D;
12400
+ var t = Cesium.Cartesian3.dot(Cesium.Cartesian3.subtract(p, v, new Cesium.Cartesian3()), Cesium.Cartesian3.subtract(w, v, new Cesium.Cartesian3())) / l2;
12401
+ if (t < 0) {
12402
+ return Cesium.Cartesian3.distance(p, v);
12403
+ }
12404
+ if (t > 1) {
12405
+ return Cesium.Cartesian3.distance(p, w);
12416
12406
  }
12417
- var dx = x1 - xx;
12418
- var dy = y1 - yy;
12419
- return Math.sqrt(dx * dx + dy * dy);
12407
+ var projection = Cesium.Cartesian3.add(v, Cesium.Cartesian3.multiplyByScalar(Cesium.Cartesian3.subtract(w, v, new Cesium.Cartesian3()), t, new Cesium.Cartesian3()), new Cesium.Cartesian3());
12408
+ return Cesium.Cartesian3.distance(p, projection);
12420
12409
  }
12410
+ /**
12411
+ * Returns splice index into a list of positions to insert a new position.
12412
+ * @param positions List of positions to insert into.
12413
+ * @param pos3d New position to insert.
12414
+ * @returns Index to insert at.
12415
+ */
12421
12416
  function getInsertIndex(positions, pos3d) {
12422
12417
  if (positions.length < 2) {
12423
12418
  return 0;
12424
12419
  }
12420
+ var minDistance = Infinity;
12425
12421
  var index = -1;
12426
- if (positions) {
12427
- var distance = void 0;
12428
- for (var j = 0; j < positions.length; j++) {
12429
- var pos1 = positions[j];
12430
- var pos2 = void 0;
12431
- var pos2Index = -1;
12432
- if (j >= positions.length - 1) {
12433
- pos2 = positions[0];
12434
- pos2Index = 0;
12435
- }
12436
- else {
12437
- pos2 = positions[j + 1];
12438
- pos2Index = j + 1;
12439
- }
12440
- if (bruceModels.Cartes.ValidateCartes3(pos1), bruceModels.Cartes.ValidateCartes3(pos2)) {
12441
- var length_1 = avgDistanceFromPointPair(pos3d, pos1, pos2);
12442
- if (index == -1 || length_1 < distance) {
12443
- var insertIndex = pos2Index == 0 ? 0 : j > pos2Index ? j : pos2Index;
12444
- index = insertIndex;
12445
- distance = length_1;
12446
- }
12447
- }
12422
+ for (var i = 0; i < positions.length; i++) {
12423
+ var pos1 = positions[i];
12424
+ var pos2 = i < positions.length - 1 ? positions[i + 1] : positions[0];
12425
+ var dist = distanceToSegment$1(pos3d, pos1, pos2);
12426
+ if (dist < minDistance) {
12427
+ minDistance = dist;
12428
+ index = i + 1;
12448
12429
  }
12449
12430
  }
12450
- return index == -1 ? 0 : index;
12431
+ return index;
12451
12432
  }
12452
12433
  var OUTLINE_COLOR = "rgba(51, 177, 255, 0.2)";
12453
12434
  var FILL_COLOR = "#33B1FF";
@@ -12850,71 +12831,61 @@
12850
12831
  }());
12851
12832
 
12852
12833
  var DEFAULT_SMOOTH_MULTIPLIER$1 = 0;
12853
- function avgDistanceFromPointPair$1(refPoint, pos1, pos2) {
12854
- var carto1 = Cesium.Cartographic.fromCartesian(refPoint);
12855
- var carto2 = Cesium.Cartographic.fromCartesian(pos1);
12856
- var carto3 = Cesium.Cartographic.fromCartesian(pos2);
12857
- var x1 = carto1.longitude;
12858
- var y1 = carto1.latitude;
12859
- var x2 = carto2.longitude;
12860
- var y2 = carto2.latitude;
12861
- var x3 = carto3.longitude;
12862
- var y3 = carto3.latitude;
12863
- var A = x1 - x2;
12864
- var B = y1 - y2;
12865
- var C = x3 - x2;
12866
- var D = y3 - y2;
12867
- var dot = A * C + B * D;
12868
- var lenSq = C * C + D * D;
12869
- var param = dot / lenSq;
12870
- var xx;
12871
- var yy;
12872
- if (param < 0 || x2 == x3 && y2 == y3) {
12873
- xx = x2;
12874
- yy = y2;
12875
- }
12876
- else if (param > 1) {
12877
- xx = x3;
12878
- yy = y3;
12834
+ function distanceToSegment$2(p, v, w) {
12835
+ var l2 = Cesium.Cartesian3.distanceSquared(v, w);
12836
+ if (l2 === 0) {
12837
+ return Cesium.Cartesian3.distance(p, v);
12879
12838
  }
12880
- else {
12881
- xx = x2 + param * C;
12882
- yy = y2 + param * D;
12839
+ var t = Cesium.Cartesian3.dot(Cesium.Cartesian3.subtract(p, v, new Cesium.Cartesian3()), Cesium.Cartesian3.subtract(w, v, new Cesium.Cartesian3())) / l2;
12840
+ if (t < 0) {
12841
+ return Cesium.Cartesian3.distance(p, v);
12883
12842
  }
12884
- var dx = x1 - xx;
12885
- var dy = y1 - yy;
12886
- return Math.sqrt(dx * dx + dy * dy);
12843
+ if (t > 1) {
12844
+ return Cesium.Cartesian3.distance(p, w);
12845
+ }
12846
+ var projection = Cesium.Cartesian3.add(v, Cesium.Cartesian3.multiplyByScalar(Cesium.Cartesian3.subtract(w, v, new Cesium.Cartesian3()), t, new Cesium.Cartesian3()), new Cesium.Cartesian3());
12847
+ return Cesium.Cartesian3.distance(p, projection);
12887
12848
  }
12849
+ /**
12850
+ * Returns splice index into a list of positions to insert a new position.
12851
+ * @param positions List of positions to insert into.
12852
+ * @param pos3d New position to insert.
12853
+ * @returns Index to insert at.
12854
+ */
12888
12855
  function getInsertIndex$1(positions, pos3d) {
12889
12856
  if (positions.length < 2) {
12890
12857
  return 0;
12891
12858
  }
12892
- var index = 0;
12893
- if (positions) {
12894
- var marginalShift = function (pos) {
12895
- var SHIFT = 0.001;
12896
- pos = pos.clone();
12897
- return new Cesium.Cartesian3(pos.x + SHIFT, pos.y + SHIFT, pos.z + SHIFT);
12898
- };
12899
- var distance = avgDistanceFromPointPair$1(pos3d, positions[0], marginalShift(positions[0]));
12900
- var endDistance = avgDistanceFromPointPair$1(pos3d, positions[positions.length - 1], marginalShift(positions[positions.length - 1]));
12901
- if (endDistance < distance) {
12902
- index = positions.length;
12903
- distance = endDistance;
12904
- }
12905
- for (var j = 0; j < positions.length; j++) {
12906
- var pos1 = positions[j];
12907
- var pos2 = positions[j + 1];
12908
- var pos2Index = j + 1;
12909
- if (bruceModels.Cartes.ValidateCartes3(pos1), bruceModels.Cartes.ValidateCartes3(pos2)) {
12910
- var length_1 = avgDistanceFromPointPair$1(pos3d, pos1, pos2);
12911
- if (length_1 < distance) {
12912
- var insertIndex = pos2Index == 0 ? 0 : j > pos2Index ? j : pos2Index;
12913
- index = insertIndex;
12914
- distance = length_1;
12915
- }
12916
- }
12917
- }
12859
+ var minDistance = Infinity;
12860
+ var index = -1;
12861
+ // Check against segments
12862
+ for (var i = 0; i < positions.length - 1; i++) {
12863
+ var pos1 = positions[i];
12864
+ var pos2 = positions[i + 1];
12865
+ var dist = distanceToSegment$2(pos3d, pos1, pos2);
12866
+ if (dist < minDistance) {
12867
+ minDistance = dist;
12868
+ index = i + 1;
12869
+ }
12870
+ }
12871
+ // Check against start point
12872
+ var startDist = Cesium.Cartesian3.distance(pos3d, positions[0]);
12873
+ if (startDist <= minDistance) {
12874
+ index = 0;
12875
+ minDistance = startDist;
12876
+ console.log("Insert at start");
12877
+ }
12878
+ else {
12879
+ console.log("Start distance was longer than cur distance. ".concat(startDist, " > ").concat(minDistance));
12880
+ }
12881
+ // Check against end point
12882
+ var endDist = Cesium.Cartesian3.distance(pos3d, positions[positions.length - 1]);
12883
+ if (endDist <= minDistance) {
12884
+ index = positions.length;
12885
+ console.log("Insert at end");
12886
+ }
12887
+ else {
12888
+ console.log("End distance was longer than cur distance. ".concat(endDist, " > ").concat(minDistance));
12918
12889
  }
12919
12890
  return index;
12920
12891
  }
@@ -15218,7 +15189,7 @@
15218
15189
  ViewerUtils.CreateWidgets = CreateWidgets;
15219
15190
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
15220
15191
 
15221
- var VERSION$1 = "2.7.4";
15192
+ var VERSION$1 = "2.7.5";
15222
15193
 
15223
15194
  exports.VERSION = VERSION$1;
15224
15195
  exports.CesiumViewMonitor = CesiumViewMonitor;