@loaders.gl/tile-converter 4.0.0-alpha.14 → 4.0.0-alpha.16
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 +59 -59
- package/dist/dist.min.js +262 -162
- 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 +23 -15
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/bin/www.js +33 -0
- package/dist/es5/i3s-server/bin/www.js.map +1 -0
- package/dist/es5/i3s-server/controllers/index-controller.js +23 -22
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/controllers/slpk-controller.js +35 -38
- package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +2 -2
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/i3s-server/routes/slpk-router.js +14 -13
- package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -1
- package/dist/es5/i3s-server/utils/create-scene-server.js +7 -4
- package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -1
- package/dist/es5/i3s-server/utils/server-utils.js +49 -0
- package/dist/es5/i3s-server/utils/server-utils.js.map +1 -0
- 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 +9 -9
- 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 +13 -11
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +516 -0
- package/dist/esm/i3s-server/bin/www.js +30 -0
- package/dist/esm/i3s-server/bin/www.js.map +1 -0
- package/dist/esm/i3s-server/controllers/index-controller.js +4 -7
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/esm/i3s-server/controllers/slpk-controller.js +9 -26
- package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/esm/i3s-server/routes/index.js +1 -1
- package/dist/esm/i3s-server/routes/index.js.map +1 -1
- package/dist/esm/i3s-server/routes/slpk-router.js +5 -11
- package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -1
- package/dist/esm/i3s-server/utils/create-scene-server.js +2 -5
- package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -1
- package/dist/esm/i3s-server/utils/server-utils.js +40 -0
- package/dist/esm/i3s-server/utils/server-utils.js.map +1 -0
- 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 +4 -4
- 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 +1 -2
- package/dist/i3s-server/app.d.ts.map +1 -1
- package/dist/i3s-server/app.js +23 -16
- 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 +37 -0
- package/dist/i3s-server/controllers/index-controller.d.ts +6 -1
- package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -1
- package/dist/i3s-server/controllers/index-controller.js +16 -8
- package/dist/i3s-server/controllers/slpk-controller.d.ts +13 -2
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
- package/dist/i3s-server/controllers/slpk-controller.js +20 -19
- package/dist/i3s-server/routes/index.d.ts +1 -2
- package/dist/i3s-server/routes/index.d.ts.map +1 -1
- package/dist/i3s-server/routes/index.js +6 -2
- package/dist/i3s-server/routes/slpk-router.d.ts +2 -2
- package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
- package/dist/i3s-server/routes/slpk-router.js +15 -14
- package/dist/i3s-server/utils/create-scene-server.d.ts +11 -5
- package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -1
- package/dist/i3s-server/utils/create-scene-server.js +11 -3
- package/dist/i3s-server/utils/server-utils.d.ts +24 -0
- package/dist/i3s-server/utils/server-utils.d.ts.map +1 -0
- package/dist/i3s-server/utils/server-utils.js +66 -0
- 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 +5 -8
- package/dist/slpk-extractor.min.js +44 -44
- package/package.json +25 -20
- package/src/i3s-converter/i3s-converter.ts +5 -1
- package/src/i3s-server/README.md +46 -2
- package/src/i3s-server/{app.js → app.ts} +11 -9
- package/src/i3s-server/bin/www.ts +38 -0
- package/src/i3s-server/controllers/{index-controller.js → index-controller.ts} +10 -9
- package/src/i3s-server/controllers/slpk-controller.ts +32 -0
- package/src/i3s-server/routes/{index.js → index.ts} +2 -1
- package/src/i3s-server/routes/{slpk-router.js → slpk-router.ts} +5 -10
- package/src/i3s-server/utils/create-scene-server.ts +20 -0
- package/src/i3s-server/utils/server-utils.ts +70 -0
- 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 +6 -7
- package/dist/es5/i3s-server/bin/www +0 -102
- package/dist/esm/i3s-server/bin/www +0 -102
- package/src/i3s-server/bin/www +0 -102
- package/src/i3s-server/controllers/slpk-controller.js +0 -38
- package/src/i3s-server/utils/create-scene-server.js +0 -15
|
@@ -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));\nhttpsServer.on('listening', formListeningHandler(httpsServer));\n"],"mappings":"AAAA;AAEA,SAAQA,GAAG,QAAO,QAAQ;AAC1B,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAAQC,gBAAgB,EAAEC,oBAAoB,EAAEC,aAAa,QAAO,uBAAuB;AAG3F,MAAMC,QAAQ,GAAGD,aAAa,CAACE,OAAO,CAACC,GAAG,CAACC,IAAI,IAAI,IAAI,CAAC;AACxD,IAAIH,QAAQ,KAAK,KAAK,EAAE;EACtBI,OAAO,CAACC,KAAK,sBAAsB,CAAC;EACpCJ,OAAO,CAACK,IAAI,CAAC,CAAC,CAAC;AACjB;AACA,MAAMC,SAAS,GAAGR,aAAa,CAACE,OAAO,CAACC,GAAG,CAACM,UAAU,IAAI,KAAK,CAAC;AAChE,IAAID,SAAS,KAAK,KAAK,EAAE;EACvBH,OAAO,CAACC,KAAK,uBAAuB,CAAC;EACrCJ,OAAO,CAACK,IAAI,CAAC,CAAC,CAAC;AACjB;AAGA,MAAMG,OAAO,GAAG;EACdC,GAAG,EAAEf,EAAE,CAACgB,YAAY,CAACf,IAAI,CAACgB,IAAI,CAACC,SAAS,EAAE,kBAAkB,CAAC,CAAC;EAC9DC,IAAI,EAAEnB,EAAE,CAACgB,YAAY,CAACf,IAAI,CAACgB,IAAI,CAACC,SAAS,EAAE,mBAAmB,CAAC;AACjE,CAAC;AAED,MAAME,UAAU,GAAGrB,IAAI,CAACsB,YAAY,CAACxB,GAAG,CAAC;AACzC,MAAMyB,WAAW,GAAGxB,KAAK,CAACuB,YAAY,CAACP,OAAO,EAAEjB,GAAG,CAAC;AAGpDuB,UAAU,CAACG,MAAM,CAAClB,QAAQ,CAAC;AAC3Be,UAAU,CAACI,EAAE,CAAC,OAAO,EAAEtB,gBAAgB,CAACG,QAAQ,CAAC,CAAC;AAClDe,UAAU,CAACI,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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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","
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 { FileHandleProvider } from '@loaders.gl/tile-converter';
|
|
10
4
|
let slpkArchive;
|
|
11
|
-
const loadArchive = async fullLayerPath => {
|
|
12
|
-
slpkArchive = await (await
|
|
5
|
+
export const loadArchive = async fullLayerPath => {
|
|
6
|
+
slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath), msg => console.log(msg));
|
|
7
|
+
console.log('The server is ready to use');
|
|
13
8
|
};
|
|
14
|
-
|
|
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
|
|
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":["
|
|
1
|
+
{"version":3,"file":"slpk-controller.js","names":["parseSLPK","FileHandleProvider","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 {FileHandleProvider} from '@loaders.gl/tile-converter';\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 FileHandleProvider.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,kBAAkB,QAAO,4BAA4B;AAE7D,IAAIC,WAAW;AAMf,OAAO,MAAMC,WAAW,GAAG,MAAOC,aAAqB,IAAoB;EACzEF,WAAW,GAAG,MAAMF,SAAS,CAAC,MAAMC,kBAAkB,CAACI,IAAI,CAACD,aAAa,CAAC,EAAGE,GAAG,IAC9EC,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["express","
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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","
|
|
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
|
-
|
|
2
|
-
|
|
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","
|
|
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,SAASE,aAAaA,CAACC,GAAW,EAA2B;EAClE,MAAMC,OAAO,GAAGC,QAAQ,CAACF,GAAG,EAAE,EAAE,CAAC;EAEjC,IAAIG,MAAM,CAACC,KAAK,CAACH,OAAO,CAAC,EAAE;IAEzB,OAAOD,GAAG;EACZ;EAEA,IAAIC,OAAO,IAAI,CAAC,EAAE;IAEhB,OAAOA,OAAO;EAChB;EAEA,OAAO,KAAK;AACd;AAOA,OAAO,SAASI,gBAAgBA,CAC9BC,YAA6B,EACW;EACxC,OAAO,SAASC,OAAOA,CAACC,KAA4B,EAAE;IACpD,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;MAC9B,MAAMD,KAAK;IACb;IAEA,MAAME,IAAI,GAAG,OAAOJ,YAAY,KAAK,QAAQ,WAAAK,MAAA,CAAWL,YAAY,YAAAK,MAAA,CAAaL,YAAY,CAAE;IAG/F,QAAQE,KAAK,CAACI,IAAI;MAChB,KAAK,QAAQ;QACXC,OAAO,CAACL,KAAK,IAAAG,MAAA,CAAID,IAAI,kCAA+B,CAAC;QACrDI,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;QACf;MACF,KAAK,YAAY;QACfF,OAAO,CAACL,KAAK,IAAAG,MAAA,CAAID,IAAI,uBAAoB,CAAC;QAC1CI,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;QACf;MACF;QACE,MAAMP,KAAK;IACf;EACF,CAAC;AACH;AAOA,OAAO,SAASQ,oBAAoBA,CAACC,cAAwC,EAAc;EACzF,OAAO,SAASC,WAAWA,CAAA,EAAG;IAC5B,MAAMC,IAAI,GAAGF,cAAc,CAACG,OAAO,CAAC,CAAC;IACrC,MAAMV,IAAI,GAAG,OAAOS,IAAI,KAAK,QAAQ,WAAAR,MAAA,CAAWQ,IAAI,YAAAR,MAAA,CAAaQ,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEE,IAAI,CAAE;IAC7EvB,KAAK,iBAAAa,MAAA,CAAiBD,IAAI,CAAE,CAAC;EAC/B,CAAC;AACH"}
|
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.16" !== 'undefined' ? "4.0.0-alpha.16" : '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, 8, 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, 8, 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,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AIN,GAAG,KAAKO,SAAS,EAAE;MACrB,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;IACzC;IACA,OAAOR,GAAG;EACZ;EAMA,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,14 +16,14 @@ 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
|
-
var _localHeader
|
|
21
|
+
var _localHeader;
|
|
22
22
|
await this.writeFile(await this.unGzip({
|
|
23
23
|
name: this.correctIndexNames(localHeader.fileName),
|
|
24
24
|
data: await provider.slice(localHeader.fileDataOffset, localHeader.fileDataOffset + localHeader.compressedSize)
|
|
25
25
|
}), options.outputPath);
|
|
26
|
-
localHeader = await parseZipLocalFileHeader(
|
|
26
|
+
localHeader = await parseZipLocalFileHeader(localHeader.fileDataOffset + ((_localHeader = localHeader) === null || _localHeader === void 0 ? void 0 : _localHeader.compressedSize), provider);
|
|
27
27
|
}
|
|
28
28
|
return 'success';
|
|
29
29
|
}
|
|
@@ -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","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,k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Options = 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);
|
package/dist/i3s-server/app.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,GAAG,6CAAY,CAAC"}
|
package/dist/i3s-server/app.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.app = void 0;
|
|
7
|
+
const express_1 = __importDefault(require("express"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const morgan_1 = __importDefault(require("morgan"));
|
|
10
|
+
const cors_1 = __importDefault(require("cors"));
|
|
11
|
+
const slpk_controller_1 = require("./controllers/slpk-controller");
|
|
8
12
|
const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
app
|
|
13
|
-
app.use(
|
|
14
|
-
app.use(
|
|
13
|
+
const FULL_LAYER_PATH = path_1.default.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef
|
|
14
|
+
(0, slpk_controller_1.loadArchive)(FULL_LAYER_PATH);
|
|
15
|
+
const indexRouter = require('./routes/index');
|
|
16
|
+
exports.app = (0, express_1.default)();
|
|
17
|
+
exports.app.use((0, morgan_1.default)('dev'));
|
|
18
|
+
exports.app.use(express_1.default.json());
|
|
19
|
+
exports.app.use(express_1.default.urlencoded({ extended: false }));
|
|
20
|
+
exports.app.use(express_1.default.static(path_1.default.join(__dirname, 'public')));
|
|
21
|
+
exports.app.use((0, cors_1.default)());
|
|
15
22
|
if (/\.slpk$/.test(I3S_LAYER_PATH)) {
|
|
16
|
-
|
|
17
|
-
app.use('/SceneServer',
|
|
23
|
+
const { sceneServerRouter, router } = require('./routes/slpk-router');
|
|
24
|
+
exports.app.use('/SceneServer/layers/0', router);
|
|
25
|
+
exports.app.use('/SceneServer', sceneServerRouter);
|
|
18
26
|
}
|
|
19
27
|
else {
|
|
20
|
-
app.use('/', indexRouter);
|
|
28
|
+
exports.app.use('/', indexRouter);
|
|
21
29
|
}
|
|
22
|
-
module.exports = app;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"www.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/bin/www.ts"],"names":[],"mappings":""}
|