@loaders.gl/tile-converter 4.0.0-alpha.9 → 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 +32715 -32567
  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 +113 -39
  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 +38 -12
  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 +27 -21
  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 +56 -11
  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 -63
  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
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ import { app } from '../app';
3
+ import https from 'https';
4
+ import http from 'http';
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { formErrorHandler, formListeningHandler, normalizePort } from '../utils/server-utils';
8
+ const httpPort = normalizePort(process.env.PORT || '80');
9
+ if (httpPort === false) {
10
+ console.error("Incorrect HTTP port");
11
+ process.exit(1);
12
+ }
13
+ const httpsPort = normalizePort(process.env.HTTPS_PORT || '443');
14
+ if (httpsPort === false) {
15
+ console.error("Incorrect HTTPs port");
16
+ process.exit(1);
17
+ }
18
+ const options = {
19
+ key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),
20
+ cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))
21
+ };
22
+ const httpServer = http.createServer(app);
23
+ const httpsServer = https.createServer(options, app);
24
+ httpServer.listen(httpPort);
25
+ httpServer.on('error', formErrorHandler(httpPort));
26
+ httpServer.on('listening', formListeningHandler(httpServer));
27
+ httpsServer.listen(httpsPort);
28
+ httpsServer.on('error', formErrorHandler(httpsPort));
29
+ httpsServer.on('listening', formListeningHandler(httpsServer));
30
+ //# sourceMappingURL=www.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"www.js","names":["app","https","http","fs","path","formErrorHandler","formListeningHandler","normalizePort","httpPort","process","env","PORT","console","error","exit","httpsPort","HTTPS_PORT","options","key","readFileSync","join","__dirname","cert","httpServer","createServer","httpsServer","listen","on"],"sources":["../../../../src/i3s-server/bin/www.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport {app} from '../app';\nimport https from 'https';\nimport http from 'http';\nimport fs from 'fs';\nimport path from 'path';\nimport {formErrorHandler, formListeningHandler, normalizePort} from '../utils/server-utils';\n\n/** Get port from environment and store in Express. */\nconst httpPort = normalizePort(process.env.PORT || '80');\nif (httpPort === false) {\n console.error(`Incorrect HTTP port`);\n process.exit(1);\n}\nconst httpsPort = normalizePort(process.env.HTTPS_PORT || '443');\nif (httpsPort === false) {\n console.error(`Incorrect HTTPs port`);\n process.exit(1);\n}\n\n/** Create HTTP server. */\nconst options = {\n key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),\n cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))\n};\n\nconst httpServer = http.createServer(app);\nconst httpsServer = https.createServer(options, app);\n\n/** Listen on provided port, on all network interfaces. */\nhttpServer.listen(httpPort);\nhttpServer.on('error', formErrorHandler(httpPort));\nhttpServer.on('listening', formListeningHandler(httpServer));\n\nhttpsServer.listen(httpsPort);\nhttpsServer.on('error', formErrorHandler(httpsPort));\nhtt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EAAE,CAAC,WAAW,EAAErB,oBAAoB,CAACiB,UAAU,CAAC,CAAC;AAE5DE,WAAW,CAACC,MAAM,CAACX,SAAS,CAAC;AAC7BU,WAAW,CAACE,EAAE,CAAC,OAAO,EAAEtB,gBAAgB,CAACU,SAAS,CAAC,CAAC;AACpDU,WAAW,CAACE,EAAE,CAAC,WAAW,EAAErB,oBAAoB,CAACmB,WAAW,CAAC,CAAC"}
@@ -1,12 +1,12 @@
1
- const path = require('path');
2
- const fs = require('fs');
1
+ import path from 'path';
2
+ import fs from 'fs';
3
3
  const {
4
4
  promises
5
5
  } = fs;
6
6
  const I3S_LAYER_PATH = process.env.I3sLayerPath || '';
