bruce-models 1.1.5 → 1.1.7
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 +180 -121
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +177 -119
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/abstract-api.js +1 -1
- package/dist/lib/api/abstract-api.js.map +1 -1
- package/dist/lib/api/api.js +2 -1
- package/dist/lib/api/api.js.map +1 -1
- package/dist/lib/common/bounds.js +59 -0
- package/dist/lib/common/bounds.js.map +1 -1
- package/dist/types/api/api.d.ts +1 -1
- package/dist/types/common/bounds.d.ts +7 -0
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -74,7 +74,8 @@ var Api;
|
|
|
74
74
|
EEnv["UAT"] = "UAT";
|
|
75
75
|
EEnv["PROD"] = "PROD";
|
|
76
76
|
})(EEnv = Api.EEnv || (Api.EEnv = {}));
|
|
77
|
-
|
|
77
|
+
// False = cache is enabled by default for req-params.
|
|
78
|
+
Api.DEFAULT_NO_CACHE = false;
|
|
78
79
|
/**
|
|
79
80
|
* Prepares a string to be included in a url.
|
|
80
81
|
* @param str
|
|
@@ -463,7 +464,7 @@ class AbstractApi {
|
|
|
463
464
|
GetCacheItem(key, reqParams) {
|
|
464
465
|
let noCache = reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache;
|
|
465
466
|
if (noCache == null) {
|
|
466
|
-
noCache = Api.
|
|
467
|
+
noCache = Api.DEFAULT_NO_CACHE;
|
|
467
468
|
}
|
|
468
469
|
if (noCache) {
|
|
469
470
|
return null;
|
|
@@ -1965,6 +1966,182 @@ var Calculator;
|
|
|
1965
1966
|
Calculator.GetInputValue = GetInputValue;
|
|
1966
1967
|
})(Calculator || (Calculator = {}));
|
|
1967
1968
|
|
|
1969
|
+
/**
|
|
1970
|
+
* Describes vector geometry that Bruce uses.
|
|
1971
|
+
*/
|
|
1972
|
+
var Geometry;
|
|
1973
|
+
(function (Geometry) {
|
|
1974
|
+
let EPolygonRingType;
|
|
1975
|
+
(function (EPolygonRingType) {
|
|
1976
|
+
EPolygonRingType["Boundaries"] = "out";
|
|
1977
|
+
EPolygonRingType["Hole"] = "in";
|
|
1978
|
+
})(EPolygonRingType = Geometry.EPolygonRingType || (Geometry.EPolygonRingType = {}));
|
|
1979
|
+
/**
|
|
1980
|
+
* Turns an array of points into string vector geometry that Bruce can use.
|
|
1981
|
+
* This is used for saving polyline and polygon data.
|
|
1982
|
+
* @param points
|
|
1983
|
+
* @returns
|
|
1984
|
+
*/
|
|
1985
|
+
function LineStrFromPoints(points) {
|
|
1986
|
+
if (!points.length) {
|
|
1987
|
+
throw ("points is empty.");
|
|
1988
|
+
}
|
|
1989
|
+
let carto = points[0];
|
|
1990
|
+
let lineString = `${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
|
|
1991
|
+
for (let i = 1; i < points.length; i++) {
|
|
1992
|
+
carto = points[i];
|
|
1993
|
+
lineString += ` ${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
|
|
1994
|
+
}
|
|
1995
|
+
return lineString;
|
|
1996
|
+
}
|
|
1997
|
+
Geometry.LineStrFromPoints = LineStrFromPoints;
|
|
1998
|
+
/**
|
|
1999
|
+
* Removes same points that occur in a row.
|
|
2000
|
+
* This will not modify the original array.
|
|
2001
|
+
* @param positions
|
|
2002
|
+
* @returns
|
|
2003
|
+
*/
|
|
2004
|
+
function RemoveRepeatPoints(positions) {
|
|
2005
|
+
const filteredList = [];
|
|
2006
|
+
for (let i = 0; i < positions.length; i++) {
|
|
2007
|
+
const pos = positions[i];
|
|
2008
|
+
const lastPos = filteredList.length > 0 ? filteredList[filteredList.length - 1] : null;
|
|
2009
|
+
if (!lastPos || (pos.latitude != lastPos.latitude || pos.longitude != lastPos.longitude || pos.altitude != lastPos.altitude)) {
|
|
2010
|
+
filteredList.push(pos);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
return filteredList;
|
|
2014
|
+
}
|
|
2015
|
+
Geometry.RemoveRepeatPoints = RemoveRepeatPoints;
|
|
2016
|
+
function ParsePoints(data) {
|
|
2017
|
+
data = data.replace(/[^\d.,-\s]/g, "");
|
|
2018
|
+
let splitterCoordinates = " ";
|
|
2019
|
+
let splitterAxis = ",";
|
|
2020
|
+
const commaIndex = data.indexOf(",");
|
|
2021
|
+
const spaceIndex = data.indexOf(" ");
|
|
2022
|
+
if ((spaceIndex > -1 && commaIndex > spaceIndex) || commaIndex <= -1) {
|
|
2023
|
+
splitterCoordinates = ",";
|
|
2024
|
+
splitterAxis = " ";
|
|
2025
|
+
}
|
|
2026
|
+
let points = data.trim().split(splitterCoordinates);
|
|
2027
|
+
points = points.filter(a => a != "");
|
|
2028
|
+
const result = [];
|
|
2029
|
+
for (let i = 0; i < points.length; i++) {
|
|
2030
|
+
const pointData = points[i];
|
|
2031
|
+
const coords = pointData.trim().split(splitterAxis);
|
|
2032
|
+
if (coords.length == 2 || coords.length == 3) {
|
|
2033
|
+
const longitude = Number(coords[0]);
|
|
2034
|
+
const latitude = Number(coords[1]);
|
|
2035
|
+
const altitude = Number(coords.length >= 3 ? coords[2] : 0);
|
|
2036
|
+
if (longitude != null && latitude != null) {
|
|
2037
|
+
result.push({
|
|
2038
|
+
altitude: altitude,
|
|
2039
|
+
latitude: latitude,
|
|
2040
|
+
longitude: longitude
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
2043
|
+
else {
|
|
2044
|
+
console.warn("Invalid point data detected.", pointData);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
return result;
|
|
2049
|
+
}
|
|
2050
|
+
Geometry.ParsePoints = ParsePoints;
|
|
2051
|
+
/**
|
|
2052
|
+
* Parses both string and object Bruce geometry.
|
|
2053
|
+
* String geometry is legacy Bruce data.
|
|
2054
|
+
* @param geometry
|
|
2055
|
+
* @returns
|
|
2056
|
+
*/
|
|
2057
|
+
function ParseGeometry(geometry) {
|
|
2058
|
+
if (typeof geometry == "string") {
|
|
2059
|
+
let positions = [];
|
|
2060
|
+
const geometryParsed = (geometry || "").split(";");
|
|
2061
|
+
for (let i = 0; i < geometryParsed.length; i++) {
|
|
2062
|
+
const data = geometryParsed[i];
|
|
2063
|
+
const points = ParsePoints(data);
|
|
2064
|
+
if (points && points.length > 0) {
|
|
2065
|
+
positions = positions.concat(points);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
positions = RemoveRepeatPoints(positions);
|
|
2069
|
+
const newGeometry = {};
|
|
2070
|
+
if (positions.length > 0) {
|
|
2071
|
+
const topPoint = positions[0];
|
|
2072
|
+
newGeometry.Point = `${topPoint.latitude},${topPoint.longitude}` + (topPoint.altitude != null ? `,${topPoint.altitude}` : "");
|
|
2073
|
+
if (positions.length > 1) {
|
|
2074
|
+
newGeometry.Polygon = [{ Facing: EPolygonRingType.Boundaries, LinearRing: LineStrFromPoints(positions) }];
|
|
2075
|
+
}
|
|
2076
|
+
if (positions.length > 2) {
|
|
2077
|
+
newGeometry.LineString = LineStrFromPoints(positions);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
return newGeometry;
|
|
2081
|
+
}
|
|
2082
|
+
return geometry;
|
|
2083
|
+
}
|
|
2084
|
+
Geometry.ParseGeometry = ParseGeometry;
|
|
2085
|
+
})(Geometry || (Geometry = {}));
|
|
2086
|
+
|
|
2087
|
+
var Bounds;
|
|
2088
|
+
(function (Bounds) {
|
|
2089
|
+
/**
|
|
2090
|
+
* Calculates boundaries from entity.
|
|
2091
|
+
* This will not use the set entity boundaries and instead calculate from geometry and location.
|
|
2092
|
+
* @param entity
|
|
2093
|
+
*/
|
|
2094
|
+
function FromEntity(entity) {
|
|
2095
|
+
const bounds = {
|
|
2096
|
+
maxAltitude: null,
|
|
2097
|
+
maxLatitude: null,
|
|
2098
|
+
maxLongitude: null,
|
|
2099
|
+
minAltitude: null,
|
|
2100
|
+
minLatitude: null,
|
|
2101
|
+
minLongitude: null
|
|
2102
|
+
};
|
|
2103
|
+
const points = [];
|
|
2104
|
+
if (entity.location) {
|
|
2105
|
+
points.push(entity.location);
|
|
2106
|
+
}
|
|
2107
|
+
if (entity.geometry) {
|
|
2108
|
+
if (entity.geometry.Point) {
|
|
2109
|
+
points.push(...Geometry.ParsePoints(entity.geometry.Point));
|
|
2110
|
+
}
|
|
2111
|
+
if (entity.geometry.LineString) {
|
|
2112
|
+
points.push(...Geometry.ParsePoints(entity.geometry.LineString));
|
|
2113
|
+
}
|
|
2114
|
+
if (entity.geometry.Polygon) {
|
|
2115
|
+
for (const ring of entity.geometry.Polygon) {
|
|
2116
|
+
points.push(...Geometry.ParsePoints(ring.LinearRing));
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
for (const point of points) {
|
|
2121
|
+
if (bounds.maxLatitude == null || point.latitude > bounds.maxLatitude) {
|
|
2122
|
+
bounds.maxLatitude = point.latitude;
|
|
2123
|
+
}
|
|
2124
|
+
if (bounds.maxLongitude == null || point.longitude > bounds.maxLongitude) {
|
|
2125
|
+
bounds.maxLongitude = point.longitude;
|
|
2126
|
+
}
|
|
2127
|
+
if (bounds.maxAltitude == null || point.altitude > bounds.maxAltitude) {
|
|
2128
|
+
bounds.maxAltitude = point.altitude;
|
|
2129
|
+
}
|
|
2130
|
+
if (bounds.minLatitude == null || point.latitude < bounds.minLatitude) {
|
|
2131
|
+
bounds.minLatitude = point.latitude;
|
|
2132
|
+
}
|
|
2133
|
+
if (bounds.minLongitude == null || point.longitude < bounds.minLongitude) {
|
|
2134
|
+
bounds.minLongitude = point.longitude;
|
|
2135
|
+
}
|
|
2136
|
+
if (bounds.minAltitude == null || point.altitude < bounds.minAltitude) {
|
|
2137
|
+
bounds.minAltitude = point.altitude;
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
return bounds;
|
|
2141
|
+
}
|
|
2142
|
+
Bounds.FromEntity = FromEntity;
|
|
2143
|
+
})(Bounds || (Bounds = {}));
|
|
2144
|
+
|
|
1968
2145
|
/**
|
|
1969
2146
|
* Simple event utility.
|
|
1970
2147
|
* Instantiate the model, then subscribe and trigger events.
|
|
@@ -2249,124 +2426,6 @@ class DelayQueue {
|
|
|
2249
2426
|
}
|
|
2250
2427
|
}
|
|
2251
2428
|
|
|
2252
|
-
/**
|
|
2253
|
-
* Describes vector geometry that Bruce uses.
|
|
2254
|
-
*/
|
|
2255
|
-
var Geometry;
|
|
2256
|
-
(function (Geometry) {
|
|
2257
|
-
let EPolygonRingType;
|
|
2258
|
-
(function (EPolygonRingType) {
|
|
2259
|
-
EPolygonRingType["Boundaries"] = "out";
|
|
2260
|
-
EPolygonRingType["Hole"] = "in";
|
|
2261
|
-
})(EPolygonRingType = Geometry.EPolygonRingType || (Geometry.EPolygonRingType = {}));
|
|
2262
|
-
/**
|
|
2263
|
-
* Turns an array of points into string vector geometry that Bruce can use.
|
|
2264
|
-
* This is used for saving polyline and polygon data.
|
|
2265
|
-
* @param points
|
|
2266
|
-
* @returns
|
|
2267
|
-
*/
|
|
2268
|
-
function LineStrFromPoints(points) {
|
|
2269
|
-
if (!points.length) {
|
|
2270
|
-
throw ("points is empty.");
|
|
2271
|
-
}
|
|
2272
|
-
let carto = points[0];
|
|
2273
|
-
let lineString = `${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
|
|
2274
|
-
for (let i = 1; i < points.length; i++) {
|
|
2275
|
-
carto = points[i];
|
|
2276
|
-
lineString += ` ${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
|
|
2277
|
-
}
|
|
2278
|
-
return lineString;
|
|
2279
|
-
}
|
|
2280
|
-
Geometry.LineStrFromPoints = LineStrFromPoints;
|
|
2281
|
-
/**
|
|
2282
|
-
* Removes same points that occur in a row.
|
|
2283
|
-
* This will not modify the original array.
|
|
2284
|
-
* @param positions
|
|
2285
|
-
* @returns
|
|
2286
|
-
*/
|
|
2287
|
-
function RemoveRepeatPoints(positions) {
|
|
2288
|
-
const filteredList = [];
|
|
2289
|
-
for (let i = 0; i < positions.length; i++) {
|
|
2290
|
-
const pos = positions[i];
|
|
2291
|
-
const lastPos = filteredList.length > 0 ? filteredList[filteredList.length - 1] : null;
|
|
2292
|
-
if (!lastPos || (pos.latitude != lastPos.latitude || pos.longitude != lastPos.longitude || pos.altitude != lastPos.altitude)) {
|
|
2293
|
-
filteredList.push(pos);
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
return filteredList;
|
|
2297
|
-
}
|
|
2298
|
-
Geometry.RemoveRepeatPoints = RemoveRepeatPoints;
|
|
2299
|
-
function ParsePoints(data) {
|
|
2300
|
-
data = data.replace(/[^\d.,-\s]/g, "");
|
|
2301
|
-
let splitterCoordinates = " ";
|
|
2302
|
-
let splitterAxis = ",";
|
|
2303
|
-
const commaIndex = data.indexOf(",");
|
|
2304
|
-
const spaceIndex = data.indexOf(" ");
|
|
2305
|
-
if ((spaceIndex > -1 && commaIndex > spaceIndex) || commaIndex <= -1) {
|
|
2306
|
-
splitterCoordinates = ",";
|
|
2307
|
-
splitterAxis = " ";
|
|
2308
|
-
}
|
|
2309
|
-
let points = data.trim().split(splitterCoordinates);
|
|
2310
|
-
points = points.filter(a => a != "");
|
|
2311
|
-
const result = [];
|
|
2312
|
-
for (let i = 0; i < points.length; i++) {
|
|
2313
|
-
const pointData = points[i];
|
|
2314
|
-
const coords = pointData.trim().split(splitterAxis);
|
|
2315
|
-
if (coords.length == 2 || coords.length == 3) {
|
|
2316
|
-
const longitude = Number(coords[0]);
|
|
2317
|
-
const latitude = Number(coords[1]);
|
|
2318
|
-
const altitude = Number(coords.length >= 3 ? coords[2] : 0);
|
|
2319
|
-
if (longitude != null && latitude != null) {
|
|
2320
|
-
result.push({
|
|
2321
|
-
altitude: altitude,
|
|
2322
|
-
latitude: latitude,
|
|
2323
|
-
longitude: longitude
|
|
2324
|
-
});
|
|
2325
|
-
}
|
|
2326
|
-
else {
|
|
2327
|
-
console.warn("Invalid point data detected.", pointData);
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
}
|
|
2331
|
-
return result;
|
|
2332
|
-
}
|
|
2333
|
-
Geometry.ParsePoints = ParsePoints;
|
|
2334
|
-
/**
|
|
2335
|
-
* Parses both string and object Bruce geometry.
|
|
2336
|
-
* String geometry is legacy Bruce data.
|
|
2337
|
-
* @param geometry
|
|
2338
|
-
* @returns
|
|
2339
|
-
*/
|
|
2340
|
-
function ParseGeometry(geometry) {
|
|
2341
|
-
if (typeof geometry == "string") {
|
|
2342
|
-
let positions = [];
|
|
2343
|
-
const geometryParsed = (geometry || "").split(";");
|
|
2344
|
-
for (let i = 0; i < geometryParsed.length; i++) {
|
|
2345
|
-
const data = geometryParsed[i];
|
|
2346
|
-
const points = ParsePoints(data);
|
|
2347
|
-
if (points && points.length > 0) {
|
|
2348
|
-
positions = positions.concat(points);
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
positions = RemoveRepeatPoints(positions);
|
|
2352
|
-
const newGeometry = {};
|
|
2353
|
-
if (positions.length > 0) {
|
|
2354
|
-
const topPoint = positions[0];
|
|
2355
|
-
newGeometry.Point = `${topPoint.latitude},${topPoint.longitude}` + (topPoint.altitude != null ? `,${topPoint.altitude}` : "");
|
|
2356
|
-
if (positions.length > 1) {
|
|
2357
|
-
newGeometry.Polygon = [{ Facing: EPolygonRingType.Boundaries, LinearRing: LineStrFromPoints(positions) }];
|
|
2358
|
-
}
|
|
2359
|
-
if (positions.length > 2) {
|
|
2360
|
-
newGeometry.LineString = LineStrFromPoints(positions);
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
return newGeometry;
|
|
2364
|
-
}
|
|
2365
|
-
return geometry;
|
|
2366
|
-
}
|
|
2367
|
-
Geometry.ParseGeometry = ParseGeometry;
|
|
2368
|
-
})(Geometry || (Geometry = {}));
|
|
2369
|
-
|
|
2370
2429
|
/**
|
|
2371
2430
|
* Describes a Bruce stored date.
|
|
2372
2431
|
*/
|
|
@@ -6110,5 +6169,5 @@ var Markup;
|
|
|
6110
6169
|
})(Entity3d = Markup.Entity3d || (Markup.Entity3d = {}));
|
|
6111
6170
|
})(Markup || (Markup = {}));
|
|
6112
6171
|
|
|
6113
|
-
export { AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, Calculator, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, Style, TilesetEntitiesMapTiles, TilesetExtMapTiles, Tileset, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup };
|
|
6172
|
+
export { AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, Style, TilesetEntitiesMapTiles, TilesetExtMapTiles, Tileset, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup };
|
|
6114
6173
|
//# sourceMappingURL=bruce-models.es5.js.map
|