@loaders.gl/i3s 4.0.0-alpha.5 → 4.0.0-alpha.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.
Files changed (209) hide show
  1. package/dist/arcgis-webscene-loader.d.ts +7 -0
  2. package/dist/arcgis-webscene-loader.d.ts.map +1 -0
  3. package/dist/arcgis-webscene-loader.js +28 -0
  4. package/dist/bundle.js +2 -2
  5. package/dist/dist.min.js +9390 -8570
  6. package/dist/es5/arcgis-webscene-loader.js +40 -0
  7. package/dist/es5/arcgis-webscene-loader.js.map +1 -0
  8. package/dist/es5/bundle.js +6 -0
  9. package/dist/es5/bundle.js.map +1 -0
  10. package/dist/es5/i3s-attribute-loader.js +195 -0
  11. package/dist/es5/i3s-attribute-loader.js.map +1 -0
  12. package/dist/es5/i3s-building-scene-layer-loader.js +46 -0
  13. package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -0
  14. package/dist/es5/i3s-content-loader.js +56 -0
  15. package/dist/es5/i3s-content-loader.js.map +1 -0
  16. package/dist/es5/i3s-loader.js +193 -0
  17. package/dist/es5/i3s-loader.js.map +1 -0
  18. package/dist/es5/i3s-node-page-loader.js +39 -0
  19. package/dist/es5/i3s-node-page-loader.js.map +1 -0
  20. package/dist/es5/i3s-slpk-loader.js +20 -0
  21. package/dist/es5/i3s-slpk-loader.js.map +1 -0
  22. package/dist/es5/index.js +68 -0
  23. package/dist/es5/index.js.map +1 -0
  24. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +312 -0
  25. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -0
  26. package/dist/es5/lib/parsers/constants.js +72 -0
  27. package/dist/es5/lib/parsers/constants.js.map +1 -0
  28. package/dist/es5/lib/parsers/parse-arcgis-webscene.js +158 -0
  29. package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -0
  30. package/dist/es5/lib/parsers/parse-i3s-attribute.js +76 -0
  31. package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -0
  32. package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +65 -0
  33. package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
  34. package/dist/es5/lib/parsers/parse-i3s-tile-content.js +510 -0
  35. package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -0
  36. package/dist/es5/lib/parsers/parse-i3s.js +116 -0
  37. package/dist/es5/lib/parsers/parse-i3s.js.map +1 -0
  38. package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +94 -0
  39. package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -0
  40. package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +112 -0
  41. package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -0
  42. package/dist/es5/lib/parsers/parse-zip/cd-file-header.js +44 -0
  43. package/dist/es5/lib/parsers/parse-zip/cd-file-header.js.map +1 -0
  44. package/dist/es5/lib/parsers/parse-zip/local-file-header.js +26 -0
  45. package/dist/es5/lib/parsers/parse-zip/local-file-header.js.map +1 -0
  46. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +17 -0
  47. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -0
  48. package/dist/es5/lib/utils/customizeColors.js +159 -0
  49. package/dist/es5/lib/utils/customizeColors.js.map +1 -0
  50. package/dist/es5/lib/utils/url-utils.js +33 -0
  51. package/dist/es5/lib/utils/url-utils.js.map +1 -0
  52. package/dist/es5/types.js +26 -0
  53. package/dist/es5/types.js.map +1 -0
  54. package/dist/es5/workers/i3s-content-worker-node.js +7 -0
  55. package/dist/es5/workers/i3s-content-worker-node.js.map +1 -0
  56. package/dist/es5/workers/i3s-content-worker.js +6 -0
  57. package/dist/es5/workers/i3s-content-worker.js.map +1 -0
  58. package/dist/esm/arcgis-webscene-loader.js +16 -0
  59. package/dist/esm/arcgis-webscene-loader.js.map +1 -0
  60. package/dist/esm/bundle.js +4 -0
  61. package/dist/esm/bundle.js.map +1 -0
  62. package/dist/esm/i3s-attribute-loader.js +119 -0
  63. package/dist/esm/i3s-attribute-loader.js.map +1 -0
  64. package/dist/esm/i3s-building-scene-layer-loader.js +19 -0
  65. package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -0
  66. package/dist/esm/i3s-content-loader.js +30 -0
  67. package/dist/esm/i3s-content-loader.js.map +1 -0
  68. package/dist/esm/i3s-loader.js +87 -0
  69. package/dist/esm/i3s-loader.js.map +1 -0
  70. package/dist/esm/i3s-node-page-loader.js +15 -0
  71. package/dist/esm/i3s-node-page-loader.js.map +1 -0
  72. package/dist/esm/i3s-slpk-loader.js +13 -0
  73. package/dist/esm/i3s-slpk-loader.js.map +1 -0
  74. package/dist/esm/index.js +9 -0
  75. package/dist/esm/index.js.map +1 -0
  76. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +198 -0
  77. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -0
  78. package/dist/esm/lib/parsers/constants.js +57 -0
  79. package/dist/esm/lib/parsers/constants.js.map +1 -0
  80. package/dist/esm/lib/parsers/parse-arcgis-webscene.js +70 -0
  81. package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -0
  82. package/dist/esm/lib/parsers/parse-i3s-attribute.js +60 -0
  83. package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -0
  84. package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +39 -0
  85. package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
  86. package/dist/esm/lib/parsers/parse-i3s-tile-content.js +435 -0
  87. package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -0
  88. package/dist/esm/lib/parsers/parse-i3s.js +83 -0
  89. package/dist/esm/lib/parsers/parse-i3s.js.map +1 -0
  90. package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js +37 -0
  91. package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +1 -0
  92. package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js +58 -0
  93. package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -0
  94. package/dist/esm/lib/parsers/parse-zip/cd-file-header.js +37 -0
  95. package/dist/esm/lib/parsers/parse-zip/cd-file-header.js.map +1 -0
  96. package/dist/esm/lib/parsers/parse-zip/local-file-header.js +19 -0
  97. package/dist/esm/lib/parsers/parse-zip/local-file-header.js.map +1 -0
  98. package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js +9 -0
  99. package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -0
  100. package/dist/esm/lib/utils/customizeColors.js +92 -0
  101. package/dist/esm/lib/utils/customizeColors.js.map +1 -0
  102. package/dist/esm/lib/utils/url-utils.js +28 -0
  103. package/dist/esm/lib/utils/url-utils.js.map +1 -0
  104. package/dist/esm/types.js +18 -0
  105. package/dist/esm/types.js.map +1 -0
  106. package/dist/esm/workers/i3s-content-worker-node.js +5 -0
  107. package/dist/esm/workers/i3s-content-worker-node.js.map +1 -0
  108. package/dist/esm/workers/i3s-content-worker.js +4 -0
  109. package/dist/esm/workers/i3s-content-worker.js.map +1 -0
  110. package/dist/i3s-attribute-loader.d.ts +9 -2
  111. package/dist/i3s-attribute-loader.d.ts.map +1 -1
  112. package/dist/i3s-attribute-loader.js +155 -132
  113. package/dist/i3s-building-scene-layer-loader.js +23 -18
  114. package/dist/i3s-content-loader.d.ts.map +1 -1
  115. package/dist/i3s-content-loader.js +29 -22
  116. package/dist/i3s-content-worker-node.js +197 -0
  117. package/dist/i3s-content-worker-node.js.map +7 -0
  118. package/dist/i3s-content-worker.js +1178 -1137
  119. package/dist/i3s-loader.d.ts +5 -0
  120. package/dist/i3s-loader.d.ts.map +1 -1
  121. package/dist/i3s-loader.js +88 -83
  122. package/dist/i3s-node-page-loader.d.ts +3 -2
  123. package/dist/i3s-node-page-loader.d.ts.map +1 -1
  124. package/dist/i3s-node-page-loader.js +20 -20
  125. package/dist/i3s-slpk-loader.d.ts +10 -0
  126. package/dist/i3s-slpk-loader.d.ts.map +1 -0
  127. package/dist/i3s-slpk-loader.js +20 -0
  128. package/dist/index.d.ts +5 -2
  129. package/dist/index.d.ts.map +1 -1
  130. package/dist/index.js +21 -6
  131. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +1 -0
  132. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
  133. package/dist/lib/helpers/i3s-nodepages-tiles.js +231 -228
  134. package/dist/lib/parsers/constants.js +85 -63
  135. package/dist/lib/parsers/parse-arcgis-webscene.d.ts +7 -0
  136. package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -0
  137. package/dist/lib/parsers/parse-arcgis-webscene.js +88 -0
  138. package/dist/lib/parsers/parse-i3s-attribute.d.ts +6 -4
  139. package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -1
  140. package/dist/lib/parsers/parse-i3s-attribute.js +87 -62
  141. package/dist/lib/parsers/parse-i3s-building-scene-layer.js +41 -40
  142. package/dist/lib/parsers/parse-i3s-tile-content.d.ts +2 -2
  143. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  144. package/dist/lib/parsers/parse-i3s-tile-content.js +454 -454
  145. package/dist/lib/parsers/parse-i3s.d.ts +1 -1
  146. package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
  147. package/dist/lib/parsers/parse-i3s.js +92 -88
  148. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts +4 -0
  149. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -0
  150. package/dist/lib/parsers/parse-slpk/parse-slpk.js +50 -0
  151. package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts +32 -0
  152. package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -0
  153. package/dist/lib/parsers/parse-slpk/slpk-archieve.js +79 -0
  154. package/dist/lib/parsers/parse-zip/cd-file-header.d.ts +38 -0
  155. package/dist/lib/parsers/parse-zip/cd-file-header.d.ts.map +1 -0
  156. package/dist/lib/parsers/parse-zip/cd-file-header.js +48 -0
  157. package/dist/lib/parsers/parse-zip/local-file-header.d.ts +30 -0
  158. package/dist/lib/parsers/parse-zip/local-file-header.d.ts.map +1 -0
  159. package/dist/lib/parsers/parse-zip/local-file-header.js +28 -0
  160. package/dist/lib/utils/convert-i3s-obb-to-mbs.js +19 -8
  161. package/dist/lib/utils/customizeColors.d.ts +14 -0
  162. package/dist/lib/utils/customizeColors.d.ts.map +1 -0
  163. package/dist/lib/utils/customizeColors.js +94 -0
  164. package/dist/lib/utils/url-utils.js +41 -28
  165. package/dist/types.d.ts +518 -97
  166. package/dist/types.d.ts.map +1 -1
  167. package/dist/types.js +18 -19
  168. package/dist/workers/i3s-content-worker-node.d.ts +2 -0
  169. package/dist/workers/i3s-content-worker-node.d.ts.map +1 -0
  170. package/dist/workers/i3s-content-worker-node.js +7 -0
  171. package/dist/workers/i3s-content-worker.js +5 -4
  172. package/package.json +16 -14
  173. package/src/arcgis-webscene-loader.ts +31 -0
  174. package/src/i3s-attribute-loader.ts +9 -9
  175. package/src/i3s-content-loader.ts +17 -5
  176. package/src/i3s-loader.ts +22 -13
  177. package/src/i3s-node-page-loader.ts +6 -10
  178. package/src/i3s-slpk-loader.ts +25 -0
  179. package/src/index.ts +22 -5
  180. package/src/lib/helpers/i3s-nodepages-tiles.ts +14 -3
  181. package/src/lib/parsers/constants.ts +1 -1
  182. package/src/lib/parsers/parse-arcgis-webscene.ts +102 -0
  183. package/src/lib/parsers/parse-i3s-attribute.ts +21 -14
  184. package/src/lib/parsers/parse-i3s-tile-content.ts +99 -76
  185. package/src/lib/parsers/parse-i3s.ts +8 -3
  186. package/src/lib/parsers/parse-slpk/parse-slpk.ts +61 -0
  187. package/src/lib/parsers/parse-slpk/slpk-archieve.ts +108 -0
  188. package/src/lib/parsers/parse-zip/cd-file-header.ts +93 -0
  189. package/src/lib/parsers/parse-zip/local-file-header.ts +56 -0
  190. package/src/lib/utils/customizeColors.ts +134 -0
  191. package/src/types.ts +482 -33
  192. package/src/workers/i3s-content-worker-node.ts +6 -0
  193. package/dist/bundle.js.map +0 -1
  194. package/dist/i3s-attribute-loader.js.map +0 -1
  195. package/dist/i3s-building-scene-layer-loader.js.map +0 -1
  196. package/dist/i3s-content-loader.js.map +0 -1
  197. package/dist/i3s-loader.js.map +0 -1
  198. package/dist/i3s-node-page-loader.js.map +0 -1
  199. package/dist/index.js.map +0 -1
  200. package/dist/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
  201. package/dist/lib/parsers/constants.js.map +0 -1
  202. package/dist/lib/parsers/parse-i3s-attribute.js.map +0 -1
  203. package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
  204. package/dist/lib/parsers/parse-i3s-tile-content.js.map +0 -1
  205. package/dist/lib/parsers/parse-i3s.js.map +0 -1
  206. package/dist/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
  207. package/dist/lib/utils/url-utils.js.map +0 -1
  208. package/dist/types.js.map +0 -1
  209. package/dist/workers/i3s-content-worker.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-content-worker.js","names":["createLoaderWorker","I3SContentLoader"],"sources":["../../../src/workers/i3s-content-worker.ts"],"sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {I3SContentLoader} from '../i3s-content-loader';\n\ncreateLoaderWorker(I3SContentLoader);\n"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,0BAA0B;AAC3D,SAAQC,gBAAgB,QAAO,uBAAuB;AAEtDD,kBAAkB,CAACC,gBAAgB,CAAC"}
