chiitiler 1.12.4 → 1.12.6
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/README.md +53 -0
- package/dist/cache/s3.d.ts +2 -1
- package/dist/cache/s3.js +1 -0
- package/dist/cli.js +5 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/s3.d.ts +3 -2
- package/dist/s3.js +4 -14
- package/dist/source/pmtiles.js +2 -1
- package/dist/source/s3.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,6 +102,7 @@ you can pass server options via environment variables
|
|
|
102
102
|
| CHIITILER_S3CACHE_BUCKET | | s3cache bucket name |
|
|
103
103
|
| CHIITILER_S3_REGION | us-east1 | s3 bucket region for caching/fetching |
|
|
104
104
|
| CHIITILER_S3_ENDPOINT | | s3 endpoint for caching/fetching |
|
|
105
|
+
| CHIITILER_S3_FORCE_PATH_STYLE | false | force path style for s3, needed for minio |
|
|
105
106
|
|
|
106
107
|
### Local
|
|
107
108
|
|
|
@@ -236,6 +237,58 @@ node dist/main.js tile-server -c s3 -s3b chiitiler -s3r ap-northeast-1
|
|
|
236
237
|
}
|
|
237
238
|
```
|
|
238
239
|
|
|
240
|
+
## Library Mode
|
|
241
|
+
|
|
242
|
+
- chiitiler can be used as a library to render MapLibre Style.
|
|
243
|
+
- methods to render MapLibre Style are exposed from `chiitiler` package.
|
|
244
|
+
|
|
245
|
+
### installation
|
|
246
|
+
|
|
247
|
+
```sh
|
|
248
|
+
npm install chiitiler
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
- chiitiler requires some dependencies in runtime, you can find them in [Dockerfile](./Dockerfile)
|
|
252
|
+
|
|
253
|
+
### Usage
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
import {
|
|
257
|
+
getRenderedBboxBuffer,
|
|
258
|
+
getRenderedTileBuffer,
|
|
259
|
+
ChiitilerCache
|
|
260
|
+
} from 'chiitiler';
|
|
261
|
+
|
|
262
|
+
const s3Cache = ChiitilerCache.s3Cache({
|
|
263
|
+
bucket: 'chiitiler',
|
|
264
|
+
region: 'ap-northeast-1',
|
|
265
|
+
endpoint: null,
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const tileBuf = await getRenderedTileBuffer({
|
|
269
|
+
stylejson: 'https://example.com/style.json', // or StyleSpecification object
|
|
270
|
+
z: 0,
|
|
271
|
+
x: 0,
|
|
272
|
+
y: 0,
|
|
273
|
+
tileSize: 512,
|
|
274
|
+
ext: 'webp', // png, webp, jpg
|
|
275
|
+
cache: s3Cache,
|
|
276
|
+
quality: 80,
|
|
277
|
+
margin: 0,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const bboxBuf = await getRenderedBboxBuffer({
|
|
281
|
+
stylejson: 'file://path/to/style.json', // or StyleSpecification object
|
|
282
|
+
bbox: [123.4, 34.5, 124.5, 35.6],
|
|
283
|
+
size: 1024,
|
|
284
|
+
cache: s3Cache,
|
|
285
|
+
ext: 'webp',
|
|
286
|
+
quality: 80,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// return value is Buffer - binary of each image
|
|
290
|
+
```
|
|
291
|
+
|
|
239
292
|
## development
|
|
240
293
|
|
|
241
294
|
- run `docker compose up`
|
package/dist/cache/s3.d.ts
CHANGED
package/dist/cache/s3.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ function parseCacheStrategy(method, options) {
|
|
|
19
19
|
bucket: options.s3CacheBucket,
|
|
20
20
|
region: options.s3Region,
|
|
21
21
|
endpoint: options.s3Endpoint,
|
|
22
|
+
forcePathStyle: options.s3ForcePathStyle,
|
|
22
23
|
});
|
|
23
24
|
// command-line is not specified -> try to read from env
|
|
24
25
|
const cacheEnv = process.env.CHIITILER_CACHE_METHOD;
|
|
@@ -36,7 +37,8 @@ function parseCacheStrategy(method, options) {
|
|
|
36
37
|
return caches.s3Cache({
|
|
37
38
|
bucket: process.env.CHIITILER_S3CACHE_BUCKET ?? '',
|
|
38
39
|
region: process.env.CHIITILER_S3_REGION ?? 'us-east1',
|
|
39
|
-
endpoint: process.env.CHIITILER_S3_ENDPOINT
|
|
40
|
+
endpoint: process.env.CHIITILER_S3_ENDPOINT,
|
|
41
|
+
forcePathStyle: process.env.CHIITILER_S3_FORCE_PATH_STYLE === 'true',
|
|
40
42
|
});
|
|
41
43
|
// undefined or invalid
|
|
42
44
|
return caches.noneCache();
|
|
@@ -74,6 +76,7 @@ export function createProgram() {
|
|
|
74
76
|
.option('-s3r --s3-region <region-name>', 's3 bucket region for get/put', 'us-east1')
|
|
75
77
|
.option('-s3b --s3-cache-bucket <bucket-name>', 's3 cache bucket name', '')
|
|
76
78
|
.option('-s3e --s3-endpoint <url>', 's3 endpoint url', '')
|
|
79
|
+
.option('-3p --s3-force-path-style', 's3 force path style', '')
|
|
77
80
|
.option('-p --port <port>', 'port number')
|
|
78
81
|
.option('-D --debug', 'debug mode')
|
|
79
82
|
.action((options) => {
|
|
@@ -85,6 +88,7 @@ export function createProgram() {
|
|
|
85
88
|
s3CacheBucket: options.s3CacheBucket,
|
|
86
89
|
s3Region: options.s3Region,
|
|
87
90
|
s3Endpoint: options.s3Endpoint,
|
|
91
|
+
s3ForcePathStyle: options.s3ForcePathStyle === 'true',
|
|
88
92
|
}),
|
|
89
93
|
port: parsePort(options.port),
|
|
90
94
|
debug: parseDebug(options.debug),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export * as
|
|
1
|
+
export { getRenderedBboxBuffer, getRenderedTileBuffer, } from './render/index.js';
|
|
2
|
+
export * as ChiitilerCache from './cache/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export * as
|
|
1
|
+
export { getRenderedBboxBuffer, getRenderedTileBuffer, } from './render/index.js';
|
|
2
|
+
export * as ChiitilerCache from './cache/index.js';
|
package/dist/s3.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
-
declare const getS3Client: ({ region, endpoint, }: {
|
|
2
|
+
declare const getS3Client: ({ region, endpoint, forcePathStyle, }: {
|
|
3
3
|
region: string;
|
|
4
|
-
endpoint
|
|
4
|
+
endpoint?: string | undefined;
|
|
5
|
+
forcePathStyle?: boolean | undefined;
|
|
5
6
|
}) => S3Client;
|
|
6
7
|
export { getS3Client };
|
package/dist/s3.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
2
|
let s3Client; // singleton
|
|
3
|
-
const getS3Client = function ({ region, endpoint, }) {
|
|
3
|
+
const getS3Client = function ({ region, endpoint, forcePathStyle, }) {
|
|
4
4
|
if (s3Client !== undefined)
|
|
5
5
|
return s3Client;
|
|
6
|
-
|
|
6
|
+
const s3ClientConfig = {
|
|
7
7
|
region,
|
|
8
|
-
endpoint
|
|
8
|
+
endpoint,
|
|
9
|
+
forcePathStyle,
|
|
9
10
|
};
|
|
10
|
-
if (process.env.NODE_ENV === 'development') {
|
|
11
|
-
s3ClientConfig = {
|
|
12
|
-
region,
|
|
13
|
-
credentials: {
|
|
14
|
-
accessKeyId: 'minioadmin',
|
|
15
|
-
secretAccessKey: 'minioadmin',
|
|
16
|
-
},
|
|
17
|
-
forcePathStyle: true,
|
|
18
|
-
endpoint: 'http://minio:9000',
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
11
|
s3Client = new S3Client(s3ClientConfig);
|
|
22
12
|
return s3Client;
|
|
23
13
|
};
|
package/dist/source/pmtiles.js
CHANGED
|
@@ -32,7 +32,8 @@ class S3Source {
|
|
|
32
32
|
this.key = key;
|
|
33
33
|
this.s3Client = getS3Client({
|
|
34
34
|
region: process.env.CHIITILER_S3_REGION ?? 'us-east1',
|
|
35
|
-
endpoint: process.env.CHIITILER_S3_ENDPOINT
|
|
35
|
+
endpoint: process.env.CHIITILER_S3_ENDPOINT,
|
|
36
|
+
forcePathStyle: process.env.CHIITILER_S3_FORCE_PATH_STYLE === 'true',
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
getKey() {
|
package/dist/source/s3.js
CHANGED
|
@@ -3,7 +3,8 @@ import { getS3Client } from '../s3.js';
|
|
|
3
3
|
async function getS3Source(uri) {
|
|
4
4
|
const s3Client = getS3Client({
|
|
5
5
|
region: process.env.CHIITILER_S3_REGION ?? 'us-east1',
|
|
6
|
-
endpoint: process.env.CHIITILER_S3_ENDPOINT
|
|
6
|
+
endpoint: process.env.CHIITILER_S3_ENDPOINT,
|
|
7
|
+
forcePathStyle: process.env.CHIITILER_S3_FORCE_PATH_STYLE === 'true',
|
|
7
8
|
});
|
|
8
9
|
const bucket = uri.replace('s3://', '').split('/')[0];
|
|
9
10
|
const key = uri.replace(`s3://${bucket}/`, '');
|