@loaders.gl/tile-converter 4.0.0-alpha.8 → 4.0.0-beta.1

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 (300) hide show
  1. package/bin/i3s-server.js +4 -0
  2. package/bin/slpk-extractor.js +4 -0
  3. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +5 -5
  4. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +10 -5
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  7. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +10 -0
  8. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -0
  9. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +2 -1
  10. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -1
  11. package/dist/converter.min.js +172 -103
  12. package/dist/deps-installer/deps-installer.d.ts +3 -2
  13. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  14. package/dist/dist.min.js +32718 -32568
  15. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +97 -117
  16. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  17. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +24 -22
  18. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  19. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js +63 -0
  20. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
  21. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  22. package/dist/es5/converter-cli.js +25 -65
  23. package/dist/es5/converter-cli.js.map +1 -1
  24. package/dist/es5/deps-installer/deps-installer.js +115 -40
  25. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  26. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +45 -15
  27. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  28. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  29. package/dist/es5/i3s-converter/helpers/feature-attributes.js +8 -18
  30. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
  31. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +83 -43
  32. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  33. package/dist/es5/i3s-converter/helpers/geometry-converter.js +100 -102
  34. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  35. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  36. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +70 -4
  37. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
  38. package/dist/es5/i3s-converter/helpers/node-index-document.js +3 -2
  39. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
  40. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +47 -12
  41. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  42. package/dist/es5/i3s-converter/i3s-converter.js +187 -174
  43. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  44. package/dist/es5/i3s-converter/types.js +11 -11
  45. package/dist/es5/i3s-converter/types.js.map +1 -1
  46. package/dist/es5/i3s-server/README.md +46 -2
  47. package/dist/es5/i3s-server/app.js +23 -15
  48. package/dist/es5/i3s-server/app.js.map +1 -1
  49. package/dist/es5/i3s-server/bin/www.js +33 -0
  50. package/dist/es5/i3s-server/bin/www.js.map +1 -0
  51. package/dist/es5/i3s-server/controllers/index-controller.js +23 -22
  52. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
  53. package/dist/es5/i3s-server/controllers/slpk-controller.js +35 -38
  54. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  55. package/dist/es5/i3s-server/routes/index.js +2 -2
  56. package/dist/es5/i3s-server/routes/index.js.map +1 -1
  57. package/dist/es5/i3s-server/routes/slpk-router.js +14 -13
  58. package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -1
  59. package/dist/es5/i3s-server/utils/create-scene-server.js +7 -4
  60. package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -1
  61. package/dist/es5/i3s-server/utils/server-utils.js +49 -0
  62. package/dist/es5/i3s-server/utils/server-utils.js.map +1 -0
  63. package/dist/es5/lib/utils/cli-utils.js +57 -0
  64. package/dist/es5/lib/utils/cli-utils.js.map +1 -0
  65. package/dist/es5/lib/utils/compress-util.js +1 -1
  66. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  67. package/dist/es5/lib/utils/lod-conversion-utils.js +10 -4
  68. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  69. package/dist/es5/pgm-loader.js +11 -3
  70. package/dist/es5/pgm-loader.js.map +1 -1
  71. package/dist/es5/slpk-extractor/slpk-extractor.js +171 -0
  72. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -0
  73. package/dist/es5/slpk-extractor-cli.js +117 -0
  74. package/dist/es5/slpk-extractor-cli.js.map +1 -0
  75. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +51 -58
  76. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  77. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +12 -11
  78. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  79. package/dist/esm/3d-tiles-converter/helpers/load-i3s.js +32 -0
  80. package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
  81. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  82. package/dist/esm/converter-cli.js +8 -48
  83. package/dist/esm/converter-cli.js.map +1 -1
  84. package/dist/esm/deps-installer/deps-installer.js +40 -13
  85. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  86. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +28 -11
  87. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  88. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  89. package/dist/esm/i3s-converter/helpers/feature-attributes.js +10 -8
  90. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
  91. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +77 -34
  92. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  93. package/dist/esm/i3s-converter/helpers/geometry-converter.js +60 -61
  94. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  95. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  96. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js +33 -4
  97. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
  98. package/dist/esm/i3s-converter/helpers/node-index-document.js +2 -1
  99. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
  100. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +37 -12
  101. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  102. package/dist/esm/i3s-converter/i3s-converter.js +101 -73
  103. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  104. package/dist/esm/i3s-converter/types.js +9 -9
  105. package/dist/esm/i3s-converter/types.js.map +1 -1
  106. package/dist/esm/i3s-server/README.md +46 -2
  107. package/dist/esm/i3s-server/app.js +13 -11
  108. package/dist/esm/i3s-server/app.js.map +1 -1
  109. package/dist/esm/i3s-server/bin/i3s-server.min.js +516 -0
  110. package/dist/esm/i3s-server/bin/www.js +30 -0
  111. package/dist/esm/i3s-server/bin/www.js.map +1 -0
  112. package/dist/esm/i3s-server/controllers/index-controller.js +4 -7
  113. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
  114. package/dist/esm/i3s-server/controllers/slpk-controller.js +9 -26
  115. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  116. package/dist/esm/i3s-server/routes/index.js +1 -1
  117. package/dist/esm/i3s-server/routes/index.js.map +1 -1
  118. package/dist/esm/i3s-server/routes/slpk-router.js +5 -11
  119. package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -1
  120. package/dist/esm/i3s-server/utils/create-scene-server.js +2 -5
  121. package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -1
  122. package/dist/esm/i3s-server/utils/server-utils.js +40 -0
  123. package/dist/esm/i3s-server/utils/server-utils.js.map +1 -0
  124. package/dist/esm/lib/utils/cli-utils.js +47 -0
  125. package/dist/esm/lib/utils/cli-utils.js.map +1 -0
  126. package/dist/esm/lib/utils/compress-util.js +1 -1
  127. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  128. package/dist/esm/lib/utils/lod-conversion-utils.js +6 -4
  129. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  130. package/dist/esm/pgm-loader.js +7 -4
  131. package/dist/esm/pgm-loader.js.map +1 -1
  132. package/dist/esm/slpk-extractor/slpk-extractor.js +63 -0
  133. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -0
  134. package/dist/esm/slpk-extractor-cli.js +74 -0
  135. package/dist/esm/slpk-extractor-cli.js.map +1 -0
  136. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +15 -2
  137. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  138. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +1 -2
  139. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  140. package/dist/i3s-converter/helpers/feature-attributes.d.ts +8 -8
  141. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  142. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  143. package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -9
  144. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  145. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +3 -3
  146. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  147. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +15 -0
  148. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -1
  149. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  150. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +4 -5
  151. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  152. package/dist/i3s-converter/i3s-converter.d.ts +3 -2
  153. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  154. package/dist/i3s-converter/types.d.ts +48 -7
  155. package/dist/i3s-converter/types.d.ts.map +1 -1
  156. package/dist/i3s-server/app.d.ts +1 -2
  157. package/dist/i3s-server/app.d.ts.map +1 -1
  158. package/dist/i3s-server/bin/www.d.ts +3 -0
  159. package/dist/i3s-server/bin/www.d.ts.map +1 -0
  160. package/dist/i3s-server/controllers/index-controller.d.ts +6 -1
  161. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -1
  162. package/dist/i3s-server/controllers/slpk-controller.d.ts +13 -2
  163. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
  164. package/dist/i3s-server/routes/index.d.ts +1 -2
  165. package/dist/i3s-server/routes/index.d.ts.map +1 -1
  166. package/dist/i3s-server/routes/slpk-router.d.ts +2 -2
  167. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  168. package/dist/i3s-server/utils/create-scene-server.d.ts +11 -5
  169. package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -1
  170. package/dist/i3s-server/utils/server-utils.d.ts +24 -0
  171. package/dist/i3s-server/utils/server-utils.d.ts.map +1 -0
  172. package/dist/lib/utils/cli-utils.d.ts +34 -0
  173. package/dist/lib/utils/cli-utils.d.ts.map +1 -0
  174. package/dist/lib/utils/lod-conversion-utils.d.ts +2 -2
  175. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  176. package/dist/pgm-loader.d.ts +9 -2
  177. package/dist/pgm-loader.d.ts.map +1 -1
  178. package/dist/slpk-extractor/slpk-extractor.d.ts +23 -0
  179. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -0
  180. package/dist/slpk-extractor-cli.d.ts +17 -0
  181. package/dist/slpk-extractor-cli.d.ts.map +1 -0
  182. package/dist/slpk-extractor.min.js +189 -0
  183. package/package.json +28 -22
  184. package/src/3d-tiles-converter/3d-tiles-converter.ts +65 -69
  185. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +23 -19
  186. package/src/3d-tiles-converter/helpers/load-i3s.ts +52 -0
  187. package/src/3d-tiles-converter/helpers/texture-atlas.ts +6 -2
  188. package/src/converter-cli.ts +16 -74
  189. package/src/deps-installer/deps-installer.ts +58 -12
  190. package/src/i3s-converter/helpers/batch-ids-extensions.ts +77 -32
  191. package/src/i3s-converter/helpers/coordinate-converter.ts +1 -2
  192. package/src/i3s-converter/helpers/feature-attributes.ts +23 -18
  193. package/src/i3s-converter/helpers/geometry-attributes.ts +81 -44
  194. package/src/i3s-converter/helpers/geometry-converter.ts +149 -126
  195. package/src/i3s-converter/helpers/gltf-attributes.ts +9 -10
  196. package/src/i3s-converter/helpers/load-3d-tiles.ts +61 -5
  197. package/src/i3s-converter/helpers/node-index-document.ts +5 -1
  198. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +70 -21
  199. package/src/i3s-converter/i3s-converter.ts +145 -73
  200. package/src/i3s-converter/types.ts +49 -7
  201. package/src/i3s-server/README.md +46 -2
  202. package/src/i3s-server/{app.js → app.ts} +11 -9
  203. package/src/i3s-server/bin/www.ts +38 -0
  204. package/src/i3s-server/controllers/{index-controller.js → index-controller.ts} +10 -9
  205. package/src/i3s-server/controllers/slpk-controller.ts +32 -0
  206. package/src/i3s-server/routes/{index.js → index.ts} +2 -1
  207. package/src/i3s-server/routes/{slpk-router.js → slpk-router.ts} +5 -10
  208. package/src/i3s-server/utils/create-scene-server.ts +20 -0
  209. package/src/i3s-server/utils/server-utils.ts +70 -0
  210. package/src/lib/utils/cli-utils.ts +78 -0
  211. package/src/lib/utils/compress-util.ts +1 -1
  212. package/src/lib/utils/lod-conversion-utils.ts +10 -6
  213. package/src/pgm-loader.ts +15 -7
  214. package/src/slpk-extractor/slpk-extractor.ts +101 -0
  215. package/src/slpk-extractor-cli.ts +128 -0
  216. package/dist/3d-tiles-attributes-worker.d.ts +0 -28
  217. package/dist/3d-tiles-attributes-worker.d.ts.map +0 -1
  218. package/dist/3d-tiles-attributes-worker.js +0 -3
  219. package/dist/3d-tiles-attributes-worker.js.map +0 -7
  220. package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -288
  221. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -269
  222. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
  223. package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -52
  224. package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
  225. package/dist/bundle.js +0 -5
  226. package/dist/constants.js +0 -4
  227. package/dist/converter-cli.js +0 -280
  228. package/dist/deps-installer/deps-installer.js +0 -62
  229. package/dist/es5/3d-tiles-attributes-worker.js +0 -25
  230. package/dist/es5/3d-tiles-attributes-worker.js.map +0 -1
  231. package/dist/es5/i3s-attributes-worker.js +0 -25
  232. package/dist/es5/i3s-attributes-worker.js.map +0 -1
  233. package/dist/es5/i3s-server/bin/www +0 -102
  234. package/dist/es5/workers/3d-tiles-attributes-worker.js +0 -28
  235. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +0 -1
  236. package/dist/es5/workers/i3s-attributes-worker.js +0 -30
  237. package/dist/es5/workers/i3s-attributes-worker.js.map +0 -1
  238. package/dist/esm/3d-tiles-attributes-worker.js +0 -16
  239. package/dist/esm/3d-tiles-attributes-worker.js.map +0 -1
  240. package/dist/esm/i3s-attributes-worker.js +0 -16
  241. package/dist/esm/i3s-attributes-worker.js.map +0 -1
  242. package/dist/esm/i3s-server/bin/www +0 -102
  243. package/dist/esm/workers/3d-tiles-attributes-worker.js +0 -8
  244. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +0 -1
  245. package/dist/esm/workers/i3s-attributes-worker.js +0 -7
  246. package/dist/esm/workers/i3s-attributes-worker.js.map +0 -1
  247. package/dist/i3s-attributes-worker.d.ts +0 -45
  248. package/dist/i3s-attributes-worker.d.ts.map +0 -1
  249. package/dist/i3s-attributes-worker.js +0 -9
  250. package/dist/i3s-attributes-worker.js.map +0 -7
  251. package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -138
  252. package/dist/i3s-converter/helpers/coordinate-converter.js +0 -123
  253. package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
  254. package/dist/i3s-converter/helpers/feature-attributes.js +0 -216
  255. package/dist/i3s-converter/helpers/geometry-attributes.js +0 -202
  256. package/dist/i3s-converter/helpers/geometry-converter.js +0 -1225
  257. package/dist/i3s-converter/helpers/gltf-attributes.js +0 -128
  258. package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -53
  259. package/dist/i3s-converter/helpers/node-debug.js +0 -120
  260. package/dist/i3s-converter/helpers/node-index-document.js +0 -268
  261. package/dist/i3s-converter/helpers/node-pages.js +0 -316
  262. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -76
  263. package/dist/i3s-converter/helpers/tileset-traversal.js +0 -29
  264. package/dist/i3s-converter/i3s-converter.js +0 -911
  265. package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
  266. package/dist/i3s-converter/json-templates/layers.js +0 -139
  267. package/dist/i3s-converter/json-templates/metadata.js +0 -25
  268. package/dist/i3s-converter/json-templates/node.js +0 -89
  269. package/dist/i3s-converter/json-templates/scene-server.js +0 -31
  270. package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
  271. package/dist/i3s-converter/json-templates/store.js +0 -103
  272. package/dist/i3s-converter/types.js +0 -17
  273. package/dist/i3s-server/app.js +0 -22
  274. package/dist/i3s-server/controllers/index-controller.js +0 -23
  275. package/dist/i3s-server/controllers/slpk-controller.js +0 -32
  276. package/dist/i3s-server/routes/index.js +0 -16
  277. package/dist/i3s-server/routes/slpk-router.js +0 -33
  278. package/dist/i3s-server/utils/create-scene-server.js +0 -14
  279. package/dist/index.js +0 -10
  280. package/dist/lib/utils/compress-util.js +0 -257
  281. package/dist/lib/utils/file-utils.js +0 -139
  282. package/dist/lib/utils/geometry-utils.js +0 -18
  283. package/dist/lib/utils/lod-conversion-utils.js +0 -76
  284. package/dist/lib/utils/queue.js +0 -18
  285. package/dist/lib/utils/statistic-utills.js +0 -64
  286. package/dist/lib/utils/write-queue.js +0 -80
  287. package/dist/pgm-loader.js +0 -24
  288. package/dist/workers/3d-tiles-attributes-worker.d.ts +0 -2
  289. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +0 -1
  290. package/dist/workers/3d-tiles-attributes-worker.js +0 -9
  291. package/dist/workers/i3s-attributes-worker.d.ts +0 -2
  292. package/dist/workers/i3s-attributes-worker.d.ts.map +0 -1
  293. package/dist/workers/i3s-attributes-worker.js +0 -5
  294. package/src/3d-tiles-attributes-worker.ts +0 -43
  295. package/src/i3s-attributes-worker.ts +0 -59
  296. package/src/i3s-server/bin/www +0 -102
  297. package/src/i3s-server/controllers/slpk-controller.js +0 -38
  298. package/src/i3s-server/utils/create-scene-server.js +0 -15
  299. package/src/workers/3d-tiles-attributes-worker.ts +0 -6
  300. package/src/workers/i3s-attributes-worker.ts +0 -7