@@ -1,8 +1,9 @@
1
- import type { LoaderWithParser } from '@loaders.gl/loader-utils';
1
+ import type { LoaderOptions, LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ import type { I3STileAttributes } from './lib/parsers/parse-i3s-attribute';
2
3
  /**
3
4
  * Loader for I3S attributes
4
5
  */
5
- export declare const I3SAttributeLoader: LoaderWithParser;
6
+ export declare const I3SAttributeLoader: LoaderWithParser<I3STileAttributes, never, LoaderOptions>;
6
7
  /**
7
8
  * Load attributes based on feature id
8
9
  * @param {Object} tile
@@ -11,4 +12,10 @@ export declare const I3SAttributeLoader: LoaderWithParser;
11
12
  * @returns {Promise}
12
13
  */
13
14
  export declare function loadFeatureAttributes(tile: any, featureId: any, options?: {}): Promise<{} | null>;
15
+ /**
16
+ * Get attribute value type based on property names
17
+ * @param {Object} attribute
18
+ * @returns {String}
19
+ */
20
+ export declare function getAttributeValueType(attribute: any): any;
14
21
  //# sourceMappingURL=i3s-attribute-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-attribute-loader.d.ts","sourceRoot":"","sources":["../src/i3s-attribute-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAU/D;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAUhC,CAAC;AAOF;;;;;;GAMG;AAEH,wBAAsB,qBAAqB,CAAC,IAAI,KAAA,EAAE,SAAS,KAAA,EAAE,OAAO,KAAK,sBA+BxE"}
1
+ {"version":3,"file":"i3s-attribute-loader.d.ts","sourceRoot":"","sources":["../src/i3s-attribute-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAE9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mCAAmC,CAAC;AAUzE;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,iBAAiB,EAAE,KAAK,EAAE,aAAa,CAUxF,CAAC;AAKF;;;;;;GAMG;AAEH,wBAAsB,qBAAqB,CAAC,IAAI,KAAA,EAAE,SAAS,KAAA,EAAE,OAAO,KAAK,sBA+BxE;AAeD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,KAAA,OAO9C"}
@@ -1,152 +1,175 @@
1
- import { load } from '@loaders.gl/core';
2
- import { parseI3STileAttribute } from './lib/parsers/parse-i3s-attribute';
3
- import { getUrlWithToken } from './lib/utils/url-utils';
4
- const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAttributeValueType = exports.loadFeatureAttributes = exports.I3SAttributeLoader = void 0;
4
+ const core_1 = require("@loaders.gl/core");
5
+ const parse_i3s_attribute_1 = require("./lib/parsers/parse-i3s-attribute");
6
+ const url_utils_1 = require("./lib/utils/url-utils");
7
+ // __VERSION__ is injected by babel-plugin-version-inline
8
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
9
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
5
10
  const EMPTY_VALUE = '';
6
11
  const REJECTED_STATUS = 'rejected';
7
- export const I3SAttributeLoader = {
8
- name: 'I3S Attribute',
9
- id: 'i3s-attribute',
10
- module: 'i3s',
11
- version: VERSION,
12
- mimeTypes: ['application/binary'],
13
- parse,
14
- extensions: ['bin'],
15
- options: {},
16
- binary: true
12
+ /**
13
+ * Loader for I3S attributes
14
+ */
15
+ exports.I3SAttributeLoader = {
16
+ name: 'I3S Attribute',
17
+ id: 'i3s-attribute',
18
+ module: 'i3s',
19
+ version: VERSION,
20
+ mimeTypes: ['application/binary'],
21
+ parse: async (arrayBuffer, options) => (0, parse_i3s_attribute_1.parseI3STileAttribute)(arrayBuffer, options),
22
+ extensions: ['bin'],
23
+ options: {},
24
+ binary: true
17
25
  };
18
-
19
- async function parse(data, options) {
20
- data = parseI3STileAttribute(data, options);
21
- return data;
26
+ // TODO - these seem to use the loader rather than being part of the loader. Move to different file...
27
+ /**
28
+ * Load attributes based on feature id
29
+ * @param {Object} tile
30
+ * @param {number} featureId
31
+ * @param {Object} options
32
+ * @returns {Promise}
33
+ */
34
+ // eslint-disable-next-line complexity
35
+ async function loadFeatureAttributes(tile, featureId, options = {}) {
36
+ const { attributeStorageInfo, attributeUrls, tilesetFields } = getAttributesData(tile);
37
+ if (!attributeStorageInfo || !attributeUrls || featureId < 0) {
38
+ return null;
39
+ }
40
+ let attributes = [];
41
+ const attributeLoadPromises = [];
42
+ for (let index = 0; index < attributeStorageInfo.length; index++) {
43
+ // @ts-ignore
44
+ const url = (0, url_utils_1.getUrlWithToken)(attributeUrls[index], options.i3s?.token);
45
+ const attributeName = attributeStorageInfo[index].name;
46
+ const attributeType = getAttributeValueType(attributeStorageInfo[index]);
47
+ const loadOptions = { ...options, attributeName, attributeType };
48
+ const promise = (0, core_1.load)(url, exports.I3SAttributeLoader, loadOptions);
49
+ attributeLoadPromises.push(promise);
50
+ }
51
+ try {
52
+ attributes = await Promise.allSettled(attributeLoadPromises);
53
+ }
54
+ catch (error) {
55
+ // do nothing
56
+ }
57
+ if (!attributes.length) {
58
+ return null;
59
+ }
60
+ return generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields);
22
61
  }
23
-
24
- export async function loadFeatureAttributes(tile, featureId, options = {}) {
25
- const {
26
- attributeStorageInfo,
27
- attributeUrls,
28
- tilesetFields
29
- } = getAttributesData(tile);
30
-
31
- if (!attributeStorageInfo || !attributeUrls || !featureId) {
32
- return null;
33
- }
34
-
35
- let attributes = [];
36
- const attributeLoadPromises = [];
37
-
38
- for (let index = 0; index < attributeStorageInfo.length; index++) {
39
- var _options$i3s;
40
-
41
- const url = getUrlWithToken(attributeUrls[index], (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
42
- const attributeName = attributeStorageInfo[index].name;
43
- const attributeType = getAttributeValueType(attributeStorageInfo[index]);
44
- const loadOptions = { ...options,
45
- attributeName,
46
- attributeType
47
- };
48
- const promise = load(url, I3SAttributeLoader, loadOptions);
49
- attributeLoadPromises.push(promise);
50
- }
51
-
52
- try {
53
- attributes = await Promise.allSettled(attributeLoadPromises);
54
- } catch (error) {}
55
-
56
- if (!attributes.length) {
57
- return null;
58
- }
59
-
60
- return generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields);
61
- }
62
-
62
+ exports.loadFeatureAttributes = loadFeatureAttributes;
63
+ /**
64
+ * Gets attributes data from tile.
65
+ * @param tile
66
+ * @returns
67
+ */
63
68
  function getAttributesData(tile) {
64
- var _tile$tileset, _tile$tileset$tileset, _tile$header, _tile$tileset2, _tile$tileset2$tilese;
65
-
66
- const attributeStorageInfo = (_tile$tileset = tile.tileset) === null || _tile$tileset === void 0 ? void 0 : (_tile$tileset$tileset = _tile$tileset.tileset) === null || _tile$tileset$tileset === void 0 ? void 0 : _tile$tileset$tileset.attributeStorageInfo;
67
- const attributeUrls = (_tile$header = tile.header) === null || _tile$header === void 0 ? void 0 : _tile$header.attributeUrls;
68
- const tilesetFields = ((_tile$tileset2 = tile.tileset) === null || _tile$tileset2 === void 0 ? void 0 : (_tile$tileset2$tilese = _tile$tileset2.tileset) === null || _tile$tileset2$tilese === void 0 ? void 0 : _tile$tileset2$tilese.fields) || [];
69
- return {
70
- attributeStorageInfo,
71
- attributeUrls,
72
- tilesetFields
73
- };
69
+ const attributeStorageInfo = tile.tileset?.tileset?.attributeStorageInfo;
70
+ const attributeUrls = tile.header?.attributeUrls;
71
+ const tilesetFields = tile.tileset?.tileset?.fields || [];
72
+ return { attributeStorageInfo, attributeUrls, tilesetFields };
74
73
  }
75
-
74
+ /**
75
+ * Get attribute value type based on property names
76
+ * @param {Object} attribute
77
+ * @returns {String}
78
+ */
76
79
  function getAttributeValueType(attribute) {
77
- if (attribute.hasOwnProperty('objectIds')) {
78
- return 'Oid32';
79
- } else if (attribute.hasOwnProperty('attributeValues')) {
80
- return attribute.attributeValues.valueType;
81
- }
82
-
83
- return '';
80
+ if (attribute.hasOwnProperty('objectIds')) {
81
+ return 'Oid32';
82
+ }
83
+ else if (attribute.hasOwnProperty('attributeValues')) {
84
+ return attribute.attributeValues.valueType;
85
+ }
86
+ return '';
84
87
  }
85
-
88
+ exports.getAttributeValueType = getAttributeValueType;
89
+ /**
90
+ * Find in attributeStorageInfo attribute name responsible for feature ids list.
91
+ * @param attributeStorageInfo
92
+ * @returns Feature ids attribute name
93
+ */
86
94
  function getFeatureIdsAttributeName(attributeStorageInfo) {
87
- const objectIdsAttribute = attributeStorageInfo.find(attribute => attribute.name.includes('OBJECTID'));
88
- return objectIdsAttribute === null || objectIdsAttribute === void 0 ? void 0 : objectIdsAttribute.name;
95
+ const objectIdsAttribute = attributeStorageInfo.find(attribute => attribute.name.includes('OBJECTID'));
96
+ return objectIdsAttribute?.name;
89
97
  }
90
-
98
+ /**
99
+ * Generates mapping featureId to feature attributes
100
+ * @param {Array} attributes
101
+ * @param {Object} attributeStorageInfo
102
+ * @param {number} featureId
103
+ * @returns {Object}
104
+ */
91
105
  function generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields) {
92
- const objectIdsAttributeName = getFeatureIdsAttributeName(attributeStorageInfo);
93
- const objectIds = attributes.find(attribute => attribute.value[objectIdsAttributeName]);
94
-
95
- if (!objectIds) {
96
- return null;
97
- }
98
-
99
- const attributeIndex = objectIds.value[objectIdsAttributeName].indexOf(featureId);
100
-
101
- if (attributeIndex < 0) {
102
- return null;
103
- }
104
-
105
- return getFeatureAttributesByIndex(attributes, attributeIndex, attributeStorageInfo, tilesetFields);
106
+ const objectIdsAttributeName = getFeatureIdsAttributeName(attributeStorageInfo);
107
+ const objectIds = attributes.find((attribute) => attribute.value[objectIdsAttributeName]);
108
+ if (!objectIds) {
109
+ return null;
110
+ }
111
+ const attributeIndex = objectIds.value[objectIdsAttributeName].indexOf(featureId);
112
+ if (attributeIndex < 0) {
113
+ return null;
114
+ }
115
+ return getFeatureAttributesByIndex(attributes, attributeIndex, attributeStorageInfo, tilesetFields);
106
116
  }
107
-
117
+ /**
118
+ * Generates attribute object for feature mapping by feature id
119
+ * @param {Array} attributes
120
+ * @param {Number} featureIdIndex
121
+ * @param {Object} attributeStorageInfo
122
+ * @returns {Object}
123
+ */
108
124
  function getFeatureAttributesByIndex(attributes, featureIdIndex, attributeStorageInfo, tilesetFields) {
109
- const attributesObject = {};
110
-
111
- for (let index = 0; index < attributeStorageInfo.length; index++) {
112
- const attributeName = attributeStorageInfo[index].name;
113
- const codedValues = getAttributeCodedValues(attributeName, tilesetFields);
114
- const attribute = getAttributeByIndexAndAttributeName(attributes, index, attributeName);
115
- attributesObject[attributeName] = formatAttributeValue(attribute, featureIdIndex, codedValues);
116
- }
117
-
118
- return attributesObject;
125
+ const attributesObject = {};
126
+ for (let index = 0; index < attributeStorageInfo.length; index++) {
127
+ const attributeName = attributeStorageInfo[index].name;
128
+ const codedValues = getAttributeCodedValues(attributeName, tilesetFields);
129
+ const attribute = getAttributeByIndexAndAttributeName(attributes, index, attributeName);
130
+ attributesObject[attributeName] = formatAttributeValue(attribute, featureIdIndex, codedValues);
131
+ }
132
+ return attributesObject;
119
133
  }
120
-
134
+ /**
135
+ * Get coded values list from tileset.
136
+ * @param attributeName
137
+ * @param tilesetFields
138
+ */
121
139
  function getAttributeCodedValues(attributeName, tilesetFields) {
122
- var _attributeField$domai;
123
-
124
- const attributeField = tilesetFields.find(field => field.name === attributeName || field.alias === attributeName);
125
- return (attributeField === null || attributeField === void 0 ? void 0 : (_attributeField$domai = attributeField.domain) === null || _attributeField$domai === void 0 ? void 0 : _attributeField$domai.codedValues) || [];
140
+ const attributeField = tilesetFields
141
+ .find(field => field.name === attributeName || field.alias === attributeName);
142
+ return attributeField?.domain?.codedValues || [];
126
143
  }
127
-
144
+ /**
145
+ * Return attribute value if it presents in atrributes list
146
+ * @param {array} attributes
147
+ * @param {number} index
148
+ * @param {string} attributesName
149
+ */
128
150
  function getAttributeByIndexAndAttributeName(attributes, index, attributesName) {
129
- const attributeObject = attributes[index];
130
-
131
- if (attributeObject.status === REJECTED_STATUS) {
132
- return null;
133
- }
134
-
135
- return attributeObject.value[attributesName];
151
+ const attributeObject = attributes[index];
152
+ if (attributeObject.status === REJECTED_STATUS) {
153
+ return null;
154
+ }
155
+ return attributeObject.value[attributesName];
136
156
  }
137
-
157
+ /**
158
+ * Do formatting of attribute values or return empty string.
159
+ * @param {Array} attribute
160
+ * @param {Number} featureIdIndex
161
+ * @returns {String}
162
+ */
138
163
  function formatAttributeValue(attribute, featureIdIndex, codedValues) {
139
- let value = EMPTY_VALUE;
140
-
141
- if (attribute && featureIdIndex in attribute) {
142
- value = String(attribute[featureIdIndex]).replace(/\u0000|NaN/g, '').trim();
143
- }
144
-
145
- if (codedValues.length) {
146
- const codeValue = codedValues.find(codedValue => codedValue.code === Number(value));
147
- value = (codeValue === null || codeValue === void 0 ? void 0 : codeValue.name) || EMPTY_VALUE;
148
- }
149
-
150
- return value;
164
+ let value = EMPTY_VALUE;
165
+ if (attribute && (featureIdIndex in attribute)) {
166
+ // eslint-disable-next-line no-control-regex
167
+ value = String(attribute[featureIdIndex]).replace(/\u0000|NaN/g, '').trim();
168
+ }
169
+ // Check if coded values are existed. If so we use them.
170
+ if (codedValues.length) {
171
+ const codeValue = codedValues.find(codedValue => codedValue.code === Number(value));
172
+ value = codeValue?.name || EMPTY_VALUE;
173
+ }
174
+ return value;
151
175
  }
152
- //# sourceMappingURL=i3s-attribute-loader.js.map
@@ -1,21 +1,26 @@
1
- import { parseBuildingSceneLayer } from './lib/parsers/parse-i3s-building-scene-layer';
2
- const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'beta';
3
- export const I3SBuildingSceneLayerLoader = {
4
- name: 'I3S Building Scene Layer',
5
- id: 'i3s-building-scene-layer',
6
- module: 'i3s',
7
- version: VERSION,
8
- mimeTypes: ['application/json'],
9
- parse,
10
- extensions: ['json'],
11
- options: {}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I3SBuildingSceneLayerLoader = void 0;
4
+ const parse_i3s_building_scene_layer_1 = require("./lib/parsers/parse-i3s-building-scene-layer");
5
+ // __VERSION__ is injected by babel-plugin-version-inline
6
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
8
+ /**
9
+ * Loader for I3S - Building Scene Layer
10
+ */
11
+ exports.I3SBuildingSceneLayerLoader = {
12
+ name: 'I3S Building Scene Layer',
13
+ id: 'i3s-building-scene-layer',
14
+ module: 'i3s',
15
+ version: VERSION,
16
+ mimeTypes: ['application/json'],
17
+ parse,
18
+ extensions: ['json'],
19
+ options: {}
12
20
  };
13
-
14
21
  async function parse(data, options, context) {
15
- if (!(context !== null && context !== void 0 && context.url)) {
16
- throw new Error('Url is not provided');
17
- }
18
-
19
- return parseBuildingSceneLayer(data, context.url);
22
+ if (!context?.url) {
23
+ throw new Error('Url is not provided');
24
+ }
25
+ return (0, parse_i3s_building_scene_layer_1.parseBuildingSceneLayer)(data, context.url);
20
26
  }
21
- //# sourceMappingURL=i3s-building-scene-layer-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-content-loader.d.ts","sourceRoot":"","sources":["../src/i3s-content-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAA+B,MAAM,0BAA0B,CAAC;AAO7F;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAY9B,CAAC"}
1
+ {"version":3,"file":"i3s-content-loader.d.ts","sourceRoot":"","sources":["../src/i3s-content-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAS9E;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAY9B,CAAC"}
@@ -1,25 +1,32 @@
1
- import { parseI3STileContent } from './lib/parsers/parse-i3s-tile-content';
2
- const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'beta';
3
- export const I3SContentLoader = {
4
- name: 'I3S Content (Indexed Scene Layers)',
5
- id: 'i3s-content',
6
- module: 'i3s',
7
- worker: true,
8
- version: VERSION,
9
- mimeTypes: ['application/octet-stream'],
10
- parse,
11
- extensions: ['bin'],
12
- options: {
13
- 'i3s-content': {}
14
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I3SContentLoader = void 0;
4
+ const parse_i3s_tile_content_1 = require("./lib/parsers/parse-i3s-tile-content");
5
+ // __VERSION__ is injected by babel-plugin-version-inline
6
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
8
+ /**
9
+ * Loader for I3S - Indexed 3D Scene Layer
10
+ */
11
+ exports.I3SContentLoader = {
12
+ name: 'I3S Content (Indexed Scene Layers)',
13
+ id: 'i3s-content',
14
+ module: 'i3s',
15
+ worker: true,
16
+ version: VERSION,
17
+ mimeTypes: ['application/octet-stream'],
18
+ parse,
19
+ extensions: ['bin'],
20
+ options: {
21
+ 'i3s-content': {}
22
+ }
15
23
  };
16
-
17
24
  async function parse(data, options, context) {
18
- const {
19
- tile,
20
- tileset
21
- } = (options === null || options === void 0 ? void 0 : options.i3s) || {};
22
- await parseI3STileContent(data, tile, tileset, options, context);
23
- return tile.content;
25
+ const { tile, _tileOptions, tileset, _tilesetOptions } = options?.i3s || {};
26
+ const tileOptions = _tileOptions || tile;
27
+ const tilesetOptions = _tilesetOptions || tileset;
28
+ if (!tileOptions || !tilesetOptions) {
29
+ return null;
30
+ }
31
+ return await (0, parse_i3s_tile_content_1.parseI3STileContent)(data, tileOptions, tilesetOptions, options, context);
24
32
  }
25
- //# sourceMappingURL=i3s-content-loader.js.map