bruce-models 1.1.6 → 1.1.8

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.
@@ -1966,6 +1966,182 @@ var Calculator;
1966
1966
  Calculator.GetInputValue = GetInputValue;
1967
1967
  })(Calculator || (Calculator = {}));
1968
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
+
1969
2145
  /**
1970
2146
  * Simple event utility.
1971
2147
  * Instantiate the model, then subscribe and trigger events.
@@ -2250,124 +2426,6 @@ class DelayQueue {
2250
2426
  }
2251
2427
  }
2252
2428
 
2253
- /**
2254
- * Describes vector geometry that Bruce uses.
2255
- */
2256
- var Geometry;
2257
- (function (Geometry) {
2258
- let EPolygonRingType;
2259
- (function (EPolygonRingType) {
2260
- EPolygonRingType["Boundaries"] = "out";
2261
- EPolygonRingType["Hole"] = "in";
2262
- })(EPolygonRingType = Geometry.EPolygonRingType || (Geometry.EPolygonRingType = {}));
2263
- /**
2264
- * Turns an array of points into string vector geometry that Bruce can use.
2265
- * This is used for saving polyline and polygon data.
2266
- * @param points
2267
- * @returns
2268
- */
2269
- function LineStrFromPoints(points) {
2270
- if (!points.length) {
2271
- throw ("points is empty.");
2272
- }
2273
- let carto = points[0];
2274
- let lineString = `${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
2275
- for (let i = 1; i < points.length; i++) {
2276
- carto = points[i];
2277
- lineString += ` ${carto.longitude},${carto.latitude}` + (carto.altitude != null ? `,${carto.altitude}` : "");
2278
- }
2279
- return lineString;
2280
- }
2281
- Geometry.LineStrFromPoints = LineStrFromPoints;
2282
- /**
2283
- * Removes same points that occur in a row.
2284
- * This will not modify the original array.
2285
- * @param positions
2286
- * @returns
2287
- */
2288
- function RemoveRepeatPoints(positions) {
2289
- const filteredList = [];
2290
- for (let i = 0; i < positions.length; i++) {
2291
- const pos = positions[i];
2292
- const lastPos = filteredList.length > 0 ? filteredList[filteredList.length - 1] : null;
2293
- if (!lastPos || (pos.latitude != lastPos.latitude || pos.longitude != lastPos.longitude || pos.altitude != lastPos.altitude)) {
2294
- filteredList.push(pos);
2295
- }
2296
- }
2297
- return filteredList;
2298
- }
2299
- Geometry.RemoveRepeatPoints = RemoveRepeatPoints;
2300
- function ParsePoints(data) {
2301
- data = data.replace(/[^\d.,-\s]/g, "");
2302
- let splitterCoordinates = " ";
2303
- let splitterAxis = ",";
2304
- const commaIndex = data.indexOf(",");
2305
- const spaceIndex = data.indexOf(" ");
2306
- if ((spaceIndex > -1 && commaIndex > spaceIndex) || commaIndex <= -1) {
2307
- splitterCoordinates = ",";
2308
- splitterAxis = " ";
2309
- }
2310
- let points = data.trim().split(splitterCoordinates);
2311
- points = points.filter(a => a != "");
2312
- const result = [];
2313
- for (let i = 0; i < points.length; i++) {
2314
- const pointData = points[i];
2315
- const coords = pointData.trim().split(splitterAxis);
2316
- if (coords.length == 2 || coords.length == 3) {
2317
- const longitude = Number(coords[0]);
2318
- const latitude = Number(coords[1]);
2319
- const altitude = Number(coords.length >= 3 ? coords[2] : 0);
2320
- if (longitude != null && latitude != null) {
2321
- result.push({
2322
- altitude: altitude,
2323
- latitude: latitude,
2324
- longitude: longitude
2325
- });
2326
- }
2327
- else {
2328
- console.warn("Invalid point data detected.", pointData);
2329
- }
2330
- }
2331
- }
2332
- return result;
2333
- }
2334
- Geometry.ParsePoints = ParsePoints;
2335
- /**
2336
- * Parses both string and object Bruce geometry.
2337
- * String geometry is legacy Bruce data.
2338
- * @param geometry
2339
- * @returns
2340
- */
2341
- function ParseGeometry(geometry) {
2342
- if (typeof geometry == "string") {
2343
- let positions = [];
2344
- const geometryParsed = (geometry || "").split(";");
2345
- for (let i = 0; i < geometryParsed.length; i++) {
2346
- const data = geometryParsed[i];
2347
- const points = ParsePoints(data);
2348
- if (points && points.length > 0) {
2349
- positions = positions.concat(points);
2350
- }
2351
- }
2352
- positions = RemoveRepeatPoints(positions);
2353
- const newGeometry = {};
2354
- if (positions.length > 0) {
2355
- const topPoint = positions[0];
2356
- newGeometry.Point = `${topPoint.latitude},${topPoint.longitude}` + (topPoint.altitude != null ? `,${topPoint.altitude}` : "");
2357
- if (positions.length > 1) {
2358
- newGeometry.Polygon = [{ Facing: EPolygonRingType.Boundaries, LinearRing: LineStrFromPoints(positions) }];
2359
- }
2360
- if (positions.length > 2) {
2361
- newGeometry.LineString = LineStrFromPoints(positions);
2362
- }
2363
- }
2364
- return newGeometry;
2365
- }
2366
- return geometry;
2367
- }
2368
- Geometry.ParseGeometry = ParseGeometry;
2369
- })(Geometry || (Geometry = {}));
2370
-
2371
2429
  /**
2372
2430
  * Describes a Bruce stored date.
2373
2431
  */
@@ -2490,7 +2548,7 @@ var EntityAttachment;
2490
2548
  throw ("Entity ID, Type ID, and File ID are required.");
2491
2549
  }
2492
2550
  const url = `entity/${data["Entity.ID"]}/attachment/${data["EntityAttachmentType.ID"]}/${data["ClientFile.ID"]}`;
2493
- data = yield api.POST(url, data, Api.PrepReqParams(reqParams));
2551
+ data = yield api.PUT(url, data, Api.PrepReqParams(reqParams));
2494
2552
  api.Cache.Remove(GetCacheKey(data["Entity.ID"], data["EntityAttachmentType.ID"], data["ClientFile.ID"]));
2495
2553
  api.Cache.RemoveByStartsWith(GetListCacheKey(data["Entity.ID"]));
2496
2554
  return data;
@@ -6111,5 +6169,5 @@ var Markup;
6111
6169
  })(Entity3d = Markup.Entity3d || (Markup.Entity3d = {}));
6112
6170
  })(Markup || (Markup = {}));
6113
6171
 
6114
- 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 };
6115
6173
  //# sourceMappingURL=bruce-models.es5.js.map