bruce-cesium 2.9.4 → 2.9.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.
@@ -1965,6 +1965,24 @@
1965
1965
  _billboardCache.Set(key, data);
1966
1966
  return data;
1967
1967
  };
1968
+ /**
1969
+ * Removes duplicate points in a row and returns a new array.
1970
+ * Passed array is not mutated.
1971
+ * @param posses
1972
+ */
1973
+ function cullDuplicatePoints(posses) {
1974
+ var newPosses = [];
1975
+ var lastPos = null;
1976
+ for (var i = 0; i < posses.length; i++) {
1977
+ var pos = posses[i];
1978
+ // Avoiding 'Cesium.Cartesian3.equals' because passed data might be just a json blob in certain cases.
1979
+ if (pos && (!lastPos || (pos.x != lastPos.x || pos.y != lastPos.y || pos.z != lastPos.z))) {
1980
+ newPosses.push(pos);
1981
+ lastPos = pos;
1982
+ }
1983
+ }
1984
+ return newPosses;
1985
+ }
1968
1986
  (function (EntityRenderEngine) {
1969
1987
  function Render(params) {
1970
1988
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -2095,10 +2113,13 @@
2095
2113
  }
2096
2114
  });
2097
2115
  rendered = rendered.concat(Object.values(cLines));
2116
+ if (!!rendered.length) return [3 /*break*/, 4];
2098
2117
  return [4 /*yield*/, Point.RenderGroup(pParams)];
2099
2118
  case 3:
2100
2119
  cPoints = _k.sent();
2101
2120
  rendered = rendered.concat(Object.values(cPoints));
2121
+ _k.label = 4;
2122
+ case 4:
2102
2123
  rendered = rendered.filter(function (x) { return x != null; });
2103
2124
  if (rendered.length) {
2104
2125
  rootEntity_1 = new Cesium.Entity({});
@@ -2549,6 +2570,7 @@
2549
2570
  flattenPoints = true;
2550
2571
  }
2551
2572
  var posses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees(EnsureNumber(x.longitude), EnsureNumber(x.latitude), EnsureNumber(flattenPoints ? 0 : x.altitude)); });
2573
+ posses = cullDuplicatePoints(posses);
2552
2574
  // 5 points should be enough to tell most bad data.
2553
2575
  var CHECK_POINTS = 5;
2554
2576
  var MIN_LEN = 0.001;
@@ -2727,6 +2749,10 @@
2727
2749
  bruceModels.Cartes.CloseRing3(posses);
2728
2750
  var extrusion = getPolygonExtrusion(entity, params.tags, outerRing, posses, heightRef, style);
2729
2751
  posses = extrusion.posses;
2752
+ posses = cullDuplicatePoints(posses);
2753
+ if (posses.length < 4) {
2754
+ return null;
2755
+ }
2730
2756
  var flattenPoints = false;
2731
2757
  if (heightRef == Cesium.HeightReference.CLAMP_TO_GROUND && shouldApplyFlatFix((_b = params.viewer) === null || _b === void 0 ? void 0 : _b.terrainProvider)) {
2732
2758
  heightRef = Cesium.HeightReference.NONE;
@@ -2735,8 +2761,10 @@
2735
2761
  var holeRings = pRings.filter(function (x) { return x.Facing == bruceModels.Geometry.EPolygonRingType.Hole; });
2736
2762
  var holePosses = holeRings.map(function (x) {
2737
2763
  var points = bruceModels.Geometry.ParsePoints(x.LinearRing);
2738
- return points.map(function (x) { return Cesium.Cartesian3.fromDegrees(EnsureNumber(x.longitude), EnsureNumber(x.latitude), EnsureNumber(flattenPoints ? 0 : x.altitude)); });
2739
- });
2764
+ var holePosses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees(EnsureNumber(x.longitude), EnsureNumber(x.latitude), EnsureNumber(flattenPoints ? 0 : x.altitude)); });
2765
+ holePosses = cullDuplicatePoints(holePosses);
2766
+ return holePosses;
2767
+ }).filter(function (x) { return x.length >= 4; });
2740
2768
  var zIndex = getZIndex(style, entity, params.tags);
2741
2769
  var size = getSizeOfPolygonEntity(entity);
2742
2770
  var classification = Cesium.ClassificationType.TERRAIN;
@@ -16653,7 +16681,7 @@
16653
16681
  ViewerUtils.CreateWidgets = CreateWidgets;
16654
16682
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
16655
16683
 
16656
- var VERSION$1 = "2.9.4";
16684
+ var VERSION$1 = "2.9.5";
16657
16685
 
16658
16686
  exports.VERSION = VERSION$1;
16659
16687
  exports.CesiumViewMonitor = CesiumViewMonitor;