bruce-models 3.4.4 → 3.4.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.
- package/dist/bruce-models.es5.js +73 -44
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +72 -43
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/entity/entity.js +51 -21
- package/dist/lib/entity/entity.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/entity/entity.d.ts +3 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -2823,6 +2823,27 @@
|
|
|
2823
2823
|
PathUtils.ParseLegacy = ParseLegacy;
|
|
2824
2824
|
})(exports.PathUtils || (exports.PathUtils = {}));
|
|
2825
2825
|
|
|
2826
|
+
/**
|
|
2827
|
+
* Describes an expectation on what should be rendered for a menu item-
|
|
2828
|
+
* between a min-max distance of an entity to the camera.
|
|
2829
|
+
*/
|
|
2830
|
+
(function (ZoomControl) {
|
|
2831
|
+
/**
|
|
2832
|
+
* Available display types for a menu item.
|
|
2833
|
+
*/
|
|
2834
|
+
let EDisplayType;
|
|
2835
|
+
(function (EDisplayType) {
|
|
2836
|
+
// Hidden means it will not be rendered.
|
|
2837
|
+
EDisplayType["Hidden"] = "hidden";
|
|
2838
|
+
// Point will try render a point based on any available Entity data.
|
|
2839
|
+
EDisplayType["Point"] = "point";
|
|
2840
|
+
// Geometry means it will try render multi-geometry, polygon, polyline, or point in order of priority.
|
|
2841
|
+
EDisplayType["Geometry"] = "geometry";
|
|
2842
|
+
// 3D means it will try render 3D model, multi-geometry, polygon, polyline, or point in order of priority.
|
|
2843
|
+
EDisplayType["Model3D"] = "3d";
|
|
2844
|
+
})(EDisplayType = ZoomControl.EDisplayType || (ZoomControl.EDisplayType = {}));
|
|
2845
|
+
})(exports.ZoomControl || (exports.ZoomControl = {}));
|
|
2846
|
+
|
|
2826
2847
|
(function (Entity) {
|
|
2827
2848
|
/**
|
|
2828
2849
|
* Returns cache identifier for an entity record.
|
|
@@ -3337,11 +3358,28 @@
|
|
|
3337
3358
|
}
|
|
3338
3359
|
Entity.GetList = GetList;
|
|
3339
3360
|
function ToGeoJson(params) {
|
|
3340
|
-
const { entities, excludeAltitude, altitude, includeUserData } = params;
|
|
3361
|
+
const { entities, excludeAltitude, altitude, includeUserData, allowedDisplayTypes } = params;
|
|
3341
3362
|
const features = [];
|
|
3363
|
+
const allowPoint = allowedDisplayTypes == null || allowedDisplayTypes.includes(exports.ZoomControl.EDisplayType.Point);
|
|
3364
|
+
const allowGeometry = allowedDisplayTypes == null || allowedDisplayTypes.includes(exports.ZoomControl.EDisplayType.Geometry);
|
|
3342
3365
|
const cloneObj = (obj) => {
|
|
3343
3366
|
return JSON.parse(JSON.stringify(obj));
|
|
3344
3367
|
};
|
|
3368
|
+
const areCoordinatesEqual = (coord1, coord2) => {
|
|
3369
|
+
return coord1[0] === coord2[0] && coord1[1] === coord2[1] && (coord1[2] === coord2[2] || (coord1.length < 3 && coord2.length < 3));
|
|
3370
|
+
};
|
|
3371
|
+
const removeConsecutiveDuplicates = (coordinates) => {
|
|
3372
|
+
return coordinates.filter((coord, index, array) => {
|
|
3373
|
+
return index === 0 || !areCoordinatesEqual(coord, array[index - 1]);
|
|
3374
|
+
});
|
|
3375
|
+
};
|
|
3376
|
+
const closePolygonCoordinates = (coordinates) => {
|
|
3377
|
+
if (coordinates.length > 0 && !areCoordinatesEqual(coordinates[0], coordinates[coordinates.length - 1])) {
|
|
3378
|
+
const firstPointCopy = [...coordinates[0]];
|
|
3379
|
+
coordinates.push(firstPointCopy);
|
|
3380
|
+
}
|
|
3381
|
+
return coordinates;
|
|
3382
|
+
};
|
|
3345
3383
|
const populateProperties = (feature, entity) => {
|
|
3346
3384
|
let properties = null;
|
|
3347
3385
|
// All properties.
|
|
@@ -3362,45 +3400,57 @@
|
|
|
3362
3400
|
feature.properties = properties;
|
|
3363
3401
|
};
|
|
3364
3402
|
const processGeometry = (geometry, entity) => {
|
|
3403
|
+
var _a, _b;
|
|
3365
3404
|
const feature = {
|
|
3366
|
-
type:
|
|
3405
|
+
type: "Feature",
|
|
3367
3406
|
properties: {},
|
|
3368
3407
|
geometry: null
|
|
3369
3408
|
};
|
|
3370
3409
|
populateProperties(feature, entity);
|
|
3371
|
-
if (geometry.
|
|
3410
|
+
if (((_a = geometry.MultiGeometry) === null || _a === void 0 ? void 0 : _a.length) && allowGeometry) {
|
|
3411
|
+
geometry.MultiGeometry.forEach(geo => processGeometry(geo, entity));
|
|
3412
|
+
return;
|
|
3413
|
+
}
|
|
3414
|
+
else if (((_b = geometry.Polygon) === null || _b === void 0 ? void 0 : _b.length) && allowGeometry) {
|
|
3372
3415
|
const sortedPolygons = geometry.Polygon.sort((a, b) => a.Facing === exports.Geometry.EPolygonRingType.Boundaries ? -1 : 1);
|
|
3373
|
-
const coordinates = sortedPolygons.map(polygonRing => polygonRing.LinearRing.split(' ').map(coord => {
|
|
3416
|
+
const coordinates = sortedPolygons.map(polygonRing => closePolygonCoordinates(removeConsecutiveDuplicates(polygonRing.LinearRing.split(' ').map(coord => {
|
|
3374
3417
|
const [lon, lat, alt] = coord.split(',').map(Number);
|
|
3375
3418
|
return excludeAltitude ? [lon, lat] : [lon, lat, altitude !== undefined ? altitude : (alt !== undefined ? alt : [])];
|
|
3376
|
-
}));
|
|
3419
|
+
}))));
|
|
3420
|
+
// Check if the polygon has at least 4 points.
|
|
3421
|
+
const isValidPolygon = coordinates.every(polygon => polygon.length >= 4);
|
|
3422
|
+
if (!isValidPolygon) {
|
|
3423
|
+
// Perhaps try other geometry instead of returning?
|
|
3424
|
+
return;
|
|
3425
|
+
}
|
|
3377
3426
|
feature.geometry = {
|
|
3378
|
-
type:
|
|
3427
|
+
type: "Polygon",
|
|
3379
3428
|
coordinates: coordinates,
|
|
3380
3429
|
};
|
|
3381
3430
|
}
|
|
3382
|
-
if (geometry.
|
|
3383
|
-
const
|
|
3384
|
-
|
|
3431
|
+
else if (geometry.LineString && (allowedDisplayTypes == null || allowedDisplayTypes.includes(exports.ZoomControl.EDisplayType.Geometry))) {
|
|
3432
|
+
const coordinates = removeConsecutiveDuplicates(geometry.LineString.split(' ').map(coord => {
|
|
3433
|
+
const [lon, lat, alt] = coord.split(',').map(Number);
|
|
3434
|
+
return excludeAltitude ? [lon, lat] : [lon, lat, altitude !== undefined ? altitude : (alt !== undefined ? alt : [])];
|
|
3435
|
+
}));
|
|
3436
|
+
// Check if the polyline has at least 2 points.
|
|
3437
|
+
if (coordinates.length < 2) {
|
|
3438
|
+
// Perhaps try other geometry instead of returning?
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3385
3441
|
feature.geometry = {
|
|
3386
|
-
type:
|
|
3442
|
+
type: "LineString",
|
|
3387
3443
|
coordinates,
|
|
3388
3444
|
};
|
|
3389
3445
|
}
|
|
3390
|
-
if (geometry.
|
|
3391
|
-
const
|
|
3392
|
-
|
|
3393
|
-
return excludeAltitude ? [lon, lat] : [lon, lat, altitude !== undefined ? altitude : (alt !== undefined ? alt : [])];
|
|
3394
|
-
});
|
|
3446
|
+
else if (geometry.Point && allowPoint) {
|
|
3447
|
+
const [lon, lat, alt] = geometry.Point.split(',').map(Number);
|
|
3448
|
+
const coordinates = excludeAltitude ? [lon, lat] : [lon, lat, altitude !== undefined ? altitude : (alt !== undefined ? alt : [])];
|
|
3395
3449
|
feature.geometry = {
|
|
3396
|
-
type:
|
|
3450
|
+
type: "Point",
|
|
3397
3451
|
coordinates,
|
|
3398
3452
|
};
|
|
3399
3453
|
}
|
|
3400
|
-
if (geometry.MultiGeometry) {
|
|
3401
|
-
geometry.MultiGeometry.forEach(geo => processGeometry(geo, entity));
|
|
3402
|
-
return;
|
|
3403
|
-
}
|
|
3404
3454
|
features.push(feature);
|
|
3405
3455
|
};
|
|
3406
3456
|
entities.forEach(entity => {
|
|
@@ -3417,7 +3467,7 @@
|
|
|
3417
3467
|
processGeometry(geometry, entity);
|
|
3418
3468
|
});
|
|
3419
3469
|
return {
|
|
3420
|
-
type:
|
|
3470
|
+
type: "FeatureCollection",
|
|
3421
3471
|
features,
|
|
3422
3472
|
};
|
|
3423
3473
|
}
|
|
@@ -6926,27 +6976,6 @@
|
|
|
6926
6976
|
ProgramKey.Update = Update;
|
|
6927
6977
|
})(exports.ProgramKey || (exports.ProgramKey = {}));
|
|
6928
6978
|
|
|
6929
|
-
/**
|
|
6930
|
-
* Describes an expectation on what should be rendered for a menu item-
|
|
6931
|
-
* between a min-max distance of an entity to the camera.
|
|
6932
|
-
*/
|
|
6933
|
-
(function (ZoomControl) {
|
|
6934
|
-
/**
|
|
6935
|
-
* Available display types for a menu item.
|
|
6936
|
-
*/
|
|
6937
|
-
let EDisplayType;
|
|
6938
|
-
(function (EDisplayType) {
|
|
6939
|
-
// Hidden means it will not be rendered.
|
|
6940
|
-
EDisplayType["Hidden"] = "hidden";
|
|
6941
|
-
// Point will try render a point based on any available Entity data.
|
|
6942
|
-
EDisplayType["Point"] = "point";
|
|
6943
|
-
// Geometry means it will try render multi-geometry, polygon, polyline, or point in order of priority.
|
|
6944
|
-
EDisplayType["Geometry"] = "geometry";
|
|
6945
|
-
// 3D means it will try render 3D model, multi-geometry, polygon, polyline, or point in order of priority.
|
|
6946
|
-
EDisplayType["Model3D"] = "3d";
|
|
6947
|
-
})(EDisplayType = ZoomControl.EDisplayType || (ZoomControl.EDisplayType = {}));
|
|
6948
|
-
})(exports.ZoomControl || (exports.ZoomControl = {}));
|
|
6949
|
-
|
|
6950
6979
|
(function (Tileset) {
|
|
6951
6980
|
/**
|
|
6952
6981
|
* Returns cache identifier for a tileset.
|
|
@@ -10543,7 +10572,7 @@
|
|
|
10543
10572
|
DataSource.GetList = GetList;
|
|
10544
10573
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
10545
10574
|
|
|
10546
|
-
const VERSION = "3.4.
|
|
10575
|
+
const VERSION = "3.4.5";
|
|
10547
10576
|
|
|
10548
10577
|
exports.VERSION = VERSION;
|
|
10549
10578
|
exports.AbstractApi = AbstractApi;
|