@loaders.gl/tile-converter 4.0.0-alpha.15 → 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/dist/converter.min.js +64 -64
- package/dist/dist.min.js +22 -36
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-server/app.js +20 -12
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/bin/www.js +25 -53
- package/dist/es5/i3s-server/bin/www.js.map +1 -1
- 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 +31 -30
- 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/pgm-loader.js +1 -1
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +1 -1
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +1 -1
- package/dist/es5/slpk-extractor/slpk-extractor.js +2 -2
- 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-server/app.js +9 -7
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +124 -222
- package/dist/esm/i3s-server/bin/www.js +14 -43
- package/dist/esm/i3s-server/bin/www.js.map +1 -1
- 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 +8 -19
- 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/pgm-loader.js +1 -1
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +1 -1
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +1 -1
- package/dist/esm/slpk-extractor/slpk-extractor.js +2 -2
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -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 +22 -15
- package/dist/i3s-server/bin/www.d.ts.map +1 -1
- package/dist/i3s-server/bin/www.js +31 -77
- 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 +19 -13
- 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/slpk-extractor/helpers/file-handle-provider.js +1 -1
- package/dist/slpk-extractor/slpk-extractor.js +1 -1
- package/dist/slpk-extractor.min.js +1 -1
- package/package.json +19 -15
- package/src/i3s-server/{app.js → app.ts} +10 -8
- 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/slpk-extractor/helpers/file-handle-provider.ts +1 -1
- package/src/slpk-extractor/slpk-extractor.ts +1 -1
- package/src/i3s-server/bin/www.js +0 -102
- package/src/i3s-server/controllers/slpk-controller.js +0 -31
- package/src/i3s-server/utils/create-scene-server.js +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.16",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -42,21 +42,21 @@
|
|
|
42
42
|
"build-bundle": "esbuild ./src/index.ts --bundle --outfile=dist/dist.min.js --platform=node --external:join-images",
|
|
43
43
|
"build-converter-bundle": "esbuild src/converter-cli.ts --outfile=dist/converter.min.js --platform=node --target=esnext,node14 --external:join-images --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
44
44
|
"build-slpk-extractor-bundle": "esbuild src/slpk-extractor-cli.ts --outfile=dist/slpk-extractor.min.js --platform=node --target=esnext,node14 --external:join-images --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
45
|
-
"build-i3s-server-bundle": "esbuild src/i3s-server/bin/www.
|
|
45
|
+
"build-i3s-server-bundle": "esbuild src/i3s-server/bin/www.ts --outfile=dist/esm/i3s-server/bin/i3s-server.min.js --platform=node --target=esnext,node14 --external:join-images --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@loaders.gl/3d-tiles": "4.0.0-alpha.
|
|
49
|
-
"@loaders.gl/crypto": "4.0.0-alpha.
|
|
50
|
-
"@loaders.gl/draco": "4.0.0-alpha.
|
|
51
|
-
"@loaders.gl/gltf": "4.0.0-alpha.
|
|
52
|
-
"@loaders.gl/i3s": "4.0.0-alpha.
|
|
53
|
-
"@loaders.gl/images": "4.0.0-alpha.
|
|
54
|
-
"@loaders.gl/loader-utils": "4.0.0-alpha.
|
|
55
|
-
"@loaders.gl/polyfills": "4.0.0-alpha.
|
|
56
|
-
"@loaders.gl/textures": "4.0.0-alpha.
|
|
57
|
-
"@loaders.gl/tiles": "4.0.0-alpha.
|
|
58
|
-
"@loaders.gl/worker-utils": "4.0.0-alpha.
|
|
59
|
-
"@loaders.gl/zip": "4.0.0-alpha.
|
|
48
|
+
"@loaders.gl/3d-tiles": "4.0.0-alpha.16",
|
|
49
|
+
"@loaders.gl/crypto": "4.0.0-alpha.16",
|
|
50
|
+
"@loaders.gl/draco": "4.0.0-alpha.16",
|
|
51
|
+
"@loaders.gl/gltf": "4.0.0-alpha.16",
|
|
52
|
+
"@loaders.gl/i3s": "4.0.0-alpha.16",
|
|
53
|
+
"@loaders.gl/images": "4.0.0-alpha.16",
|
|
54
|
+
"@loaders.gl/loader-utils": "4.0.0-alpha.16",
|
|
55
|
+
"@loaders.gl/polyfills": "4.0.0-alpha.16",
|
|
56
|
+
"@loaders.gl/textures": "4.0.0-alpha.16",
|
|
57
|
+
"@loaders.gl/tiles": "4.0.0-alpha.16",
|
|
58
|
+
"@loaders.gl/worker-utils": "4.0.0-alpha.16",
|
|
59
|
+
"@loaders.gl/zip": "4.0.0-alpha.16",
|
|
60
60
|
"@math.gl/core": "^3.5.1",
|
|
61
61
|
"@math.gl/culling": "^3.5.1",
|
|
62
62
|
"@math.gl/geoid": "^3.5.1",
|
|
@@ -79,5 +79,9 @@
|
|
|
79
79
|
"join-images": "^1.1.3",
|
|
80
80
|
"sharp": "^0.31.3"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "87e9714165c3ce143a04ac45bbd9d922006f1b63",
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@types/express": "^4.17.17",
|
|
85
|
+
"@types/node": "^20.4.2"
|
|
86
|
+
}
|
|
83
87
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import logger from 'morgan';
|
|
4
|
+
import cors from 'cors';
|
|
5
|
+
import {loadArchive} from './controllers/slpk-controller';
|
|
6
|
+
|
|
7
|
+
const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
|
|
8
|
+
const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef
|
|
9
|
+
loadArchive(FULL_LAYER_PATH);
|
|
5
10
|
|
|
6
11
|
const indexRouter = require('./routes/index');
|
|
7
12
|
|
|
8
|
-
const
|
|
9
|
-
const app = express();
|
|
13
|
+
export const app = express();
|
|
10
14
|
|
|
11
15
|
app.use(logger('dev'));
|
|
12
16
|
app.use(express.json());
|
|
@@ -21,5 +25,3 @@ if (/\.slpk$/.test(I3S_LAYER_PATH)) {
|
|
|
21
25
|
} else {
|
|
22
26
|
app.use('/', indexRouter);
|
|
23
27
|
}
|
|
24
|
-
|
|
25
|
-
module.exports = app;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {app} from '../app';
|
|
4
|
+
import https from 'https';
|
|
5
|
+
import http from 'http';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import {formErrorHandler, formListeningHandler, normalizePort} from '../utils/server-utils';
|
|
9
|
+
|
|
10
|
+
/** Get port from environment and store in Express. */
|
|
11
|
+
const httpPort = normalizePort(process.env.PORT || '80');
|
|
12
|
+
if (httpPort === false) {
|
|
13
|
+
console.error(`Incorrect HTTP port`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
const httpsPort = normalizePort(process.env.HTTPS_PORT || '443');
|
|
17
|
+
if (httpsPort === false) {
|
|
18
|
+
console.error(`Incorrect HTTPs port`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Create HTTP server. */
|
|
23
|
+
const options = {
|
|
24
|
+
key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),
|
|
25
|
+
cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const httpServer = http.createServer(app);
|
|
29
|
+
const httpsServer = https.createServer(options, app);
|
|
30
|
+
|
|
31
|
+
/** Listen on provided port, on all network interfaces. */
|
|
32
|
+
httpServer.listen(httpPort);
|
|
33
|
+
httpServer.on('error', formErrorHandler(httpPort));
|
|
34
|
+
httpServer.on('listening', formListeningHandler(httpServer));
|
|
35
|
+
|
|
36
|
+
httpsServer.listen(httpsPort);
|
|
37
|
+
httpsServer.on('error', formErrorHandler(httpsPort));
|
|
38
|
+
httpsServer.on('listening', formListeningHandler(httpsServer));
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
3
|
|
|
4
4
|
const {promises} = fs;
|
|
5
5
|
|
|
6
|
-
const I3S_LAYER_PATH = process.env.I3sLayerPath || '';
|
|
7
|
-
const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef
|
|
6
|
+
const I3S_LAYER_PATH = process.env.I3sLayerPath || '';
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Get local file name by input HTTP URL
|
|
10
|
+
* @param url - I3S HTTP service url
|
|
11
|
+
* @returns - local file name
|
|
12
|
+
*/
|
|
13
|
+
export async function getFileNameByUrl(url: string): Promise<string | null> {
|
|
10
14
|
const extensions = ['json', 'bin', 'jpg', 'jpeg', 'png', 'bin.dds', 'ktx2'];
|
|
15
|
+
const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);
|
|
11
16
|
for (const ext of extensions) {
|
|
12
17
|
const fileName = `${FULL_LAYER_PATH}${url}/index.${ext}`;
|
|
13
18
|
try {
|
|
@@ -19,7 +24,3 @@ async function getFileNameByUrl(url) {
|
|
|
19
24
|
}
|
|
20
25
|
return null;
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
getFileNameByUrl
|
|
25
|
-
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import '@loaders.gl/polyfills';
|
|
2
|
+
import {parseSLPK} from '@loaders.gl/i3s';
|
|
3
|
+
import {FileHandleProvider} from '@loaders.gl/tile-converter';
|
|
4
|
+
|
|
5
|
+
let slpkArchive;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Open SLPK file for reading and load HASH file
|
|
9
|
+
* @param fullLayerPath - full path to SLPK file
|
|
10
|
+
*/
|
|
11
|
+
export const loadArchive = async (fullLayerPath: string): Promise<void> => {
|
|
12
|
+
slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath), (msg) =>
|
|
13
|
+
console.log(msg)
|
|
14
|
+
);
|
|
15
|
+
console.log('The server is ready to use');
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get a file from SLPK
|
|
20
|
+
* @param url - I3S HTTP URL
|
|
21
|
+
* @returns - file content
|
|
22
|
+
*/
|
|
23
|
+
export async function getFileByUrl(url: string) {
|
|
24
|
+
const trimmedPath = /^\/?(.*)\/?$/.exec(url);
|
|
25
|
+
let uncompressedFile: Buffer | null = null;
|
|
26
|
+
if (trimmedPath) {
|
|
27
|
+
try {
|
|
28
|
+
uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));
|
|
29
|
+
} catch (e) {}
|
|
30
|
+
}
|
|
31
|
+
return uncompressedFile;
|
|
32
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import {getFileByUrl} from '../controllers/slpk-controller';
|
|
3
|
+
import {createSceneServer} from '../utils/create-scene-server';
|
|
4
4
|
|
|
5
|
-
const sceneServerRouter = express.Router();
|
|
5
|
+
export const sceneServerRouter = express.Router();
|
|
6
6
|
sceneServerRouter.get('*', async function (req, res, next) {
|
|
7
7
|
const file = await getFileByUrl('/');
|
|
8
8
|
if (file) {
|
|
@@ -15,7 +15,7 @@ sceneServerRouter.get('*', async function (req, res, next) {
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
const router = express.Router();
|
|
18
|
+
export const router = express.Router();
|
|
19
19
|
router.get('*', async function (req, res, next) {
|
|
20
20
|
console.log(req.path);
|
|
21
21
|
const file = await getFileByUrl(req.path);
|
|
@@ -26,8 +26,3 @@ router.get('*', async function (req, res, next) {
|
|
|
26
26
|
res.send('File not found');
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
|
|
30
|
-
module.exports = {
|
|
31
|
-
sceneServerRouter,
|
|
32
|
-
router
|
|
33
|
-
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {SceneLayer3D} from '@loaders.gl/i3s';
|
|
2
|
+
import {v4 as uuidv4} from 'uuid';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create `/SceneServer` response
|
|
6
|
+
* @param name - service name, custom user-friendly name of the service
|
|
7
|
+
* @param layer - I3S layer JSON
|
|
8
|
+
* @returns reponse JSON for `/SceneServer` route
|
|
9
|
+
*/
|
|
10
|
+
export const createSceneServer = (name: string, layer: SceneLayer3D) => {
|
|
11
|
+
return {
|
|
12
|
+
serviceItemId: uuidv4().replace(/-/gi, ''),
|
|
13
|
+
serviceName: name,
|
|
14
|
+
name,
|
|
15
|
+
currentVersion: '10.7',
|
|
16
|
+
serviceVersion: '1.8',
|
|
17
|
+
supportedBindings: ['REST'],
|
|
18
|
+
layers: [layer]
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type {Server as HttpsServer} from 'https';
|
|
2
|
+
import type {Server as HttpServer} from 'http';
|
|
3
|
+
|
|
4
|
+
import debugFactory from 'debug';
|
|
5
|
+
const debug = debugFactory('i3s-server:server');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Normalize a port into a number, string, or false.
|
|
9
|
+
* @param val - port value from env variables
|
|
10
|
+
* @returns - `number` for port, `string` for a named pipe, or `false` if the port number is not correct
|
|
11
|
+
*/
|
|
12
|
+
export function normalizePort(val: string): number | string | false {
|
|
13
|
+
const chkPort = parseInt(val, 10);
|
|
14
|
+
|
|
15
|
+
if (Number.isNaN(chkPort)) {
|
|
16
|
+
// named pipe
|
|
17
|
+
return val;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (chkPort >= 0) {
|
|
21
|
+
// port number
|
|
22
|
+
return chkPort;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Event listener creator for HTTP/HTTPS server "error" event.
|
|
30
|
+
* @param optionalPort - the port/named pipe the server is started on
|
|
31
|
+
* @return callback to handle server errors
|
|
32
|
+
*/
|
|
33
|
+
export function formErrorHandler(
|
|
34
|
+
optionalPort: string | number
|
|
35
|
+
): (error: NodeJS.ErrnoException) => void {
|
|
36
|
+
return function onError(error: NodeJS.ErrnoException) {
|
|
37
|
+
if (error.syscall !== 'listen') {
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const bind = typeof optionalPort === 'string' ? `Pipe ${optionalPort}` : `Port ${optionalPort}`;
|
|
42
|
+
|
|
43
|
+
// handle specific listen errors with friendly messages
|
|
44
|
+
switch (error.code) {
|
|
45
|
+
case 'EACCES':
|
|
46
|
+
console.error(`${bind} requires elevated privileges`); // eslint-disable-line no-console, no-undef
|
|
47
|
+
process.exit(1); // eslint-disable-line no-process-exit, no-undef
|
|
48
|
+
break;
|
|
49
|
+
case 'EADDRINUSE':
|
|
50
|
+
console.error(`${bind} is already in use`); // eslint-disable-line no-console, no-undef
|
|
51
|
+
process.exit(1); // eslint-disable-line no-process-exit, no-undef
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Event listener for HTTP/HTTPS server "listening" event.
|
|
61
|
+
* @param optionalServer - http or https NodeJS server
|
|
62
|
+
* @return callback that is triggered when the server has started
|
|
63
|
+
*/
|
|
64
|
+
export function formListeningHandler(optionalServer: HttpsServer | HttpServer): () => void {
|
|
65
|
+
return function onListening() {
|
|
66
|
+
const addr = optionalServer.address();
|
|
67
|
+
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr?.port}`;
|
|
68
|
+
debug(`Listening on ${bind}`);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -77,7 +77,7 @@ export class FileHandleProvider implements FileProvider {
|
|
|
77
77
|
*/
|
|
78
78
|
async getBigUint64(offset: bigint): Promise<bigint> {
|
|
79
79
|
const val = new BigInt64Array(
|
|
80
|
-
(await this.fileDescriptor.read(Buffer.alloc(8), 0,
|
|
80
|
+
(await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer
|
|
81
81
|
).at(0);
|
|
82
82
|
if (val === undefined) {
|
|
83
83
|
throw new Error('something went wrong');
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Module dependencies.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const app = require('../app');
|
|
8
|
-
const debug = require('debug')('i3s-server:server');
|
|
9
|
-
const https = require('https');
|
|
10
|
-
const http = require('http');
|
|
11
|
-
const fs = require('fs');
|
|
12
|
-
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
|
-
|
|
25
|
-
const options = {
|
|
26
|
-
key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),
|
|
27
|
-
cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const httpServer = http.createServer(app);
|
|
31
|
-
const httpsServer = https.createServer(options, app);
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Listen on provided port, on all network interfaces.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
httpServer.listen(httpPort);
|
|
38
|
-
httpServer.on('error', formErrorHandler(httpPort));
|
|
39
|
-
httpServer.on('listening', formListeningHandler(httpServer));
|
|
40
|
-
|
|
41
|
-
httpsServer.listen(httpsPort);
|
|
42
|
-
httpsServer.on('error', formErrorHandler(httpsPort));
|
|
43
|
-
httpsServer.on('listening', formListeningHandler(httpsServer));
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Normalize a port into a number, string, or false.
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
function normalizePort(val) {
|
|
50
|
-
const chkPort = parseInt(val, 10);
|
|
51
|
-
|
|
52
|
-
if (isNaN(chkPort)) {
|
|
53
|
-
// named pipe
|
|
54
|
-
return val;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (chkPort >= 0) {
|
|
58
|
-
// port number
|
|
59
|
-
return chkPort;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Event listener for HTTP/HTTPS server "error" event.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
function formErrorHandler(optionalPort) {
|
|
70
|
-
return function onError(error) {
|
|
71
|
-
if (error.syscall !== 'listen') {
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const bind = typeof global.port === 'string' ? `Pipe ${optionalPort}` : `Port ${optionalPort}`;
|
|
76
|
-
|
|
77
|
-
// handle specific listen errors with friendly messages
|
|
78
|
-
switch (error.code) {
|
|
79
|
-
case 'EACCES':
|
|
80
|
-
console.error(`${bind} requires elevated privileges`); // eslint-disable-line no-console, no-undef
|
|
81
|
-
process.exit(1); // eslint-disable-line no-process-exit, no-undef
|
|
82
|
-
break;
|
|
83
|
-
case 'EADDRINUSE':
|
|
84
|
-
console.error(`${bind} is already in use`); // eslint-disable-line no-console, no-undef
|
|
85
|
-
process.exit(1); // eslint-disable-line no-process-exit, no-undef
|
|
86
|
-
break;
|
|
87
|
-
default:
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Event listener for HTTP/HTTPS server "listening" event.
|
|
95
|
-
*/
|
|
96
|
-
function formListeningHandler(optionalServer) {
|
|
97
|
-
return function onListening() {
|
|
98
|
-
const addr = optionalServer.address();
|
|
99
|
-
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`;
|
|
100
|
-
debug(`Listening on ${bind}`);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require('@loaders.gl/polyfills');
|
|
2
|
-
const {parseSLPK} = require('@loaders.gl/i3s');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const {FileHandleProvider} = require('@loaders.gl/tile-converter');
|
|
5
|
-
|
|
6
|
-
let slpkArchive;
|
|
7
|
-
|
|
8
|
-
const loadArchive = async (fullLayerPath) => {
|
|
9
|
-
slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath));
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
|
|
13
|
-
const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef
|
|
14
|
-
|
|
15
|
-
loadArchive(FULL_LAYER_PATH);
|
|
16
|
-
|
|
17
|
-
async function getFileByUrl(url) {
|
|
18
|
-
const trimmedPath = /^\/?(.*)\/?$/.exec(url);
|
|
19
|
-
let uncompressedFile;
|
|
20
|
-
if (trimmedPath) {
|
|
21
|
-
try {
|
|
22
|
-
uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));
|
|
23
|
-
} catch (e) {}
|
|
24
|
-
}
|
|
25
|
-
return uncompressedFile;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = {
|
|
29
|
-
loadArchive,
|
|
30
|
-
getFileByUrl
|
|
31
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const {v4: uuidv4} = require('uuid');
|
|
2
|
-
|
|
3
|
-
const createSceneServer = (name, layer) => {
|
|
4
|
-
return {
|
|
5
|
-
serviceItemId: uuidv4().replace(/-/gi, ''),
|
|
6
|
-
serviceName: name,
|
|
7
|
-
name,
|
|
8
|
-
currentVersion: '10.7',
|
|
9
|
-
serviceVersion: '1.8',
|
|
10
|
-
supportedBindings: ['REST'],
|
|
11
|
-
layers: [layer]
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
module.exports = createSceneServer;
|