7
- const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);
8
- async function getFileNameByUrl(url) {
7
+ export async function getFileNameByUrl(url) {
9
8
  const extensions = ['json', 'bin', 'jpg', 'jpeg', 'png', 'bin.dds', 'ktx2'];
9
+ const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);
10
10
  for (const ext of extensions) {
11
11
  const fileName = "".concat(FULL_LAYER_PATH).concat(url, "/index.").concat(ext);
12
12
  try {
@@ -18,7 +18,4 @@ async function getFileNameByUrl(url) {
18
18
  }
19
19
  return null;
20
20
  }
21
- module.exports = {
22
- getFileNameByUrl
23
- };
24
21
  //# sourceMappingURL=index-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-controller.js","names":["path","require","fs","promises","I3S_LAYER_PATH","process","env","I3sLayerPath","FULL_LAYER_PATH","join","cwd","getFileNameByUrl","url","extensions","ext","fileName","concat","access","module","exports"],"sources":["../../../../src/i3s-server/controllers/index-controller.js"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\n\nconst {promises} = fs;\n\nconst I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef\nconst FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef\n\nasync function getFileNameByUrl(url) {\n const extensions = ['json', 'bin', 'jpg', 'jpeg', 'png', 'bin.dds', 'ktx2'];\n for (const ext of extensions) {\n const fileName = `${FULL_LAYER_PATH}${url}/index.${ext}`;\n try {\n await promises.access(fileName);\n return fileName;\n } catch {\n continue; // eslint-disable-line no-continue\n }\n }\n return null;\n}\n\nmodule.exports = {\n getFileNameByUrl\n};\n"],"mappings":"AAAA,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAMC,EAAE,GAAGD,OAAO,CAAC,IAAI,CAAC;AAExB,MAAM;EAACE;AAAQ,CAAC,GAAGD,EAAE;AAErB,MAAME,cAAc,GAAGC,OAAO,CAACC,GAAG,CAACC,YAAY,IAAI,EAAE;AACrD,MAAMC,eAAe,GAAGR,IAAI,CAACS,IAAI,CAACJ,OAAO,CAACK,GAAG,CAAC,CAAC,EAAEN,cAAc,CAAC;AAEhE,eAAeO,gBAAgBA,CAACC,GAAG,EAAE;EACnC,MAAMC,UAAU,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC;EAC3E,KAAK,MAAMC,GAAG,IAAID,UAAU,EAAE;IAC5B,MAAME,QAAQ,MAAAC,MAAA,CAAMR,eAAe,EAAAQ,MAAA,CAAGJ,GAAG,aAAAI,MAAA,CAAUF,GAAG,CAAE;IACxD,IAAI;MACF,MAAMX,QAAQ,CAACc,MAAM,CAACF,QAAQ,CAAC;MAC/B,OAAOA,QAAQ;IACjB,CAAC,CAAC,MAAM;MACN;IACF;EACF;EACA,OAAO,IAAI;AACb;AAEAG,MAAM,CAACC,OAAO,GAAG;EACfR;AACF,CAAC"}
1
+ {"version":3,"file":"index-controller.js","names":["path","fs","promises","I3S_LAYER_PATH","process","env","I3sLayerPath","getFileNameByUrl","url","extensions","FULL_LAYER_PATH","join","cwd","ext","fileName","concat","access"],"sources":["../../../../src/i3s-server/controllers/index-controller.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs';\n\nconst {promises} = fs;\n\nconst I3S_LAYER_PATH = process.env.I3sLayerPath || '';\n\n/**\n * Get local file name by input HTTP URL\n * @param url - I3S HTTP service url\n * @returns - local file name\n */\nexport async function getFileNameByUrl(url: string): Promise<string | null> {\n const extensions = ['json', 'bin', 'jpg', 'jpeg', 'png', 'bin.dds', 'ktx2'];\n const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);\n for (const ext of extensions) {\n const fileName = `${FULL_LAYER_PATH}${url}/index.${ext}`;\n try {\n await promises.access(fileName);\n return fileName;\n } catch {\n continue; // eslint-disable-line no-continue\n }\n }\n return null;\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AAEnB,MAAM;EAACC;AAAQ,CAAC,GAAGD,EAAE;AAErB,MAAME,cAAc,GAAGC,OAAO,CAACC,GAAG,CAACC,YAAY,IAAI,EAAE;AAOrD,OAAO,eAAeC,gBAAgBA,CAACC,GAAW,EAA0B;EAC1E,MAAMC,UAAU,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC;EAC3E,MAAMC,eAAe,GAAGV,IAAI,CAACW,IAAI,CAACP,OAAO,CAACQ,GAAG,CAAC,CAAC,EAAET,cAAc,CAAC;EAChE,KAAK,MAAMU,GAAG,IAAIJ,UAAU,EAAE;IAC5B,MAAMK,QAAQ,MAAAC,MAAA,CAAML,eAAe,EAAAK,MAAA,CAAGP,GAAG,aAAAO,MAAA,CAAUF,GAAG,CAAE;IACxD,IAAI;MACF,MAAMX,QAAQ,CAACc,MAAM,CAACF,QAAQ,CAAC;MAC/B,OAAOA,QAAQ;IACjB,CAAC,CAAC,MAAM;MACN;IACF;EACF;EACA,OAAO,IAAI;AACb"}
@@ -1,36 +1,19 @@
1
- require('@loaders.gl/polyfills');
2
- const {
3
- fetchFile,
4
- parse
5
- } = require('@loaders.gl/core');
6
- const {
7
- SLPKLoader
8
- } = require('@loaders.gl/i3s');
9
- const path = require('path');
1
+ import '@loaders.gl/polyfills';
2
+ import { parseSLPK } from '@loaders.gl/i3s';
3
+ import { FileHandleFile } from '@loaders.gl/loader-utils';
10
4
  let slpkArchive;
11
- const loadArchive = async fullLayerPath => {
12
- slpkArchive = await (await fetchFile(fullLayerPath)).arrayBuffer();
5
+ export const loadArchive = async fullLayerPath => {
6
+ slpkArchive = await parseSLPK(await FileHandleFile.from(fullLayerPath), msg => console.log(msg));
7
+ console.log('The server is ready to use');
13
8
  };
14
- const I3S_LAYER_PATH = process.env.I3sLayerPath || '';
15
- const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);
16
- loadArchive(FULL_LAYER_PATH);
17
- async function getFileByUrl(url) {
9
+ export async function getFileByUrl(url) {
18
10
  const trimmedPath = /^\/?(.*)\/?$/.exec(url);
19
- let uncompressedFile;
11
+ let uncompressedFile = null;
20
12
  if (trimmedPath) {
21
13
  try {
22
- uncompressedFile = Buffer.from(await parse(slpkArchive, SLPKLoader, {
23
- slpk: {
24
- path: trimmedPath[1],
25
- pathMode: 'http'
26
- }
27
- }));
14
+ uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));
28
15
  } catch (e) {}
29
16
  }
30
17
  return uncompressedFile;
31
18
  }
32
- module.exports = {
33
- loadArchive,
34
- getFileByUrl
35
- };
36
19
  //# sourceMappingURL=slpk-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slpk-controller.js","names":["require","fetchFile","parse","SLPKLoader","path","slpkArchive","loadArchive","fullLayerPath","arrayBuffer","I3S_LAYER_PATH","process","env","I3sLayerPath","FULL_LAYER_PATH","join","cwd","getFileByUrl","url","trimmedPath","exec","uncompressedFile","Buffer","from","slpk","pathMode","e","module","exports"],"sources":["../../../../src/i3s-server/controllers/slpk-controller.js"],"sourcesContent":["require('@loaders.gl/polyfills');\nconst {fetchFile, parse} = require('@loaders.gl/core');\nconst {SLPKLoader} = require('@loaders.gl/i3s');\nconst path = require('path');\n\nlet slpkArchive;\n\nconst loadArchive = async (fullLayerPath) => {\n slpkArchive = await (await fetchFile(fullLayerPath)).arrayBuffer();\n};\n\nconst I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef\nconst FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef\n\nloadArchive(FULL_LAYER_PATH);\n\nasync function getFileByUrl(url) {\n const trimmedPath = /^\\/?(.*)\\/?$/.exec(url);\n let uncompressedFile;\n if (trimmedPath) {\n try {\n uncompressedFile = Buffer.from(\n await parse(slpkArchive, SLPKLoader, {\n slpk: {\n path: trimmedPath[1],\n pathMode: 'http'\n }\n })\n );\n } catch (e) {}\n }\n return uncompressedFile;\n}\n\nmodule.exports = {\n loadArchive,\n getFileByUrl\n};\n"],"mappings":"AAAAA,OAAO,CAAC,uBAAuB,CAAC;AAChC,MAAM;EAACC,SAAS;EAAEC;AAAK,CAAC,GAAGF,OAAO,CAAC,kBAAkB,CAAC;AACtD,MAAM;EAACG;AAAU,CAAC,GAAGH,OAAO,CAAC,iBAAiB,CAAC;AAC/C,MAAMI,IAAI,GAAGJ,OAAO,CAAC,MAAM,CAAC;AAE5B,IAAIK,WAAW;AAEf,MAAMC,WAAW,GAAG,MAAOC,aAAa,IAAK;EAC3CF,WAAW,GAAG,MAAM,CAAC,MAAMJ,SAAS,CAACM,aAAa,CAAC,EAAEC,WAAW,CAAC,CAAC;AACpE,CAAC;AAED,MAAMC,cAAc,GAAGC,OAAO,CAACC,GAAG,CAACC,YAAY,IAAI,EAAE;AACrD,MAAMC,eAAe,GAAGT,IAAI,CAACU,IAAI,CAACJ,OAAO,CAACK,GAAG,CAAC,CAAC,EAAEN,cAAc,CAAC;AAEhEH,WAAW,CAACO,eAAe,CAAC;AAE5B,eAAeG,YAAYA,CAACC,GAAG,EAAE;EAC/B,MAAMC,WAAW,GAAG,cAAc,CAACC,IAAI,CAACF,GAAG,CAAC;EAC5C,IAAIG,gBAAgB;EACpB,IAAIF,WAAW,EAAE;IACf,IAAI;MACFE,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CAC5B,MAAMpB,KAAK,CAACG,WAAW,EAAEF,UAAU,EAAE;QACnCoB,IAAI,EAAE;UACJnB,IAAI,EAAEc,WAAW,CAAC,CAAC,CAAC;UACpBM,QAAQ,EAAE;QACZ;MACF,CAAC,CACH,CAAC;IACH,CAAC,CAAC,OAAOC,CAAC,EAAE,CAAC;EACf;EACA,OAAOL,gBAAgB;AACzB;AAEAM,MAAM,CAACC,OAAO,GAAG;EACfrB,WAAW;EACXU;AACF,CAAC"}
1
+ {"version":3,"file":"slpk-controller.js","names":["parseSLPK","FileHandleFile","slpkArchive","loadArchive","fullLayerPath","from","msg","console","log","getFileByUrl","url","trimmedPath","exec","uncompressedFile","Buffer","getFile","e"],"sources":["../../../../src/i3s-server/controllers/slpk-controller.ts"],"sourcesContent":["import '@loaders.gl/polyfills';\nimport {parseSLPK} from '@loaders.gl/i3s';\nimport {FileHandleFile} from '@loaders.gl/loader-utils';\n\nlet slpkArchive;\n\n/**\n * Open SLPK file for reading and load HASH file\n * @param fullLayerPath - full path to SLPK file\n */\nexport const loadArchive = async (fullLayerPath: string): Promise<void> => {\n slpkArchive = await parseSLPK(await FileHandleFile.from(fullLayerPath), (msg) =>\n console.log(msg)\n );\n console.log('The server is ready to use');\n};\n\n/**\n * Get a file from SLPK\n * @param url - I3S HTTP URL\n * @returns - file content\n */\nexport async function getFileByUrl(url: string) {\n const trimmedPath = /^\\/?(.*)\\/?$/.exec(url);\n let uncompressedFile: Buffer | null = null;\n if (trimmedPath) {\n try {\n uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));\n } catch (e) {}\n }\n return uncompressedFile;\n}\n"],"mappings":"AAAA,OAAO,uBAAuB;AAC9B,SAAQA,SAAS,QAAO,iBAAiB;AACzC,SAAQC,cAAc,QAAO,0BAA0B;AAEvD,IAAIC,WAAW;AAMf,OAAO,MAAMC,WAAW,GAAG,MAAOC,aAAqB,IAAoB;EACzEF,WAAW,GAAG,MAAMF,SAAS,CAAC,MAAMC,cAAc,CAACI,IAAI,CAACD,aAAa,CAAC,EAAGE,GAAG,IAC1EC,OAAO,CAACC,GAAG,CAACF,GAAG,CACjB,CAAC;EACDC,OAAO,CAACC,GAAG,CAAC,4BAA4B,CAAC;AAC3C,CAAC;AAOD,OAAO,eAAeC,YAAYA,CAACC,GAAW,EAAE;EAC9C,MAAMC,WAAW,GAAG,cAAc,CAACC,IAAI,CAACF,GAAG,CAAC;EAC5C,IAAIG,gBAA+B,GAAG,IAAI;EAC1C,IAAIF,WAAW,EAAE;IACf,IAAI;MACFE,gBAAgB,GAAGC,MAAM,CAACT,IAAI,CAAC,MAAMH,WAAW,CAACa,OAAO,CAACJ,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC,CAAC,OAAOK,CAAC,EAAE,CAAC;EACf;EACA,OAAOH,gBAAgB;AACzB"}
@@ -1,4 +1,4 @@
1
- const express = require('express');
1
+ import express from 'express';
2
2
  const router = express.Router();
3
3
  const {
4
4
  getFileNameByUrl
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["express","require","router","Router","getFileNameByUrl","get","req","res","next","fileName","path","sendFile","status","send","module","exports"],"sources":["../../../../src/i3s-server/routes/index.js"],"sourcesContent":["const express = require('express');\nconst router = express.Router();\nconst {getFileNameByUrl} = require('../controllers/index-controller');\n\n/* GET home page. */\nrouter.get('*', async function (req, res, next) {\n const fileName = await getFileNameByUrl(req.path);\n if (fileName) {\n res.sendFile(fileName);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nmodule.exports = router;\n"],"mappings":"AAAA,MAAMA,OAAO,GAAGC,OAAO,CAAC,SAAS,CAAC;AAClC,MAAMC,MAAM,GAAGF,OAAO,CAACG,MAAM,CAAC,CAAC;AAC/B,MAAM;EAACC;AAAgB,CAAC,GAAGH,OAAO,CAAC,iCAAiC,CAAC;AAGrEC,MAAM,CAACG,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EAC9C,MAAMC,QAAQ,GAAG,MAAML,gBAAgB,CAACE,GAAG,CAACI,IAAI,CAAC;EACjD,IAAID,QAAQ,EAAE;IACZF,GAAG,CAACI,QAAQ,CAACF,QAAQ,CAAC;EACxB,CAAC,MAAM;IACLF,GAAG,CAACK,MAAM,CAAC,GAAG,CAAC;IACfL,GAAG,CAACM,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC;AAEFC,MAAM,CAACC,OAAO,GAAGb,MAAM"}
1
+ {"version":3,"file":"index.js","names":["express","router","Router","getFileNameByUrl","require","get","req","res","next","fileName","path","sendFile","status","send","module","exports"],"sources":["../../../../src/i3s-server/routes/index.ts"],"sourcesContent":["import express from 'express';\n\nconst router = express.Router();\nconst {getFileNameByUrl} = require('../controllers/index-controller');\n\n/* GET home page. */\nrouter.get('*', async function (req, res, next) {\n const fileName = await getFileNameByUrl(req.path);\n if (fileName) {\n res.sendFile(fileName);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nmodule.exports = router;\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAE7B,MAAMC,MAAM,GAAGD,OAAO,CAACE,MAAM,CAAC,CAAC;AAC/B,MAAM;EAACC;AAAgB,CAAC,GAAGC,OAAO,CAAC,iCAAiC,CAAC;AAGrEH,MAAM,CAACI,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EAC9C,MAAMC,QAAQ,GAAG,MAAMN,gBAAgB,CAACG,GAAG,CAACI,IAAI,CAAC;EACjD,IAAID,QAAQ,EAAE;IACZF,GAAG,CAACI,QAAQ,CAACF,QAAQ,CAAC;EACxB,CAAC,MAAM;IACLF,GAAG,CAACK,MAAM,CAAC,GAAG,CAAC;IACfL,GAAG,CAACM,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC;AAEFC,MAAM,CAACC,OAAO,GAAGd,MAAM"}
@@ -1,9 +1,7 @@
1
- const express = require('express');
2
- const {
3
- getFileByUrl
4
- } = require('../controllers/slpk-controller');
5
- const createSceneServer = require('../utils/create-scene-server');
6
- const sceneServerRouter = express.Router();
1
+ import express from 'express';
2
+ import { getFileByUrl } from '../controllers/slpk-controller';
3
+ import { createSceneServer } from '../utils/create-scene-server';
4
+ export const sceneServerRouter = express.Router();
7
5
  sceneServerRouter.get('*', async function (req, res, next) {
8
6
  const file = await getFileByUrl('/');
9
7
  if (file) {
@@ -15,7 +13,7 @@ sceneServerRouter.get('*', async function (req, res, next) {
15
13
  res.send('File not found');
16
14
  }
17
15
  });
18
- const router = express.Router();
16
+ export const router = express.Router();
19
17
  router.get('*', async function (req, res, next) {
20
18
  console.log(req.path);
21
19
  const file = await getFileByUrl(req.path);
@@ -26,8 +24,4 @@ router.get('*', async function (req, res, next) {
26
24
  res.send('File not found');
27
25
  }
28
26
  });
29
- module.exports = {
30
- sceneServerRouter,
31
- router
32
- };
33
27
  //# sourceMappingURL=slpk-router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slpk-router.js","names":["express","require","getFileByUrl","createSceneServer","sceneServerRouter","Router","get","req","res","next","file","layer","JSON","parse","toString","sceneServerResponse","name","send","status","router","console","log","path","module","exports"],"sources":["../../../../src/i3s-server/routes/slpk-router.js"],"sourcesContent":["const express = require('express');\nconst {getFileByUrl} = require('../controllers/slpk-controller');\nconst createSceneServer = require('../utils/create-scene-server');\n\nconst sceneServerRouter = express.Router();\nsceneServerRouter.get('*', async function (req, res, next) {\n const file = await getFileByUrl('/');\n if (file) {\n const layer = JSON.parse(file.toString());\n const sceneServerResponse = createSceneServer(layer.name, layer);\n res.send(sceneServerResponse);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nconst router = express.Router();\nrouter.get('*', async function (req, res, next) {\n console.log(req.path);\n const file = await getFileByUrl(req.path);\n if (file) {\n res.send(file);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nmodule.exports = {\n sceneServerRouter,\n router\n};\n"],"mappings":"AAAA,MAAMA,OAAO,GAAGC,OAAO,CAAC,SAAS,CAAC;AAClC,MAAM;EAACC;AAAY,CAAC,GAAGD,OAAO,CAAC,gCAAgC,CAAC;AAChE,MAAME,iBAAiB,GAAGF,OAAO,CAAC,8BAA8B,CAAC;AAEjE,MAAMG,iBAAiB,GAAGJ,OAAO,CAACK,MAAM,CAAC,CAAC;AAC1CD,iBAAiB,CAACE,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EACzD,MAAMC,IAAI,GAAG,MAAMR,YAAY,CAAC,GAAG,CAAC;EACpC,IAAIQ,IAAI,EAAE;IACR,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,QAAQ,CAAC,CAAC,CAAC;IACzC,MAAMC,mBAAmB,GAAGZ,iBAAiB,CAACQ,KAAK,CAACK,IAAI,EAAEL,KAAK,CAAC;IAChEH,GAAG,CAACS,IAAI,CAACF,mBAAmB,CAAC;EAC/B,CAAC,MAAM;IACLP,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC;IACfV,GAAG,CAACS,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC;AAEF,MAAME,MAAM,GAAGnB,OAAO,CAACK,MAAM,CAAC,CAAC;AAC/Bc,MAAM,CAACb,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EAC9CW,OAAO,CAACC,GAAG,CAACd,GAAG,CAACe,IAAI,CAAC;EACrB,MAAMZ,IAAI,GAAG,MAAMR,YAAY,CAACK,GAAG,CAACe,IAAI,CAAC;EACzC,IAAIZ,IAAI,EAAE;IACRF,GAAG,CAACS,IAAI,CAACP,IAAI,CAAC;EAChB,CAAC,MAAM;IACLF,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC;IACfV,GAAG,CAACS,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC;AAEFM,MAAM,CAACC,OAAO,GAAG;EACfpB,iBAAiB;EACjBe;AACF,CAAC"}
1
+ {"version":3,"file":"slpk-router.js","names":["express","getFileByUrl","createSceneServer","sceneServerRouter","Router","get","req","res","next","file","layer","JSON","parse","toString","sceneServerResponse","name","send","status","router","console","log","path"],"sources":["../../../../src/i3s-server/routes/slpk-router.ts"],"sourcesContent":["import express from 'express';\nimport {getFileByUrl} from '../controllers/slpk-controller';\nimport {createSceneServer} from '../utils/create-scene-server';\n\nexport const sceneServerRouter = express.Router();\nsceneServerRouter.get('*', async function (req, res, next) {\n const file = await getFileByUrl('/');\n if (file) {\n const layer = JSON.parse(file.toString());\n const sceneServerResponse = createSceneServer(layer.name, layer);\n res.send(sceneServerResponse);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nexport const router = express.Router();\nrouter.get('*', async function (req, res, next) {\n console.log(req.path);\n const file = await getFileByUrl(req.path);\n if (file) {\n res.send(file);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAC7B,SAAQC,YAAY,QAAO,gCAAgC;AAC3D,SAAQC,iBAAiB,QAAO,8BAA8B;AAE9D,OAAO,MAAMC,iBAAiB,GAAGH,OAAO,CAACI,MAAM,CAAC,CAAC;AACjDD,iBAAiB,CAACE,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EACzD,MAAMC,IAAI,GAAG,MAAMR,YAAY,CAAC,GAAG,CAAC;EACpC,IAAIQ,IAAI,EAAE;IACR,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,QAAQ,CAAC,CAAC,CAAC;IACzC,MAAMC,mBAAmB,GAAGZ,iBAAiB,CAACQ,KAAK,CAACK,IAAI,EAAEL,KAAK,CAAC;IAChEH,GAAG,CAACS,IAAI,CAACF,mBAAmB,CAAC;EAC/B,CAAC,MAAM;IACLP,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC;IACfV,GAAG,CAACS,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC;AAEF,OAAO,MAAME,MAAM,GAAGlB,OAAO,CAACI,MAAM,CAAC,CAAC;AACtCc,MAAM,CAACb,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EAC9CW,OAAO,CAACC,GAAG,CAACd,GAAG,CAACe,IAAI,CAAC;EACrB,MAAMZ,IAAI,GAAG,MAAMR,YAAY,CAACK,GAAG,CAACe,IAAI,CAAC;EACzC,IAAIZ,IAAI,EAAE;IACRF,GAAG,CAACS,IAAI,CAACP,IAAI,CAAC;EAChB,CAAC,MAAM;IACLF,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC;IACfV,GAAG,CAACS,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC"}
@@ -1,7 +1,5 @@
1
- const {
2
- v4: uuidv4
3
- } = require('uuid');
4
- const createSceneServer = (name, layer) => {
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ export const createSceneServer = (name, layer) => {
5
3
  return {
6
4
  serviceItemId: uuidv4().replace(/-/gi, ''),
7
5
  serviceName: name,
@@ -12,5 +10,4 @@ const createSceneServer = (name, layer) => {
12
10
  layers: [layer]
13
11
  };
14
12
  };
15
- module.exports = createSceneServer;
16
13
  //# sourceMappingURL=create-scene-server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-scene-server.js","names":["v4","uuidv4","require","createSceneServer","name","layer","serviceItemId","replace","serviceName","currentVersion","serviceVersion","supportedBindings","layers","module","exports"],"sources":["../../../../src/i3s-server/utils/create-scene-server.js"],"sourcesContent":["const {v4: uuidv4} = require('uuid');\n\nconst createSceneServer = (name, layer) => {\n return {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n serviceName: name,\n name,\n currentVersion: '10.7',\n serviceVersion: '1.8',\n supportedBindings: ['REST'],\n layers: [layer]\n };\n};\n\nmodule.exports = createSceneServer;\n"],"mappings":"AAAA,MAAM;EAACA,EAAE,EAAEC;AAAM,CAAC,GAAGC,OAAO,CAAC,MAAM,CAAC;AAEpC,MAAMC,iBAAiB,GAAGA,CAACC,IAAI,EAAEC,KAAK,KAAK;EACzC,OAAO;IACLC,aAAa,EAAEL,MAAM,CAAC,CAAC,CAACM,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1CC,WAAW,EAAEJ,IAAI;IACjBA,IAAI;IACJK,cAAc,EAAE,MAAM;IACtBC,cAAc,EAAE,KAAK;IACrBC,iBAAiB,EAAE,CAAC,MAAM,CAAC;IAC3BC,MAAM,EAAE,CAACP,KAAK;EAChB,CAAC;AACH,CAAC;AAEDQ,MAAM,CAACC,OAAO,GAAGX,iBAAiB"}
1
+ {"version":3,"file":"create-scene-server.js","names":["v4","uuidv4","createSceneServer","name","layer","serviceItemId","replace","serviceName","currentVersion","serviceVersion","supportedBindings","layers"],"sources":["../../../../src/i3s-server/utils/create-scene-server.ts"],"sourcesContent":["import {SceneLayer3D} from '@loaders.gl/i3s';\nimport {v4 as uuidv4} from 'uuid';\n\n/**\n * Create `/SceneServer` response\n * @param name - service name, custom user-friendly name of the service\n * @param layer - I3S layer JSON\n * @returns reponse JSON for `/SceneServer` route\n */\nexport const createSceneServer = (name: string, layer: SceneLayer3D) => {\n return {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n serviceName: name,\n name,\n currentVersion: '10.7',\n serviceVersion: '1.8',\n supportedBindings: ['REST'],\n layers: [layer]\n };\n};\n"],"mappings":"AACA,SAAQA,EAAE,IAAIC,MAAM,QAAO,MAAM;AAQjC,OAAO,MAAMC,iBAAiB,GAAGA,CAACC,IAAY,EAAEC,KAAmB,KAAK;EACtE,OAAO;IACLC,aAAa,EAAEJ,MAAM,CAAC,CAAC,CAACK,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1CC,WAAW,EAAEJ,IAAI;IACjBA,IAAI;IACJK,cAAc,EAAE,MAAM;IACtBC,cAAc,EAAE,KAAK;IACrBC,iBAAiB,EAAE,CAAC,MAAM,CAAC;IAC3BC,MAAM,EAAE,CAACP,KAAK;EAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ import debugFactory from 'debug';
2
+ const debug = debugFactory('i3s-server:server');
3
+ export function normalizePort(val) {
4
+ const chkPort = parseInt(val, 10);
5
+ if (Number.isNaN(chkPort)) {
6
+ return val;
7
+ }
8
+ if (chkPort >= 0) {
9
+ return chkPort;
10
+ }
11
+ return false;
12
+ }
13
+ export function formErrorHandler(optionalPort) {
14
+ return function onError(error) {
15
+ if (error.syscall !== 'listen') {
16
+ throw error;
17
+ }
18
+ const bind = typeof optionalPort === 'string' ? "Pipe ".concat(optionalPort) : "Port ".concat(optionalPort);
19
+ switch (error.code) {
20
+ case 'EACCES':
21
+ console.error("".concat(bind, " requires elevated privileges"));
22
+ process.exit(1);
23
+ break;
24
+ case 'EADDRINUSE':
25
+ console.error("".concat(bind, " is already in use"));
26
+ process.exit(1);
27
+ break;
28
+ default:
29
+ throw error;
30
+ }
31
+ };
32
+ }
33
+ export function formListeningHandler(optionalServer) {
34
+ return function onListening() {
35
+ const addr = optionalServer.address();
36
+ const bind = typeof addr === 'string' ? "pipe ".concat(addr) : "port ".concat(addr === null || addr === void 0 ? void 0 : addr.port);
37
+ debug("Listening on ".concat(bind));
38
+ };
39
+ }
40
+ //# sourceMappingURL=server-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-utils.js","names":["debugFactory","debug","normalizePort","val","chkPort","parseInt","Number","isNaN","formErrorHandler","optionalPort","onError","error","syscall","bind","concat","code","console","process","exit","formListeningHandler","optionalServer","onListening","addr","address","port"],"sources":["../../../../src/i3s-server/utils/server-utils.ts"],"sourcesContent":["import type {Server as HttpsServer} from 'https';\nimport type {Server as HttpServer} from 'http';\n\nimport debugFactory from 'debug';\nconst debug = debugFactory('i3s-server:server');\n\n/**\n * Normalize a port into a number, string, or false.\n * @param val - port value from env variables\n * @returns - `number` for port, `string` for a named pipe, or `false` if the port number is not correct\n */\nexport function normalizePort(val: string): number | string | false {\n const chkPort = parseInt(val, 10);\n\n if (Number.isNaN(chkPort)) {\n // named pipe\n return val;\n }\n\n if (chkPort >= 0) {\n // port number\n return chkPort;\n }\n\n return false;\n}\n\n/**\n * Event listener creator for HTTP/HTTPS server \"error\" event.\n * @param optionalPort - the port/named pipe the server is started on\n * @return callback to handle server errors\n */\nexport function formErrorHandler(\n optionalPort: string | number\n): (error: NodeJS.ErrnoException) => void {\n return function onError(error: NodeJS.ErrnoException) {\n if (error.syscall !== 'listen') {\n throw error;\n }\n\n const bind = typeof optionalPort === 'string' ? `Pipe ${optionalPort}` : `Port ${optionalPort}`;\n\n // handle specific listen errors with friendly messages\n switch (error.code) {\n case 'EACCES':\n console.error(`${bind} requires elevated privileges`); // eslint-disable-line no-console, no-undef\n process.exit(1); // eslint-disable-line no-process-exit, no-undef\n break;\n case 'EADDRINUSE':\n console.error(`${bind} is already in use`); // eslint-disable-line no-console, no-undef\n process.exit(1); // eslint-disable-line no-process-exit, no-undef\n break;\n default:\n throw error;\n }\n };\n}\n\n/**\n * Event listener for HTTP/HTTPS server \"listening\" event.\n * @param optionalServer - http or https NodeJS server\n * @return callback that is triggered when the server has started\n */\nexport function formListeningHandler(optionalServer: HttpsServer | HttpServer): () => void {\n return function onListening() {\n const addr = optionalServer.address();\n const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr?.port}`;\n debug(`Listening on ${bind}`);\n };\n}\n"],"mappings":"AAGA,OAAOA,YAAY,MAAM,OAAO;AAChC,MAAMC,KAAK,GAAGD,YAAY,CAAC,mBAAmB,CAAC;AAO/C,OAAO,SAAS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EAC/B,CAAC;AACH"}
@@ -0,0 +1,47 @@
1
+ export function getStringValue(index, args) {
2
+ if (index + 1 >= args.length) {
3
+ return '';
4
+ }
5
+ const value = args[index + 1];
6
+ if (value.indexOf('--') === 0) {
7
+ return '';
8
+ }
9
+ return value;
10
+ }
11
+ export function getURLValue(index, args) {
12
+ const value = getStringValue(index, args);
13
+ console.log("Input tileset value: ".concat(value));
14
+ console.log("Modified tileset value: ".concat(value.replace(/\\/g, '/')));
15
+ return value.replace(/\\/g, '/');
16
+ }
17
+ export function validateOptionsWithEqual(args) {
18
+ return args.reduce((acc, curr) => {
19
+ const equalSignIndex = curr.indexOf('=');
20
+ const beforeEqual = curr.slice(0, equalSignIndex);
21
+ const afterEqual = curr.slice(equalSignIndex + 1, curr.length);
22
+ const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;
23
+ if (condition) {
24
+ return acc.concat(beforeEqual, afterEqual);
25
+ }
26
+ return acc.concat(curr);
27
+ }, []);
28
+ }
29
+ export function getIntegerValue(index, args) {
30
+ const stringValue = getStringValue(index, args);
31
+ const result = Number.parseInt(stringValue);
32
+ if (isFinite(result)) {
33
+ return result;
34
+ }
35
+ return NaN;
36
+ }
37
+ export function getBooleanValue(index, args) {
38
+ const stringValue = getStringValue(index, args).toLowerCase().trim();
39
+ if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
40
+ return false;
41
+ }
42
+ if (!stringValue || stringValue === 'true') {
43
+ return true;
44
+ }
45
+ return false;
46
+ }
47
+ //# sourceMappingURL=cli-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-utils.js","names":["getStringValue","index","args","length","value","indexOf","getURLValue","console","log","concat","replace","validateOptionsWithEqual","reduce","acc","curr","equalSignIndex","beforeEqual","slice","afterEqual","condition","includes","startsWith","getIntegerValue","stringValue","result","Number","parseInt","isFinite","NaN","getBooleanValue","toLowerCase","trim"],"sources":["../../../../src/lib/utils/cli-utils.ts"],"sourcesContent":["/**\n * Get string option value from cli arguments\n * @param index - option's name index in the argument's array.\n * The value of the option should be next to name of the option.\n * @param args - cli arguments array\n * @returns - string value of the option\n */\nexport function getStringValue(index: number, args: string[]): string {\n if (index + 1 >= args.length) {\n return '';\n }\n const value = args[index + 1];\n if (value.indexOf('--') === 0) {\n return '';\n }\n return value;\n}\n\n/**\n * Modyfy URL path to be compatible with fetch\n * @param index - option's name index in the argument's array.\n * The value of the option should be next to name of the option.\n * @param args - cli arguments array\n * @returns - string value of the option\n */\nexport function getURLValue(index: number, args: string[]): string {\n const value = getStringValue(index, args);\n console.log(`Input tileset value: ${value}`);\n console.log(`Modified tileset value: ${value.replace(/\\\\/g, '/')}`);\n return value.replace(/\\\\/g, '/');\n}\n\nexport function validateOptionsWithEqual(args: string[]): string[] {\n return args.reduce((acc: string[], curr) => {\n const equalSignIndex = curr.indexOf('=');\n const beforeEqual = curr.slice(0, equalSignIndex);\n const afterEqual = curr.slice(equalSignIndex + 1, curr.length);\n const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;\n if (condition) {\n return acc.concat(beforeEqual, afterEqual);\n }\n return acc.concat(curr);\n }, []);\n}\n\n/**\n * Get integer option value from cli arguments\n * @param index - option's name index in the argument's array\n * The value of the option should be next to name of the option.\n * @param args - cli arguments array\n * @returns - number value of the option\n */\nexport function getIntegerValue(index: number, args: string[]): number {\n const stringValue: string = getStringValue(index, args);\n const result: number = Number.parseInt(stringValue);\n if (isFinite(result)) {\n return result;\n }\n return NaN;\n}\n\n/**\n * Get boolean option value from cli arguments\n * @param index - option's name index in the argument's array\n * The value of the option should be next to name of the option.\n * @param args - cli arguments array\n * @returns - boolean value of the option\n */\nexport function getBooleanValue(index: number, args: string[]): boolean {\n const stringValue: string = getStringValue(index, args).toLowerCase().trim();\n if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {\n return false;\n }\n if (!stringValue || stringValue === 'true') {\n return true;\n }\n return false;\n}\n"],"mappings":"AAOA,OAAO,SAASA,cAAcA,CAACC,KAAa,EAA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J,MAAM,CAACK,IAAI,CAAC;EACzB,CAAC,EAAE,EAAE,CAAC;AACR;AASA,OAAO,SAASQ,eAAeA,CAACrB,KAAa,EAAEC,IAAc,EAAU;EACrE,MAAMqB,WAAmB,GAAGvB,cAAc,CAACC,KAAK,EAAEC,IAAI,CAAC;EACvD,MAAMsB,MAAc,GAAGC,MAAM,CAACC,QAAQ,CAACH,WAAW,CAAC;EACnD,IAAII,QAAQ,CAACH,MAAM,CAAC,EAAE;IACpB,OAAOA,MAAM;EACf;EACA,OAAOI,GAAG;AACZ;AASA,OAAO,SAASC,eAAeA,CAAC5B,KAAa,EAAEC,IAAc,EAAW;EACtE,MAAMqB,WAAmB,GAAGvB,cAAc,CAACC,KAAK,EAAEC,IAAI,CAAC,CAAC4B,WAAW,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;EAC5E,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAACX,QAAQ,CAAClB,IAAI,CAACD,KAAK,CAAC,CAAC,IAAI,CAACsB,WAAW,EAAE;IACzE,OAAO,KAAK;EACd;EACA,IAAI,CAACA,WAAW,IAAIA,WAAW,KAAK,MAAM,EAAE;IAC1C,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd"}
@@ -112,7 +112,7 @@ export async function generateHash128FromZip(inputZipFile, outputFile) {
112
112
  const _data = '_data';
113
113
  const content = zipEntry[_data].compressedContent;
114
114
  if (zipEntry.dir) continue;
115
- const hash = await new MD5Hash().hash(Buffer.from(relativePath.toLowerCase()));
115
+ const hash = await new MD5Hash().hash(Buffer.from(relativePath.toLowerCase()), 'base64');
116
116
  hashTable.push({
117
117
  key: atob(hash),
118
118
  value: content.byteOffset
@@ -1 +1 @@
1
- {"version":3,"file":"compress-util.js","names":["createGzip","join","promises","fs","createReadStream","createWriteStream","archiver","removeFile","ChildProcessProxy","JSZip","MD5Hash","crypt","getAbsoluteFilePath","compressFileWithGzip","pathFile","compressedPathFile","concat","gzip","input","output","Promise","resolve","reject","on","console","log","error","pipe","compressFilesWithZip","fileMap","outputFile","level","arguments","length","undefined","e","archive","zlib","pointer","err","subFileName","subFileData","appendFileToArchive","finalize","compressWithChildProcess","inputFolder","inputFiles","sevenZipExe","process","platform","compressWithChildProcessWindows","compressWithChildProcessUnix","fullOutputFile","args","childProcess","start","command","spawn","cwd","wait","substr","generateHash128FromZip","inputZipFile","readFile","zip","loadAsync","hashTable","zipFiles","files","relativePath","zipEntry","_data","content","compressedContent","dir","hash","Buffer","from","toLowerCase","push","key","atob","value","byteOffset","sort","prev","next","item","longToByteArray","write","hexToBytes","close","long","buffer","ArrayBuffer","longNum","Float64Array","parseInt","Array","Uint8Array","reverse","addFileToZip","fileName","zipFile","fileStream","append","name"],"sources":["../../../../src/lib/utils/compress-util.ts"],"sourcesContent":["import {createGzip} from 'zlib';\nimport {join} from 'path';\nimport {promises as fs, createReadStream, createWriteStream} from 'fs';\nimport archiver from 'archiver';\nimport {removeFile} from './file-utils';\nimport {ChildProcessProxy} from '@loaders.gl/worker-utils';\nimport JSZip from 'jszip';\nimport {MD5Hash} from '@loaders.gl/crypto';\nimport crypt from 'crypt';\nimport {getAbsoluteFilePath} from './file-utils';\n\n/**\n * Compress file to gzip file\n *\n * @param pathFile - the path to the file\n * @return the path to the gzip file\n */\nexport function compressFileWithGzip(pathFile: string): Promise<string> {\n const compressedPathFile = `${pathFile}.gz`;\n const gzip = createGzip();\n const input = createReadStream(pathFile);\n const output = createWriteStream(compressedPathFile);\n\n return new Promise((resolve, reject) => {\n input.on('end', () => {\n console.log(`${compressedPathFile} compressed and saved.`); // eslint-disable-line no-undef,no-console\n resolve(compressedPathFile);\n });\n input.on('error', (error) => {\n console.log(`${compressedPathFile}: compression error!`); // eslint-disable-line no-undef,no-console\n reject(error);\n });\n input.pipe(gzip).pipe(output);\n });\n}\n\n/**\n * Compress files from map into slpk file\n *\n * @param fileMap - map with file paths (key: output path, value: input path)\n * @param outputFile - output slpk file\n * @param level - compression level\n */\nexport async function compressFilesWithZip(\n fileMap: {[key: string]: string},\n outputFile: string,\n level: number = 0\n) {\n // Before creating a new file, we need to delete the old file\n try {\n await removeFile(outputFile);\n } catch (e) {\n // Do nothing if old file doesn't exist\n }\n\n const output = createWriteStream(outputFile);\n const archive = archiver('zip', {\n zlib: {level} // Sets the compression level.\n });\n\n return new Promise(async (resolve, reject) => {\n // listen for all archive data to be writte\n // 'close' event is fired only when a file descriptor is involved\n output.on('close', function () {\n console.log(`${outputFile} saved.`); // eslint-disable-line no-undef,no-console\n console.log(`${archive.pointer()} total bytes`); // eslint-disable-line no-undef,no-console\n resolve(null);\n });\n\n // This event is fired when the data source is drained no matter what was the data source.\n // It is not part of this library but rather from the NodeJS Stream API.\n // @see: https://nodejs.org/api/stream.html#stream_event_end\n output.on('end', function () {\n console.log('Data has been drained'); // eslint-disable-line no-undef,no-console\n resolve(null);\n });\n\n // good practice to catch warnings (ie stat failures and other non-blocking errors)\n archive.on('warning', function (err) {\n console.log(err); // eslint-disable-line no-undef,no-console\n reject(err);\n });\n\n // good practice to catch this error explicitly\n archive.on('error', function (err) {\n reject(err);\n });\n\n // pipe archive data to the file\n archive.pipe(output);\n\n for (const subFileName in fileMap) {\n const subFileData = fileMap[subFileName];\n await appendFileToArchive(archive, subFileName, subFileData);\n }\n\n // finalize the archive (ie we are done appending files but streams have to finish yet)\n archive.finalize();\n });\n}\n\n/**\n * Compress files using external tool 'zip'/'7z'\n *\n * @param inputFolder - folder to archive - for cwd option\n * @param outputFile - output slpk file\n * @param level - compression level\n * @param inputFiles - input files path to pass to the executable as option\n * @param sevenZipExe - path to 7z.exe executable\n */\nexport async function compressWithChildProcess(\n inputFolder: string,\n outputFile: string,\n level: number,\n inputFiles: string,\n sevenZipExe: string\n) {\n // eslint-disable-next-line no-undef\n if (process.platform === 'win32') {\n await compressWithChildProcessWindows(inputFolder, outputFile, level, inputFiles, sevenZipExe);\n } else {\n await compressWithChildProcessUnix(inputFolder, outputFile, level, inputFiles);\n }\n}\n\n/**\n * Compress files using external linux tool 'zip'\n *\n * @param inputFolder - folder to archive - for cwd option\n * @param outputFile - output slpk file\n * @param level - compression level\n * @param inputFiles - input files path to pass to the executable as option\n */\nasync function compressWithChildProcessUnix(\n inputFolder: string,\n outputFile: string,\n level: number = 0,\n inputFiles: string = '.'\n) {\n const fullOutputFile = getAbsoluteFilePath(outputFile);\n const args = [`-${level}`, '-r', fullOutputFile, inputFiles];\n const childProcess = new ChildProcessProxy();\n await childProcess.start({\n command: 'zip',\n arguments: args,\n spawn: {\n cwd: inputFolder\n },\n wait: 0\n });\n}\n\n/**\n * Compress files using windows external tool '7z'\n *\n * @param inputFolder - folder to archive - for cwd option\n * @param outputFile - output slpk file\n * @param level - compression level\n * @param inputFiles - input files path to pass to the executable as option\n * @param sevenZipExe - path to 7z.exe executable\n */\nasync function compressWithChildProcessWindows(\n inputFolder: string,\n outputFile: string,\n level: number = 0,\n inputFiles: string = join('.', '*'),\n sevenZipExe: string\n) {\n // Workaround for @listfile issue. In 7z.exe @-leading files are handled as listfiles\n // https://sevenzip.osdn.jp/chm/cmdline/syntax.htm\n if (inputFiles[0] === '@') {\n inputFiles = `*${inputFiles.substr(1)}`;\n }\n\n const fullOutputFile = getAbsoluteFilePath(outputFile);\n const args = ['a', '-tzip', `-mx=${level}`, fullOutputFile, inputFiles];\n const childProcess = new ChildProcessProxy();\n await childProcess.start({\n command: sevenZipExe,\n arguments: args,\n spawn: {\n cwd: `${inputFolder}`\n },\n wait: 0\n });\n}\n\n/**\n * Generate hash file from zip archive\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/slpk_hashtable.cmn.md\n *\n * @param inputZipFile\n * @param outputFile\n */\nexport async function generateHash128FromZip(inputZipFile: string, outputFile: string) {\n const input = await fs.readFile(inputZipFile);\n const zip = await JSZip.loadAsync(input);\n const hashTable: {key: string; value: string}[] = [];\n const zipFiles = zip.files;\n for (const relativePath in zipFiles) {\n const zipEntry = zipFiles[relativePath];\n // Had to use a workaround because the correct string is getting the wrong data\n // const content = await zipEntry.async('nodebuffer');\n // _data isn't described in the interface, so lint thought it was wrong\n const _data = '_data';\n const content = zipEntry[_data].compressedContent;\n if (zipEntry.dir) continue; // eslint-disable-line no-continue\n // eslint-disable-next-line no-undef\n const hash = await new MD5Hash().hash(Buffer.from(relativePath.toLowerCase()));\n // eslint-disable-next-line no-undef\n hashTable.push({key: atob(hash), value: content.byteOffset});\n }\n\n hashTable.sort((prev, next) => {\n if (prev.key === next.key) {\n return prev.value < next.value ? -1 : 1;\n }\n return prev.key < next.key ? -1 : 1;\n });\n\n const output = createWriteStream(outputFile);\n return new Promise((resolve, reject) => {\n output.on('close', function () {\n console.log(`${outputFile} generated and saved`); // eslint-disable-line\n resolve(null);\n });\n output.on('error', function (err) {\n console.log(err); // eslint-disable-line\n reject(err);\n });\n for (const key in hashTable) {\n const item = hashTable[key];\n const value = longToByteArray(item.value);\n // TODO: perhaps you need to wait for the 'drain' event if the write returns 'false'\n // eslint-disable-next-line no-undef\n output.write(Buffer.from(crypt.hexToBytes(item.key).concat(value)));\n }\n output.close();\n });\n}\n\n/**\n * Encode 64 bit value to byte array\n *\n * @param long - stringified number\n * @returns\n */\nfunction longToByteArray(long: string): number[] {\n const buffer = new ArrayBuffer(8); // JS numbers are 8 bytes long, or 64 bits\n const longNum = new Float64Array(buffer); // so equivalent to Float64\n longNum[0] = parseInt(long);\n return Array.from(new Uint8Array(buffer)).reverse(); // reverse to get little endian\n}\n\n/**\n * Add file to zip archive\n *\n * @param inputFile\n * @param fileName\n * @param zipFile\n * @param sevenZipExe\n */\nexport async function addFileToZip(\n inputFolder: string,\n fileName: string,\n zipFile: string,\n sevenZipExe: string\n) {\n await compressWithChildProcess(inputFolder, zipFile, 0, fileName, sevenZipExe);\n console.log(`${fileName} added to ${zipFile}.`); // eslint-disable-line\n}\n\n/**\n *\n * @param archive zip archive instance\n * @param subFileName file path inside archive\n * @param subFileData source file path\n * @returns\n */\nfunction appendFileToArchive(archive: any, subFileName: string, subFileData: string) {\n return new Promise((resolve) => {\n const fileStream = createReadStream(subFileData);\n console.log(`Compression start: ${subFileName}`); // eslint-disable-line no-undef,no-console\n fileStream.on('close', () => {\n console.log(`Compression finish: ${subFileName}`); // eslint-disable-line no-undef,no-console\n resolve(null);\n });\n archive.append(fileStream, {name: subFileName});\n });\n}\n"],"mappings":"AAAA,SAAQA,UAAU,QAAO,MAAM;AAC/B,SAAQC,IAAI,QAAO,MAAM;AACzB,SAAQC,QAAQ,IAAIC,EAAE,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAO,IAAI;AACtE,OAAOC,QAAQ,MAAM,UAAU;AAC/B,SAAQC,UAAU,QAAO,cAAc;AACvC,SAAQC,iBAAiB,QAAO,0BAA0B;AAC1D,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,OAAO,QAAO,oBAAoB;AAC1C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,mBAAmB,QAAO,cAAc;AAQhD,OAAO,SAASC,oBAAoBA,CAACC,QAAgB,EAAmB;EACtE,MAAMC,kBAAkB,MAAAC,MAAA,CAAMF,QAAQ,QAAK;EAC3C,MAAMG,IAAI,GAAGjB,UAAU,CAAC,CAAC;EACzB,MAAMkB,KAAK,GAAGd,gBAAgB,CAACU,QAAQ,CAAC;EACxC,MAAMK,MAAM,GAAGd,iBAAiB,CAACU,kBAAkB,CAAC;EAEpD,OAAO,IAAIK,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtCJ,KAAK,CAACK,EAAE,CAAC,KAAK,EAAE,MAAM;MACpBC,OAAO,CAACC,GAAG,IAAAT,MAAA,CAAID,kBAAkB,2BAAwB,CAAC;MAC1DM,OAAO,CAACN,kBAAkB,CAAC;IAC7B,CAAC,CAAC;IACFG,KAAK,CAACK,EAAE,CAAC,OAAO,EAAGG,KAAK,IAAK;MAC3BF,OAAO,CAACC,GAAG,IAAAT,MAAA,CAAID,kBAAkB,yBAAsB,CAAC;MACxDO,MAAM,CAACI,KAAK,CAAC;IACf,CAAC,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AAU,GAAGpG,gBAAgB,CAACqC,WAAW,CAAC;IAChDjB,OAAO,CAACC,GAAG,uBAAAT,MAAA,CAAuBwB,WAAW,CAAE,CAAC;IAChDgE,UAAU,CAACjF,EAAE,CAAC,OAAO,EAAE,MAAM;MAC3BC,OAAO,CAACC,GAAG,wBAAAT,MAAA,CAAwBwB,WAAW,CAAE,CAAC;MACjDnB,OAAO,CAAC,IAAI,CAAC;IACf,CAAC,CAAC;IACFe,OAAO,CAACqE,MAAM,CAACD,UAAU,EAAE;MAACE,IAAI,EAAElE;IAAW,CAAC,CAAC;EACjD,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"compress-util.js","names":["createGzip","join","promises","fs","createReadStream","createWriteStream","archiver","removeFile","ChildProcessProxy","JSZip","MD5Hash","crypt","getAbsoluteFilePath","compressFileWithGzip","pathFile","compressedPathFile","concat","gzip","input","output","Promise","resolve","reject","on","console","log","error","pipe","compressFilesWithZip","fileMap","outputFile","level","arguments","length","undefined","e","archive","zlib","pointer","err","subFileName","subFileData","appendFileToArchive","finalize","compressWithChildProcess","inputFolder","inputFiles","sevenZipExe","process","platform","compressWithChildProcessWindows","compressWithChildProcessUnix","fullOutputFile","args","childProcess","start","command","spawn","cwd","wait","substr","generateHash128FromZip","inputZipFile","readFile","zip","loadAsync","hashTable","zipFiles","files","relativePath","zipEntry","_data","content","compressedContent","dir","hash","Buffer","from","toLowerCase","push","key","atob","value","byteOffset","sort","prev","next","item","longToByteArray","write","hexToBytes","close","long","buffer","ArrayBuffer","longNum","Float64Array","parseInt","Array","Uint8Array","reverse","addFileToZip","fileName","zipFile","fileStream","append","name"],"sources":["../../../../src/lib/utils/compress-util.ts"],"sourcesContent":["import {createGzip} from 'zlib';\nimport {join} from 'path';\nimport {promises as fs, createReadStream, createWriteStream} from 'fs';\nimport archiver from 'archiver';\nimport {removeFile} from './file-utils';\nimport {ChildProcessProxy} from '@loaders.gl/worker-utils';\nimport JSZip from 'jszip';\nimport {MD5Hash} from '@loaders.gl/crypto';\nimport crypt from 'crypt';\nimport {getAbsoluteFilePath} from './file-utils';\n\n/**\n * Compress file to gzip file\n *\n * @param pathFile - the path to the file\n * @return the path to the gzip file\n */\nexport function compressFileWithGzip(pathFile: string): Promise<string> {\n const compressedPathFile = `${pathFile}.gz`;\n const gzip = createGzip();\n const input = createReadStream(pathFile);\n const output = createWriteStream(compressedPathFile);\n\n return new Promise((resolve, reject) => {\n input.on('end', () => {\n console.log(`${compressedPathFile} compressed and saved.`); // eslint-disable-line no-undef,no-console\n resolve(compressedPathFile);\n });\n input.on('error', (error) => {\n console.log(`${compressedPathFile}: compression error!`); // eslint-disable-line no-undef,no-console\n reject(error);\n });\n input.pipe(gzip).pipe(output);\n });\n}\n\n/**\n * Compress files from map into slpk file\n *\n * @param fileMap - map with file paths (key: output path, value: input path)\n * @param outputFile - output slpk file\n * @param level - compression level\n */\nexport async function compressFilesWithZip(\n fileMap: {[key: string]: string},\n outputFile: string,\n level: number = 0\n) {\n // Before creating a new file, we need to delete the old file\n try {\n await removeFile(outputFile);\n } catch (e) {\n // Do nothing if old file doesn't exist\n }\n\n const output = createWriteStream(outputFile);\n const archive = archiver('zip', {\n zlib: {level} // Sets the compression level.\n });\n\n return new Promise(async (resolve, reject) => {\n // listen for all archive data to be writte\n // 'close' event is fired only when a file descriptor is involved\n output.on('close', function () {\n console.log(`${outputFile} saved.`); // eslint-disable-line no-undef,no-console\n console.log(`${archive.pointer()} total bytes`); // eslint-disable-line no-undef,no-console\n resolve(null);\n });\n\n // This event is fired when the data source is drained no matter what was the data source.\n // It is not part of this library but rather from the NodeJS Stream API.\n // @see: https://nodejs.org/api/stream.html#stream_event_end\n output.on('end', function () {\n console.log('Data has been drained'); // eslint-disable-line no-undef,no-console\n resolve(null);\n });\n\n // good practice to catch warnings (ie stat failures and other non-blocking errors)\n archive.on('warning', function (err) {\n console.log(err); // eslint-disable-line no-undef,no-console\n reject(err);\n });\n\n // good practice to catch this error explicitly\n archive.on('error', function (err) {\n reject(err);\n });\n\n // pipe archive data to the file\n archive.pipe(output);\n\n for (const subFileName in fileMap) {\n const subFileData = fileMap[subFileName];\n await appendFileToArchive(archive, subFileName, subFileData);\n }\n\n // finalize the archive (ie we are done appending files but streams have to finish yet)\n archive.finalize();\n });\n}\n\n/**\n * Compress files using external tool 'zip'/'7z'\n *\n * @param inputFolder - folder to archive - for cwd option\n * @param outputFile - output slpk file\n * @param level - compression level\n * @param inputFiles - input files path to pass to the executable as option\n * @param sevenZipExe - path to 7z.exe executable\n */\nexport async function compressWithChildProcess(\n inputFolder: string,\n outputFile: string,\n level: number,\n inputFiles: string,\n sevenZipExe: string\n) {\n // eslint-disable-next-line no-undef\n if (process.platform === 'win32') {\n await compressWithChildProcessWindows(inputFolder, outputFile, level, inputFiles, sevenZipExe);\n } else {\n await compressWithChildProcessUnix(inputFolder, outputFile, level, inputFiles);\n }\n}\n\n/**\n * Compress files using external linux tool 'zip'\n *\n * @param inputFolder - folder to archive - for cwd option\n * @param outputFile - output slpk file\n * @param level - compression level\n * @param inputFiles - input files path to pass to the executable as option\n */\nasync function compressWithChildProcessUnix(\n inputFolder: string,\n outputFile: string,\n level: number = 0,\n inputFiles: string = '.'\n) {\n const fullOutputFile = getAbsoluteFilePath(outputFile);\n const args = [`-${level}`, '-r', fullOutputFile, inputFiles];\n const childProcess = new ChildProcessProxy();\n await childProcess.start({\n command: 'zip',\n arguments: args,\n spawn: {\n cwd: inputFolder\n },\n wait: 0\n });\n}\n\n/**\n * Compress files using windows external tool '7z'\n *\n * @param inputFolder - folder to archive - for cwd option\n * @param outputFile - output slpk file\n * @param level - compression level\n * @param inputFiles - input files path to pass to the executable as option\n * @param sevenZipExe - path to 7z.exe executable\n */\nasync function compressWithChildProcessWindows(\n inputFolder: string,\n outputFile: string,\n level: number = 0,\n inputFiles: string = join('.', '*'),\n sevenZipExe: string\n) {\n // Workaround for @listfile issue. In 7z.exe @-leading files are handled as listfiles\n // https://sevenzip.osdn.jp/chm/cmdline/syntax.htm\n if (inputFiles[0] === '@') {\n inputFiles = `*${inputFiles.substr(1)}`;\n }\n\n const fullOutputFile = getAbsoluteFilePath(outputFile);\n const args = ['a', '-tzip', `-mx=${level}`, fullOutputFile, inputFiles];\n const childProcess = new ChildProcessProxy();\n await childProcess.start({\n command: sevenZipExe,\n arguments: args,\n spawn: {\n cwd: `${inputFolder}`\n },\n wait: 0\n });\n}\n\n/**\n * Generate hash file from zip archive\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/slpk_hashtable.cmn.md\n *\n * @param inputZipFile\n * @param outputFile\n */\nexport async function generateHash128FromZip(inputZipFile: string, outputFile: string) {\n const input = await fs.readFile(inputZipFile);\n const zip = await JSZip.loadAsync(input);\n const hashTable: {key: string; value: string}[] = [];\n const zipFiles = zip.files;\n for (const relativePath in zipFiles) {\n const zipEntry = zipFiles[relativePath];\n // Had to use a workaround because the correct string is getting the wrong data\n // const content = await zipEntry.async('nodebuffer');\n // _data isn't described in the interface, so lint thought it was wrong\n const _data = '_data';\n const content = zipEntry[_data].compressedContent;\n if (zipEntry.dir) continue; // eslint-disable-line no-continue\n // eslint-disable-next-line no-undef\n const hash = await new MD5Hash().hash(Buffer.from(relativePath.toLowerCase()), 'base64');\n // eslint-disable-next-line no-undef\n hashTable.push({key: atob(hash), value: content.byteOffset});\n }\n\n hashTable.sort((prev, next) => {\n if (prev.key === next.key) {\n return prev.value < next.value ? -1 : 1;\n }\n return prev.key < next.key ? -1 : 1;\n });\n\n const output = createWriteStream(outputFile);\n return new Promise((resolve, reject) => {\n output.on('close', function () {\n console.log(`${outputFile} generated and saved`); // eslint-disable-line\n resolve(null);\n });\n output.on('error', function (err) {\n console.log(err); // eslint-disable-line\n reject(err);\n });\n for (const key in hashTable) {\n const item = hashTable[key];\n const value = longToByteArray(item.value);\n // TODO: perhaps you need to wait for the 'drain' event if the write returns 'false'\n // eslint-disable-next-line no-undef\n output.write(Buffer.from(crypt.hexToBytes(item.key).concat(value)));\n }\n output.close();\n });\n}\n\n/**\n * Encode 64 bit value to byte array\n *\n * @param long - stringified number\n * @returns\n */\nfunction longToByteArray(long: string): number[] {\n const buffer = new ArrayBuffer(8); // JS numbers are 8 bytes long, or 64 bits\n const longNum = new Float64Array(buffer); // so equivalent to Float64\n longNum[0] = parseInt(long);\n return Array.from(new Uint8Array(buffer)).reverse(); // reverse to get little endian\n}\n\n/**\n * Add file to zip archive\n *\n * @param inputFile\n * @param fileName\n * @param zipFile\n * @param sevenZipExe\n */\nexport async function addFileToZip(\n inputFolder: string,\n fileName: string,\n zipFile: string,\n sevenZipExe: string\n) {\n await compressWithChildProcess(inputFolder, zipFile, 0, fileName, sevenZipExe);\n console.log(`${fileName} added to ${zipFile}.`); // eslint-disable-line\n}\n\n/**\n *\n * @param archive zip archive instance\n * @param subFileName file path inside archive\n * @param subFileData source file path\n * @returns\n */\nfunction appendFileToArchive(archive: any, subFileName: string, subFileData: string) {\n return new Promise((resolve) => {\n const fileStream = createReadStream(subFileData);\n console.log(`Compression start: ${subFileName}`); // eslint-disable-line no-undef,no-console\n fileStream.on('close', () => {\n console.log(`Compression finish: ${subFileName}`); // eslint-disable-line no-undef,no-console\n resolve(null);\n });\n archive.append(fileStream, {name: subFileName});\n });\n}\n"],"mappings":"AAAA,SAAQA,UAAU,QAAO,MAAM;AAC/B,SAAQC,IAAI,QAAO,MAAM;AACzB,SAAQC,QAAQ,IAAIC,EAAE,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAO,IAAI;AACtE,OAAOC,QAAQ,MAAM,UAAU;AAC/B,SAAQC,UAAU,QAAO,cAAc;AACvC,SAAQC,iBAAiB,QAAO,0BAA0B;AAC1D,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,OAAO,QAAO,oBAAoB;AAC1C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,mBAAmB,QAAO,cAAc;AAQhD,OAAO,SAASC,oBAAoBA,CAACC,QAAgB,EAAmB;EACtE,MAAMC,kBAAkB,MAAAC,MAAA,CAAMF,Q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OAAO,CAAC,CAAC,CAAC,GAAGE,QAAQ,CAACL,IAAI,CAAC;EAC3B,OAAOM,KAAK,CAACrB,IAAI,CAAC,IAAIsB,UAAU,CAACN,MAAM,CAAC,CAAC,CAACO,OAAO,CAAC,CAAC;AACrD;AAUA,OAAO,eAAeC,YAAYA,CAChCxD,WAAmB,EACnByD,QAAgB,EAChBC,OAAe,EACfxD,WAAmB,EACnB;EACA,MAAMH,wBAAwB,CAACC,WAAW,EAAE0D,OAAO,EAAE,CAAC,EAAED,QAAQ,EAAEvD,WAAW,CAAC;EAC9EvB,OAAO,CAACC,GAAG,IAAAT,MAAA,CAAIsF,QAAQ,gBAAAtF,MAAA,CAAauF,OAAO,MAAG,CAAC;AACjD;AASA,SAAS7D,mBAAmBA,CAACN,OAAY,EAAEI,WAAmB,EAAEC,WAAmB,EAAE;EACnF,OAAO,IAAIrB,OAAO,CAAEC,OAAO,IAAK;IAC9B,MAAMmF,UAAU,GAAGpG,gBAAgB,CAACqC,WAAW,CAAC;IAChDjB,OAAO,CAACC,GAAG,uBAAAT,MAAA,CAAuBwB,WAAW,CAAE,CAAC;IAChDgE,UAAU,CAACjF,EAAE,CAAC,OAAO,EAAE,MAAM;MAC3BC,OAAO,CAACC,GAAG,wBAAAT,MAAA,CAAwBwB,WAAW,CAAE,CAAC;MACjDnB,OAAO,CAAC,IAAI,CAAC;IACf,CAAC,CAAC;IACFe,OAAO,CAACqE,MAAM,CAACD,UAAU,EAAE;MAACE,IAAI,EAAElE;IAAW,CAAC,CAAC;EACjD,CAAC,CAAC;AACJ"}
@@ -21,10 +21,12 @@ export function convertGeometricErrorToScreenThreshold(tile, coordinates) {
21
21
  return lodSelection;
22
22
  }
23
23
  export function convertScreenThresholdToGeometricError(node) {
24
- const metricData = node.header.lodSelection.maxScreenThreshold || {};
25
- let maxError = metricData.maxError;
24
+ var _node$lodSelection;
25
+ const metricData = (_node$lodSelection = node.lodSelection) === null || _node$lodSelection === void 0 ? void 0 : _node$lodSelection.find(metric => metric.metricType === 'maxScreenThreshold');
26
+ let maxError = metricData === null || metricData === void 0 ? void 0 : metricData.maxError;
26
27
  if (!maxError) {
27
- const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;
28
+ var _node$lodSelection2;
29
+ const sqMetricData = (_node$lodSelection2 = node.lodSelection) === null || _node$lodSelection2 === void 0 ? void 0 : _node$lodSelection2.find(metric => metric.metricType === 'maxScreenThresholdSQ');
28
30
  if (sqMetricData) {
29
31
  maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
30
32
  }
@@ -32,6 +34,6 @@ export function convertScreenThresholdToGeometricError(node) {
32
34
  if (!maxError) {
33
35
  maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;
34
36
  }
35
- return node.header.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR / maxError;
37
+ return node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR / maxError;
36
38
  }
37
39
  //# sourceMappingURL=lod-conversion-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lod-conversion-utils.js","names":["DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR","convertGeometricErrorToScreenThreshold","tile","coordinates","lodSelection","boundingVolume","lodMetricValue","maxScreenThreshold","metricType","maxError","mbs","maxScreenThresholdSQ","Math","PI","constructor","name","push","convertScreenThresholdToGeometricError","node","metricData","header","sqMetricData","sqrt"],"sources":["../../../../src/lib/utils/lod-conversion-utils.ts"],"sourcesContent":["import {Tiles3DTileJSONPostprocessed} from '@loaders.gl/3d-tiles';\nimport {BoundingVolumes} from '@loaders.gl/i3s';\nimport {Tile3D} from '@loaders.gl/tiles';\n\n// https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html\nconst DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;\n/**\n * Do conversion from geometric error to screen threshold\n * \n * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.\n * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.\n * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles\n * 3DTiles spec:\n * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error\n * I3S spec:\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md\n * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us\n * to make child maxError bigger than his parent maxError.\n * \n * @param tile - 3d-tiles tile JSON\n * @param coordinates - node converted coordinates\n * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection\n * @example \n * [\n {\n \"metricType\": \"maxScreenThresholdSQ\",\n \"maxError\": 870638.071285568\n },\n {\n \"metricType\": \"maxScreenThreshold\",\n \"maxError\": 1052.8679031638949\n }\n ]\n */\nexport function convertGeometricErrorToScreenThreshold(\n tile: Tiles3DTileJSONPostprocessed,\n coordinates: BoundingVolumes\n) {\n const lodSelection: {metricType: string; maxError: number}[] = [];\n const boundingVolume = tile.boundingVolume;\n const lodMetricValue = tile.lodMetricValue || 0.1;\n const maxScreenThreshold = {\n metricType: 'maxScreenThreshold',\n maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue\n };\n const maxScreenThresholdSQ = {\n metricType: 'maxScreenThresholdSQ',\n maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError\n };\n\n if (boundingVolume.constructor.name === 'OrientedBoundingBox') {\n lodSelection.push(maxScreenThresholdSQ);\n lodSelection.push(maxScreenThreshold);\n } else {\n lodSelection.push(maxScreenThreshold);\n lodSelection.push(maxScreenThresholdSQ);\n }\n\n return lodSelection;\n}\n\n/**\n * Convert LOD metric from \"Screen Threshold\" to \"Screen Space Error\"\n * @param node - i3s node data\n * @returns lod metric in 3d-tiles format\n */\nexport function convertScreenThresholdToGeometricError(node: Tile3D): number {\n const metricData = node.header.lodSelection.maxScreenThreshold || {};\n let maxError = metricData.maxError;\n if (!maxError) {\n const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;\n if (sqMetricData) {\n maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));\n }\n }\n\n if (!maxError) {\n maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;\n }\n\n return (node.header.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;\n}\n"],"mappings":"AAKA,MAAMA,kCAAkC,GAAG,EAAE;AA6B7C,OAAO,SAASC,sCAAsCA,CACpDC,IAAkC,EAClCC,WAA4B,EAC5B;EACA,MAAMC,YAAsD,GAAG,EAAE;EACjE,MAAMC,cAAc,GAAGH,IAAI,CAACG,cAAc;EAC1C,MAAMC,cAAc,GAAGJ,IAAI,CAACI,cAAc,IAAI,GAAG;EACjD,MAAMC,kBAAkB,GAAG;IACzBC,UAAU,EAAE,oBAAoB;IAChCC,QAAQ,EAAGN,WAAW,CAACO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIM;EAC5E,CAAC;EACD,MAAMK,oBAAoB,GAAG;IAC3BH,UAAU,EAAE,sBAAsB;IAClCC,QAAQ,EAAEG,IAAI,CAACC,EAAE,GAAG,IAAI,GAAGN,kBAAkB,CAACE,QAAQ,GAAGF,kBAAkB,CAACE;EAC9E,CAAC;EAED,IAAIJ,cAAc,CAACS,WAAW,CAACC,IAAI,KAAK,qBAAqB,EAAE;IAC7DX,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;IACvCP,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;EACvC,CAAC,MAAM;IACLH,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;IACrCH,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;EACzC;EAEA,OAAOP,YAAY;AACrB;AAOA,OAAO,SAASa,sCAAsCA,CAACC,IAAY,EAAU;EAC3E,MAAMC,UAAU,GAAGD,IAAI,CAACE,MAAM,CAAChB,YAAY,CAACG,kBAAkB,IAAI,CAAC,CAAC;EACpE,IAAIE,QAAQ,GAAGU,UAAU,CAACV,QAAQ;EAClC,IAAI,CAACA,QAAQ,EAAE;IACb,MAAMY,YAAY,GAAGH,IAAI,CAACE,MAAM,CAAChB,YAAY,CAACO,oBAAoB;IAClE,IAAIU,YAAY,EAAE;MAChBZ,QAAQ,GAAGG,IAAI,CAACU,IAAI,CAACD,YAAY,CAACZ,QAAQ,IAAIG,IAAI,CAACC,EAAE,GAAG,IAAI,CAAC,CAAC;IAChE;EACF;EAEA,IAAI,CAACJ,QAAQ,EAAE;IACbA,QAAQ,GAAGT,kCAAkC;EAC/C;EAEA,OAAQkB,IAAI,CAACE,MAAM,CAACV,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIS,QAAQ;AACjF"}
1
+ {"version":3,"file":"lod-conversion-utils.js","names":["DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR","convertGeometricErrorToScreenThreshold","tile","coordinates","lodSelection","boundingVolume","lodMetricValue","maxScreenThreshold","metricType","maxError","mbs","maxScreenThresholdSQ","Math","PI","constructor","name","push","convertScreenThresholdToGeometricError","node","_node$lodSelection","metricData","find","metric","_node$lodSelection2","sqMetricData","sqrt"],"sources":["../../../../src/lib/utils/lod-conversion-utils.ts"],"sourcesContent":["import {Tiles3DTileJSONPostprocessed} from '@loaders.gl/3d-tiles';\nimport {BoundingVolumes} from '@loaders.gl/i3s';\nimport {I3STileHeader} from '@loaders.gl/i3s/src/types';\n\n// https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html\nconst DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;\n/**\n * Do conversion from geometric error to screen threshold\n * \n * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.\n * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.\n * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles\n * 3DTiles spec:\n * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error\n * I3S spec:\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md\n * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us\n * to make child maxError bigger than his parent maxError.\n * \n * @param tile - 3d-tiles tile JSON\n * @param coordinates - node converted coordinates\n * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection\n * @example \n * [\n {\n \"metricType\": \"maxScreenThresholdSQ\",\n \"maxError\": 870638.071285568\n },\n {\n \"metricType\": \"maxScreenThreshold\",\n \"maxError\": 1052.8679031638949\n }\n ]\n */\nexport function convertGeometricErrorToScreenThreshold(\n tile: Tiles3DTileJSONPostprocessed,\n coordinates: BoundingVolumes\n) {\n const lodSelection: {metricType: string; maxError: number}[] = [];\n const boundingVolume = tile.boundingVolume;\n const lodMetricValue = tile.lodMetricValue || 0.1;\n const maxScreenThreshold = {\n metricType: 'maxScreenThreshold',\n maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue\n };\n const maxScreenThresholdSQ = {\n metricType: 'maxScreenThresholdSQ',\n maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError\n };\n\n if (boundingVolume.constructor.name === 'OrientedBoundingBox') {\n lodSelection.push(maxScreenThresholdSQ);\n lodSelection.push(maxScreenThreshold);\n } else {\n lodSelection.push(maxScreenThreshold);\n lodSelection.push(maxScreenThresholdSQ);\n }\n\n return lodSelection;\n}\n\n/**\n * Convert LOD metric from \"Screen Threshold\" to \"Screen Space Error\"\n * @param node - i3s node data\n * @returns lod metric in 3d-tiles format\n */\nexport function convertScreenThresholdToGeometricError(node: I3STileHeader): number {\n const metricData = node.lodSelection?.find(\n (metric) => metric.metricType === 'maxScreenThreshold'\n );\n let maxError = metricData?.maxError;\n if (!maxError) {\n const sqMetricData = node.lodSelection?.find(\n (metric) => metric.metricType === 'maxScreenThresholdSQ'\n );\n if (sqMetricData) {\n maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));\n }\n }\n\n if (!maxError) {\n maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;\n }\n\n return (node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;\n}\n"],"mappings":"AAKA,MAAMA,kCAAkC,GAAG,EAAE;AA6B7C,OAAO,SAASC,sCAAsCA,CACpDC,IAAkC,EAClCC,WAA4B,EAC5B;EACA,MAAMC,YAAsD,GAAG,EAAE;EACjE,MAAMC,cAAc,GAAGH,IAAI,CAACG,cAAc;EAC1C,MAAMC,cAAc,GAAGJ,IAAI,CAACI,cAAc,IAAI,GAAG;EACjD,MAAMC,kBAAkB,GAAG;IACzBC,UAAU,EAAE,oBAAoB;IAChCC,QAAQ,EAAGN,WAAW,CAACO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIM;EAC5E,CAAC;EACD,MAAMK,oBAAoB,GAAG;IAC3BH,UAAU,EAAE,sBAAsB;IAClCC,QAAQ,EAAEG,IAAI,CAACC,EAAE,GAAG,IAAI,GAAGN,kBAAkB,CAACE,QAAQ,GAAGF,kBAAkB,CAACE;EAC9E,CAAC;EAED,IAAIJ,cAAc,CAACS,WAAW,CAACC,IAAI,KAAK,qBAAqB,EAAE;IAC7DX,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;IACvCP,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;EACvC,CAAC,MAAM;IACLH,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;IACrCH,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;EACzC;EAEA,OAAOP,YAAY;AACrB;AAOA,OAAO,SAASa,sCAAsCA,CAACC,IAAmB,EAAU;EAAA,IAAAC,kBAAA;EAClF,MAAMC,UAAU,IAAAD,kBAAA,GAAGD,IAAI,CAACd,YAAY,cAAAe,kBAAA,uBAAjBA,kBAAA,CAAmBE,IAAI,CACvCC,MAAM,IAAKA,MAAM,CAACd,UAAU,KAAK,oBACpC,CAAC;EACD,IAAIC,QAAQ,GAAGW,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEX,QAAQ;EACnC,IAAI,CAACA,QAAQ,EAAE;IAAA,IAAAc,mBAAA;IACb,MAAMC,YAAY,IAAAD,mBAAA,GAAGL,IAAI,CAACd,YAAY,cAAAmB,mBAAA,uBAAjBA,mBAAA,CAAmBF,IAAI,CACzCC,MAAM,IAAKA,MAAM,CAACd,UAAU,KAAK,sBACpC,CAAC;IACD,IAAIgB,YAAY,EAAE;MAChBf,QAAQ,GAAGG,IAAI,CAACa,IAAI,CAACD,YAAY,CAACf,QAAQ,IAAIG,IAAI,CAACC,EAAE,GAAG,IAAI,CAAC,CAAC;IAChE;EACF;EAEA,IAAI,CAACJ,QAAQ,EAAE;IACbA,QAAQ,GAAGT,kCAAkC;EAC/C;EAEA,OAAQkB,IAAI,CAACR,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIS,QAAQ;AAC1E"}
@@ -1,15 +1,18 @@
1
- import { parsePGM } from '@math.gl/geoid';
2
- const VERSION = typeof "4.0.0-alpha.9" !== 'undefined' ? "4.0.0-alpha.9" : 'latest';
1
+ import { Geoid, parsePGM } from '@math.gl/geoid';
2
+ const VERSION = typeof "4.0.0-beta.1" !== 'undefined' ? "4.0.0-beta.1" : 'latest';
3
+ export { Geoid };
3
4
  export const PGMLoader = {
4
5
  name: 'PGM - Netpbm grayscale image format',
5
6
  id: 'pgm',
6
7
  module: 'tile-converter',
7
8
  version: VERSION,
8
9
  mimeTypes: ['image/x-portable-graymap'],
9
- parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),
10
+ parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), (options === null || options === void 0 ? void 0 : options.pgm) || {}),
10
11
  extensions: ['pgm'],
11
12
  options: {
12
- cubic: false
13
+ pgm: {
14
+ cubic: false
15
+ }
13
16
  }
14
17
  };
15
18
  //# sourceMappingURL=pgm-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pgm-loader.js","names":["parsePGM","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","extensions","cubic"],"sources":["../../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {parsePGM} from '@math.gl/geoid';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n // @ts-expect-error LoaderOptions does not have cubic parameter\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),\n extensions: ['pgm'],\n options: {\n // TODO - use pgm namespace\n cubic: false\n }\n};\n"],"mappings":"AACA,SAAQA,QAAQ,QAAO,gBAAgB;AAIvC,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAK3E,OAAO,MAAMC,SAA2B,GAAG;EACzCC,IAAI,EAAE,qCAAqC;EAC3CC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAEvCC,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEC,OAAO,KAAKV,QAAQ,CAAC,IAAIW,UAAU,CAACF,WAAW,CAAC,EAAEC,OAAO,CAAC;EACrFE,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBF,OAAO,EAAE;IAEPG,KAAK,EAAE;EACT;AACF,CAAC"}
1
+ {"version":3,"file":"pgm-loader.js","names":["Geoid","parsePGM","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","pgm","extensions","cubic"],"sources":["../../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {Geoid, parsePGM} from '@math.gl/geoid';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport {Geoid};\n\nexport type PGMLoaderOptions = LoaderOptions & {\n pgm?: {\n cubic?: boolean;\n };\n};\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser<Geoid, never, PGMLoaderOptions> = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options?.pgm || {}),\n extensions: ['pgm'],\n options: {\n pgm: {\n cubic: false\n }\n }\n};\n"],"mappings":"AACA,SAAQA,KAAK,EAAEC,QAAQ,QAAO,gBAAgB;AAI9C,MAAMC,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAE3E,SAAQF,KAAK;AAWb,OAAO,MAAMG,SAA2D,GAAG;EACzEC,IAAI,EAAE,qCAAqC;EAC3CC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,0BAA0B,CAAC;EACvCC,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEC,OAAO,KAAKV,QAAQ,CAAC,IAAIW,UAAU,CAACF,WAAW,CAAC,EAAE,CAAAC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,GAAG,KAAI,CAAC,CAAC,CAAC;EAChGC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBH,OAAO,EAAE;IACPE,GAAG,EAAE;MACHE,KAAK,EAAE;IACT;EACF;AACF,CAAC"}