@loaders.gl/tile-converter 4.0.0-alpha.4 → 4.0.0-alpha.5

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 (134) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +78 -0
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +9 -7
  4. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +78 -18
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
  7. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +19 -9
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  9. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +4 -7
  10. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
  11. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  12. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
  13. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
  14. package/dist/3d-tiles-converter/helpers/texture-atlas.js +1 -1
  15. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  16. package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
  17. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
  18. package/dist/3d-tiles-converter/json-templates/tileset.js +12 -9
  19. package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  20. package/dist/bundle.d.ts +2 -0
  21. package/dist/bundle.d.ts.map +1 -0
  22. package/dist/converter.min.js +22 -22
  23. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  24. package/dist/deps-installer/deps-installer.js +2 -6
  25. package/dist/deps-installer/deps-installer.js.map +1 -1
  26. package/dist/dist.min.js +86527 -0
  27. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
  28. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  29. package/dist/i3s-converter/helpers/coordinate-converter.js +35 -3
  30. package/dist/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  31. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  32. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  33. package/dist/i3s-converter/helpers/create-scene-server-path.js +2 -2
  34. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  35. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +23 -0
  36. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  37. package/dist/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  38. package/dist/i3s-converter/helpers/geometry-converter.d.ts +5 -1
  39. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  40. package/dist/i3s-converter/helpers/geometry-converter.js +88 -42
  41. package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -1
  42. package/dist/i3s-converter/helpers/node-debug.d.ts +2 -0
  43. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  44. package/dist/i3s-converter/helpers/node-debug.js +2 -4
  45. package/dist/i3s-converter/helpers/node-debug.js.map +1 -1
  46. package/dist/i3s-converter/helpers/node-pages.d.ts +83 -111
  47. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  48. package/dist/i3s-converter/helpers/node-pages.js +15 -4
  49. package/dist/i3s-converter/helpers/node-pages.js.map +1 -1
  50. package/dist/i3s-converter/i3s-converter.d.ts +320 -0
  51. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  52. package/dist/i3s-converter/i3s-converter.js +158 -65
  53. package/dist/i3s-converter/i3s-converter.js.map +1 -1
  54. package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
  55. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  56. package/dist/i3s-converter/json-templates/layers.js +37 -27
  57. package/dist/i3s-converter/json-templates/layers.js.map +1 -1
  58. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  59. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  60. package/dist/i3s-converter/json-templates/metadata.js +2 -2
  61. package/dist/i3s-converter/json-templates/metadata.js.map +1 -1
  62. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  63. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  64. package/dist/i3s-converter/json-templates/node.js +16 -12
  65. package/dist/i3s-converter/json-templates/node.js.map +1 -1
  66. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  67. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  68. package/dist/i3s-converter/json-templates/scene-server.js +2 -2
  69. package/dist/i3s-converter/json-templates/scene-server.js.map +1 -1
  70. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  71. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  72. package/dist/i3s-converter/json-templates/shared-resources.js +19 -14
  73. package/dist/i3s-converter/json-templates/shared-resources.js.map +1 -1
  74. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  75. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  76. package/dist/i3s-converter/json-templates/store.js.map +1 -1
  77. package/dist/i3s-converter/types.d.ts +14 -0
  78. package/dist/i3s-converter/types.d.ts.map +1 -0
  79. package/dist/i3s-converter/types.js +2 -0
  80. package/dist/i3s-converter/types.js.map +1 -0
  81. package/dist/i3s-server/app.d.ts +3 -0
  82. package/dist/i3s-server/app.d.ts.map +1 -0
  83. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  84. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  85. package/dist/i3s-server/routes/index.d.ts +3 -0
  86. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  87. package/dist/index.d.ts +5 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
  90. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  91. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  92. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  93. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  94. package/dist/pgm-loader.d.ts +6 -0
  95. package/dist/pgm-loader.d.ts.map +1 -0
  96. package/dist/pgm-loader.js +3 -3
  97. package/dist/pgm-loader.js.map +1 -1
  98. package/package.json +21 -19
  99. package/src/3d-tiles-converter/3d-tiles-converter.ts +25 -21
  100. package/src/3d-tiles-converter/helpers/{b3dm-converter.js → b3dm-converter.ts} +35 -11
  101. package/src/3d-tiles-converter/helpers/{i3s-obb-to-3d-tiles-obb.js → i3s-obb-to-3d-tiles-obb.ts} +16 -1
  102. package/src/3d-tiles-converter/helpers/texture-atlas.ts +4 -4
  103. package/src/3d-tiles-converter/json-templates/{tileset.js → tileset.ts} +9 -9
  104. package/src/deps-installer/deps-installer.js +2 -2
  105. package/src/i3s-converter/helpers/coordinate-converter.ts +62 -9
  106. package/src/i3s-converter/helpers/{create-scene-server-path.js → create-scene-server-path.ts} +2 -2
  107. package/src/i3s-converter/helpers/{geometry-attributes.js → geometry-attributes.ts} +4 -4
  108. package/src/i3s-converter/helpers/geometry-converter.d.ts +5 -1
  109. package/src/i3s-converter/helpers/geometry-converter.js +110 -33
  110. package/src/i3s-converter/helpers/{node-debug.js → node-debug.ts} +3 -2
  111. package/src/i3s-converter/helpers/{node-pages.js → node-pages.ts} +41 -26
  112. package/src/i3s-converter/i3s-converter.ts +214 -136
  113. package/src/i3s-converter/json-templates/{layers.js → layers.ts} +29 -27
  114. package/src/i3s-converter/json-templates/{metadata.js → metadata.ts} +2 -2
  115. package/src/i3s-converter/json-templates/{node.js → node.ts} +12 -12
  116. package/src/i3s-converter/json-templates/{scene-server.js → scene-server.ts} +2 -2
  117. package/src/i3s-converter/json-templates/{shared-resources.js → shared-resources.ts} +14 -14
  118. package/src/i3s-converter/json-templates/{store.js → store.ts} +0 -0
  119. package/src/i3s-converter/types.ts +14 -0
  120. package/src/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
  121. package/src/pgm-loader.ts +2 -2
  122. package/dist/lib/geoid-height-model.d.ts +0 -41
  123. package/dist/lib/geoid-height-model.js +0 -140
  124. package/dist/lib/geoid-height-model.js.map +0 -1
  125. package/dist/lib/pgm-parser.d.ts +0 -14
  126. package/dist/lib/pgm-parser.js +0 -183
  127. package/dist/lib/pgm-parser.js.map +0 -1
  128. package/src/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
  129. package/src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
  130. package/src/i3s-converter/helpers/node-pages.d.ts +0 -144
  131. package/src/lib/geoid-height-model.d.ts +0 -41
  132. package/src/lib/geoid-height-model.js +0 -239
  133. package/src/lib/pgm-parser.d.ts +0 -14
  134. package/src/lib/pgm-parser.js +0 -179
