bruce-cesium 4.1.8 → 4.2.0
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 +381 -279
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +379 -277
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/entity-render-engine.js +4 -4
- package/dist/lib/rendering/entity-render-engine.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js +64 -36
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js +53 -36
- package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +68 -40
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
- package/dist/lib/utils/simplify-geometry.js +211 -160
- package/dist/lib/utils/simplify-geometry.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/utils/simplify-geometry.d.ts +3 -2
- package/package.json +2 -2
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
1
|
+
import { BruceEvent, Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ProjectViewTile, DelayQueue, EncryptUtils, 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, JulianDate,
|
|
3
|
+
import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, ColorMaterialProperty, Entity, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorBlendMode, HeadingPitchRoll, Transforms, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, OrthographicFrustum, EasingFunction, SceneTransforms, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Quaternion, Intersect } from 'cesium';
|
|
4
4
|
|
|
5
5
|
/*! *****************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4646,6 +4646,11 @@ function OneTimeError(key, message) {
|
|
|
4646
4646
|
}
|
|
4647
4647
|
}
|
|
4648
4648
|
|
|
4649
|
+
// Hash of input geometry to the simplified geometry.
|
|
4650
|
+
var _cache = new LRUCache(1000);
|
|
4651
|
+
function getHash(entityId, geometry) {
|
|
4652
|
+
return EncryptUtils.Cyrb53Hash(entityId + JSON.stringify(geometry));
|
|
4653
|
+
}
|
|
4649
4654
|
/**
|
|
4650
4655
|
* Util for simplifying geometry on the fly.
|
|
4651
4656
|
*/
|
|
@@ -4654,14 +4659,19 @@ var SimplifyGeometry;
|
|
|
4654
4659
|
/**
|
|
4655
4660
|
* Returns the total number of points in the geometry.
|
|
4656
4661
|
* @param geometry
|
|
4662
|
+
* @param limit number to count up to before returning.
|
|
4657
4663
|
* @returns
|
|
4658
4664
|
*/
|
|
4659
|
-
function CountPoints(geometry) {
|
|
4665
|
+
function CountPoints(geometry, limit) {
|
|
4660
4666
|
var count = 0;
|
|
4661
4667
|
var traverse = function (geometry) {
|
|
4662
4668
|
if (geometry.MultiGeometry) {
|
|
4663
4669
|
for (var i = 0; i < geometry.MultiGeometry.length; i++) {
|
|
4664
4670
|
traverse(geometry.MultiGeometry[i]);
|
|
4671
|
+
// Reached the limit, return.
|
|
4672
|
+
if (limit && count >= limit) {
|
|
4673
|
+
return;
|
|
4674
|
+
}
|
|
4665
4675
|
}
|
|
4666
4676
|
}
|
|
4667
4677
|
else if (geometry.Polygon) {
|
|
@@ -4686,193 +4696,234 @@ var SimplifyGeometry;
|
|
|
4686
4696
|
* This will turn it into GeoJSON, run it through turf, then back to Bruce geometry.
|
|
4687
4697
|
* @param geometry
|
|
4688
4698
|
*/
|
|
4689
|
-
function Simplify(geometry, tolerance) {
|
|
4690
|
-
|
|
4699
|
+
function Simplify(entityId, geometry, tolerance) {
|
|
4700
|
+
var _a;
|
|
4701
|
+
if (!geometry || !turf || !turf.simplify) {
|
|
4691
4702
|
return geometry;
|
|
4692
4703
|
}
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
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
|
-
}
|
|
4704
|
+
// Generate unique hash for the geometry.
|
|
4705
|
+
var hash = getHash(entityId, geometry);
|
|
4706
|
+
if (_cache.Get(hash)) {
|
|
4707
|
+
return _cache.Get(hash);
|
|
4708
|
+
}
|
|
4709
|
+
// Convert to geojson so that we can interact with turf.
|
|
4710
|
+
var gFeature = Geometry.ToGeoJsonFeature({
|
|
4711
|
+
geometry: geometry
|
|
4714
4712
|
});
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
//
|
|
4720
|
-
|
|
4721
|
-
|
|
4713
|
+
// Unkink the geometry.
|
|
4714
|
+
// This removes overlapping polygons before we start merging and simplifying.
|
|
4715
|
+
// Commented out because it has crashes and doesn't handle holes.
|
|
4716
|
+
untangleFeature(gFeature);
|
|
4717
|
+
// Union the geometry.
|
|
4718
|
+
// This merges overlapping polygons.
|
|
4719
|
+
unionFeature(gFeature);
|
|
4720
|
+
// Simplify the geometry.
|
|
4721
|
+
if (tolerance > 0) {
|
|
4722
|
+
gFeature.geometry = turf.simplify(gFeature.geometry, {
|
|
4723
|
+
tolerance: tolerance,
|
|
4724
|
+
highQuality: true,
|
|
4725
|
+
mutate: true
|
|
4726
|
+
});
|
|
4727
|
+
}
|
|
4728
|
+
// Converting back to Bruce geometry.
|
|
4729
|
+
geometry = (_a = Geometry.FromGeoJson({
|
|
4730
|
+
geoJson: gFeature
|
|
4731
|
+
})) === null || _a === void 0 ? void 0 : _a.geometry;
|
|
4732
|
+
// Store cached result to avoid recalculating.
|
|
4733
|
+
// Hashing a large geometry string is slow, but all these operations are slower.
|
|
4734
|
+
_cache.Set(hash, geometry);
|
|
4735
|
+
return geometry;
|
|
4722
4736
|
}
|
|
4723
4737
|
SimplifyGeometry.Simplify = Simplify;
|
|
4724
4738
|
})(SimplifyGeometry || (SimplifyGeometry = {}));
|
|
4725
4739
|
/**
|
|
4726
|
-
*
|
|
4727
|
-
* @param
|
|
4728
|
-
* @returns
|
|
4740
|
+
* Runs through all found polygons and runs unkink through turf on them.
|
|
4741
|
+
* @param feature
|
|
4729
4742
|
*/
|
|
4730
|
-
function
|
|
4731
|
-
|
|
4732
|
-
var
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
};
|
|
4736
|
-
var removeConsecutiveDuplicates = function (coordinates) {
|
|
4737
|
-
return coordinates.filter(function (coord, index, array) {
|
|
4738
|
-
return index === 0 || !areCoordinatesEqual(coord, array[index - 1]);
|
|
4739
|
-
});
|
|
4743
|
+
function untangleFeature(feature) {
|
|
4744
|
+
// Collection to add to because the result might be multiple from an unkink.
|
|
4745
|
+
var collection = {
|
|
4746
|
+
geometries: [],
|
|
4747
|
+
type: "GeometryCollection"
|
|
4740
4748
|
};
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4749
|
+
// Runs a dedupe and unkink on the coordinates.
|
|
4750
|
+
// Returns if the coordinates were added to the collection.
|
|
4751
|
+
var processCoordinates = function (coords) {
|
|
4752
|
+
try {
|
|
4753
|
+
// Dedupe the coordinates to avoid issues with unkink.
|
|
4754
|
+
coords = dedupeCoordinates(coords);
|
|
4755
|
+
var tmpFeature = turf.polygon(coords);
|
|
4756
|
+
var untangled = turf.unkinkPolygon(tmpFeature);
|
|
4757
|
+
if (untangled.features.length) {
|
|
4758
|
+
if (untangled.type == "FeatureCollection") {
|
|
4759
|
+
for (var i = 0; i < untangled.features.length; i++) {
|
|
4760
|
+
collection.geometries.push(untangled.features[i].geometry);
|
|
4761
|
+
}
|
|
4762
|
+
return true;
|
|
4763
|
+
}
|
|
4764
|
+
else {
|
|
4765
|
+
console.error("Unexpected unkink result.", untangled);
|
|
4766
|
+
}
|
|
4767
|
+
}
|
|
4745
4768
|
}
|
|
4746
|
-
|
|
4769
|
+
catch (e) {
|
|
4770
|
+
console.error("Failed to unkink polygon.", e);
|
|
4771
|
+
}
|
|
4772
|
+
return false;
|
|
4747
4773
|
};
|
|
4748
4774
|
var processGeometry = function (geometry) {
|
|
4749
|
-
var
|
|
4750
|
-
|
|
4751
|
-
|
|
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
|
-
};
|
|
4775
|
+
var added = false;
|
|
4776
|
+
if (geometry.type == "Polygon") {
|
|
4777
|
+
added = processCoordinates(geometry.coordinates);
|
|
4779
4778
|
}
|
|
4780
|
-
else if (geometry.
|
|
4781
|
-
var
|
|
4782
|
-
|
|
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;
|
|
4779
|
+
else if (geometry.type == "MultiPolygon") {
|
|
4780
|
+
for (var i = 0; i < geometry.coordinates.length; i++) {
|
|
4781
|
+
added = processCoordinates(geometry.coordinates[i]) || added;
|
|
4789
4782
|
}
|
|
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
4783
|
}
|
|
4803
|
-
if (
|
|
4804
|
-
|
|
4784
|
+
if (!added) {
|
|
4785
|
+
// Adding original since we can't unkink it.
|
|
4786
|
+
collection.geometries.push(geometry);
|
|
4805
4787
|
}
|
|
4806
4788
|
};
|
|
4807
|
-
|
|
4808
|
-
|
|
4789
|
+
if (feature.geometry.type == "GeometryCollection") {
|
|
4790
|
+
feature.geometry.geometries.forEach(function (geometry) {
|
|
4791
|
+
processGeometry(geometry);
|
|
4792
|
+
});
|
|
4809
4793
|
}
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4794
|
+
else {
|
|
4795
|
+
processGeometry(feature.geometry);
|
|
4796
|
+
}
|
|
4797
|
+
// Re-assign the geometry.
|
|
4798
|
+
if (collection.geometries.length == 1) {
|
|
4799
|
+
feature.geometry = collection.geometries[0];
|
|
4800
|
+
}
|
|
4801
|
+
else {
|
|
4802
|
+
feature.geometry = collection;
|
|
4813
4803
|
}
|
|
4814
|
-
var geoJson = {
|
|
4815
|
-
type: "FeatureCollection",
|
|
4816
|
-
features: features,
|
|
4817
|
-
};
|
|
4818
|
-
return geoJson;
|
|
4819
4804
|
}
|
|
4820
4805
|
/**
|
|
4821
|
-
*
|
|
4822
|
-
*
|
|
4823
|
-
* @
|
|
4806
|
+
* Runs through all found polygons and unions them using turf.
|
|
4807
|
+
* Failed unions are ignored and the original is kept.
|
|
4808
|
+
* @param feature
|
|
4824
4809
|
*/
|
|
4825
|
-
function
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
Polygon: [],
|
|
4831
|
-
MultiGeometry: []
|
|
4810
|
+
function unionFeature(feature) {
|
|
4811
|
+
// Collection to add to because the result might be multiple from an unkink.
|
|
4812
|
+
var collection = {
|
|
4813
|
+
geometries: [],
|
|
4814
|
+
type: "GeometryCollection"
|
|
4832
4815
|
};
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4816
|
+
// We'll turn each geometry into a feature and union them.
|
|
4817
|
+
var tmpCollection = {
|
|
4818
|
+
features: [],
|
|
4819
|
+
type: "FeatureCollection"
|
|
4820
|
+
};
|
|
4821
|
+
if (feature.geometry.type == "GeometryCollection") {
|
|
4822
|
+
feature.geometry.geometries.forEach(function (geometry) {
|
|
4823
|
+
if (geometry.type == "Polygon") {
|
|
4824
|
+
tmpCollection.features.push({
|
|
4825
|
+
type: "Feature",
|
|
4826
|
+
geometry: geometry,
|
|
4827
|
+
properties: {}
|
|
4828
|
+
});
|
|
4829
|
+
}
|
|
4830
|
+
else if (geometry.type == "MultiPolygon") {
|
|
4831
|
+
for (var i = 0; i < geometry.coordinates.length; i++) {
|
|
4832
|
+
tmpCollection.features.push({
|
|
4833
|
+
type: "Feature",
|
|
4834
|
+
geometry: {
|
|
4835
|
+
type: "Polygon",
|
|
4836
|
+
coordinates: geometry.coordinates[i]
|
|
4837
|
+
},
|
|
4838
|
+
properties: {}
|
|
4839
|
+
});
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4842
|
+
// Only focusing on polygons.
|
|
4843
|
+
else {
|
|
4844
|
+
collection.geometries.push(geometry);
|
|
4845
|
+
}
|
|
4840
4846
|
});
|
|
4841
|
-
return geometry;
|
|
4842
4847
|
}
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4848
|
+
else if (feature.geometry.type == "Polygon") {
|
|
4849
|
+
tmpCollection.features.push({
|
|
4850
|
+
type: "Feature",
|
|
4851
|
+
geometry: feature.geometry,
|
|
4852
|
+
properties: {}
|
|
4853
|
+
});
|
|
4854
|
+
}
|
|
4855
|
+
else if (feature.geometry.type == "MultiPolygon") {
|
|
4856
|
+
for (var i = 0; i < feature.geometry.coordinates.length; i++) {
|
|
4857
|
+
tmpCollection.features.push({
|
|
4858
|
+
type: "Feature",
|
|
4859
|
+
geometry: {
|
|
4860
|
+
type: "Polygon",
|
|
4861
|
+
coordinates: feature.geometry.coordinates[i]
|
|
4862
|
+
},
|
|
4863
|
+
properties: {}
|
|
4853
4864
|
});
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
// No polygons to union.
|
|
4868
|
+
// Need at least 2 to union.
|
|
4869
|
+
if (tmpCollection.features.length < 2) {
|
|
4870
|
+
return;
|
|
4871
|
+
}
|
|
4872
|
+
// Now we'll union them.
|
|
4873
|
+
try {
|
|
4874
|
+
var union = turf.union(tmpCollection);
|
|
4875
|
+
if (union.geometry.type == "Polygon") {
|
|
4876
|
+
collection.geometries.push(union.geometry);
|
|
4877
|
+
}
|
|
4878
|
+
else if (union.geometry.type == "MultiPolygon") {
|
|
4879
|
+
for (var i = 0; i < union.geometry.coordinates.length; i++) {
|
|
4880
|
+
collection.geometries.push({
|
|
4881
|
+
type: "Polygon",
|
|
4882
|
+
coordinates: union.geometry.coordinates[i]
|
|
4870
4883
|
});
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4884
|
+
}
|
|
4885
|
+
}
|
|
4886
|
+
else {
|
|
4887
|
+
// Returning early because the result is unexpected.
|
|
4888
|
+
return;
|
|
4889
|
+
}
|
|
4890
|
+
}
|
|
4891
|
+
catch (e) {
|
|
4892
|
+
console.error("Failed to union polygons.", e);
|
|
4893
|
+
return;
|
|
4894
|
+
}
|
|
4895
|
+
// Re-assign the geometry.
|
|
4896
|
+
if (collection.geometries.length == 1) {
|
|
4897
|
+
feature.geometry = collection.geometries[0];
|
|
4874
4898
|
}
|
|
4875
|
-
|
|
4899
|
+
else {
|
|
4900
|
+
feature.geometry = collection;
|
|
4901
|
+
}
|
|
4902
|
+
}
|
|
4903
|
+
function dedupeCoordinates(inputCoords) {
|
|
4904
|
+
return inputCoords.map(function (ring) {
|
|
4905
|
+
if (ring.length < 2) {
|
|
4906
|
+
return ring;
|
|
4907
|
+
}
|
|
4908
|
+
var dedupeCoords = [];
|
|
4909
|
+
var uniqueCoords = new Set();
|
|
4910
|
+
// Dedupe the points.
|
|
4911
|
+
ring.forEach(function (coord) {
|
|
4912
|
+
var key = coord.join(',');
|
|
4913
|
+
if (!uniqueCoords.has(key)) {
|
|
4914
|
+
uniqueCoords.add(key);
|
|
4915
|
+
dedupeCoords.push(coord);
|
|
4916
|
+
}
|
|
4917
|
+
});
|
|
4918
|
+
// Make sure the last point matches the first.
|
|
4919
|
+
if (dedupeCoords.length > 1) {
|
|
4920
|
+
if (dedupeCoords[0][0] != dedupeCoords[dedupeCoords.length - 1][0] ||
|
|
4921
|
+
dedupeCoords[0][1] != dedupeCoords[dedupeCoords.length - 1][1]) {
|
|
4922
|
+
dedupeCoords.push(dedupeCoords[0]);
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
return dedupeCoords;
|
|
4926
|
+
});
|
|
4876
4927
|
}
|
|
4877
4928
|
|
|
4878
4929
|
function colorToCColor(color) {
|
|
@@ -5574,13 +5625,13 @@ var EntityRenderEngine;
|
|
|
5574
5625
|
// Note that this modifies the Entity object.
|
|
5575
5626
|
if (params.optimizeGeometry) {
|
|
5576
5627
|
if (params.optimizeMinPoints == null) {
|
|
5577
|
-
params.optimizeMinPoints =
|
|
5628
|
+
params.optimizeMinPoints = 500;
|
|
5578
5629
|
}
|
|
5579
|
-
if (geometry && SimplifyGeometry.CountPoints(geometry) >= params.optimizeMinPoints) {
|
|
5630
|
+
if (geometry && SimplifyGeometry.CountPoints(geometry, params.optimizeMinPoints) >= params.optimizeMinPoints) {
|
|
5580
5631
|
if (params.optimizeTolerance == null) {
|
|
5581
|
-
params.optimizeTolerance = 0.
|
|
5632
|
+
params.optimizeTolerance = 0.00001;
|
|
5582
5633
|
}
|
|
5583
|
-
optimized = SimplifyGeometry.Simplify(geometry, params.optimizeTolerance);
|
|
5634
|
+
optimized = SimplifyGeometry.Simplify(entity.Bruce.ID, geometry, params.optimizeTolerance);
|
|
5584
5635
|
if (optimized) {
|
|
5585
5636
|
// Continue on with the rendering using the optimized geometry.
|
|
5586
5637
|
geometry = optimized;
|
|
@@ -11249,12 +11300,12 @@ var EntitiesRenderManager;
|
|
|
11249
11300
|
* @param force TODO: This should re-render entities that are already rendered.
|
|
11250
11301
|
*/
|
|
11251
11302
|
Manager.prototype.renderAsGeojson = function (entities, force) {
|
|
11252
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
11303
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
11253
11304
|
return __awaiter(this, void 0, void 0, function () {
|
|
11254
|
-
var zoomItem, lods, withLods_1,
|
|
11305
|
+
var zoomItem, lods, withLods_1, individuals_1, style, e_4, entityTypeId, entityType, e_5, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, i, entity, geometry, optimized, collection, i, entity, feature, individuals, source, groups, applyStyle, toForceUpdate, register, sEntities, i, cEntity;
|
|
11255
11306
|
var _this = this;
|
|
11256
|
-
return __generator(this, function (
|
|
11257
|
-
switch (
|
|
11307
|
+
return __generator(this, function (_l) {
|
|
11308
|
+
switch (_l.label) {
|
|
11258
11309
|
case 0:
|
|
11259
11310
|
entities = entities.filter(function (entity) {
|
|
11260
11311
|
var _a;
|
|
@@ -11284,43 +11335,43 @@ var EntitiesRenderManager;
|
|
|
11284
11335
|
}
|
|
11285
11336
|
})];
|
|
11286
11337
|
case 1:
|
|
11287
|
-
lods = (
|
|
11338
|
+
lods = (_l.sent()).lods;
|
|
11288
11339
|
if (this.disposed) {
|
|
11289
11340
|
this.doDispose();
|
|
11290
11341
|
return [2 /*return*/];
|
|
11291
11342
|
}
|
|
11292
11343
|
withLods_1 = lods.filter(function (x) { return x.entityId && !!x.clientFileId; }).map(function (x) { return x.entityId; });
|
|
11293
|
-
|
|
11344
|
+
individuals_1 = entities.filter(function (entity) {
|
|
11294
11345
|
var _a;
|
|
11295
11346
|
return withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
|
|
11296
11347
|
});
|
|
11297
|
-
if (
|
|
11298
|
-
this.renderAsIndividuals(
|
|
11348
|
+
if (individuals_1.length) {
|
|
11349
|
+
this.renderAsIndividuals(individuals_1, force);
|
|
11299
11350
|
}
|
|
11300
11351
|
// Now we proceed with what is left.
|
|
11301
11352
|
entities = entities.filter(function (entity) {
|
|
11302
11353
|
var _a;
|
|
11303
11354
|
return !withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
|
|
11304
11355
|
});
|
|
11305
|
-
|
|
11356
|
+
_l.label = 2;
|
|
11306
11357
|
case 2:
|
|
11307
11358
|
if (!entities.length) {
|
|
11308
11359
|
return [2 /*return*/];
|
|
11309
11360
|
}
|
|
11310
11361
|
style = null;
|
|
11311
11362
|
if (!((zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) && (zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) > -1)) return [3 /*break*/, 6];
|
|
11312
|
-
|
|
11363
|
+
_l.label = 3;
|
|
11313
11364
|
case 3:
|
|
11314
|
-
|
|
11365
|
+
_l.trys.push([3, 5, , 6]);
|
|
11315
11366
|
return [4 /*yield*/, Style.Get({
|
|
11316
11367
|
api: this.apiGetter.getApi(),
|
|
11317
11368
|
styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
|
|
11318
11369
|
})];
|
|
11319
11370
|
case 4:
|
|
11320
|
-
style = (_a = (
|
|
11371
|
+
style = (_a = (_l.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
11321
11372
|
return [3 /*break*/, 6];
|
|
11322
11373
|
case 5:
|
|
11323
|
-
e_4 =
|
|
11374
|
+
e_4 = _l.sent();
|
|
11324
11375
|
console.error(e_4);
|
|
11325
11376
|
return [3 /*break*/, 6];
|
|
11326
11377
|
case 6:
|
|
@@ -11329,15 +11380,15 @@ var EntitiesRenderManager;
|
|
|
11329
11380
|
entityTypeId = (_d = (_c = entities.find(function (x) { var _a; return !!((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]); })) === null || _c === void 0 ? void 0 : _c.Bruce) === null || _d === void 0 ? void 0 : _d["EntityType.ID"];
|
|
11330
11381
|
}
|
|
11331
11382
|
if (!entityTypeId) return [3 /*break*/, 12];
|
|
11332
|
-
|
|
11383
|
+
_l.label = 7;
|
|
11333
11384
|
case 7:
|
|
11334
|
-
|
|
11385
|
+
_l.trys.push([7, 11, , 12]);
|
|
11335
11386
|
return [4 /*yield*/, EntityType.Get({
|
|
11336
11387
|
entityTypeId: entityTypeId,
|
|
11337
11388
|
api: this.apiGetter.getApi()
|
|
11338
11389
|
})];
|
|
11339
11390
|
case 8:
|
|
11340
|
-
entityType = (_e = (
|
|
11391
|
+
entityType = (_e = (_l.sent())) === null || _e === void 0 ? void 0 : _e.entityType;
|
|
11341
11392
|
if (!(!style && entityType)) return [3 /*break*/, 10];
|
|
11342
11393
|
if (!(entityType["DisplaySetting.ID"] && entityType["DisplaySetting.ID"] > 0)) return [3 /*break*/, 10];
|
|
11343
11394
|
return [4 /*yield*/, Style.Get({
|
|
@@ -11345,11 +11396,11 @@ var EntitiesRenderManager;
|
|
|
11345
11396
|
styleId: entityType["DisplaySetting.ID"]
|
|
11346
11397
|
})];
|
|
11347
11398
|
case 9:
|
|
11348
|
-
style = (_f = (
|
|
11349
|
-
|
|
11399
|
+
style = (_f = (_l.sent()).style) === null || _f === void 0 ? void 0 : _f.Settings;
|
|
11400
|
+
_l.label = 10;
|
|
11350
11401
|
case 10: return [3 /*break*/, 12];
|
|
11351
11402
|
case 11:
|
|
11352
|
-
e_5 =
|
|
11403
|
+
e_5 = _l.sent();
|
|
11353
11404
|
console.error(e_5);
|
|
11354
11405
|
return [3 /*break*/, 12];
|
|
11355
11406
|
case 12:
|
|
@@ -11379,13 +11430,13 @@ var EntitiesRenderManager;
|
|
|
11379
11430
|
});
|
|
11380
11431
|
if (geometry) {
|
|
11381
11432
|
if (this.item.optimizeMinPoints == null) {
|
|
11382
|
-
this.item.optimizeMinPoints =
|
|
11433
|
+
this.item.optimizeMinPoints = 500;
|
|
11383
11434
|
}
|
|
11384
|
-
if (SimplifyGeometry.CountPoints(geometry)
|
|
11435
|
+
if (SimplifyGeometry.CountPoints(geometry, this.item.optimizeMinPoints) >= this.item.optimizeMinPoints) {
|
|
11385
11436
|
if (this.item.optimizeTolerance == null) {
|
|
11386
|
-
this.item.optimizeTolerance = 0.
|
|
11437
|
+
this.item.optimizeTolerance = 0.00001;
|
|
11387
11438
|
}
|
|
11388
|
-
optimized = SimplifyGeometry.Simplify(geometry, this.item.optimizeTolerance);
|
|
11439
|
+
optimized = SimplifyGeometry.Simplify(entity.Bruce.ID, geometry, this.item.optimizeTolerance);
|
|
11389
11440
|
if (optimized) {
|
|
11390
11441
|
// Dereference the Entity object now that we have done a destructive operation.
|
|
11391
11442
|
entity = Object.assign({}, entity);
|
|
@@ -11402,34 +11453,51 @@ var EntitiesRenderManager;
|
|
|
11402
11453
|
entity.Bruce.VectorGeometry = geometry;
|
|
11403
11454
|
}
|
|
11404
11455
|
}
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11456
|
+
collection = {
|
|
11457
|
+
features: [],
|
|
11458
|
+
type: "FeatureCollection"
|
|
11459
|
+
};
|
|
11460
|
+
for (i = 0; i < entities.length; i++) {
|
|
11461
|
+
entity = entities[i];
|
|
11462
|
+
feature = Geometry.ToGeoJsonFeature({
|
|
11463
|
+
geometry: entity.Bruce.VectorGeometry,
|
|
11464
|
+
noAltitude: polygonsClamped && lineWidthPx <= 0,
|
|
11465
|
+
altitude: lineWidthPx > 0 && polygonsClamped ? 1 : null,
|
|
11466
|
+
properties: __assign(__assign({}, entity), { Bruce: __assign(__assign({}, entity.Bruce), {
|
|
11467
|
+
// Exclude as we just converted it to geojson.
|
|
11468
|
+
VectorGeometry: null }) })
|
|
11417
11469
|
});
|
|
11470
|
+
if (feature) {
|
|
11471
|
+
collection.features.push(feature);
|
|
11472
|
+
}
|
|
11473
|
+
}
|
|
11474
|
+
individuals = entities.filter(function (entity) {
|
|
11475
|
+
var feature = collection.features.find(function (x) { var _a, _b; return ((_b = (_a = x.properties) === null || _a === void 0 ? void 0 : _a.Bruce) === null || _b === void 0 ? void 0 : _b.ID) == entity.Bruce.ID; });
|
|
11476
|
+
if (!feature) {
|
|
11477
|
+
return true;
|
|
11478
|
+
}
|
|
11479
|
+
if (feature.geometry.type == "Point") {
|
|
11480
|
+
return true;
|
|
11481
|
+
}
|
|
11482
|
+
return false;
|
|
11418
11483
|
});
|
|
11419
|
-
if (
|
|
11420
|
-
this.renderAsIndividuals(
|
|
11484
|
+
if (individuals.length) {
|
|
11485
|
+
this.renderAsIndividuals(individuals, force);
|
|
11421
11486
|
}
|
|
11422
|
-
|
|
11487
|
+
// Filter out points (the ones we just rendered as individuals).
|
|
11488
|
+
collection.features = collection.features.filter(function (x) { return x.geometry.type != "Point"; });
|
|
11489
|
+
// If there is nothing to render now, return.
|
|
11490
|
+
if (!collection.features.length) {
|
|
11423
11491
|
return [2 /*return*/];
|
|
11424
11492
|
}
|
|
11425
|
-
return [4 /*yield*/, GeoJsonDataSource.load(
|
|
11493
|
+
return [4 /*yield*/, GeoJsonDataSource.load(collection, {
|
|
11426
11494
|
stroke: cLineColor,
|
|
11427
11495
|
fill: cFillColor,
|
|
11428
11496
|
strokeWidth: lineWidthPx,
|
|
11429
11497
|
clampToGround: lineWidthPx <= 0 && polygonsClamped
|
|
11430
11498
|
})];
|
|
11431
11499
|
case 13:
|
|
11432
|
-
source =
|
|
11500
|
+
source = _l.sent();
|
|
11433
11501
|
this.viewer.dataSources.add(source);
|
|
11434
11502
|
this.sources.push(source);
|
|
11435
11503
|
if (this.disposed) {
|
|
@@ -12161,12 +12229,12 @@ var EntitiesLoadedRenderManager;
|
|
|
12161
12229
|
* @param force TODO: This should re-render entities that are already rendered.
|
|
12162
12230
|
*/
|
|
12163
12231
|
Manager.prototype.renderAsGeojson = function (entities, force) {
|
|
12164
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
12232
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
12165
12233
|
return __awaiter(this, void 0, void 0, function () {
|
|
12166
|
-
var zoomItem, lods, withLods_1,
|
|
12234
|
+
var zoomItem, lods, withLods_1, individuals_1, style, e_3, entityTypeId, entityType, e_4, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, collection, i, entity, feature, individuals, source, groups, applyStyle, toForceUpdate, register, sEntities, i, cEntity;
|
|
12167
12235
|
var _this = this;
|
|
12168
|
-
return __generator(this, function (
|
|
12169
|
-
switch (
|
|
12236
|
+
return __generator(this, function (_l) {
|
|
12237
|
+
switch (_l.label) {
|
|
12170
12238
|
case 0:
|
|
12171
12239
|
entities = entities.filter(function (entity) {
|
|
12172
12240
|
var _a;
|
|
@@ -12196,43 +12264,43 @@ var EntitiesLoadedRenderManager;
|
|
|
12196
12264
|
}
|
|
12197
12265
|
})];
|
|
12198
12266
|
case 1:
|
|
12199
|
-
lods = (
|
|
12267
|
+
lods = (_l.sent()).lods;
|
|
12200
12268
|
if (this.disposed) {
|
|
12201
12269
|
this.doDispose();
|
|
12202
12270
|
return [2 /*return*/];
|
|
12203
12271
|
}
|
|
12204
12272
|
withLods_1 = lods.filter(function (x) { return x.entityId && !!x.clientFileId; }).map(function (x) { return x.entityId; });
|
|
12205
|
-
|
|
12273
|
+
individuals_1 = entities.filter(function (entity) {
|
|
12206
12274
|
var _a;
|
|
12207
12275
|
return withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
|
|
12208
12276
|
});
|
|
12209
|
-
if (
|
|
12210
|
-
this.renderAsIndividuals(
|
|
12277
|
+
if (individuals_1.length) {
|
|
12278
|
+
this.renderAsIndividuals(individuals_1, force);
|
|
12211
12279
|
}
|
|
12212
12280
|
// Now we proceed with what is left.
|
|
12213
12281
|
entities = entities.filter(function (entity) {
|
|
12214
12282
|
var _a;
|
|
12215
12283
|
return !withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
|
|
12216
12284
|
});
|
|
12217
|
-
|
|
12285
|
+
_l.label = 2;
|
|
12218
12286
|
case 2:
|
|
12219
12287
|
if (!entities.length) {
|
|
12220
12288
|
return [2 /*return*/];
|
|
12221
12289
|
}
|
|
12222
12290
|
style = null;
|
|
12223
12291
|
if (!((zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) && (zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) > -1)) return [3 /*break*/, 6];
|
|
12224
|
-
|
|
12292
|
+
_l.label = 3;
|
|
12225
12293
|
case 3:
|
|
12226
|
-
|
|
12294
|
+
_l.trys.push([3, 5, , 6]);
|
|
12227
12295
|
return [4 /*yield*/, Style.Get({
|
|
12228
12296
|
api: this.apiGetter.getApi(),
|
|
12229
12297
|
styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
|
|
12230
12298
|
})];
|
|
12231
12299
|
case 4:
|
|
12232
|
-
style = (_a = (
|
|
12300
|
+
style = (_a = (_l.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
12233
12301
|
return [3 /*break*/, 6];
|
|
12234
12302
|
case 5:
|
|
12235
|
-
e_3 =
|
|
12303
|
+
e_3 = _l.sent();
|
|
12236
12304
|
console.error(e_3);
|
|
12237
12305
|
return [3 /*break*/, 6];
|
|
12238
12306
|
case 6:
|
|
@@ -12241,15 +12309,15 @@ var EntitiesLoadedRenderManager;
|
|
|
12241
12309
|
entityTypeId = (_d = (_c = entities.find(function (x) { var _a; return !!((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]); })) === null || _c === void 0 ? void 0 : _c.Bruce) === null || _d === void 0 ? void 0 : _d["EntityType.ID"];
|
|
12242
12310
|
}
|
|
12243
12311
|
if (!entityTypeId) return [3 /*break*/, 12];
|
|
12244
|
-
|
|
12312
|
+
_l.label = 7;
|
|
12245
12313
|
case 7:
|
|
12246
|
-
|
|
12314
|
+
_l.trys.push([7, 11, , 12]);
|
|
12247
12315
|
return [4 /*yield*/, EntityType.Get({
|
|
12248
12316
|
entityTypeId: entityTypeId,
|
|
12249
12317
|
api: this.apiGetter.getApi()
|
|
12250
12318
|
})];
|
|
12251
12319
|
case 8:
|
|
12252
|
-
entityType = (_e = (
|
|
12320
|
+
entityType = (_e = (_l.sent())) === null || _e === void 0 ? void 0 : _e.entityType;
|
|
12253
12321
|
if (!(!style && entityType)) return [3 /*break*/, 10];
|
|
12254
12322
|
if (!(entityType["DisplaySetting.ID"] && entityType["DisplaySetting.ID"] > 0)) return [3 /*break*/, 10];
|
|
12255
12323
|
return [4 /*yield*/, Style.Get({
|
|
@@ -12257,11 +12325,11 @@ var EntitiesLoadedRenderManager;
|
|
|
12257
12325
|
styleId: entityType["DisplaySetting.ID"]
|
|
12258
12326
|
})];
|
|
12259
12327
|
case 9:
|
|
12260
|
-
style = (_f = (
|
|
12261
|
-
|
|
12328
|
+
style = (_f = (_l.sent()).style) === null || _f === void 0 ? void 0 : _f.Settings;
|
|
12329
|
+
_l.label = 10;
|
|
12262
12330
|
case 10: return [3 /*break*/, 12];
|
|
12263
12331
|
case 11:
|
|
12264
|
-
e_4 =
|
|
12332
|
+
e_4 = _l.sent();
|
|
12265
12333
|
console.error(e_4);
|
|
12266
12334
|
return [3 /*break*/, 12];
|
|
12267
12335
|
case 12:
|
|
@@ -12281,34 +12349,51 @@ var EntitiesLoadedRenderManager;
|
|
|
12281
12349
|
lineWidthPx = 0;
|
|
12282
12350
|
}
|
|
12283
12351
|
lineWidthPx = Math.round(lineWidthPx);
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12352
|
+
collection = {
|
|
12353
|
+
features: [],
|
|
12354
|
+
type: "FeatureCollection"
|
|
12355
|
+
};
|
|
12356
|
+
for (i = 0; i < entities.length; i++) {
|
|
12357
|
+
entity = entities[i];
|
|
12358
|
+
feature = Geometry.ToGeoJsonFeature({
|
|
12359
|
+
geometry: entity.Bruce.VectorGeometry,
|
|
12360
|
+
noAltitude: polygonsClamped && lineWidthPx <= 0,
|
|
12361
|
+
altitude: lineWidthPx > 0 && polygonsClamped ? 1 : null,
|
|
12362
|
+
properties: __assign(__assign({}, entity), { Bruce: __assign(__assign({}, entity.Bruce), {
|
|
12363
|
+
// Exclude as we just converted it to geojson.
|
|
12364
|
+
VectorGeometry: null }) })
|
|
12296
12365
|
});
|
|
12366
|
+
if (feature) {
|
|
12367
|
+
collection.features.push(feature);
|
|
12368
|
+
}
|
|
12369
|
+
}
|
|
12370
|
+
individuals = entities.filter(function (entity) {
|
|
12371
|
+
var feature = collection.features.find(function (x) { var _a, _b; return ((_b = (_a = x.properties) === null || _a === void 0 ? void 0 : _a.Bruce) === null || _b === void 0 ? void 0 : _b.ID) == entity.Bruce.ID; });
|
|
12372
|
+
if (!feature) {
|
|
12373
|
+
return true;
|
|
12374
|
+
}
|
|
12375
|
+
if (feature.geometry.type == "Point") {
|
|
12376
|
+
return true;
|
|
12377
|
+
}
|
|
12378
|
+
return false;
|
|
12297
12379
|
});
|
|
12298
|
-
if (
|
|
12299
|
-
this.renderAsIndividuals(
|
|
12380
|
+
if (individuals.length) {
|
|
12381
|
+
this.renderAsIndividuals(individuals, force);
|
|
12300
12382
|
}
|
|
12301
|
-
|
|
12383
|
+
// Filter out points (the ones we just rendered as individuals).
|
|
12384
|
+
collection.features = collection.features.filter(function (x) { return x.geometry.type != "Point"; });
|
|
12385
|
+
// If there is nothing to render now, return.
|
|
12386
|
+
if (!collection.features.length) {
|
|
12302
12387
|
return [2 /*return*/];
|
|
12303
12388
|
}
|
|
12304
|
-
return [4 /*yield*/, GeoJsonDataSource.load(
|
|
12389
|
+
return [4 /*yield*/, GeoJsonDataSource.load(collection, {
|
|
12305
12390
|
stroke: cLineColor,
|
|
12306
12391
|
fill: cFillColor,
|
|
12307
12392
|
strokeWidth: lineWidthPx,
|
|
12308
12393
|
clampToGround: lineWidthPx <= 0 && polygonsClamped
|
|
12309
12394
|
})];
|
|
12310
12395
|
case 13:
|
|
12311
|
-
source =
|
|
12396
|
+
source = _l.sent();
|
|
12312
12397
|
this.viewer.dataSources.add(source);
|
|
12313
12398
|
this.sources.push(source);
|
|
12314
12399
|
if (this.disposed) {
|
|
@@ -12784,12 +12869,12 @@ var EntitiesIdsRenderManager;
|
|
|
12784
12869
|
* @param force TODO: This should re-render entities that are already rendered.
|
|
12785
12870
|
*/
|
|
12786
12871
|
Manager.prototype.renderAsGeojson = function (entities, force) {
|
|
12787
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
12872
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
12788
12873
|
return __awaiter(this, void 0, void 0, function () {
|
|
12789
|
-
var zoomItem, lods, withLods_1,
|
|
12874
|
+
var zoomItem, lods, withLods_1, individuals_1, style, e_3, entityTypeId, entityType, e_4, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, collection, i, entity, feature, individuals, source, groups, applyStyle, toForceUpdate, register, sEntities, i, cEntity;
|
|
12790
12875
|
var _this = this;
|
|
12791
|
-
return __generator(this, function (
|
|
12792
|
-
switch (
|
|
12876
|
+
return __generator(this, function (_l) {
|
|
12877
|
+
switch (_l.label) {
|
|
12793
12878
|
case 0:
|
|
12794
12879
|
entities = entities.filter(function (entity) {
|
|
12795
12880
|
var _a;
|
|
@@ -12819,43 +12904,43 @@ var EntitiesIdsRenderManager;
|
|
|
12819
12904
|
}
|
|
12820
12905
|
})];
|
|
12821
12906
|
case 1:
|
|
12822
|
-
lods = (
|
|
12907
|
+
lods = (_l.sent()).lods;
|
|
12823
12908
|
if (this.disposed) {
|
|
12824
12909
|
this.doDispose();
|
|
12825
12910
|
return [2 /*return*/];
|
|
12826
12911
|
}
|
|
12827
12912
|
withLods_1 = lods.filter(function (x) { return x.entityId && !!x.clientFileId; }).map(function (x) { return x.entityId; });
|
|
12828
|
-
|
|
12913
|
+
individuals_1 = entities.filter(function (entity) {
|
|
12829
12914
|
var _a;
|
|
12830
12915
|
return withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
|
|
12831
12916
|
});
|
|
12832
|
-
if (
|
|
12833
|
-
this.renderAsIndividuals(
|
|
12917
|
+
if (individuals_1.length) {
|
|
12918
|
+
this.renderAsIndividuals(individuals_1, force);
|
|
12834
12919
|
}
|
|
12835
12920
|
// Now we proceed with what is left.
|
|
12836
12921
|
entities = entities.filter(function (entity) {
|
|
12837
12922
|
var _a;
|
|
12838
12923
|
return !withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
|
|
12839
12924
|
});
|
|
12840
|
-
|
|
12925
|
+
_l.label = 2;
|
|
12841
12926
|
case 2:
|
|
12842
12927
|
if (!entities.length) {
|
|
12843
12928
|
return [2 /*return*/];
|
|
12844
12929
|
}
|
|
12845
12930
|
style = null;
|
|
12846
12931
|
if (!((zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) && (zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) > -1)) return [3 /*break*/, 6];
|
|
12847
|
-
|
|
12932
|
+
_l.label = 3;
|
|
12848
12933
|
case 3:
|
|
12849
|
-
|
|
12934
|
+
_l.trys.push([3, 5, , 6]);
|
|
12850
12935
|
return [4 /*yield*/, Style.Get({
|
|
12851
12936
|
api: this.apiGetter.getApi(),
|
|
12852
12937
|
styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
|
|
12853
12938
|
})];
|
|
12854
12939
|
case 4:
|
|
12855
|
-
style = (_a = (
|
|
12940
|
+
style = (_a = (_l.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
12856
12941
|
return [3 /*break*/, 6];
|
|
12857
12942
|
case 5:
|
|
12858
|
-
e_3 =
|
|
12943
|
+
e_3 = _l.sent();
|
|
12859
12944
|
console.error(e_3);
|
|
12860
12945
|
return [3 /*break*/, 6];
|
|
12861
12946
|
case 6:
|
|
@@ -12864,15 +12949,15 @@ var EntitiesIdsRenderManager;
|
|
|
12864
12949
|
entityTypeId = (_d = (_c = entities.find(function (x) { var _a; return !!((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]); })) === null || _c === void 0 ? void 0 : _c.Bruce) === null || _d === void 0 ? void 0 : _d["EntityType.ID"];
|
|
12865
12950
|
}
|
|
12866
12951
|
if (!entityTypeId) return [3 /*break*/, 12];
|
|
12867
|
-
|
|
12952
|
+
_l.label = 7;
|
|
12868
12953
|
case 7:
|
|
12869
|
-
|
|
12954
|
+
_l.trys.push([7, 11, , 12]);
|
|
12870
12955
|
return [4 /*yield*/, EntityType.Get({
|
|
12871
12956
|
entityTypeId: entityTypeId,
|
|
12872
12957
|
api: this.apiGetter.getApi()
|
|
12873
12958
|
})];
|
|
12874
12959
|
case 8:
|
|
12875
|
-
entityType = (_e = (
|
|
12960
|
+
entityType = (_e = (_l.sent())) === null || _e === void 0 ? void 0 : _e.entityType;
|
|
12876
12961
|
if (!(!style && entityType)) return [3 /*break*/, 10];
|
|
12877
12962
|
if (!(entityType["DisplaySetting.ID"] && entityType["DisplaySetting.ID"] > 0)) return [3 /*break*/, 10];
|
|
12878
12963
|
return [4 /*yield*/, Style.Get({
|
|
@@ -12880,11 +12965,11 @@ var EntitiesIdsRenderManager;
|
|
|
12880
12965
|
styleId: entityType["DisplaySetting.ID"]
|
|
12881
12966
|
})];
|
|
12882
12967
|
case 9:
|
|
12883
|
-
style = (_f = (
|
|
12884
|
-
|
|
12968
|
+
style = (_f = (_l.sent()).style) === null || _f === void 0 ? void 0 : _f.Settings;
|
|
12969
|
+
_l.label = 10;
|
|
12885
12970
|
case 10: return [3 /*break*/, 12];
|
|
12886
12971
|
case 11:
|
|
12887
|
-
e_4 =
|
|
12972
|
+
e_4 = _l.sent();
|
|
12888
12973
|
console.error(e_4);
|
|
12889
12974
|
return [3 /*break*/, 12];
|
|
12890
12975
|
case 12:
|
|
@@ -12904,34 +12989,51 @@ var EntitiesIdsRenderManager;
|
|
|
12904
12989
|
lineWidthPx = 0;
|
|
12905
12990
|
}
|
|
12906
12991
|
lineWidthPx = Math.round(lineWidthPx);
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12992
|
+
collection = {
|
|
12993
|
+
features: [],
|
|
12994
|
+
type: "FeatureCollection"
|
|
12995
|
+
};
|
|
12996
|
+
for (i = 0; i < entities.length; i++) {
|
|
12997
|
+
entity = entities[i];
|
|
12998
|
+
feature = Geometry.ToGeoJsonFeature({
|
|
12999
|
+
geometry: entity.Bruce.VectorGeometry,
|
|
13000
|
+
noAltitude: polygonsClamped && lineWidthPx <= 0,
|
|
13001
|
+
altitude: lineWidthPx > 0 && polygonsClamped ? 1 : null,
|
|
13002
|
+
properties: __assign(__assign({}, entity), { Bruce: __assign(__assign({}, entity.Bruce), {
|
|
13003
|
+
// Exclude as we just converted it to geojson.
|
|
13004
|
+
VectorGeometry: null }) })
|
|
12919
13005
|
});
|
|
13006
|
+
if (feature) {
|
|
13007
|
+
collection.features.push(feature);
|
|
13008
|
+
}
|
|
13009
|
+
}
|
|
13010
|
+
individuals = entities.filter(function (entity) {
|
|
13011
|
+
var feature = collection.features.find(function (x) { var _a, _b; return ((_b = (_a = x.properties) === null || _a === void 0 ? void 0 : _a.Bruce) === null || _b === void 0 ? void 0 : _b.ID) == entity.Bruce.ID; });
|
|
13012
|
+
if (!feature) {
|
|
13013
|
+
return true;
|
|
13014
|
+
}
|
|
13015
|
+
if (feature.geometry.type == "Point") {
|
|
13016
|
+
return true;
|
|
13017
|
+
}
|
|
13018
|
+
return false;
|
|
12920
13019
|
});
|
|
12921
|
-
if (
|
|
12922
|
-
this.renderAsIndividuals(
|
|
13020
|
+
if (individuals.length) {
|
|
13021
|
+
this.renderAsIndividuals(individuals, force);
|
|
12923
13022
|
}
|
|
12924
|
-
|
|
13023
|
+
// Filter out points (the ones we just rendered as individuals).
|
|
13024
|
+
collection.features = collection.features.filter(function (x) { return x.geometry.type != "Point"; });
|
|
13025
|
+
// If there is nothing to render now, return.
|
|
13026
|
+
if (!collection.features.length) {
|
|
12925
13027
|
return [2 /*return*/];
|
|
12926
13028
|
}
|
|
12927
|
-
return [4 /*yield*/, GeoJsonDataSource.load(
|
|
13029
|
+
return [4 /*yield*/, GeoJsonDataSource.load(collection, {
|
|
12928
13030
|
stroke: cLineColor,
|
|
12929
13031
|
fill: cFillColor,
|
|
12930
13032
|
strokeWidth: lineWidthPx,
|
|
12931
13033
|
clampToGround: lineWidthPx <= 0 && polygonsClamped
|
|
12932
13034
|
})];
|
|
12933
13035
|
case 13:
|
|
12934
|
-
source =
|
|
13036
|
+
source = _l.sent();
|
|
12935
13037
|
this.viewer.dataSources.add(source);
|
|
12936
13038
|
this.sources.push(source);
|
|
12937
13039
|
if (this.disposed) {
|
|
@@ -25609,7 +25711,7 @@ var ViewRenderEngine;
|
|
|
25609
25711
|
ViewRenderEngine.Render = Render;
|
|
25610
25712
|
})(ViewRenderEngine || (ViewRenderEngine = {}));
|
|
25611
25713
|
|
|
25612
|
-
var VERSION = "4.
|
|
25714
|
+
var VERSION = "4.2.0";
|
|
25613
25715
|
|
|
25614
25716
|
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 };
|
|
25615
25717
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|