@loaders.gl/tile-converter 4.0.0-alpha.14 → 4.0.0-alpha.15
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.
- package/bin/i3s-server.js +4 -0
- package/dist/converter.min.js +58 -58
- package/dist/dist.min.js +241 -127
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +26 -22
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-server/README.md +46 -2
- package/dist/es5/i3s-server/app.js +3 -3
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/bin/www.js +61 -0
- package/dist/es5/i3s-server/bin/www.js.map +1 -0
- package/dist/es5/i3s-server/controllers/slpk-controller.js +14 -18
- package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/es5/index.js +7 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +59 -26
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +1 -1
- package/dist/es5/slpk-extractor/helpers/fs-promises.js +77 -0
- package/dist/es5/slpk-extractor/helpers/fs-promises.js.map +1 -0
- package/dist/es5/slpk-extractor/slpk-extractor.js +7 -7
- package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +5 -1
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-server/README.md +46 -2
- package/dist/esm/i3s-server/app.js +4 -4
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +614 -0
- package/dist/esm/i3s-server/bin/{www → www.js} +12 -55
- package/dist/esm/i3s-server/bin/www.js.map +1 -0
- package/dist/esm/i3s-server/controllers/slpk-controller.js +6 -12
- package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +17 -6
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +1 -1
- package/dist/esm/slpk-extractor/helpers/fs-promises.js +32 -0
- package/dist/esm/slpk-extractor/helpers/fs-promises.js.map +1 -0
- package/dist/esm/slpk-extractor/slpk-extractor.js +2 -2
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +5 -1
- package/dist/i3s-server/app.d.ts.map +1 -1
- package/dist/i3s-server/app.js +1 -1
- package/dist/i3s-server/bin/www.d.ts +3 -0
- package/dist/i3s-server/bin/www.d.ts.map +1 -0
- package/dist/i3s-server/bin/www.js +83 -0
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
- package/dist/i3s-server/controllers/slpk-controller.js +4 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts +15 -12
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +1 -1
- package/dist/slpk-extractor/helpers/file-handle-provider.js +25 -10
- package/dist/slpk-extractor/helpers/fs-promises.d.ts +38 -0
- package/dist/slpk-extractor/helpers/fs-promises.d.ts.map +1 -0
- package/dist/slpk-extractor/helpers/fs-promises.js +51 -0
- package/dist/slpk-extractor/slpk-extractor.d.ts +2 -2
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
- package/dist/slpk-extractor/slpk-extractor.js +4 -7
- package/dist/slpk-extractor.min.js +44 -44
- package/package.json +21 -20
- package/src/i3s-converter/i3s-converter.ts +5 -1
- package/src/i3s-server/README.md +46 -2
- package/src/i3s-server/app.js +1 -1
- package/{dist/es5/i3s-server/bin/www → src/i3s-server/bin/www.js} +7 -7
- package/src/i3s-server/controllers/slpk-controller.js +4 -11
- package/src/index.ts +1 -0
- package/src/slpk-extractor/helpers/file-handle-provider.ts +36 -18
- package/src/slpk-extractor/helpers/fs-promises.ts +66 -0
- package/src/slpk-extractor/slpk-extractor.ts +5 -6
- package/src/i3s-server/bin/www +0 -102
|
@@ -1,102 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Module dependencies.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
2
|
const app = require('../app');
|
|
8
3
|
const debug = require('debug')('i3s-server:server');
|
|
9
4
|
const https = require('https');
|
|
10
5
|
const http = require('http');
|
|
11
6
|
const fs = require('fs');
|
|
12
7
|
const path = require('path');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Get port from environment and store in Express.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const httpPort = normalizePort(process.env.PORT || '80'); // eslint-disable-line no-process-env, no-undef
|
|
19
|
-
const httpsPort = normalizePort(process.env.HTTPS_PORT || '443'); // eslint-disable-line no-process-env, no-undef
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Create HTTP server.
|
|
23
|
-
*/
|
|
24
|
-
|
|
8
|
+
const httpPort = normalizePort(process.env.PORT || '80');
|
|
9
|
+
const httpsPort = normalizePort(process.env.HTTPS_PORT || '443');
|
|
25
10
|
const options = {
|
|
26
11
|
key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),
|
|
27
12
|
cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))
|
|
28
13
|
};
|
|
29
|
-
|
|
30
14
|
const httpServer = http.createServer(app);
|
|
31
15
|
const httpsServer = https.createServer(options, app);
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Listen on provided port, on all network interfaces.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
16
|
httpServer.listen(httpPort);
|
|
38
17
|
httpServer.on('error', formErrorHandler(httpPort));
|
|
39
18
|
httpServer.on('listening', formListeningHandler(httpServer));
|
|
40
|
-
|
|
41
19
|
httpsServer.listen(httpsPort);
|
|
42
20
|
httpsServer.on('error', formErrorHandler(httpsPort));
|
|
43
21
|
httpsServer.on('listening', formListeningHandler(httpsServer));
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Normalize a port into a number, string, or false.
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
22
|
function normalizePort(val) {
|
|
50
23
|
const chkPort = parseInt(val, 10);
|
|
51
|
-
|
|
52
24
|
if (isNaN(chkPort)) {
|
|
53
|
-
// named pipe
|
|
54
25
|
return val;
|
|
55
26
|
}
|
|
56
|
-
|
|
57
27
|
if (chkPort >= 0) {
|
|
58
|
-
// port number
|
|
59
28
|
return chkPort;
|
|
60
29
|
}
|
|
61
|
-
|
|
62
30
|
return false;
|
|
63
31
|
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Event listener for HTTP/HTTPS server "error" event.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
32
|
function formErrorHandler(optionalPort) {
|
|
70
33
|
return function onError(error) {
|
|
71
34
|
if (error.syscall !== 'listen') {
|
|
72
35
|
throw error;
|
|
73
36
|
}
|
|
74
|
-
|
|
75
|
-
const bind = typeof port === 'string' ? `Pipe ${optionalPort}`: `Port ${optionalPort}`;
|
|
76
|
-
|
|
77
|
-
// handle specific listen errors with friendly messages
|
|
37
|
+
const bind = typeof global.port === 'string' ? "Pipe ".concat(optionalPort) : "Port ".concat(optionalPort);
|
|
78
38
|
switch (error.code) {
|
|
79
39
|
case 'EACCES':
|
|
80
|
-
console.error(
|
|
81
|
-
process.exit(1)
|
|
40
|
+
console.error("".concat(bind, " requires elevated privileges"));
|
|
41
|
+
process.exit(1);
|
|
82
42
|
break;
|
|
83
43
|
case 'EADDRINUSE':
|
|
84
|
-
console.error(
|
|
85
|
-
process.exit(1)
|
|
44
|
+
console.error("".concat(bind, " is already in use"));
|
|
45
|
+
process.exit(1);
|
|
86
46
|
break;
|
|
87
47
|
default:
|
|
88
48
|
throw error;
|
|
89
49
|
}
|
|
90
|
-
}
|
|
50
|
+
};
|
|
91
51
|
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Event listener for HTTP/HTTPS server "listening" event.
|
|
95
|
-
*/
|
|
96
52
|
function formListeningHandler(optionalServer) {
|
|
97
53
|
return function onListening() {
|
|
98
54
|
const addr = optionalServer.address();
|
|
99
|
-
const bind = typeof addr === 'string' ?
|
|
100
|
-
debug(
|
|
101
|
-
}
|
|
55
|
+
const bind = typeof addr === 'string' ? "pipe ".concat(addr) : "port ".concat(addr.port);
|
|
56
|
+
debug("Listening on ".concat(bind));
|
|
57
|
+
};
|
|
102
58
|
}
|
|
59
|
+
//# sourceMappingURL=www.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"www.js","names":["app","require","debug","https","http","fs","path","httpPort","normalizePort","process","env","PORT","httpsPort","HTTPS_PORT","options","key","readFileSync","join","__dirname","cert","httpServer","createServer","httpsServer","listen","on","formErrorHandler","formListeningHandler","val","chkPort","parseInt","isNaN","optionalPort","onError","error","syscall","bind","global","port","concat","code","console","exit","optionalServer","onListening","addr","address"],"sources":["../../../../src/i3s-server/bin/www.js"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nconst app = require('../app');\nconst debug = require('debug')('i3s-server:server');\nconst https = require('https');\nconst http = require('http');\nconst fs = require('fs');\nconst path = require('path');\n\n/**\n * Get port from environment and store in Express.\n */\n\nconst httpPort = normalizePort(process.env.PORT || '80'); // eslint-disable-line no-process-env, no-undef\nconst httpsPort = normalizePort(process.env.HTTPS_PORT || '443'); // eslint-disable-line no-process-env, no-undef\n\n/**\n * Create HTTP server.\n */\n\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/**\n * Listen on provided port, on all network interfaces.\n */\n\nhttpServer.listen(httpPort);\nhttpServer.on('error', formErrorHandler(httpPort));\nhttpServer.on('listening', formListeningHandler(httpServer));\n\nhttpsServer.listen(httpsPort);\nhttpsServer.on('error', formErrorHandler(httpsPort));\nhttpsServer.on('listening', formListeningHandler(httpsServer));\n\n/**\n * Normalize a port into a number, string, or false.\n */\n\nfunction normalizePort(val) {\n const chkPort = parseInt(val, 10);\n\n if (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 for HTTP/HTTPS server \"error\" event.\n */\n\nfunction formErrorHandler(optionalPort) {\n return function onError(error) {\n if (error.syscall !== 'listen') {\n throw error;\n }\n\n const bind = typeof global.port === '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 */\nfunction formListeningHandler(optionalServer) {\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":"AAAA;AAMA,MAAMA,GAAG,GAAGC,OAAO,CAAC,QAAQ,CAAC;AAC7B,MAAMC,KAAK,GAAGD,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC;AACnD,MAAME,KAAK,GAAGF,OAAO,CAAC,OAAO,CAAC;AAC9B,MAAMG,IAAI,GAAGH,OAAO,CAAC,MAAM,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
|
|
3
|
+
parseSLPK
|
|
8
4
|
} = require('@loaders.gl/i3s');
|
|
9
5
|
const path = require('path');
|
|
6
|
+
const {
|
|
7
|
+
FileHandleProvider
|
|
8
|
+
} = require('@loaders.gl/tile-converter');
|
|
10
9
|
let slpkArchive;
|
|
11
10
|
const loadArchive = async fullLayerPath => {
|
|
12
|
-
slpkArchive = await (await
|
|
11
|
+
slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath));
|
|
13
12
|
};
|
|
14
13
|
const I3S_LAYER_PATH = process.env.I3sLayerPath || '';
|
|
15
14
|
const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);
|
|
@@ -19,12 +18,7 @@ async function getFileByUrl(url) {
|
|
|
19
18
|
let uncompressedFile;
|
|
20
19
|
if (trimmedPath) {
|
|
21
20
|
try {
|
|
22
|
-
uncompressedFile = Buffer.from(await
|
|
23
|
-
slpk: {
|
|
24
|
-
path: trimmedPath[1],
|
|
25
|
-
pathMode: 'http'
|
|
26
|
-
}
|
|
27
|
-
}));
|
|
21
|
+
uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));
|
|
28
22
|
} catch (e) {}
|
|
29
23
|
}
|
|
30
24
|
return uncompressedFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slpk-controller.js","names":["require","
|
|
1
|
+
{"version":3,"file":"slpk-controller.js","names":["require","parseSLPK","path","FileHandleProvider","slpkArchive","loadArchive","fullLayerPath","from","I3S_LAYER_PATH","process","env","I3sLayerPath","FULL_LAYER_PATH","join","cwd","getFileByUrl","url","trimmedPath","exec","uncompressedFile","Buffer","getFile","e","module","exports"],"sources":["../../../../src/i3s-server/controllers/slpk-controller.js"],"sourcesContent":["require('@loaders.gl/polyfills');\nconst {parseSLPK} = require('@loaders.gl/i3s');\nconst path = require('path');\nconst {FileHandleProvider} = require('@loaders.gl/tile-converter');\n\nlet slpkArchive;\n\nconst loadArchive = async (fullLayerPath) => {\n slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath));\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(await slpkArchive.getFile(trimmedPath[1], 'http'));\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;AAAS,CAAC,GAAGD,OAAO,CAAC,iBAAiB,CAAC;AAC9C,MAAME,IAAI,GAAGF,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAM;EAACG;AAAkB,CAAC,GAAGH,OAAO,CAAC,4BAA4B,CAAC;AAElE,IAAII,WAAW;AAEf,MAAMC,WAAW,GAAG,MAAOC,aAAa,IAAK;EAC3CF,WAAW,GAAG,MAAMH,SAAS,CAAC,MAAME,kBAAkB,CAACI,IAAI,CAACD,aAAa,CAAC,CAAC;AAC7E,CAAC;AAED,MAAME,cAAc,GAAGC,OAAO,CAACC,GAAG,CAACC,YAAY,IAAI,EAAE;AACrD,MAAMC,eAAe,GAAGV,IAAI,CAACW,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,CAACb,IAAI,CAAC,MAAMH,WAAW,CAACiB,OAAO,CAACJ,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC,CAAC,OAAOK,CAAC,EAAE,CAAC;EACf;EACA,OAAOH,gBAAgB;AACzB;AAEAI,MAAM,CAACC,OAAO,GAAG;EACfnB,WAAW;EACXU;AACF,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as I3SConverter } from './i3s-converter/i3s-converter';
|
|
2
2
|
export { default as Tiles3DConverter } from './3d-tiles-converter/3d-tiles-converter';
|
|
3
|
+
export { FileHandleProvider } from './slpk-extractor/helpers/file-handle-provider';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","I3SConverter","Tiles3DConverter"],"sources":["../../src/index.ts"],"sourcesContent":["export {default as I3SConverter} from './i3s-converter/i3s-converter';\nexport {default as Tiles3DConverter} from './3d-tiles-converter/3d-tiles-converter';\n"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,YAAY,QAAO,+BAA+B;AACrE,SAAQD,OAAO,IAAIE,gBAAgB,QAAO,yCAAyC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","I3SConverter","Tiles3DConverter","FileHandleProvider"],"sources":["../../src/index.ts"],"sourcesContent":["export {default as I3SConverter} from './i3s-converter/i3s-converter';\nexport {default as Tiles3DConverter} from './3d-tiles-converter/3d-tiles-converter';\nexport {FileHandleProvider} from './slpk-extractor/helpers/file-handle-provider';\n"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,YAAY,QAAO,+BAA+B;AACrE,SAAQD,OAAO,IAAIE,gBAAgB,QAAO,yCAAyC;AACnF,SAAQC,kBAAkB,QAAO,+CAA+C"}
|
package/dist/esm/pgm-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parsePGM } from '@math.gl/geoid';
|
|
2
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
2
|
+
const VERSION = typeof "4.0.0-alpha.15" !== 'undefined' ? "4.0.0-alpha.15" : 'latest';
|
|
3
3
|
export const PGMLoader = {
|
|
4
4
|
name: 'PGM - Netpbm grayscale image format',
|
|
5
5
|
id: 'pgm',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import {
|
|
2
|
+
import { FileHandle } from './fs-promises';
|
|
3
3
|
export class FileHandleProvider {
|
|
4
4
|
static async from(path) {
|
|
5
|
-
const fileDescriptor = await
|
|
6
|
-
return new FileHandleProvider(fileDescriptor,
|
|
5
|
+
const fileDescriptor = await FileHandle.open(path);
|
|
6
|
+
return new FileHandleProvider(fileDescriptor, fileDescriptor.stat.size);
|
|
7
7
|
}
|
|
8
8
|
constructor(fileDescriptor, size) {
|
|
9
9
|
_defineProperty(this, "fileDescriptor", void 0);
|
|
@@ -32,9 +32,20 @@ export class FileHandleProvider {
|
|
|
32
32
|
}
|
|
33
33
|
return val;
|
|
34
34
|
}
|
|
35
|
-
async
|
|
36
|
-
const
|
|
37
|
-
|
|
35
|
+
async getBigUint64(offset) {
|
|
36
|
+
const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 4, offset)).buffer.buffer).at(0);
|
|
37
|
+
if (val === undefined) {
|
|
38
|
+
throw new Error('something went wrong');
|
|
39
|
+
}
|
|
40
|
+
return val;
|
|
41
|
+
}
|
|
42
|
+
async slice(startOffsset, endOffset) {
|
|
43
|
+
const bigLength = endOffset - startOffsset;
|
|
44
|
+
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
45
|
+
throw new Error('too big slice');
|
|
46
|
+
}
|
|
47
|
+
const length = Number(bigLength);
|
|
48
|
+
return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer.buffer;
|
|
38
49
|
}
|
|
39
50
|
get length() {
|
|
40
51
|
return this.size;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-handle-provider.js","names":["
|
|
1
|
+
{"version":3,"file":"file-handle-provider.js","names":["FileHandle","FileHandleProvider","from","path","fileDescriptor","open","stat","size","constructor","_defineProperty","getUint8","offset","val","Uint8Array","read","Buffer","alloc","buffer","at","undefined","Error","getUint16","Uint16Array","getUint32","Uint32Array","getBigUint64","BigInt64Array","slice","startOffsset","endOffset","bigLength","Number","MAX_SAFE_INTEGER","length"],"sources":["../../../../src/slpk-extractor/helpers/file-handle-provider.ts"],"sourcesContent":["import {FileProvider} from '@loaders.gl/i3s';\nimport {FileHandle} from './fs-promises';\n\n/**\n * Provides file data using node fs library\n */\nexport class FileHandleProvider implements FileProvider {\n /**\n * Returns a new copy of FileHandleProvider\n * @param path The path to the file in file system\n */\n static async from(path: string): Promise<FileHandleProvider> {\n const fileDescriptor = await FileHandle.open(path);\n return new FileHandleProvider(fileDescriptor, fileDescriptor.stat.size);\n }\n\n /**\n * The FileHandle from which data is provided\n */\n private fileDescriptor: FileHandle;\n\n /**\n * The file length in bytes\n */\n private size: bigint;\n\n private constructor(fileDescriptor: FileHandle, size: bigint) {\n this.fileDescriptor = fileDescriptor;\n this.size = size;\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n const val = new Uint8Array(\n (await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n const val = new Uint16Array(\n (await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n const val = new Uint32Array(\n (await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n const val = new BigInt64Array(\n (await this.fileDescriptor.read(Buffer.alloc(8), 0, 4, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffsset The offset, in byte, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n const bigLength = endOffset - startOffsset;\n if (bigLength > Number.MAX_SAFE_INTEGER) {\n throw new Error('too big slice');\n }\n const length = Number(bigLength);\n return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer\n .buffer;\n }\n\n /**\n * the length (in bytes) of the data.\n */\n get length(): bigint {\n return this.size;\n }\n}\n"],"mappings":";AACA,SAAQA,UAAU,QAAO,eAAe;AAKxC,OAAO,MAAMC,kBAAkB,CAAyB;EAKtD,aAAaC,IAAIA,CAACC,IAAY,EAA+B;IAC3D,MAAMC,cAAc,GAAG,MAAMJ,UAAU,CAACK,IAAI,CAACF,IAAI,CAAC;IAClD,OAAO,IAAIF,kBAAkB,CAACG,cAAc,EAAEA,cAAc,CAACE,IAAI,CAACC,IAAI,CAAC;EACzE;EAYQC,WAAWA,CAACJ,cAA0B,EAAEG,IAAY,EAAE;IAAAE,eAAA;IAAAA,eAAA;IAC5D,IAAI,CA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MA,MAAMa,YAAYA,CAACd,MAAc,EAAmB;IAClD,MAAMC,GAAG,GAAG,IAAIc,aAAa,CAC3B,CAAC,MAAM,IAAI,CAACtB,cAAc,CAACU,IAAI,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAEL,MAAM,CAAC,EAAEM,MAAM,CAACA,MACzE,CAAC,CAACC,EAAE,CAAC,CAAC,CAAC;IACP,IAAIN,GAAG,KAAKO,SAAS,EAAE;MACrB,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;IACzC;IACA,OAAOR,GAAG;EACZ;EAOA,MAAMe,KAAKA,CAACC,YAAoB,EAAEC,SAAiB,EAAwB;IACzE,MAAMC,SAAS,GAAGD,SAAS,GAAGD,YAAY;IAC1C,IAAIE,SAAS,GAAGC,MAAM,CAACC,gBAAgB,EAAE;MACvC,MAAM,IAAIZ,KAAK,CAAC,eAAe,CAAC;IAClC;IACA,MAAMa,MAAM,GAAGF,MAAM,CAACD,SAAS,CAAC;IAChC,OAAO,CAAC,MAAM,IAAI,CAAC1B,cAAc,CAACU,IAAI,CAACC,MAAM,CAACC,KAAK,CAACiB,MAAM,CAAC,EAAE,CAAC,EAAEA,MAAM,EAAEL,YAAY,CAAC,EAAEX,MAAM,CAC1FA,MAAM;EACX;EAKA,IAAIgB,MAAMA,CAAA,EAAW;IACnB,OAAO,IAAI,CAAC1B,IAAI;EAClB;AACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { read, open, stat } from 'fs';
|
|
3
|
+
export class FileHandle {
|
|
4
|
+
constructor(fileDescriptor, stats) {
|
|
5
|
+
_defineProperty(this, "fileDescriptor", void 0);
|
|
6
|
+
_defineProperty(this, "stats", void 0);
|
|
7
|
+
_defineProperty(this, "read", (buffer, offset, length, position) => {
|
|
8
|
+
return new Promise(s => {
|
|
9
|
+
read(this.fileDescriptor, buffer, offset, length, position, (_err, bytesRead, buffer) => s({
|
|
10
|
+
bytesRead,
|
|
11
|
+
buffer
|
|
12
|
+
}));
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
this.fileDescriptor = fileDescriptor;
|
|
16
|
+
this.stats = stats;
|
|
17
|
+
}
|
|
18
|
+
get stat() {
|
|
19
|
+
return this.stats;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
_defineProperty(FileHandle, "open", async path => {
|
|
23
|
+
const [fd, stats] = await Promise.all([new Promise(s => {
|
|
24
|
+
open(path, undefined, undefined, (_err, fd) => s(fd));
|
|
25
|
+
}), new Promise(s => {
|
|
26
|
+
stat(path, {
|
|
27
|
+
bigint: true
|
|
28
|
+
}, (_err, stats) => s(stats));
|
|
29
|
+
})]);
|
|
30
|
+
return new FileHandle(fd, stats);
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=fs-promises.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-promises.js","names":["read","open","stat","FileHandle","constructor","fileDescriptor","stats","_defineProperty","buffer","offset","length","position","Promise","s","_err","bytesRead","path","fd","all","undefined","bigint"],"sources":["../../../../src/slpk-extractor/helpers/fs-promises.ts"],"sourcesContent":["import {read, open, stat, BigIntStats} from 'fs';\n\n/** file reading result */\nexport type FileReadResult = {\n /** amount of the bytes read */\n bytesRead: number;\n /** the buffer filled with data from file*/\n buffer: Buffer;\n};\n\n/** Object handling file info */\nexport class FileHandle {\n private fileDescriptor: number;\n private stats: BigIntStats;\n private constructor(fileDescriptor: number, stats: BigIntStats) {\n this.fileDescriptor = fileDescriptor;\n this.stats = stats;\n }\n /**\n * Opens a `FileHandle`.\n *\n * @param path path to the file\n * @return Fulfills with a {FileHandle} object.\n */\n\n static open = async (path: string): Promise<FileHandle> => {\n const [fd, stats] = await Promise.all([\n new Promise<number>((s) => {\n open(path, undefined, undefined, (_err, fd) => s(fd));\n }),\n new Promise<BigIntStats>((s) => {\n stat(path, {bigint: true}, (_err, stats) => s(stats));\n })\n ]);\n return new FileHandle(fd, stats);\n };\n\n /**\n * Reads data from the file and stores that in the given buffer.\n *\n * If the file is not modified concurrently, the end-of-file is reached when the\n * number of bytes read is zero.\n * @param buffer A buffer that will be filled with the file data read.\n * @param offset The location in the buffer at which to start filling.\n * @param length The number of bytes to read.\n * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an\n * integer, the current file position will remain unchanged.\n * @return Fulfills upon success with a FileReadResult object\n */\n read = (\n buffer: Buffer,\n offset: number,\n length: number,\n position: number | bigint\n ): Promise<FileReadResult> => {\n return new Promise((s) => {\n read(this.fileDescriptor, buffer, offset, length, position, (_err, bytesRead, buffer) =>\n s({bytesRead, buffer})\n );\n });\n };\n\n get stat(): BigIntStats {\n return this.stats;\n }\n}\n"],"mappings":";AAAA,SAAQA,IAAI,EAAEC,IAAI,EAAEC,IAAI,QAAoB,IAAI;AAWhD,OAAO,MAAMC,UAAU,CAAC;EAGdC,WAAWA,CAACC,cAAsB,EAAEC,KAAkB,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,eAmCzD,CACLC,MAAc,EACdC,MAAc,EACdC,MAAc,EACdC,QAAyB,KACG;MAC5B,OAAO,IAAIC,OAAO,CAAEC,CAAC,IAAK;QACxBb,IAAI,CAAC,IAAI,CAACK,cAAc,EAAEG,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,CAACG,IAAI,EAAEC,SAAS,EAAEP,MAAM,KAClFK,CAAC,CAAC;UAACE,SAAS;UAAEP;QAAM,CAAC,CACvB,CAAC;MACH,CAAC,CAAC;IACJ,CAAC;IA7CC,IAAI,CAACH,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,KAAK,GAAGA,KAAK;EACpB;EA6CA,IAAIJ,IAAIA,CAAA,EAAgB;IACtB,OAAO,IAAI,CAACI,KAAK;EACnB;AACF;AAACC,eAAA,CAtDYJ,UAAU,UAcP,MAAOa,IAAY,IAA0B;EACzD,MAAM,CAACC,EAAE,EAAEX,KAAK,CAAC,GAAG,MAAMM,OAAO,CAACM,GAAG,CAAC,CACpC,IAAIN,OAAO,CAAUC,CAAC,IAAK;IACzBZ,IAAI,CAACe,IAAI,EAAEG,SAAS,EAAEA,SAAS,EAAE,CAACL,IAAI,EAAEG,EAAE,KAAKJ,CAAC,CAACI,EAAE,CAAC,CAAC;EACvD,CAAC,CAAC,EACF,IAAIL,OAAO,CAAeC,CAAC,IAAK;IAC9BX,IAAI,CAACc,IAAI,EAAE;MAACI,MAAM,EAAE;IAAI,CAAC,EAAE,CAACN,IAAI,EAAER,KAAK,KAAKO,CAAC,CAACP,KAAK,CAAC,CAAC;EACvD,CAAC,CAAC,CACH,CAAC;EACF,OAAO,IAAIH,UAAU,CAACc,EAAE,EAAEX,KAAK,CAAC;AAClC,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { path } from '@loaders.gl/loader-utils';
|
|
|
6
6
|
import { GZipCompression } from '@loaders.gl/compression';
|
|
7
7
|
import { writeFile } from '../lib/utils/file-utils';
|
|
8
8
|
const indexNames = ['3dSceneLayer.json.gz', '3dNodeIndexDocument.json.gz', 'sharedResource.json.gz'];
|
|
9
|
-
export default class
|
|
9
|
+
export default class SLPKConverter {
|
|
10
10
|
async extract(options) {
|
|
11
11
|
if (isBrowser) {
|
|
12
12
|
console.log(BROWSER_ERROR_MESSAGE);
|
|
@@ -16,7 +16,7 @@ export default class SLPKExtractor {
|
|
|
16
16
|
inputUrl
|
|
17
17
|
} = options;
|
|
18
18
|
const provider = await FileHandleProvider.from(inputUrl);
|
|
19
|
-
let localHeader = await parseZipLocalFileHeader(
|
|
19
|
+
let localHeader = await parseZipLocalFileHeader(0n, provider);
|
|
20
20
|
while (localHeader) {
|
|
21
21
|
var _localHeader, _localHeader2;
|
|
22
22
|
await this.writeFile(await this.unGzip({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slpk-extractor.js","names":["isBrowser","BROWSER_ERROR_MESSAGE","FileHandleProvider","parseZipLocalFileHeader","path","GZipCompression","writeFile","indexNames","
|
|
1
|
+
{"version":3,"file":"slpk-extractor.js","names":["isBrowser","BROWSER_ERROR_MESSAGE","FileHandleProvider","parseZipLocalFileHeader","path","GZipCompression","writeFile","indexNames","SLPKConverter","extract","options","console","log","inputUrl","provider","from","localHeader","_localHeader","_localHeader2","unGzip","name","correctIndexNames","fileName","data","slice","fileDataOffset","compressedSize","outputPath","includes","filename","join","dirname","parts","exec","concat","at","file","_file$name","test","_file$name2","compression","decompressedData","decompress","Promise","resolve","finalPath","dirName"],"sources":["../../../src/slpk-extractor/slpk-extractor.ts"],"sourcesContent":["import {isBrowser} from '@loaders.gl/core';\n\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {FileHandleProvider} from './helpers/file-handle-provider';\nimport {parseZipLocalFileHeader} from '@loaders.gl/i3s';\nimport {path} from '@loaders.gl/loader-utils';\nimport {GZipCompression} from '@loaders.gl/compression';\nimport {writeFile} from '../lib/utils/file-utils';\n\nconst indexNames = [\n '3dSceneLayer.json.gz',\n '3dNodeIndexDocument.json.gz',\n 'sharedResource.json.gz'\n];\n\n/**\n * Description of the file in the SLPK\n */\ntype File = {\n name: string | null;\n data: ArrayBuffer;\n};\n\n/**\n * Converter from slpk to i3s\n */\nexport default class SLPKConverter {\n /**\n * Extract slpk to i3s\n * @param options\n * @param options.inputUrl the url to read SLPK file\n * @param options.outputPath the output filename\n */\n public async extract(options: {inputUrl: string; outputPath: string}): Promise<string> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl} = options;\n\n const provider = await FileHandleProvider.from(inputUrl);\n\n let localHeader = await parseZipLocalFileHeader(0n, provider);\n while (localHeader) {\n await this.writeFile(\n await this.unGzip({\n name: this.correctIndexNames(localHeader.fileName),\n data: await provider.slice(\n localHeader.fileDataOffset,\n localHeader.fileDataOffset + localHeader.compressedSize\n )\n }),\n options.outputPath\n );\n localHeader = await parseZipLocalFileHeader(\n localHeader?.fileDataOffset + localHeader?.compressedSize,\n provider\n );\n }\n\n return 'success';\n }\n\n /**\n * Defines file name and path for i3s format\n * @param fileName initial file name and path\n */\n\n private correctIndexNames(fileName: string): string | null {\n if (indexNames.includes(path.filename(path.join('/', fileName)))) {\n return path.join(path.dirname(fileName), 'index.json.gz');\n }\n // finds path with name part and extention part\n let parts = /^(.*\\/[^\\/\\.]*)(\\..+)$/.exec(fileName);\n if (!parts) {\n return null;\n }\n return `${parts?.at(1)}/index${parts?.at(2)}`;\n }\n\n private async unGzip(file: File): Promise<File> {\n if (/\\.gz$/.test(file.name ?? '')) {\n const compression = new GZipCompression();\n\n const decompressedData = await compression.decompress(file.data);\n\n return {data: decompressedData, name: (file.name ?? '').slice(0, -3)};\n }\n return Promise.resolve(file);\n }\n\n private async writeFile(options: File, outputPath: string): Promise<void> {\n if (!options.name) {\n return;\n }\n const finalPath = path.join(outputPath, options.name);\n const dirName = path.dirname(finalPath);\n const fileName = path.filename(finalPath);\n await writeFile(dirName, options.data, fileName);\n }\n}\n"],"mappings":"AAAA,SAAQA,SAAS,QAAO,kBAAkB;AAE1C,SAAQC,qBAAqB,QAAO,cAAc;AAClD,SAAQC,kBAAkB,QAAO,gCAAgC;AACjE,SAAQC,uBAAuB,QAAO,iBAAiB;AACvD,SAAQC,IAAI,QAAO,0BAA0B;AAC7C,SAAQC,eAAe,QAAO,yBAAyB;AACvD,SAAQC,SAAS,QAAO,yBAAyB;AAEjD,MAAMC,UAAU,GAAG,CACjB,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,CACzB;AAaD,eAAe,MAAMC,aAAa,CAAC;EAOjC,MAAaC,OAAOA,CAACC,OAA+C,EAAmB;IACrF,IAAIV,SAAS,EAAE;MACbW,OAAO,CAACC,GAAG,CAACX,qBAAqB,CAAC;MAClC,OAAOA,qBAAqB;IAC9B;IACA,MAAM;MAACY;IAAQ,CA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W,aAAa;IAc3B;;;OAGG;YACW,WAAW;IAsCzB;;;;;;OAMG;YACW,WAAW;IAiCzB;;;;OAIG;YACW,YAAY;IAc1B;;;;;;;OAOG;YACW,WAAW;IAsGzB;;;;;;;;;;OAUG;YACW,iBAAiB;IAiC/B;;;;;;;;;;;;;;OAcG;YACW,sBAAsB;IA+DpC;;;;;;;;;OASG;YACW,eAAe;IAiB7B;;;;;;OAMG;YACW,gBAAgB;IAoC9B;;;;;;OAMG;YACW,YAAY;IAwB1B;;;;;OAKG;YACW,aAAa;IA+D3B;;;;;;;OAOG;YACW,gBAAgB;IAwB9B;;;;;OAKG;YACW,gBAAgB;IA0B9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;OAGG;IACH,OAAO,CAAC,qCAAqC;IAyB7C;;;OAGG;YACW,iBAAiB;IAqB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;YAIZ,WAAW;CAkB1B"}
|
|
@@ -169,10 +169,14 @@ class I3SConverter {
|
|
|
169
169
|
await this.loadWorkers();
|
|
170
170
|
try {
|
|
171
171
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
172
|
+
let tilesetUrl = inputUrl;
|
|
173
|
+
if (preloadOptions.url) {
|
|
174
|
+
tilesetUrl = preloadOptions.url;
|
|
175
|
+
}
|
|
172
176
|
if (preloadOptions.headers) {
|
|
173
177
|
this.loadOptions.fetch = { headers: preloadOptions.headers };
|
|
174
178
|
}
|
|
175
|
-
this.sourceTileset = await (0, core_1.load)(
|
|
179
|
+
this.sourceTileset = await (0, core_1.load)(tilesetUrl, this.Loader, this.loadOptions);
|
|
176
180
|
const preprocessResult = await this.preprocessConversion();
|
|
177
181
|
if (preprocessResult) {
|
|
178
182
|
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.js"],"names":[],"mappings":";AAQA,uBAAsB"}
|
package/dist/i3s-server/app.js
CHANGED
|
@@ -4,7 +4,6 @@ const path = require('path');
|
|
|
4
4
|
const logger = require('morgan');
|
|
5
5
|
const cors = require('cors');
|
|
6
6
|
const indexRouter = require('./routes/index');
|
|
7
|
-
const { sceneServerRouter, router } = require('./routes/slpk-router');
|
|
8
7
|
const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
|
|
9
8
|
const app = express();
|
|
10
9
|
app.use(logger('dev'));
|
|
@@ -13,6 +12,7 @@ app.use(express.urlencoded({ extended: false }));
|
|
|
13
12
|
app.use(express.static(path.join(__dirname, 'public')));
|
|
14
13
|
app.use(cors());
|
|
15
14
|
if (/\.slpk$/.test(I3S_LAYER_PATH)) {
|
|
15
|
+
const { sceneServerRouter, router } = require('./routes/slpk-router');
|
|
16
16
|
app.use('/SceneServer/layers/0', router);
|
|
17
17
|
app.use('/SceneServer', sceneServerRouter);
|
|
18
18
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"www.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/bin/www.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Module dependencies.
|
|
5
|
+
*/
|
|
6
|
+
const app = require('../app');
|
|
7
|
+
const debug = require('debug')('i3s-server:server');
|
|
8
|
+
const https = require('https');
|
|
9
|
+
const http = require('http');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
/**
|
|
13
|
+
* Get port from environment and store in Express.
|
|
14
|
+
*/
|
|
15
|
+
const httpPort = normalizePort(process.env.PORT || '80'); // eslint-disable-line no-process-env, no-undef
|
|
16
|
+
const httpsPort = normalizePort(process.env.HTTPS_PORT || '443'); // eslint-disable-line no-process-env, no-undef
|
|
17
|
+
/**
|
|
18
|
+
* Create HTTP server.
|
|
19
|
+
*/
|
|
20
|
+
const options = {
|
|
21
|
+
key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),
|
|
22
|
+
cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))
|
|
23
|
+
};
|
|
24
|
+
const httpServer = http.createServer(app);
|
|
25
|
+
const httpsServer = https.createServer(options, app);
|
|
26
|
+
/**
|
|
27
|
+
* Listen on provided port, on all network interfaces.
|
|
28
|
+
*/
|
|
29
|
+
httpServer.listen(httpPort);
|
|
30
|
+
httpServer.on('error', formErrorHandler(httpPort));
|
|
31
|
+
httpServer.on('listening', formListeningHandler(httpServer));
|
|
32
|
+
httpsServer.listen(httpsPort);
|
|
33
|
+
httpsServer.on('error', formErrorHandler(httpsPort));
|
|
34
|
+
httpsServer.on('listening', formListeningHandler(httpsServer));
|
|
35
|
+
/**
|
|
36
|
+
* Normalize a port into a number, string, or false.
|
|
37
|
+
*/
|
|
38
|
+
function normalizePort(val) {
|
|
39
|
+
const chkPort = parseInt(val, 10);
|
|
40
|
+
if (isNaN(chkPort)) {
|
|
41
|
+
// named pipe
|
|
42
|
+
return val;
|
|
43
|
+
}
|
|
44
|
+
if (chkPort >= 0) {
|
|
45
|
+
// port number
|
|
46
|
+
return chkPort;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Event listener for HTTP/HTTPS server "error" event.
|
|
52
|
+
*/
|
|
53
|
+
function formErrorHandler(optionalPort) {
|
|
54
|
+
return function onError(error) {
|
|
55
|
+
if (error.syscall !== 'listen') {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
const bind = typeof global.port === 'string' ? `Pipe ${optionalPort}` : `Port ${optionalPort}`;
|
|
59
|
+
// handle specific listen errors with friendly messages
|
|
60
|
+
switch (error.code) {
|
|
61
|
+
case 'EACCES':
|
|
62
|
+
console.error(`${bind} requires elevated privileges`); // eslint-disable-line no-console, no-undef
|
|
63
|
+
process.exit(1); // eslint-disable-line no-process-exit, no-undef
|
|
64
|
+
break;
|
|
65
|
+
case 'EADDRINUSE':
|
|
66
|
+
console.error(`${bind} is already in use`); // eslint-disable-line no-console, no-undef
|
|
67
|
+
process.exit(1); // eslint-disable-line no-process-exit, no-undef
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Event listener for HTTP/HTTPS server "listening" event.
|
|
76
|
+
*/
|
|
77
|
+
function formListeningHandler(optionalServer) {
|
|
78
|
+
return function onListening() {
|
|
79
|
+
const addr = optionalServer.address();
|
|
80
|
+
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`;
|
|
81
|
+
debug(`Listening on ${bind}`);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slpk-controller.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/controllers/slpk-controller.js"],"names":[],"mappings":"AAOA,+DAEC;AAOD,
|
|
1
|
+
{"version":3,"file":"slpk-controller.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/controllers/slpk-controller.js"],"names":[],"mappings":"AAOA,+DAEC;AAOD,oEASC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
require('@loaders.gl/polyfills');
|
|
3
|
-
const {
|
|
4
|
-
const { SLPKLoader } = require('@loaders.gl/i3s');
|
|
3
|
+
const { parseSLPK } = require('@loaders.gl/i3s');
|
|
5
4
|
const path = require('path');
|
|
5
|
+
const { FileHandleProvider } = require('@loaders.gl/tile-converter');
|
|
6
6
|
let slpkArchive;
|
|
7
7
|
const loadArchive = async (fullLayerPath) => {
|
|
8
|
-
slpkArchive = await (await
|
|
8
|
+
slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath));
|
|
9
9
|
};
|
|
10
10
|
const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
|
|
11
11
|
const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef
|
|
@@ -15,12 +15,7 @@ async function getFileByUrl(url) {
|
|
|
15
15
|
let uncompressedFile;
|
|
16
16
|
if (trimmedPath) {
|
|
17
17
|
try {
|
|
18
|
-
uncompressedFile = Buffer.from(await
|
|
19
|
-
slpk: {
|
|
20
|
-
path: trimmedPath[1],
|
|
21
|
-
pathMode: 'http'
|
|
22
|
-
}
|
|
23
|
-
}));
|
|
18
|
+
uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));
|
|
24
19
|
}
|
|
25
20
|
catch (e) { }
|
|
26
21
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as I3SConverter } from './i3s-converter/i3s-converter';
|
|
2
2
|
export { default as Tiles3DConverter } from './3d-tiles-converter/3d-tiles-converter';
|
|
3
|
+
export { FileHandleProvider } from './slpk-extractor/helpers/file-handle-provider';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,yCAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAC,kBAAkB,EAAC,MAAM,+CAA+C,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Tiles3DConverter = exports.I3SConverter = void 0;
|
|
6
|
+
exports.FileHandleProvider = exports.Tiles3DConverter = exports.I3SConverter = void 0;
|
|
7
7
|
var i3s_converter_1 = require("./i3s-converter/i3s-converter");
|
|
8
8
|
Object.defineProperty(exports, "I3SConverter", { enumerable: true, get: function () { return __importDefault(i3s_converter_1).default; } });
|
|
9
9
|
var _3d_tiles_converter_1 = require("./3d-tiles-converter/3d-tiles-converter");
|
|
10
10
|
Object.defineProperty(exports, "Tiles3DConverter", { enumerable: true, get: function () { return __importDefault(_3d_tiles_converter_1).default; } });
|
|
11
|
+
var file_handle_provider_1 = require("./slpk-extractor/helpers/file-handle-provider");
|
|
12
|
+
Object.defineProperty(exports, "FileHandleProvider", { enumerable: true, get: function () { return file_handle_provider_1.FileHandleProvider; } });
|