@@ -1,183 +0,0 @@
1
- import { GeoidHeightModel } from './geoid-height-model';
2
- const ENDL = 10;
3
- const PIXEL_MAX = 65535;
4
- export function parsePgm(data, options) {
5
- const getline = _getLineGenerator(data);
6
-
7
- let currentLine = getline.next();
8
-
9
- if (currentLine.done || currentLine.value.line !== 'P5') {
10
- throw new Error('Geoid model file: File not in PGM format');
11
- }
12
-
13
- let _offset = Number.MAX_VALUE;
14
- let _scale = 0;
15
-
16
- let _maxerror = -1;
17
-
18
- let _rmserror = -1;
19
-
20
- let _description = 'NONE';
21
- let _datetime = 'UNKNOWN';
22
- let _width = 0;
23
- let _height = 0;
24
- let _datastart = null;
25
- let _swidth = null;
26
-
27
- do {
28
- currentLine = getline.next();
29
- const s = currentLine.value.line;
30
-
31
- if (!s.length) {
32
- continue;
33
- }
34
-
35
- if (s[0] === '#') {
36
- const sArr = s.split(' ');
37
- const commentId = sArr[0];
38
- const key = sArr[1];
39
-
40
- if (commentId !== '#' || !key) {
41
- continue;
42
- }
43
-
44
- const infoArr = sArr.length > 2 ? sArr.slice(2) : [];
45
-
46
- if (key === 'Description') {
47
- _description = infoArr.join(' ');
48
- } else if (key === 'DateTime') {
49
- _datetime = infoArr.join(' ');
50
- } else if (key === 'Offset') {
51
- if (!sArr[2]) {
52
- throw new Error('Geoid model file: Error reading offset');
53
- }
54
-
55
- _offset = parseInt(sArr[2], 10);
56
- } else if (key === 'Scale') {
57
- if (!sArr[2]) {
58
- throw new Error('Geoid model file: Error reading scale');
59
- }
60
-
61
- _scale = parseFloat(sArr[2]);
62
- } else if (key === (options.cubic ? 'MaxCubicError' : 'MaxBilinearError')) {
63
- if (isFinite(parseFloat(sArr[2]))) {
64
- _maxerror = parseFloat(sArr[2]);
65
- }
66
- } else if (key === (options.cubic ? 'RMSCubicError' : 'RMSBilinearError')) {
67
- if (isFinite(parseFloat(sArr[2]))) {
68
- _rmserror = parseFloat(sArr[2]);
69
- }
70
- }
71
- } else {
72
- let sArr = s.split(' ');
73
- sArr = sArr.filter(testString => testString !== '');
74
- _width = parseInt(sArr[0], 10);
75
- _height = parseInt(sArr[1], 10);
76
-
77
- if (!(_width && _height)) {
78
- throw new Error('Geoid model file: Error reading raster size');
79
- }
80
-
81
- break;
82
- }
83
- } while (!currentLine.done);
84
-
85
- currentLine = getline.next();
86
- const maxval = parseInt(currentLine.value.line, 10);
87
-
88
- if (currentLine.done) {
89
- throw new Error('Geoid model file: Error reading maxval');
90
- }
91
-
92
- if (maxval !== PIXEL_MAX) {
93
- throw new Error('Geoid model file: Incorrect value of maxval');
94
- }
95
-
96
- _datastart = currentLine.value.offset;
97
- _swidth = _width;
98
-
99
- if (_offset === Number.MAX_VALUE) {
100
- throw new Error('Geoid model file: Offset not set');
101
- }
102
-
103
- if (_scale === 0) {
104
- throw new Error('Geoid model file: Scale not set');
105
- }
106
-
107
- if (_scale < 0) {
108
- throw new Error('Geoid model file: Scale must be positive');
109
- }
110
-
111
- if (_height < 2 || _width < 2) {
112
- throw new Error('Geoid model file: Raster size too small');
113
- }
114
-
115
- if (_width & 1) {
116
- throw new Error('Geoid model file: Raster width is odd');
117
- }
118
-
119
- if (!(_height & 1)) {
120
- throw new Error('Geoid model file: Raster height is even');
121
- }
122
-
123
- const _rlonres = _width / 360;
124
-
125
- const _rlatres = (_height - 1) / 180;
126
-
127
- return new GeoidHeightModel({
128
- cubic: options.cubic,
129
- _width,
130
- _height,
131
- _rlonres,
132
- _rlatres,
133
- _offset,
134
- _scale,
135
- _swidth,
136
- _datastart,
137
- _maxerror,
138
- _rmserror,
139
- _description,
140
- _datetime,
141
- data
142
- });
143
- }
144
-
145
- function* _getLineGenerator(data) {
146
- let offset = 0;
147
-
148
- do {
149
- const endLineIndex = data.indexOf(ENDL, offset);
150
-
151
- if (endLineIndex !== -1) {
152
- const line = data.subarray(offset, endLineIndex);
153
- offset = endLineIndex + 1;
154
- yield {
155
- offset,
156
- line: _getStringFromCharArray(line)
157
- };
158
- } else {
159
- const line = data.subarray(offset, data.length);
160
- offset = data.length;
161
- yield {
162
- offset,
163
- line: _getStringFromCharArray(line)
164
- };
165
- }
166
- } while (offset < data.length);
167
-
168
- return {
169
- offset,
170
- line: ''
171
- };
172
- }
173
-
174
- function _getStringFromCharArray(array) {
175
- let s = '';
176
-
177
- for (const char of array) {
178
- s += String.fromCharCode(char);
179
- }
180
-
181
- return s;
182
- }
183
- //# sourceMappingURL=pgm-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/pgm-parser.js"],"names":["GeoidHeightModel","ENDL","PIXEL_MAX","parsePgm","data","options","getline","_getLineGenerator","currentLine","next","done","value","line","Error","_offset","Number","MAX_VALUE","_scale","_maxerror","_rmserror","_description","_datetime","_width","_height","_datastart","_swidth","s","length","sArr","split","commentId","key","infoArr","slice","join","parseInt","parseFloat","cubic","isFinite","filter","testString","maxval","offset","_rlonres","_rlatres","endLineIndex","indexOf","subarray","_getSt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b;AACAH,MAAAA,MAAM,GAAGG,YAAY,GAAG,CAAxB;AACA,YAAM;AAACH,QAAAA,MAAD;AAAS9B,QAAAA,IAAI,EAAEoC,uBAAuB,CAACpC,IAAD;AAAtC,OAAN;AACD,KAJD,MAIO;AACL,YAAMA,IAAI,GAAGR,IAAI,CAAC2C,QAAL,CAAcL,MAAd,EAAsBtC,IAAI,CAACuB,MAA3B,CAAb;AACAe,MAAAA,MAAM,GAAGtC,IAAI,CAACuB,MAAd;AACA,YAAM;AAACe,QAAAA,MAAD;AAAS9B,QAAAA,IAAI,EAAEoC,uBAAuB,CAACpC,IAAD;AAAtC,OAAN;AACD;AACF,GAXD,QAWS8B,MAAM,GAAGtC,IAAI,CAACuB,MAXvB;;AAYA,SAAO;AAACe,IAAAA,MAAD;AAAS9B,IAAAA,IAAI,EAAE;AAAf,GAAP;AACD;;AAOD,SAASoC,uBAAT,CAAiCC,KAAjC,EAAwC;AACtC,MAAIvB,CAAC,GAAG,EAAR;;AACA,OAAK,MAAMwB,IAAX,IAAmBD,KAAnB,EAA0B;AACxBvB,IAAAA,CAAC,IAAIyB,MAAM,CAACC,YAAP,CAAoBF,IAApB,CAAL;AACD;;AACD,SAAOxB,CAAP;AACD","sourcesContent":["/**\n * Parsing code is ported from GeographicLib-1.50.1\n * https://geographiclib.sourceforge.io/html/index.html\n * Location: /GeographicLib-1.50.1/src/Geoid.cpp\n *\n * File header:\n * * \\file Geoid.cpp\n * * \\brief Implementation for GeographicLib::Geoid class\n * *\n * * Copyright (c) Charles Karney (2009-2018) <charles@karney.com> and licensed\n * * under the MIT/X11 License. For more information, see\n * * https://geographiclib.sourceforge.io/\n **********************************************************************/\n\nimport {GeoidHeightModel} from './geoid-height-model';\n\nconst ENDL = 10;\nconst PIXEL_MAX = 65535;\n\n// eslint-disable-next-line\nexport function parsePgm(data, options) {\n const getline = _getLineGenerator(data);\n let currentLine = getline.next();\n if (currentLine.done || currentLine.value.line !== 'P5') {\n throw new Error('Geoid model file: File not in PGM format');\n }\n let _offset = Number.MAX_VALUE;\n let _scale = 0;\n let _maxerror = -1;\n let _rmserror = -1;\n let _description = 'NONE';\n let _datetime = 'UNKNOWN';\n let _width = 0;\n let _height = 0;\n let _datastart = null;\n let _swidth = null;\n do {\n currentLine = getline.next();\n const s = currentLine.value.line;\n if (!s.length) {\n continue; // eslint-disable-line no-continue\n }\n if (s[0] === '#') {\n const sArr = s.split(' ');\n const commentId = sArr[0];\n const key = sArr[1];\n if (commentId !== '#' || !key) {\n continue; // eslint-disable-line no-continue\n }\n const infoArr = sArr.length > 2 ? sArr.slice(2) : [];\n if (key === 'Description') {\n _description = infoArr.join(' ');\n } else if (key === 'DateTime') {\n _datetime = infoArr.join(' ');\n } else if (key === 'Offset') {\n // eslint-disable-next-line max-depth\n if (!sArr[2]) {\n throw new Error('Geoid model file: Error reading offset');\n }\n _offset = parseInt(sArr[2], 10);\n } else if (key === 'Scale') {\n // eslint-disable-next-line max-depth\n if (!sArr[2]) {\n throw new Error('Geoid model file: Error reading scale');\n }\n _scale = parseFloat(sArr[2]);\n } else if (key === (options.cubic ? 'MaxCubicError' : 'MaxBilinearError')) {\n // It's not an error if the error can't be read\n // eslint-disable-next-line max-depth\n if (isFinite(parseFloat(sArr[2]))) {\n _maxerror = parseFloat(sArr[2]);\n }\n } else if (key === (options.cubic ? 'RMSCubicError' : 'RMSBilinearError')) {\n // It's not an error if the error can't be read\n // eslint-disable-next-line max-depth\n if (isFinite(parseFloat(sArr[2]))) {\n _rmserror = parseFloat(sArr[2]);\n }\n }\n } else {\n let sArr = s.split(' ');\n sArr = sArr.filter((testString) => testString !== '');\n _width = parseInt(sArr[0], 10);\n _height = parseInt(sArr[1], 10);\n if (!(_width && _height)) {\n throw new Error('Geoid model file: Error reading raster size');\n }\n break;\n }\n } while (!currentLine.done);\n\n currentLine = getline.next();\n const maxval = parseInt(currentLine.value.line, 10);\n if (currentLine.done) {\n throw new Error('Geoid model file: Error reading maxval');\n }\n if (maxval !== PIXEL_MAX) {\n throw new Error('Geoid model file: Incorrect value of maxval');\n }\n // Add 1 for whitespace after maxval\n _datastart = currentLine.value.offset;\n _swidth = _width;\n\n if (_offset === Number.MAX_VALUE) {\n throw new Error('Geoid model file: Offset not set');\n }\n if (_scale === 0) {\n throw new Error('Geoid model file: Scale not set');\n }\n if (_scale < 0) {\n throw new Error('Geoid model file: Scale must be positive');\n }\n if (_height < 2 || _width < 2) {\n // Coarsest grid spacing is 180deg.\n throw new Error('Geoid model file: Raster size too small');\n }\n if (_width & 1) {\n // This is so that longitude grids can be extended thru the poles.\n throw new Error('Geoid model file: Raster width is odd');\n }\n if (!(_height & 1)) {\n // This is so that latitude grid includes the equator.\n throw new Error('Geoid model file: Raster height is even');\n }\n\n const _rlonres = _width / 360;\n const _rlatres = (_height - 1) / 180;\n return new GeoidHeightModel({\n cubic: options.cubic,\n _width,\n _height,\n _rlonres,\n _rlatres,\n _offset,\n _scale,\n _swidth,\n _datastart,\n _maxerror,\n _rmserror,\n _description,\n _datetime,\n data\n });\n}\n\n/**\n * Yields strings from pgm file (splitted by 10 - new line symbol)\n * @param {Uint8Array} data - binary buffer of pgm file\n * @returns {Generator}\n */\nfunction* _getLineGenerator(data) {\n let offset = 0;\n do {\n const endLineIndex = data.indexOf(ENDL, offset);\n if (endLineIndex !== -1) {\n const line = data.subarray(offset, endLineIndex);\n offset = endLineIndex + 1;\n yield {offset, line: _getStringFromCharArray(line)};\n } else {\n const line = data.subarray(offset, data.length);\n offset = data.length;\n yield {offset, line: _getStringFromCharArray(line)};\n }\n } while (offset < data.length);\n return {offset, line: ''};\n}\n\n/**\n * Converts Uint8Array of char-codes to string\n * @param {Uint8Array} array - binary buffer of pgm file\n * @returns {string}\n */\nfunction _getStringFromCharArray(array) {\n let s = '';\n for (const char of array) {\n s += String.fromCharCode(char);\n }\n return s;\n}\n"],"file":"pgm-parser.js"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Converts content of an I3S node to *.b3dm's file content
3
- */
4
- export default class B3dmConverter {
5
- rtcCenter: Float32Array;
6
- i3sTile: any;
7
-
8
- constructor();
9
-
10
- /**
11
- * The starter of content conversion
12
- * @param i3sTile - Tile3D instance for I3S node
13
- * @returns - encoded content
14
- */
15
- convert(i3sTile: Object, attributes?: any): ArrayBuffer;
16
-
17
- /**
18
- * Build and encode gltf
19
- * @param i3sTile - Tile3D instance for I3S node
20
- * @returns - encoded glb content
21
- */
22
- buildGltf(i3sTile): ArrayBuffer;
23
- }
@@ -1,16 +0,0 @@
1
- import {GeoidHeightModel} from '@loaders.gl/tile-converter/lib/geoid-height-model';
2
-
3
- /**
4
- * Convert quaternion-based OBB to half-axes-based OBB
5
- * @param i3SObb quaternion based OBB
6
- * @param geoidHeightModel the Earth Gravity Model instance
7
- * @returns number[12] 3DTiles OBB https://github.com/CesiumGS/3d-tiles/tree/master/specification#box
8
- */
9
- export function i3sObbTo3dTilesObb(
10
- i3SObb: {
11
- center: number[];
12
- halfSize: number[];
13
- quaternion: number[];
14
- },
15
- geoidHeightModel: GeoidHeightModel
16
- ): number[];
@@ -1,144 +0,0 @@
1
- /**
2
- * Represents one page node
3
- * {@link https://github.com/Esri/i3s-spec/blob/master/docs/1.7/node.cmn.md}
4
- */
5
- export type PageNodeType = {
6
- lodThreshold: number;
7
- obb: any;
8
- children: any[];
9
- mesh?: {
10
- geometry: {
11
- resource?: number;
12
- definition?: number;
13
- };
14
- material?: {
15
- resource?: number;
16
- definition?: number;
17
- };
18
- };
19
- };
20
-
21
- /**
22
- * class NodePages - wrapper of nodePages array
23
- *
24
- * @example
25
- * import writeFile from './helpers/write-file';
26
- *
27
- * // create an instance of the class
28
- * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
29
- * ...
30
- * // push root node
31
- * const parentId = nodePages.push({
32
- lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
33
- obb: coordinates.obb,
34
- children: []
35
- });
36
- * ...
37
- * // push node with parent relation
38
- * const nodeInPage = {
39
- lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
40
- obb: coordinates.obb,
41
- children: [],
42
- mesh: {
43
- geometry: {
44
- definition: 0
45
- }
46
- }
47
- };
48
- * const nodeId = this.nodePages.push(nodeInPage, parentId);
49
- * ...
50
- * // save all the nodePages in the end of pushing all the nodes
51
- * await this.nodePages.save(layers0path);
52
- */
53
- export default class NodePages {
54
- readonly nodesPerPage: number;
55
- readonly nodesCounter: number;
56
- readonly writeFile: any;
57
- readonly nodePages: {nodes: PageNodeType[]}[];
58
-
59
- /**
60
- * @constructs
61
- * Create a nodePages instance.
62
- * @param writeFileFunc - function to save one nodePage into a file
63
- * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met
64
- */
65
- constructor(writeFileFunc, nodesPerPage);
66
-
67
- /**
68
- * Setup function to save node pages
69
- * @param func - function which should be used to save node pages
70
- */
71
- useWriteFunction(func: Function): void;
72
-
73
- /**
74
- * Get the node by its end-to-end index
75
- * @param id - end-to-end index of the node
76
- * @return the node object
77
- */
78
- getNodeById(id: number): object;
79
-
80
- /**
81
- * Add a child id into the parent node.children array
82
- * @param parentId - end-to-end parent node index
83
- * @param childId - end-to-end child node index
84
- */
85
- addChildRelation(parentId: number, childId: number): void;
86
-
87
- /**
88
- * Update resource index in node.mesh object
89
- * @param {object} node - node object
90
- */
91
- updateResourceInMesh(node: object): void;
92
-
93
- /**
94
- * Update material in node.mesh object by node id
95
- * @param id - end-to-end index of the node
96
- * @param materialId - id from scene layer materialDefinitions
97
- */
98
- updateMaterialByNodeId(id: number, materialId: number);
99
-
100
- /**
101
- * Update vertexCount in node.mesh.geometry object by node id
102
- * @param id - end-to-end index of the node
103
- * @param vertexCount - vertex count for particular node
104
- */
105
- updateVertexCountByNodeId(id: number, vertexCount: number);
106
-
107
- /**
108
- * Update resource in node.mesh.attribute object by node id
109
- * @param id - end-to-end index of the node
110
- */
111
- updateNodeAttributeByNodeId(id: number);
112
-
113
- /**
114
- * Update featureCount in node.mesh.geometry object by node id
115
- * @param id - end-to-end index of the node
116
- * @param featureCount - features count of the node
117
- */
118
- updateFeatureCountByNodeId(id: number, featureCount: number);
119
-
120
- /**
121
- * Update texelCountHint in node.mesh.material object by node id
122
- * @param id - end-to-end index of the node
123
- * @param texelCountHint - texelCountHint of particular node
124
- */
125
- updateTexelCountHintByNodeId(id: number, texelCountHint: number);
126
-
127
- /**
128
- * Put new node in nodePages array
129
- * @param node - node object
130
- * @param parentId - index of parent node
131
- * @return
132
- */
133
- push(node: PageNodeType, parentId?: number): number;
134
-
135
- /**
136
- * Save all the node pages
137
- * Run this method when all nodes is pushed in nodePages
138
- * @param {string} layers0path - path of layer
139
- * @param {Object} fileMap - fileMap which keep info for slpk archive
140
- * @param {boolean} slpk
141
- * @return {promise}
142
- */
143
- save(layers0path: string, fileMap: Object, slpk: boolean): Promise<void>;
144
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * class GeoidHeightModel - "Gravity Height Model"
3
- * Calculates difference between mean see level height and WGS84 ellipsoid height
4
- * Input data have to be loaded from "Earth Gravity Model" *.pgm file with "PGMLoader"
5
- * A particular model file can be loaded on https://geographiclib.sourceforge.io/html/geoid.html
6
- *
7
- * The implementation is ported from GeographicLib-1.50.1
8
- */
9
- export class GeoidHeightModel {
10
- /**
11
- * @constructs
12
- * Create a GeoidHeightModel instance.
13
- * @param options - object which includes parameters parsed from *.pgm header
14
- * @param options.data - binary buffer of *.pgm file
15
- */
16
- constructor(options: {
17
- cubic: boolean;
18
- _width: number;
19
- _height: number;
20
- _rlonres: number;
21
- _rlatres: number;
22
- _offset: number;
23
- _scale: number;
24
- _swidth: number;
25
- _datastart: number;
26
- _maxerror: number;
27
- _rmserror: number;
28
- _description: string;
29
- _datetime: string;
30
- data: Uint8Array;
31
- });
32
-
33
- /**
34
- * Calculates difference between mean see level height and WGS84 ellipsoid height
35
- * Code is ported from /GeographicLib-1.50.1/src/Geoid.cpp
36
- * @param lat - latitude
37
- * @param lon - longitude
38
- * @returns height in meters
39
- */
40
- getHeight(lat: number, lon: number): number;
41
- }
@@ -1,239 +0,0 @@
1
- /**
2
- * Code is ported from GeographicLib-1.50.1
3
- * https://geographiclib.sourceforge.io/html/index.html
4
- * Location: /GeographicLib-1.50.1/src/Geoid.cpp
5
- * /GeographicLib-1.50.1/include/GeographicLib/Geoid.hpp
6
- * /GeographicLib-1.50.1/src/Math.cpp
7
- *
8
- * File header:
9
- * * \file Geoid.cpp (Geoid.hpp)
10
- * * \brief Implementation for GeographicLib::Geoid class
11
- * *
12
- * * Copyright (c) Charles Karney (2009-2018) <charles@karney.com> and licensed
13
- * * under the MIT/X11 License. For more information, see
14
- * * https://geographiclib.sourceforge.io/
15
- **********************************************************************/
16
-
17
- const c0_ = 240;
18
-
19
- // prettier-ignore
20
- const c3_ = [
21
- 9, -18, -88, 0, 96, 90, 0, 0, -60, -20,
22
- -9, 18, 8, 0, -96, 30, 0, 0, 60, -20,
23
- 9, -88, -18, 90, 96, 0, -20, -60, 0, 0,
24
- 186, -42, -42, -150, -96, -150, 60, 60, 60, 60,
25
- 54, 162, -78, 30, -24, -90, -60, 60, -60, 60,
26
- -9, -32, 18, 30, 24, 0, 20, -60, 0, 0,
27
- -9, 8, 18, 30, -96, 0, -20, 60, 0, 0,
28
- 54, -78, 162, -90, -24, 30, 60, -60, 60, -60,
29
- -54, 78, 78, 90, 144, 90, -60, -60, -60, -60,
30
- 9, -8, -18, -30, -24, 0, 20, 60, 0, 0,
31
- -9, 18, -32, 0, 24, 30, 0, 0, -60, 20,
32
- 9, -18, -8, 0, -24, -30, 0, 0, 60, 20
33
- ];
34
-
35
- const c0n_ = 372;
36
-
37
- // prettier-ignore
38
- const c3n_ = [
39
- 0, 0, -131, 0, 138, 144, 0, 0, -102, -31,
40
- 0, 0, 7, 0, -138, 42, 0, 0, 102, -31,
41
- 62, 0, -31, 0, 0, -62, 0, 0, 0, 31,
42
- 124, 0, -62, 0, 0, -124, 0, 0, 0, 62,
43
- 124, 0, -62, 0, 0, -124, 0, 0, 0, 62,
44
- 62, 0, -31, 0, 0, -62, 0, 0, 0, 31,
45
- 0, 0, 45, 0, -183, -9, 0, 93, 18, 0,
46
- 0, 0, 216, 0, 33, 87, 0, -93, 12, -93,
47
- 0, 0, 156, 0, 153, 99, 0, -93, -12, -93,
48
- 0, 0, -45, 0, -3, 9, 0, 93, -18, 0,
49
- 0, 0, -55, 0, 48, 42, 0, 0, -84, 31,
50
- 0, 0, -7, 0, -48, -42, 0, 0, 84, 31,
51
- ];
52
-
53
- const c0s_ = 372;
54
-
55
- // prettier-ignore
56
- const c3s_ = [
57
- 18, -36, -122, 0, 120, 135, 0, 0, -84, -31,
58
- -18, 36, -2, 0, -120, 51, 0, 0, 84, -31,
59
- 36, -165, -27, 93, 147, -9, 0, -93, 18, 0,
60
- 210, 45, -111, -93, -57, -192, 0, 93, 12, 93,
61
- 162, 141, -75, -93, -129, -180, 0, 93, -12, 93,
62
- -36, -21, 27, 93, 39, 9, 0, -93, -18, 0,
63
- 0, 0, 62, 0, 0, 31, 0, 0, 0, -31,
64
- 0, 0, 124, 0, 0, 62, 0, 0, 0, -62,
65
- 0, 0, 124, 0, 0, 62, 0, 0, 0, -62,
66
- 0, 0, 62, 0, 0, 31, 0, 0, 0, -31,
67
- -18, 36, -64, 0, 66, 51, 0, 0, -102, 31,
68
- 18, -36, 2, 0, -66, -51, 0, 0, 102, 31,
69
- ];
70
- const stencilsize_ = 12;
71
- const nterms_ = ((3 + 1) * (3 + 2)) / 2; // for a cubic fit
72
- const PIXEL_SIZE = 2;
73
-
74
- export class GeoidHeightModel {
75
- constructor(options) {
76
- this.options = options;
77
- this._v00 = 0;
78
- this._v01 = 0;
79
- this._v10 = 0;
80
- this._v11 = 0;
81
- this._t = [];
82
-
83
- this._ix = this.options._width;
84
- this._iy = this.options._height;
85
- }
86
-
87
- // eslint-disable-next-line max-statements, complexity
88
- getHeight(lat, lon) {
89
- // C++: Math::LatFix(lat)
90
- lat = Math.abs(lat) > 90 ? NaN : lat;
91
-
92
- if (isNaN(lat) || isNaN(lon)) {
93
- return NaN;
94
- }
95
-
96
- // C++: Math::AngNormalize(lon)
97
- const rem = _remainder(lon, 360);
98
- lon = rem !== -180 ? rem : 180;
99
-
100
- let fx = lon * this.options._rlonres;
101
- let fy = -lat * this.options._rlatres;
102
- let ix = Math.floor(fx);
103
- let iy = Math.min(Math.round((this.options._height - 1) / 2 - 1), Math.floor(fy));
104
- fx -= ix;
105
- fy -= iy;
106
- iy += (this.options._height - 1) / 2;
107
- ix += ix < 0 ? this.options._width : ix >= this.options._width ? -this.options._width : 0;
108
- let v00 = 0;
109
- let v01 = 0;
110
- let v10 = 0;
111
- let v11 = 0;
112
- let t = new Array(nterms_);
113
- if (!(ix === this._ix && iy === this._iy)) {
114
- if (!this.options.cubic) {
115
- v00 = this._rawval(ix, iy);
116
- v01 = this._rawval(ix + 1, iy);
117
- v10 = this._rawval(ix, iy + 1);
118
- v11 = this._rawval(ix + 1, iy + 1);
119
- } else {
120
- const v = [
121
- this._rawval(ix, iy - 1),
122
- this._rawval(ix + 1, iy - 1),
123
- this._rawval(ix - 1, iy),
124
- this._rawval(ix, iy),
125
- this._rawval(ix + 1, iy),
126
- this._rawval(ix + 2, iy),
127
- this._rawval(ix - 1, iy + 1),
128
- this._rawval(ix, iy + 1),
129
- this._rawval(ix + 1, iy + 1),
130
- this._rawval(ix + 2, iy + 1),
131
- this._rawval(ix, iy + 2),
132
- this._rawval(ix + 1, iy + 2)
133
- ];
134
-
135
- let c3x = c3n_;
136
- if (iy !== 0) {
137
- c3x = iy === this.options._height - 2 ? c3s_ : c3_;
138
- }
139
- let c0x = c0n_;
140
- if (iy !== 0) {
141
- c0x = iy === this.options._height - 2 ? c0s_ : c0_;
142
- }
143
- for (let i = 0; i < nterms_; ++i) {
144
- t[i] = 0;
145
- // eslint-disable-next-line max-depth
146
- for (let j = 0; j < stencilsize_; ++j) {
147
- t[i] += v[j] * c3x[nterms_ * j + i];
148
- }
149
- t[i] /= c0x;
150
- }
151
- }
152
- } else if (!this.options.cubic) {
153
- // same cell; used cached coefficients
154
- v00 = this._v00;
155
- v01 = this._v01;
156
- v10 = this._v10;
157
- v11 = this._v11;
158
- } else {
159
- t = this._t;
160
- }
161
-
162
- if (!this.options.cubic) {
163
- const a = (1 - fx) * v00 + fx * v01;
164
- const b = (1 - fx) * v10 + fx * v11;
165
- const c = (1 - fy) * a + fy * b;
166
- const h = this.options._offset + this.options._scale * c;
167
- this._ix = ix;
168
- this._iy = iy;
169
- this._v00 = v00;
170
- this._v01 = v01;
171
- this._v10 = v10;
172
- this._v11 = v11;
173
- return h;
174
- }
175
- let h =
176
- t[0] +
177
- fx * (t[1] + fx * (t[3] + fx * t[6])) +
178
- fy * (t[2] + fx * (t[4] + fx * t[7]) + fy * (t[5] + fx * t[8] + fy * t[9]));
179
- h = this.options._offset + this.options._scale * h;
180
- this._ix = ix;
181
- this._iy = iy;
182
- this._t = t;
183
- return h;
184
- }
185
-
186
- /**
187
- * Method seeks for particular data in th pgm buffer
188
- * Code is ported from corresponding method
189
- * in /GeographicLib-1.50.1/include/GeographicLib/Geoid.hpp
190
- * @param {number} ix - longituge parameter
191
- * @param {number} iy - latitude parameter
192
- * @returns {number} data from pgm binary buffer
193
- */
194
- _rawval(ix, iy) {
195
- if (ix < 0) {
196
- ix += this.options._width;
197
- } else if (ix >= this.options._width) {
198
- ix -= this.options._width;
199
- }
200
- if (iy < 0 || iy >= this.options._height) {
201
- iy = iy < 0 ? -iy : 2 * (this.options._height - 1) - iy;
202
- ix += ((ix < this.options._width / 2 ? 1 : -1) * this.options._width) / 2;
203
- }
204
- const bufferPosition = this.options._datastart + PIXEL_SIZE * (iy * this.options._swidth + ix);
205
- // initial values to suppress warnings in case get fails
206
- const a = this.options.data[bufferPosition];
207
- const b = this.options.data[bufferPosition + 1];
208
- const r = (a << 8) | b;
209
- return r;
210
- }
211
- }
212
-
213
- /**
214
- * Method calculates remainder of float numbers division
215
- * Code is ported from corresponding method
216
- * in /GeographicLib-1.50.1/src/Math.cpp
217
- * Math::remainder(T x, T y)
218
- * @param {number} x - numerator
219
- * @param {number} y - denominator
220
- * @returns {number} - remainder
221
- */
222
- function _remainder(x, y) {
223
- y = Math.abs(y); // The result doesn't depend on the sign of y
224
- let z = _fmod(x, y);
225
- if (2 * Math.abs(z) === y) z -= _fmod(x, 2 * y) - z;
226
- // Implement ties to even
227
- else if (2 * Math.abs(z) > y) z += z < 0 ? y : -y; // Fold remaining cases to (-y/2, y/2)
228
- return z;
229
- }
230
-
231
- /**
232
- * Computes the floating-point remainder of the division operation x/y
233
- * @param {number} x - numerator
234
- * @param {number} y - denominator
235
- * @returns {number} - remainder
236
- */
237
- function _fmod(x, y) {
238
- return x - Math.floor(x / y) * y;
239
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Parse header of "Earth Gravity Model" *.pgm file
3
- * The implementation is ported from GeographicLib-1.50.1
4
- * https://geographiclib.sourceforge.io/html/index.html
5
- */
6
-
7
- /**
8
- * Parse "Earth Gravity Model" loaded from a *.pgm file
9
- * https://geographiclib.sourceforge.io/html/geoid.html
10
- * @param {Uint8Array} data - binary buffer of pgm file
11
- * @param {Object} options - loader options
12
- * @returns {GeoidHeightModel} - instance of GeoidHeightModel class
13
- */
14
- export function parsePgm(data, options);