@@ -1,16 +0,0 @@
1
- "use strict";
2
- const express = require('express');
3
- const router = express.Router();
4
- const { getFileNameByUrl } = require('../controllers/index-controller');
5
- /* GET home page. */
6
- router.get('*', async function (req, res, next) {
7
- const fileName = await getFileNameByUrl(req.path);
8
- if (fileName) {
9
- res.sendFile(fileName);
10
- }
11
- else {
12
- res.status(404);
13
- res.send('File not found');
14
- }
15
- });
16
- module.exports = router;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- const express = require('express');
3
- const { getFileByUrl } = require('../controllers/slpk-controller');
4
- const createSceneServer = require('../utils/create-scene-server');
5
- const sceneServerRouter = express.Router();
6
- sceneServerRouter.get('*', async function (req, res, next) {
7
- const file = await getFileByUrl('/');
8
- if (file) {
9
- const layer = JSON.parse(file.toString());
10
- const sceneServerResponse = createSceneServer(layer.name, layer);
11
- res.send(sceneServerResponse);
12
- }
13
- else {
14
- res.status(404);
15
- res.send('File not found');
16
- }
17
- });
18
- const router = express.Router();
19
- router.get('*', async function (req, res, next) {
20
- console.log(req.path);
21
- const file = await getFileByUrl(req.path);
22
- if (file) {
23
- res.send(file);
24
- }
25
- else {
26
- res.status(404);
27
- res.send('File not found');
28
- }
29
- });
30
- module.exports = {
31
- sceneServerRouter,
32
- router
33
- };
@@ -1,14 +0,0 @@
1
- "use strict";
2
- const { v4: uuidv4 } = require('uuid');
3
- const createSceneServer = (name, layer) => {
4
- return {
5
- serviceItemId: uuidv4().replace(/-/gi, ''),
6
- serviceName: name,
7
- name,
8
- currentVersion: '10.7',
9
- serviceVersion: '1.8',
10
- supportedBindings: ['REST'],
11
- layers: [layer]
12
- };
13
- };
14
- module.exports = createSceneServer;
package/dist/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Tiles3DConverter = exports.I3SConverter = void 0;
7
- var i3s_converter_1 = require("./i3s-converter/i3s-converter");
8
- Object.defineProperty(exports, "I3SConverter", { enumerable: true, get: function () { return __importDefault(i3s_converter_1).default; } });
9
- var _3d_tiles_converter_1 = require("./3d-tiles-converter/3d-tiles-converter");
10
- Object.defineProperty(exports, "Tiles3DConverter", { enumerable: true, get: function () { return __importDefault(_3d_tiles_converter_1).default; } });
@@ -1,257 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addFileToZip = exports.generateHash128FromZip = exports.compressWithChildProcess = exports.compressFilesWithZip = exports.compressFileWithGzip = void 0;
7
- const zlib_1 = require("zlib");
8
- const path_1 = require("path");
9
- const fs_1 = require("fs");
10
- const archiver_1 = __importDefault(require("archiver"));
11
- const file_utils_1 = require("./file-utils");
12
- const worker_utils_1 = require("@loaders.gl/worker-utils");
13
- const jszip_1 = __importDefault(require("jszip"));
14
- const crypto_1 = require("@loaders.gl/crypto");
15
- const crypt_1 = __importDefault(require("crypt"));
16
- const file_utils_2 = require("./file-utils");
17
- /**
18
- * Compress file to gzip file
19
- *
20
- * @param pathFile - the path to the file
21
- * @return the path to the gzip file
22
- */
23
- function compressFileWithGzip(pathFile) {
24
- const compressedPathFile = `${pathFile}.gz`;
25
- const gzip = (0, zlib_1.createGzip)();
26
- const input = (0, fs_1.createReadStream)(pathFile);
27
- const output = (0, fs_1.createWriteStream)(compressedPathFile);
28
- return new Promise((resolve, reject) => {
29
- input.on('end', () => {
30
- console.log(`${compressedPathFile} compressed and saved.`); // eslint-disable-line no-undef,no-console
31
- resolve(compressedPathFile);
32
- });
33
- input.on('error', (error) => {
34
- console.log(`${compressedPathFile}: compression error!`); // eslint-disable-line no-undef,no-console
35
- reject(error);
36
- });
37
- input.pipe(gzip).pipe(output);
38
- });
39
- }
40
- exports.compressFileWithGzip = compressFileWithGzip;
41
- /**
42
- * Compress files from map into slpk file
43
- *
44
- * @param fileMap - map with file paths (key: output path, value: input path)
45
- * @param outputFile - output slpk file
46
- * @param level - compression level
47
- */
48
- async function compressFilesWithZip(fileMap, outputFile, level = 0) {
49
- // Before creating a new file, we need to delete the old file
50
- try {
51
- await (0, file_utils_1.removeFile)(outputFile);
52
- }
53
- catch (e) {
54
- // Do nothing if old file doesn't exist
55
- }
56
- const output = (0, fs_1.createWriteStream)(outputFile);
57
- const archive = (0, archiver_1.default)('zip', {
58
- zlib: { level } // Sets the compression level.
59
- });
60
- return new Promise(async (resolve, reject) => {
61
- // listen for all archive data to be writte
62
- // 'close' event is fired only when a file descriptor is involved
63
- output.on('close', function () {
64
- console.log(`${outputFile} saved.`); // eslint-disable-line no-undef,no-console
65
- console.log(`${archive.pointer()} total bytes`); // eslint-disable-line no-undef,no-console
66
- resolve(null);
67
- });
68
- // This event is fired when the data source is drained no matter what was the data source.
69
- // It is not part of this library but rather from the NodeJS Stream API.
70
- // @see: https://nodejs.org/api/stream.html#stream_event_end
71
- output.on('end', function () {
72
- console.log('Data has been drained'); // eslint-disable-line no-undef,no-console
73
- resolve(null);
74
- });
75
- // good practice to catch warnings (ie stat failures and other non-blocking errors)
76
- archive.on('warning', function (err) {
77
- console.log(err); // eslint-disable-line no-undef,no-console
78
- reject(err);
79
- });
80
- // good practice to catch this error explicitly
81
- archive.on('error', function (err) {
82
- reject(err);
83
- });
84
- // pipe archive data to the file
85
- archive.pipe(output);
86
- for (const subFileName in fileMap) {
87
- const subFileData = fileMap[subFileName];
88
- await appendFileToArchive(archive, subFileName, subFileData);
89
- }
90
- // finalize the archive (ie we are done appending files but streams have to finish yet)
91
- archive.finalize();
92
- });
93
- }
94
- exports.compressFilesWithZip = compressFilesWithZip;
95
- /**
96
- * Compress files using external tool 'zip'/'7z'
97
- *
98
- * @param inputFolder - folder to archive - for cwd option
99
- * @param outputFile - output slpk file
100
- * @param level - compression level
101
- * @param inputFiles - input files path to pass to the executable as option
102
- * @param sevenZipExe - path to 7z.exe executable
103
- */
104
- async function compressWithChildProcess(inputFolder, outputFile, level, inputFiles, sevenZipExe) {
105
- // eslint-disable-next-line no-undef
106
- if (process.platform === 'win32') {
107
- await compressWithChildProcessWindows(inputFolder, outputFile, level, inputFiles, sevenZipExe);
108
- }
109
- else {
110
- await compressWithChildProcessUnix(inputFolder, outputFile, level, inputFiles);
111
- }
112
- }
113
- exports.compressWithChildProcess = compressWithChildProcess;
114
- /**
115
- * Compress files using external linux tool 'zip'
116
- *
117
- * @param inputFolder - folder to archive - for cwd option
118
- * @param outputFile - output slpk file
119
- * @param level - compression level
120
- * @param inputFiles - input files path to pass to the executable as option
121
- */
122
- async function compressWithChildProcessUnix(inputFolder, outputFile, level = 0, inputFiles = '.') {
123
- const fullOutputFile = (0, file_utils_2.getAbsoluteFilePath)(outputFile);
124
- const args = [`-${level}`, '-r', fullOutputFile, inputFiles];
125
- const childProcess = new worker_utils_1.ChildProcessProxy();
126
- await childProcess.start({
127
- command: 'zip',
128
- arguments: args,
129
- spawn: {
130
- cwd: inputFolder
131
- },
132
- wait: 0
133
- });
134
- }
135
- /**
136
- * Compress files using windows external tool '7z'
137
- *
138
- * @param inputFolder - folder to archive - for cwd option
139
- * @param outputFile - output slpk file
140
- * @param level - compression level
141
- * @param inputFiles - input files path to pass to the executable as option
142
- * @param sevenZipExe - path to 7z.exe executable
143
- */
144
- async function compressWithChildProcessWindows(inputFolder, outputFile, level = 0, inputFiles = (0, path_1.join)('.', '*'), sevenZipExe) {
145
- // Workaround for @listfile issue. In 7z.exe @-leading files are handled as listfiles
146
- // https://sevenzip.osdn.jp/chm/cmdline/syntax.htm
147
- if (inputFiles[0] === '@') {
148
- inputFiles = `*${inputFiles.substr(1)}`;
149
- }
150
- const fullOutputFile = (0, file_utils_2.getAbsoluteFilePath)(outputFile);
151
- const args = ['a', '-tzip', `-mx=${level}`, fullOutputFile, inputFiles];
152
- const childProcess = new worker_utils_1.ChildProcessProxy();
153
- await childProcess.start({
154
- command: sevenZipExe,
155
- arguments: args,
156
- spawn: {
157
- cwd: `${inputFolder}`
158
- },
159
- wait: 0
160
- });
161
- }
162
- /**
163
- * Generate hash file from zip archive
164
- * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/slpk_hashtable.cmn.md
165
- *
166
- * @param inputZipFile
167
- * @param outputFile
168
- */
169
- async function generateHash128FromZip(inputZipFile, outputFile) {
170
- const input = await fs_1.promises.readFile(inputZipFile);
171
- const zip = await jszip_1.default.loadAsync(input);
172
- const hashTable = [];
173
- const zipFiles = zip.files;
174
- for (const relativePath in zipFiles) {
175
- const zipEntry = zipFiles[relativePath];
176
- // Had to use a workaround because the correct string is getting the wrong data
177
- // const content = await zipEntry.async('nodebuffer');
178
- // _data isn't described in the interface, so lint thought it was wrong
179
- const _data = '_data';
180
- const content = zipEntry[_data].compressedContent;
181
- if (zipEntry.dir)
182
- continue; // eslint-disable-line no-continue
183
- // eslint-disable-next-line no-undef
184
- const hash = await new crypto_1.MD5Hash().hash(Buffer.from(relativePath.toLowerCase()));
185
- // eslint-disable-next-line no-undef
186
- hashTable.push({ key: atob(hash), value: content.byteOffset });
187
- }
188
- hashTable.sort((prev, next) => {
189
- if (prev.key === next.key) {
190
- return prev.value < next.value ? -1 : 1;
191
- }
192
- return prev.key < next.key ? -1 : 1;
193
- });
194
- const output = (0, fs_1.createWriteStream)(outputFile);
195
- return new Promise((resolve, reject) => {
196
- output.on('close', function () {
197
- console.log(`${outputFile} generated and saved`); // eslint-disable-line
198
- resolve(null);
199
- });
200
- output.on('error', function (err) {
201
- console.log(err); // eslint-disable-line
202
- reject(err);
203
- });
204
- for (const key in hashTable) {
205
- const item = hashTable[key];
206
- const value = longToByteArray(item.value);
207
- // TODO: perhaps you need to wait for the 'drain' event if the write returns 'false'
208
- // eslint-disable-next-line no-undef
209
- output.write(Buffer.from(crypt_1.default.hexToBytes(item.key).concat(value)));
210
- }
211
- output.close();
212
- });
213
- }
214
- exports.generateHash128FromZip = generateHash128FromZip;
215
- /**
216
- * Encode 64 bit value to byte array
217
- *
218
- * @param long - stringified number
219
- * @returns
220
- */
221
- function longToByteArray(long) {
222
- const buffer = new ArrayBuffer(8); // JS numbers are 8 bytes long, or 64 bits
223
- const longNum = new Float64Array(buffer); // so equivalent to Float64
224
- longNum[0] = parseInt(long);
225
- return Array.from(new Uint8Array(buffer)).reverse(); // reverse to get little endian
226
- }
227
- /**
228
- * Add file to zip archive
229
- *
230
- * @param inputFile
231
- * @param fileName
232
- * @param zipFile
233
- * @param sevenZipExe
234
- */
235
- async function addFileToZip(inputFolder, fileName, zipFile, sevenZipExe) {
236
- await compressWithChildProcess(inputFolder, zipFile, 0, fileName, sevenZipExe);
237
- console.log(`${fileName} added to ${zipFile}.`); // eslint-disable-line
238
- }
239
- exports.addFileToZip = addFileToZip;
240
- /**
241
- *
242
- * @param archive zip archive instance
243
- * @param subFileName file path inside archive
244
- * @param subFileData source file path
245
- * @returns
246
- */
247
- function appendFileToArchive(archive, subFileName, subFileData) {
248
- return new Promise((resolve) => {
249
- const fileStream = (0, fs_1.createReadStream)(subFileData);
250
- console.log(`Compression start: ${subFileName}`); // eslint-disable-line no-undef,no-console
251
- fileStream.on('close', () => {
252
- console.log(`Compression finish: ${subFileName}`); // eslint-disable-line no-undef,no-console
253
- resolve(null);
254
- });
255
- archive.append(fileStream, { name: subFileName });
256
- });
257
- }
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAbsoluteFilePath = exports.removeFile = exports.removeDir = exports.isFileExists = exports.openJson = exports.writeFileForSlpk = exports.writeFile = void 0;
4
- const core_1 = require("@loaders.gl/core");
5
- const loader_utils_1 = require("@loaders.gl/loader-utils");
6
- const fs_1 = require("fs");
7
- const path_1 = require("path");
8
- const compress_util_1 = require("./compress-util");
9
- /**
10
- * Write a file with data and name fileName to path
11
- *
12
- * @param path - output path
13
- * @param data - file content
14
- * @param fileName - name of output file (default: index.json)
15
- */
16
- async function writeFile(path, data, fileName = 'index.json') {
17
- let toWriteData;
18
- if (data instanceof Promise) {
19
- toWriteData = new Uint8Array(await data);
20
- }
21
- else if (data instanceof ArrayBuffer) {
22
- toWriteData = new Uint8Array(data);
23
- }
24
- else {
25
- toWriteData = data;
26
- }
27
- await fs_1.promises.mkdir(path, { recursive: true });
28
- const pathFile = (0, path_1.join)(path, fileName);
29
- try {
30
- await fs_1.promises.writeFile(pathFile, toWriteData);
31
- }
32
- catch (err) {
33
- throw err;
34
- }
35
- console.log(`${pathFile} saved.`); // eslint-disable-line
36
- return pathFile;
37
- }
38
- exports.writeFile = writeFile;
39
- /**
40
- * Write a file with data and name fileName to path - specific one for further packaging into slpk
41
- *
42
- * @param path - output path
43
- * @param data - file content
44
- * @param fileName - name of output file (default: index.json)
45
- * @param compress - if need to compress file with gzip (default: true)
46
- * @param compressList - if set - the file should be added to this list and compressed in the end of conversion
47
- */
48
- async function writeFileForSlpk(path, data, fileName = 'index.json', compress = true, compressList) {
49
- const pathFile = await writeFile(path, data, fileName);
50
- if (compress) {
51
- if (compressList) {
52
- if (!compressList.includes(pathFile)) {
53
- compressList.push(pathFile);
54
- return `${pathFile}.gz`;
55
- }
56
- else {
57
- return null;
58
- }
59
- }
60
- else {
61
- const pathGzFile = await (0, compress_util_1.compressFileWithGzip)(pathFile);
62
- // After compression, we don't need an uncompressed file
63
- await removeFile(pathFile);
64
- return pathGzFile;
65
- }
66
- }
67
- return pathFile;
68
- }
69
- exports.writeFileForSlpk = writeFileForSlpk;
70
- /**
71
- * Open json file
72
- * @param path - path to the file
73
- * @param fileName - file name
74
- * @returns object
75
- */
76
- async function openJson(path, fileName) {
77
- return new Promise((resolve, reject) => {
78
- let count = 0;
79
- console.log(`load ${path}/${fileName}.`); // eslint-disable-line
80
- const intervalId = setInterval(() => {
81
- const pathFile = (0, path_1.join)(path, fileName);
82
- (0, core_1.load)(pathFile, loader_utils_1.JSONLoader)
83
- .then((result) => {
84
- clearInterval(intervalId);
85
- resolve(result);
86
- })
87
- .catch(() => {
88
- count++;
89
- if (count > 100) {
90
- clearInterval(intervalId);
91
- reject(new Error(`Cannon load ${path}/${fileName}.`));
92
- }
93
- });
94
- }, 200);
95
- });
96
- }
97
- exports.openJson = openJson;
98
- /**
99
- * Check if the file exists
100
- * @param fileName - full name of file
101
- * @returns true if file exists, otherwise - false
102
- */
103
- async function isFileExists(fileName) {
104
- try {
105
- await fs_1.promises.stat(fileName);
106
- return true;
107
- }
108
- catch {
109
- return false;
110
- }
111
- }
112
- exports.isFileExists = isFileExists;
113
- /**
114
- * Remove dir with path
115
- *
116
- * @param path
117
- */
118
- function removeDir(path) {
119
- // (node:35607) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
120
- return fs_1.promises.rm(path, { recursive: true });
121
- }
122
- exports.removeDir = removeDir;
123
- /**
124
- * Remove file with path
125
- *
126
- * @param path
127
- */
128
- function removeFile(path) {
129
- return fs_1.promises.unlink(path);
130
- }
131
- exports.removeFile = removeFile;
132
- /**
133
- * Generates absolute file path
134
- * @param filePath
135
- */
136
- function getAbsoluteFilePath(filePath) {
137
- return (0, path_1.isAbsolute)(filePath) ? filePath : (0, path_1.join)(process.cwd(), filePath);
138
- }
139
- exports.getAbsoluteFilePath = getAbsoluteFilePath;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateSyntheticIndices = void 0;
4
- /**
5
- * luma.gl can not work without indices now:
6
- * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
7
- * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
8
- * @param {number} vertexCount - vertex count in the geometry
9
- * @returns {Uint32Array} indices array.
10
- */
11
- const generateSyntheticIndices = (vertexCount) => {
12
- const result = new Uint32Array(vertexCount);
13
- for (let index = 0; index < vertexCount; index++) {
14
- result[index] = index;
15
- }
16
- return result;
17
- };
18
- exports.generateSyntheticIndices = generateSyntheticIndices;
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertScreenThresholdToGeometricError = exports.convertGeometricErrorToScreenThreshold = void 0;
4
- // https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html
5
- const DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;
6
- /**
7
- * Do conversion from geometric error to screen threshold
8
- *
9
- * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.
10
- * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.
11
- * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles
12
- * 3DTiles spec:
13
- * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error
14
- * I3S spec:
15
- * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md
16
- * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us
17
- * to make child maxError bigger than his parent maxError.
18
- *
19
- * @param tile - 3d-tiles tile JSON
20
- * @param coordinates - node converted coordinates
21
- * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection
22
- * @example
23
- * [
24
- {
25
- "metricType": "maxScreenThresholdSQ",
26
- "maxError": 870638.071285568
27
- },
28
- {
29
- "metricType": "maxScreenThreshold",
30
- "maxError": 1052.8679031638949
31
- }
32
- ]
33
- */
34
- function convertGeometricErrorToScreenThreshold(tile, coordinates) {
35
- const lodSelection = [];
36
- const boundingVolume = tile.boundingVolume;
37
- const lodMetricValue = tile.lodMetricValue || 0.1;
38
- const maxScreenThreshold = {
39
- metricType: 'maxScreenThreshold',
40
- maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue
41
- };
42
- const maxScreenThresholdSQ = {
43
- metricType: 'maxScreenThresholdSQ',
44
- maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError
45
- };
46
- if (boundingVolume.constructor.name === 'OrientedBoundingBox') {
47
- lodSelection.push(maxScreenThresholdSQ);
48
- lodSelection.push(maxScreenThreshold);
49
- }
50
- else {
51
- lodSelection.push(maxScreenThreshold);
52
- lodSelection.push(maxScreenThresholdSQ);
53
- }
54
- return lodSelection;
55
- }
56
- exports.convertGeometricErrorToScreenThreshold = convertGeometricErrorToScreenThreshold;
57
- /**
58
- * Convert LOD metric from "Screen Threshold" to "Screen Space Error"
59
- * @param node - i3s node data
60
- * @returns lod metric in 3d-tiles format
61
- */
62
- function convertScreenThresholdToGeometricError(node) {
63
- const metricData = node.header.lodSelection.maxScreenThreshold || {};
64
- let maxError = metricData.maxError;
65
- if (!maxError) {
66
- const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;
67
- if (sqMetricData) {
68
- maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
69
- }
70
- }
71
- if (!maxError) {
72
- maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;
73
- }
74
- return (node.header.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;
75
- }
76
- exports.convertScreenThresholdToGeometricError = convertScreenThresholdToGeometricError;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Queue = void 0;
4
- class Queue extends Array {
5
- enqueue(val) {
6
- this.push(val);
7
- }
8
- dequeue() {
9
- return this.shift();
10
- }
11
- peek() {
12
- return this[0];
13
- }
14
- isEmpty() {
15
- return this.length === 0;
16
- }
17
- }
18
- exports.Queue = Queue;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateFilesSize = exports.timeConverter = void 0;
4
- const path_1 = require("path");
5
- const fs_1 = require("fs");
6
- const file_utils_1 = require("./file-utils");
7
- function timeConverter(time) {
8
- const nanoSecondsInMillisecond = 1e6;
9
- let timeInSeconds = time[0];
10
- const hours = Math.floor(timeInSeconds / 3600);
11
- timeInSeconds = timeInSeconds - hours * 3600;
12
- const minutes = Math.floor(timeInSeconds / 60);
13
- timeInSeconds = timeInSeconds - minutes * 60;
14
- const seconds = Math.floor(timeInSeconds);
15
- const milliseconds = time[1] / nanoSecondsInMillisecond;
16
- let result = '';
17
- if (hours) {
18
- result += `${hours}h `;
19
- }
20
- if (minutes) {
21
- result += `${minutes}m `;
22
- }
23
- if (seconds) {
24
- result += `${seconds}s`;
25
- }
26
- if (!result) {
27
- result += `${milliseconds}ms`;
28
- }
29
- return result;
30
- }
31
- exports.timeConverter = timeConverter;
32
- async function calculateFilesSize(params) {
33
- const { slpk, outputPath, tilesetName } = params;
34
- const fullOutputPath = (0, file_utils_1.getAbsoluteFilePath)(outputPath);
35
- try {
36
- if (slpk) {
37
- const slpkPath = (0, path_1.join)(fullOutputPath, `${tilesetName}.slpk`);
38
- const stat = await fs_1.promises.stat(slpkPath);
39
- return stat.size;
40
- }
41
- const directoryPath = (0, path_1.join)(fullOutputPath, tilesetName);
42
- const totalSize = await getTotalFilesSize(directoryPath);
43
- return totalSize;
44
- }
45
- catch (error) {
46
- console.log('Calculate file sizes error: ', error); // eslint-disable-line
47
- return null;
48
- }
49
- }
50
- exports.calculateFilesSize = calculateFilesSize;
51
- async function getTotalFilesSize(dirPath) {
52
- let totalFileSize = 0;
53
- const files = await fs_1.promises.readdir(dirPath);
54
- for (const file of files) {
55
- const fileStat = await fs_1.promises.stat((0, path_1.join)(dirPath, file));
56
- if (fileStat.isDirectory()) {
57
- totalFileSize += await getTotalFilesSize((0, path_1.join)(dirPath, file));
58
- }
59
- else {
60
- totalFileSize += fileStat.size;
61
- }
62
- }
63
- return totalFileSize;
64
- }