bruce-models 3.4.3 → 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 +261 -214
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +259 -212
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/common/geometry.js +0 -68
- package/dist/lib/common/geometry.js.map +1 -1
- package/dist/lib/entity/entity.js +117 -0
- package/dist/lib/entity/entity.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/common/geometry.d.ts +0 -5
- package/dist/types/entity/entity.d.ts +9 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -2436,6 +2436,128 @@
|
|
|
2436
2436
|
Color.ColorFromStr = ColorFromStr;
|
|
2437
2437
|
})(exports.Color || (exports.Color = {}));
|
|
2438
2438
|
|
|
2439
|
+
/**
|
|
2440
|
+
* Describes vector geometry that Bruce uses.
|
|
2441
|
+
*/
|
|
2442
|
+
(function (Geometry) {
|
|
2443
|
+
let EPolygonRingType;
|
|
2444
|
+
(function (EPolygonRingType) {
|
|
2445
|
+
EPolygonRingType["Boundaries"] = "out";
|
|
2446
|
+
EPolygonRingType["Hole"] = "in";
|
|
2447
|
+
})(EPolygonRingType = Geometry.EPolygonRingType || (Geometry.EPolygonRingType = {}));
|
|
2448
|
+
/**
|
|
2449
|
+
* Turns an array of points into string vector geometry that Bruce can use.
|
|
2450
|
+
* This is used for saving polyline and polygon data.
|
|
2451
|
+
* @param points
|
|
2452
|
+
* @returns
|
|
2453
|
+
*/
|
|
2454
|
+
function LineStrFromPoints(points) {
|
|
2455
|
+
if (!points.length) {
|
|
2456
|
+
throw ("points is empty.");
|
|
2457
|
+
}
|
|
2458
|
+
let carto = points[0];
|
|
2459
|
+
let lineString = `${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
|
|
2460
|
+
for (let i = 1; i < points.length; i++) {
|
|
2461
|
+
carto = points[i];
|
|
2462
|
+
lineString += ` ${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
|
|
2463
|
+
}
|
|
2464
|
+
return lineString;
|
|
2465
|
+
}
|
|
2466
|
+
Geometry.LineStrFromPoints = LineStrFromPoints;
|
|
2467
|
+
/**
|
|
2468
|
+
* Removes same points that occur in a row.
|
|
2469
|
+
* This will not modify the original array.
|
|
2470
|
+
* @param positions
|
|
2471
|
+
* @returns
|
|
2472
|
+
*/
|
|
2473
|
+
function RemoveRepeatPoints(positions) {
|
|
2474
|
+
const filteredList = [];
|
|
2475
|
+
for (let i = 0; i < positions.length; i++) {
|
|
2476
|
+
const pos = positions[i];
|
|
2477
|
+
const lastPos = filteredList.length > 0 ? filteredList[filteredList.length - 1] : null;
|
|
2478
|
+
if (!lastPos || (pos.latitude != lastPos.latitude || pos.longitude != lastPos.longitude || pos.altitude != lastPos.altitude)) {
|
|
2479
|
+
filteredList.push(pos);
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
return filteredList;
|
|
2483
|
+
}
|
|
2484
|
+
Geometry.RemoveRepeatPoints = RemoveRepeatPoints;
|
|
2485
|
+
/**
|
|
2486
|
+
* Parses a string of points into an array of points.
|
|
2487
|
+
* @param pointsStr
|
|
2488
|
+
* @returns
|
|
2489
|
+
*/
|
|
2490
|
+
function ParsePoints(pointsStr) {
|
|
2491
|
+
pointsStr = pointsStr.replace(/[^\d.,-\s]/g, "");
|
|
2492
|
+
let splitterCoordinates = " ";
|
|
2493
|
+
let splitterAxis = ",";
|
|
2494
|
+
const commaIndex = pointsStr.indexOf(",");
|
|
2495
|
+
const spaceIndex = pointsStr.indexOf(" ");
|
|
2496
|
+
if ((spaceIndex > -1 && commaIndex > spaceIndex) || commaIndex <= -1) {
|
|
2497
|
+
splitterCoordinates = ",";
|
|
2498
|
+
splitterAxis = " ";
|
|
2499
|
+
}
|
|
2500
|
+
let points = pointsStr.trim().split(splitterCoordinates);
|
|
2501
|
+
points = points.filter(a => a != "");
|
|
2502
|
+
const result = [];
|
|
2503
|
+
for (let i = 0; i < points.length; i++) {
|
|
2504
|
+
const pointData = points[i];
|
|
2505
|
+
const coords = pointData.trim().split(splitterAxis);
|
|
2506
|
+
if (coords.length == 2 || coords.length == 3) {
|
|
2507
|
+
const longitude = Number(coords[0]);
|
|
2508
|
+
const latitude = Number(coords[1]);
|
|
2509
|
+
const altitude = Number(coords.length >= 3 ? coords[2] : 0);
|
|
2510
|
+
if (longitude != null && latitude != null) {
|
|
2511
|
+
result.push({
|
|
2512
|
+
altitude: altitude,
|
|
2513
|
+
latitude: latitude,
|
|
2514
|
+
longitude: longitude
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
else {
|
|
2518
|
+
console.warn("Invalid point data detected.", pointData);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
return result;
|
|
2523
|
+
}
|
|
2524
|
+
Geometry.ParsePoints = ParsePoints;
|
|
2525
|
+
/**
|
|
2526
|
+
* Parses both string and object Bruce geometry.
|
|
2527
|
+
* String geometry is legacy Bruce data.
|
|
2528
|
+
* @param geometry
|
|
2529
|
+
* @returns
|
|
2530
|
+
*/
|
|
2531
|
+
function ParseGeometry(geometry) {
|
|
2532
|
+
if (typeof geometry == "string") {
|
|
2533
|
+
let positions = [];
|
|
2534
|
+
const geometryParsed = (geometry || "").split(";");
|
|
2535
|
+
for (let i = 0; i < geometryParsed.length; i++) {
|
|
2536
|
+
const data = geometryParsed[i];
|
|
2537
|
+
const points = ParsePoints(data);
|
|
2538
|
+
if (points && points.length > 0) {
|
|
2539
|
+
positions = positions.concat(points);
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
positions = RemoveRepeatPoints(positions);
|
|
2543
|
+
const newGeometry = {};
|
|
2544
|
+
if (positions.length > 0) {
|
|
2545
|
+
const topPoint = positions[0];
|
|
2546
|
+
newGeometry.Point = `${topPoint.latitude},${topPoint.longitude}` + (topPoint.altitude != null ? `,${topPoint.altitude}` : "");
|
|
2547
|
+
if (positions.length > 1) {
|
|
2548
|
+
newGeometry.Polygon = [{ Facing: EPolygonRingType.Boundaries, LinearRing: LineStrFromPoints(positions) }];
|
|
2549
|
+
}
|
|
2550
|
+
if (positions.length > 2) {
|
|
2551
|
+
newGeometry.LineString = LineStrFromPoints(positions);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
return newGeometry;
|
|
2555
|
+
}
|
|
2556
|
+
return geometry;
|
|
2557
|
+
}
|
|
2558
|
+
Geometry.ParseGeometry = ParseGeometry;
|
|
2559
|
+
})(exports.Geometry || (exports.Geometry = {}));
|
|
2560
|
+
|
|
2439
2561
|
(function (ObjectUtils) {
|
|
2440
2562
|
const DEFAULT_LENGTH = 36;
|
|
2441
2563
|
/**
|
|
@@ -2701,6 +2823,27 @@
|
|
|
2701
2823
|
PathUtils.ParseLegacy = ParseLegacy;
|
|
2702
2824
|
})(exports.PathUtils || (exports.PathUtils = {}));
|
|
2703
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
|
+
|
|
2704
2847
|
(function (Entity) {
|
|
2705
2848
|
/**
|
|
2706
2849
|
* Returns cache identifier for an entity record.
|
|
@@ -3214,6 +3357,121 @@
|
|
|
3214
3357
|
});
|
|
3215
3358
|
}
|
|
3216
3359
|
Entity.GetList = GetList;
|
|
3360
|
+
function ToGeoJson(params) {
|
|
3361
|
+
const { entities, excludeAltitude, altitude, includeUserData, allowedDisplayTypes } = params;
|
|
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);
|
|
3365
|
+
const cloneObj = (obj) => {
|
|
3366
|
+
return JSON.parse(JSON.stringify(obj));
|
|
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
|
+
};
|
|
3383
|
+
const populateProperties = (feature, entity) => {
|
|
3384
|
+
let properties = null;
|
|
3385
|
+
// All properties.
|
|
3386
|
+
if (includeUserData != false) {
|
|
3387
|
+
properties = cloneObj(entity);
|
|
3388
|
+
// We exclude geometry since the geojson is supposed to represent that attribute.
|
|
3389
|
+
delete properties.geometry;
|
|
3390
|
+
}
|
|
3391
|
+
// Only specific internal properties.
|
|
3392
|
+
else {
|
|
3393
|
+
properties = {
|
|
3394
|
+
Bruce: entity.Bruce ? cloneObj(entity.Bruce) : null,
|
|
3395
|
+
location: entity.location ? cloneObj(entity.location) : null,
|
|
3396
|
+
transform: entity.transform ? cloneObj(entity.transform) : null,
|
|
3397
|
+
boundaries: entity.boundaries ? cloneObj(entity.boundaries) : null,
|
|
3398
|
+
};
|
|
3399
|
+
}
|
|
3400
|
+
feature.properties = properties;
|
|
3401
|
+
};
|
|
3402
|
+
const processGeometry = (geometry, entity) => {
|
|
3403
|
+
var _a, _b;
|
|
3404
|
+
const feature = {
|
|
3405
|
+
type: "Feature",
|
|
3406
|
+
properties: {},
|
|
3407
|
+
geometry: null
|
|
3408
|
+
};
|
|
3409
|
+
populateProperties(feature, entity);
|
|
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) {
|
|
3415
|
+
const sortedPolygons = geometry.Polygon.sort((a, b) => a.Facing === exports.Geometry.EPolygonRingType.Boundaries ? -1 : 1);
|
|
3416
|
+
const coordinates = sortedPolygons.map(polygonRing => closePolygonCoordinates(removeConsecutiveDuplicates(polygonRing.LinearRing.split(' ').map(coord => {
|
|
3417
|
+
const [lon, lat, alt] = coord.split(',').map(Number);
|
|
3418
|
+
return excludeAltitude ? [lon, lat] : [lon, lat, altitude !== undefined ? altitude : (alt !== undefined ? alt : [])];
|
|
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
|
+
}
|
|
3426
|
+
feature.geometry = {
|
|
3427
|
+
type: "Polygon",
|
|
3428
|
+
coordinates: coordinates,
|
|
3429
|
+
};
|
|
3430
|
+
}
|
|
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
|
+
}
|
|
3441
|
+
feature.geometry = {
|
|
3442
|
+
type: "LineString",
|
|
3443
|
+
coordinates,
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
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 : [])];
|
|
3449
|
+
feature.geometry = {
|
|
3450
|
+
type: "Point",
|
|
3451
|
+
coordinates,
|
|
3452
|
+
};
|
|
3453
|
+
}
|
|
3454
|
+
features.push(feature);
|
|
3455
|
+
};
|
|
3456
|
+
entities.forEach(entity => {
|
|
3457
|
+
var _a, _b, _c;
|
|
3458
|
+
if (!((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID)) {
|
|
3459
|
+
return;
|
|
3460
|
+
}
|
|
3461
|
+
let geometry = entity.geometry;
|
|
3462
|
+
if (!geometry && (((_b = entity.location) === null || _b === void 0 ? void 0 : _b.longitude) && ((_c = entity.location) === null || _c === void 0 ? void 0 : _c.latitude))) {
|
|
3463
|
+
geometry = {
|
|
3464
|
+
Point: `${entity.location.longitude},${entity.location.latitude}` + (entity.location.altitude != null ? `,${entity.location.altitude}` : ""),
|
|
3465
|
+
};
|
|
3466
|
+
}
|
|
3467
|
+
processGeometry(geometry, entity);
|
|
3468
|
+
});
|
|
3469
|
+
return {
|
|
3470
|
+
type: "FeatureCollection",
|
|
3471
|
+
features,
|
|
3472
|
+
};
|
|
3473
|
+
}
|
|
3474
|
+
Entity.ToGeoJson = ToGeoJson;
|
|
3217
3475
|
})(exports.Entity || (exports.Entity = {}));
|
|
3218
3476
|
|
|
3219
3477
|
/**
|
|
@@ -3710,196 +3968,6 @@
|
|
|
3710
3968
|
Calculator.GetInputValue = GetInputValue;
|
|
3711
3969
|
})(exports.Calculator || (exports.Calculator = {}));
|
|
3712
3970
|
|
|
3713
|
-
/**
|
|
3714
|
-
* Describes vector geometry that Bruce uses.
|
|
3715
|
-
*/
|
|
3716
|
-
(function (Geometry) {
|
|
3717
|
-
let EPolygonRingType;
|
|
3718
|
-
(function (EPolygonRingType) {
|
|
3719
|
-
EPolygonRingType["Boundaries"] = "out";
|
|
3720
|
-
EPolygonRingType["Hole"] = "in";
|
|
3721
|
-
})(EPolygonRingType = Geometry.EPolygonRingType || (Geometry.EPolygonRingType = {}));
|
|
3722
|
-
/**
|
|
3723
|
-
* Turns an array of points into string vector geometry that Bruce can use.
|
|
3724
|
-
* This is used for saving polyline and polygon data.
|
|
3725
|
-
* @param points
|
|
3726
|
-
* @returns
|
|
3727
|
-
*/
|
|
3728
|
-
function LineStrFromPoints(points) {
|
|
3729
|
-
if (!points.length) {
|
|
3730
|
-
throw ("points is empty.");
|
|
3731
|
-
}
|
|
3732
|
-
let carto = points[0];
|
|
3733
|
-
let lineString = `${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
|
|
3734
|
-
for (let i = 1; i < points.length; i++) {
|
|
3735
|
-
carto = points[i];
|
|
3736
|
-
lineString += ` ${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
|
|
3737
|
-
}
|
|
3738
|
-
return lineString;
|
|
3739
|
-
}
|
|
3740
|
-
Geometry.LineStrFromPoints = LineStrFromPoints;
|
|
3741
|
-
/**
|
|
3742
|
-
* Removes same points that occur in a row.
|
|
3743
|
-
* This will not modify the original array.
|
|
3744
|
-
* @param positions
|
|
3745
|
-
* @returns
|
|
3746
|
-
*/
|
|
3747
|
-
function RemoveRepeatPoints(positions) {
|
|
3748
|
-
const filteredList = [];
|
|
3749
|
-
for (let i = 0; i < positions.length; i++) {
|
|
3750
|
-
const pos = positions[i];
|
|
3751
|
-
const lastPos = filteredList.length > 0 ? filteredList[filteredList.length - 1] : null;
|
|
3752
|
-
if (!lastPos || (pos.latitude != lastPos.latitude || pos.longitude != lastPos.longitude || pos.altitude != lastPos.altitude)) {
|
|
3753
|
-
filteredList.push(pos);
|
|
3754
|
-
}
|
|
3755
|
-
}
|
|
3756
|
-
return filteredList;
|
|
3757
|
-
}
|
|
3758
|
-
Geometry.RemoveRepeatPoints = RemoveRepeatPoints;
|
|
3759
|
-
/**
|
|
3760
|
-
* Parses a string of points into an array of points.
|
|
3761
|
-
* @param pointsStr
|
|
3762
|
-
* @returns
|
|
3763
|
-
*/
|
|
3764
|
-
function ParsePoints(pointsStr) {
|
|
3765
|
-
pointsStr = pointsStr.replace(/[^\d.,-\s]/g, "");
|
|
3766
|
-
let splitterCoordinates = " ";
|
|
3767
|
-
let splitterAxis = ",";
|
|
3768
|
-
const commaIndex = pointsStr.indexOf(",");
|
|
3769
|
-
const spaceIndex = pointsStr.indexOf(" ");
|
|
3770
|
-
if ((spaceIndex > -1 && commaIndex > spaceIndex) || commaIndex <= -1) {
|
|
3771
|
-
splitterCoordinates = ",";
|
|
3772
|
-
splitterAxis = " ";
|
|
3773
|
-
}
|
|
3774
|
-
let points = pointsStr.trim().split(splitterCoordinates);
|
|
3775
|
-
points = points.filter(a => a != "");
|
|
3776
|
-
const result = [];
|
|
3777
|
-
for (let i = 0; i < points.length; i++) {
|
|
3778
|
-
const pointData = points[i];
|
|
3779
|
-
const coords = pointData.trim().split(splitterAxis);
|
|
3780
|
-
if (coords.length == 2 || coords.length == 3) {
|
|
3781
|
-
const longitude = Number(coords[0]);
|
|
3782
|
-
const latitude = Number(coords[1]);
|
|
3783
|
-
const altitude = Number(coords.length >= 3 ? coords[2] : 0);
|
|
3784
|
-
if (longitude != null && latitude != null) {
|
|
3785
|
-
result.push({
|
|
3786
|
-
altitude: altitude,
|
|
3787
|
-
latitude: latitude,
|
|
3788
|
-
longitude: longitude
|
|
3789
|
-
});
|
|
3790
|
-
}
|
|
3791
|
-
else {
|
|
3792
|
-
console.warn("Invalid point data detected.", pointData);
|
|
3793
|
-
}
|
|
3794
|
-
}
|
|
3795
|
-
}
|
|
3796
|
-
return result;
|
|
3797
|
-
}
|
|
3798
|
-
Geometry.ParsePoints = ParsePoints;
|
|
3799
|
-
/**
|
|
3800
|
-
* Parses both string and object Bruce geometry.
|
|
3801
|
-
* String geometry is legacy Bruce data.
|
|
3802
|
-
* @param geometry
|
|
3803
|
-
* @returns
|
|
3804
|
-
*/
|
|
3805
|
-
function ParseGeometry(geometry) {
|
|
3806
|
-
if (typeof geometry == "string") {
|
|
3807
|
-
let positions = [];
|
|
3808
|
-
const geometryParsed = (geometry || "").split(";");
|
|
3809
|
-
for (let i = 0; i < geometryParsed.length; i++) {
|
|
3810
|
-
const data = geometryParsed[i];
|
|
3811
|
-
const points = ParsePoints(data);
|
|
3812
|
-
if (points && points.length > 0) {
|
|
3813
|
-
positions = positions.concat(points);
|
|
3814
|
-
}
|
|
3815
|
-
}
|
|
3816
|
-
positions = RemoveRepeatPoints(positions);
|
|
3817
|
-
const newGeometry = {};
|
|
3818
|
-
if (positions.length > 0) {
|
|
3819
|
-
const topPoint = positions[0];
|
|
3820
|
-
newGeometry.Point = `${topPoint.latitude},${topPoint.longitude}` + (topPoint.altitude != null ? `,${topPoint.altitude}` : "");
|
|
3821
|
-
if (positions.length > 1) {
|
|
3822
|
-
newGeometry.Polygon = [{ Facing: EPolygonRingType.Boundaries, LinearRing: LineStrFromPoints(positions) }];
|
|
3823
|
-
}
|
|
3824
|
-
if (positions.length > 2) {
|
|
3825
|
-
newGeometry.LineString = LineStrFromPoints(positions);
|
|
3826
|
-
}
|
|
3827
|
-
}
|
|
3828
|
-
return newGeometry;
|
|
3829
|
-
}
|
|
3830
|
-
return geometry;
|
|
3831
|
-
}
|
|
3832
|
-
Geometry.ParseGeometry = ParseGeometry;
|
|
3833
|
-
function ToGeoJson(params) {
|
|
3834
|
-
const { entities, excludeAltitude } = params;
|
|
3835
|
-
const features = [];
|
|
3836
|
-
const processGeometry = (geometry, ID) => {
|
|
3837
|
-
if (geometry.Polygon) {
|
|
3838
|
-
const sortedPolygons = geometry.Polygon.sort((a, b) => a.Facing === EPolygonRingType.Boundaries ? -1 : 1);
|
|
3839
|
-
const coordinates = sortedPolygons.map(polygonRing => polygonRing.LinearRing.split(' ').map(coord => {
|
|
3840
|
-
const [lon, lat, alt] = coord.split(',').map(Number);
|
|
3841
|
-
return excludeAltitude ? [lon, lat] : [lon, lat, ...(alt ? [alt] : [])];
|
|
3842
|
-
}));
|
|
3843
|
-
features.push({
|
|
3844
|
-
type: 'Feature',
|
|
3845
|
-
properties: { ID },
|
|
3846
|
-
geometry: {
|
|
3847
|
-
type: 'Polygon',
|
|
3848
|
-
coordinates: coordinates,
|
|
3849
|
-
}
|
|
3850
|
-
});
|
|
3851
|
-
}
|
|
3852
|
-
if (geometry.Point) {
|
|
3853
|
-
const [lon, lat, alt] = geometry.Point.split(',').map(Number);
|
|
3854
|
-
const coordinates = excludeAltitude ? [lon, lat] : [lon, lat, ...(alt ? [alt] : [])];
|
|
3855
|
-
features.push({
|
|
3856
|
-
type: 'Feature',
|
|
3857
|
-
properties: { ID },
|
|
3858
|
-
geometry: {
|
|
3859
|
-
type: 'Point',
|
|
3860
|
-
coordinates,
|
|
3861
|
-
}
|
|
3862
|
-
});
|
|
3863
|
-
}
|
|
3864
|
-
if (geometry.LineString) {
|
|
3865
|
-
const coordinates = geometry.LineString.split(' ').map(coord => {
|
|
3866
|
-
const [lon, lat, alt] = coord.split(',').map(Number);
|
|
3867
|
-
return excludeAltitude ? [lon, lat] : [lon, lat, ...(alt ? [alt] : [])];
|
|
3868
|
-
});
|
|
3869
|
-
features.push({
|
|
3870
|
-
type: 'Feature',
|
|
3871
|
-
properties: { ID },
|
|
3872
|
-
geometry: {
|
|
3873
|
-
type: 'LineString',
|
|
3874
|
-
coordinates,
|
|
3875
|
-
}
|
|
3876
|
-
});
|
|
3877
|
-
}
|
|
3878
|
-
if (geometry.MultiGeometry) {
|
|
3879
|
-
geometry.MultiGeometry.forEach(geo => processGeometry(geo, ID));
|
|
3880
|
-
}
|
|
3881
|
-
};
|
|
3882
|
-
entities.forEach(entity => {
|
|
3883
|
-
var _a, _b, _c;
|
|
3884
|
-
if (!((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID)) {
|
|
3885
|
-
return;
|
|
3886
|
-
}
|
|
3887
|
-
let geometry = entity.geometry;
|
|
3888
|
-
if (!geometry && (((_b = entity.location) === null || _b === void 0 ? void 0 : _b.longitude) && ((_c = entity.location) === null || _c === void 0 ? void 0 : _c.latitude))) {
|
|
3889
|
-
geometry = {
|
|
3890
|
-
Point: `${entity.location.longitude},${entity.location.latitude}` + (entity.location.altitude != null ? `,${entity.location.altitude}` : ""),
|
|
3891
|
-
};
|
|
3892
|
-
}
|
|
3893
|
-
processGeometry(geometry, entity.Bruce.ID);
|
|
3894
|
-
});
|
|
3895
|
-
return {
|
|
3896
|
-
type: 'FeatureCollection',
|
|
3897
|
-
features,
|
|
3898
|
-
};
|
|
3899
|
-
}
|
|
3900
|
-
Geometry.ToGeoJson = ToGeoJson;
|
|
3901
|
-
})(exports.Geometry || (exports.Geometry = {}));
|
|
3902
|
-
|
|
3903
3971
|
(function (Bounds) {
|
|
3904
3972
|
/**
|
|
3905
3973
|
* Calculates boundaries from entity.
|
|
@@ -6908,27 +6976,6 @@
|
|
|
6908
6976
|
ProgramKey.Update = Update;
|
|
6909
6977
|
})(exports.ProgramKey || (exports.ProgramKey = {}));
|
|
6910
6978
|
|
|
6911
|
-
/**
|
|
6912
|
-
* Describes an expectation on what should be rendered for a menu item-
|
|
6913
|
-
* between a min-max distance of an entity to the camera.
|
|
6914
|
-
*/
|
|
6915
|
-
(function (ZoomControl) {
|
|
6916
|
-
/**
|
|
6917
|
-
* Available display types for a menu item.
|
|
6918
|
-
*/
|
|
6919
|
-
let EDisplayType;
|
|
6920
|
-
(function (EDisplayType) {
|
|
6921
|
-
// Hidden means it will not be rendered.
|
|
6922
|
-
EDisplayType["Hidden"] = "hidden";
|
|
6923
|
-
// Point will try render a point based on any available Entity data.
|
|
6924
|
-
EDisplayType["Point"] = "point";
|
|
6925
|
-
// Geometry means it will try render multi-geometry, polygon, polyline, or point in order of priority.
|
|
6926
|
-
EDisplayType["Geometry"] = "geometry";
|
|
6927
|
-
// 3D means it will try render 3D model, multi-geometry, polygon, polyline, or point in order of priority.
|
|
6928
|
-
EDisplayType["Model3D"] = "3d";
|
|
6929
|
-
})(EDisplayType = ZoomControl.EDisplayType || (ZoomControl.EDisplayType = {}));
|
|
6930
|
-
})(exports.ZoomControl || (exports.ZoomControl = {}));
|
|
6931
|
-
|
|
6932
6979
|
(function (Tileset) {
|
|
6933
6980
|
/**
|
|
6934
6981
|
* Returns cache identifier for a tileset.
|
|
@@ -10525,7 +10572,7 @@
|
|
|
10525
10572
|
DataSource.GetList = GetList;
|
|
10526
10573
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
10527
10574
|
|
|
10528
|
-
const VERSION = "3.4.
|
|
10575
|
+
const VERSION = "3.4.5";
|
|
10529
10576
|
|
|
10530
10577
|
exports.VERSION = VERSION;
|
|
10531
10578
|
exports.AbstractApi = AbstractApi;
|