chiitiler 1.13.0 → 1.14.1

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 CHANGED
@@ -14,11 +14,17 @@ chii-tiler: "tiny" in Japanese is "chiisai", shorten into "chii"
14
14
  - In this type of server, there is a de-facto - [maptiler/tileserver-gl](https://github.com/maptiler/tileserver-gl), but this is too big for me.
15
15
  - I want a server accept style.json-url and respond raster tile, inspired by [developmentseed/titiler](https://github.com/developmentseed/titiler)
16
16
 
17
+ ## usecases
18
+
19
+ - [MIERUNE/tiles](https://github.com/MIERUNE/tiles) - You can find example [here](https://mierune.github.io/tiles/color.html#11.62/43.064/141.3375)
20
+ - [dayjournal/qgis-amazonlocationservice-plugin](https://github.com/dayjournal/qgis-amazonlocationservice-plugin) - used in Maps feature
21
+ - [Allmaps Latest - Bluesky](https://bsky.app/profile/latest.allmaps.org)
22
+
17
23
  ## features
18
24
 
19
25
  ### /tiles
20
26
 
21
- chiitiler provides you with `/tiles` raster-tile endpoint. Once server launched, you can use like this:
27
+ chiitiler provides you with an endpoint `/tiles`. Once server launched, you can use the endpoint like this:
22
28
 
23
29
  ```planetext
24
30
  http://localhost:3000/tiles/0/0/0.png?url=https://tile.openstreetmap.jp/styles/osm-bright/style.json
@@ -105,7 +111,7 @@ you can pass server options via environment variables
105
111
  | CHIITILER_S3_ENDPOINT | | s3 endpoint for caching/fetching |
106
112
  | CHIITILER_S3_FORCE_PATH_STYLE | false | force path style for s3, needed for minio |
107
113
 
108
- ### Local
114
+ ### CLI (deprecated)
109
115
 
110
116
  - Node.js v18 or v20
111
117
 
@@ -140,21 +146,23 @@ node dist/main.js tile-server -c s3 -s3b chiitiler -s3r ap-northeast-1
140
146
  # caution: TTL is not supported in S3 cache, please utilize S3 lifecycle policy
141
147
  ```
142
148
 
143
- #### debug page
149
+ ### debug page
144
150
 
145
- - in debug mode, you can access debug page: <http://localhost:3000/debug>
146
- - You can pass style.json url:
147
- - <http://localhost:3000/debug?url=https://tile.openstreetmap.jp/styles/osm-bright/style.json>
151
+ - in debug mode, you can access:
152
+ - debug page: <http://localhost:3000/debug>
153
+ - You can pass style.json url: <http://localhost:3000/debug?url=https://tile.openstreetmap.jp/styles/osm-bright/style.json>
154
+ - editor page: <http://localhost:3000/editor>
148
155
 
149
156
  ## supported protocols in style.json
150
157
 
151
158
  - `http://` or `https://` protocol are used in Style Specification
152
159
  - In addition, chiitiler supports following protocols:
153
160
  - `s3://` for S3 bucket
154
- - `file://` for local file
155
- - `mbtiles://` for local MBTIles files
156
- - `pmtiles://` form PMTiles, remote or local or s3
157
- - Only when `http://` and `https://` chiitiler will cache them with a specified method.
161
+ - `file://` for file system
162
+ - `mbtiles://` for MBTIles files
163
+ - `pmtiles://` for PMTiles, remote or local or s3
164
+ - `cog://` experimental, for Cloud Optimized GeoTIFF. CRS must be EPSG:3857.
165
+ - Only when `http://` and `https://` chiitiler cache them with a method you specified.
158
166
 
159
167
  ### example
160
168
 
@@ -191,6 +199,13 @@ node dist/main.js tile-server -c s3 -s3b chiitiler -s3r ap-northeast-1
191
199
  "s3://tiles/{z}/{x}/{y}.pbf"
192
200
  ],
193
201
  "maxzoom": 6
202
+ },
203
+ "cog": {
204
+ "type": "raster",
205
+ "tiles": [
206
+ "cog://https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/54/T/WN/2024/9/S2A_54TWN_20240908_0_L2A/TCI.tif/{z}/{x}/{y}"
207
+ ],
208
+ "tileSize": 256
194
209
  }
195
210
  },
196
211
  "layers": [
@@ -233,6 +248,14 @@ node dist/main.js tile-server -c s3 -s3b chiitiler -s3r ap-northeast-1
233
248
  "circle-radius": 3,
234
249
  "circle-color": "green"
235
250
  }
251
+ },
252
+ {
253
+ "id": "cog",
254
+ "source": "cog",
255
+ "type": "raster",
256
+ "paint": {
257
+ "raster-opacity": 0.5
258
+ }
236
259
  }
237
260
  ]
238
261
  }
@@ -11,6 +11,8 @@ const TRANSPARENT_BUFFER = {
11
11
  jpeg: Buffer.from('/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAABAAEDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiigD//2Q=='),
12
12
  };
13
13
  function handleFileExt(uri) {
14
+ if (uri.startsWith('cog://'))
15
+ return 'png'; // cog:// always returns as png
14
16
  // extract extension only, take into account query string or hash
15
17
  const basename = path.basename(uri).split(/[?#]/)[0];
16
18
  const ext = basename.split('.').pop();
@@ -1,7 +1,7 @@
1
1
  import type { RenderOptions } from '@maplibre/maplibre-gl-native';
2
2
  import type { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
3
3
  import type { Cache } from '../cache/index.js';
4
- declare function render(style: StyleSpecification, renderOptions: RenderOptions, cache: Cache, mode: 'tile' | 'static'): Promise<Uint8Array>;
4
+ declare function render(style: StyleSpecification, renderOptions: RenderOptions, cache: Cache, mode: 'tile' | 'static'): Promise<Uint8Array<ArrayBufferLike>>;
5
5
  declare function renderTile(style: StyleSpecification, z: number, x: number, y: number, options: {
6
6
  tileSize: number;
7
7
  cache: Cache;
@@ -0,0 +1,2 @@
1
+ declare function getCogSource(uri: string): Promise<Buffer | null>;
2
+ export { getCogSource };
@@ -0,0 +1,19 @@
1
+ /// <reference lib="dom" />
2
+ // for using native fetch in TypeScript
3
+ import { renderTile } from 'higuruma';
4
+ async function getCogSource(uri) {
5
+ const cogPath = uri.replace('cog://', '').replace(/\/\d+\/\d+\/\d+$/, '');
6
+ const [z, x, y] = uri.replace(`cog://${cogPath}/`, '').split('/');
7
+ try {
8
+ const tile = await renderTile(cogPath, Number(z), Number(x), Number(y));
9
+ const buf = Buffer.from(tile);
10
+ if (buf.byteLength === 129)
11
+ return null; // empty tile
12
+ return buf;
13
+ }
14
+ catch (e) {
15
+ console.error(`[ERROR] ${e}`);
16
+ return null;
17
+ }
18
+ }
19
+ export { getCogSource };
@@ -1,2 +1,2 @@
1
- declare function getFilesystemSource(uri: string): Promise<Buffer | null>;
1
+ declare function getFilesystemSource(uri: string): Promise<Buffer<ArrayBufferLike> | null>;
2
2
  export { getFilesystemSource };
@@ -3,6 +3,7 @@ import { getHttpSource } from './http.js';
3
3
  import { getPmtilesSoruce } from './pmtiles.js';
4
4
  import { getMbtilesSource } from './mbtiles.js';
5
5
  import { getS3Source } from './s3.js';
6
+ import { getCogSource } from './cog.js';
6
7
  import { noneCache } from '../cache/index.js';
7
8
  /**
8
9
  * retrieve sources from the uri
@@ -22,6 +23,10 @@ async function getSource(uri, cache = noneCache()) {
22
23
  data = await getMbtilesSource(uri);
23
24
  else if (uri.startsWith('pmtiles://'))
24
25
  data = await getPmtilesSoruce(uri, cache);
26
+ else if (uri.startsWith('cog://'))
27
+ data = await getCogSource(uri);
28
+ else
29
+ return null;
25
30
  return data;
26
31
  }
27
32
  export { getSource };
@@ -1,2 +1,2 @@
1
- declare function getS3Source(uri: string): Promise<Buffer | null>;
1
+ declare function getS3Source(uri: string): Promise<Buffer<Uint8Array<ArrayBufferLike>> | null>;
2
2
  export { getS3Source };
package/package.json CHANGED
@@ -1,52 +1,52 @@
1
1
  {
2
- "type": "module",
3
- "name": "chiitiler",
4
- "version": "1.13.0",
5
- "description": "Tiny map rendering server for MapLibre Style Spec",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
- "scripts": {
12
- "build": "tsc",
13
- "dev": "tsx watch src/main.ts tile-server -D",
14
- "start": "tsc && node ./dist/main.js tile-server",
15
- "test:unit": "vitest src",
16
- "test:coverage": "vitest src --coverage --coverage.provider=v8",
17
- "test:integration": "vitest tests/integration.test.ts",
18
- "test:benchmark": "vitest bench",
19
- "prepare": "npm run build"
20
- },
21
- "keywords": [],
22
- "author": "Kanahiro Iguchi",
23
- "license": "MIT",
24
- "devDependencies": {
25
- "@tsconfig/node20": "^20.1.4",
26
- "@types/better-sqlite3": "^7.6.10",
27
- "@types/node": "^20.6.0",
28
- "@vitest/coverage-v8": "^1.6.0",
29
- "image-size": "^1.1.1",
30
- "maplibre-gl": "^3.3.1",
31
- "ts-node": "^10.9.1",
32
- "tsx": "^4.7.1",
33
- "typescript": "^5.2.2",
34
- "vitest": "^1.6.0"
35
- },
36
- "dependencies": {
37
- "@aws-sdk/client-s3": "^3.418.0",
38
- "@hono/node-server": "^1.12.0",
39
- "@mapbox/sphericalmercator": "^1.2.0",
40
- "@mapbox/tilebelt": "^1.0.2",
41
- "@maplibre/maplibre-gl-native": "^5.4.0",
42
- "@maplibre/maplibre-gl-style-spec": "^20.2.0",
43
- "better-sqlite3": "^9.6.0",
44
- "commander": "^11.0.0",
45
- "file-system-cache": "^2.4.4",
46
- "hono": "^4.5.4",
47
- "lightning-pool": "^4.2.2",
48
- "lru-cache": "^11.0.0",
49
- "pmtiles": "^3.0.5",
50
- "sharp": "^0.32.5"
51
- }
2
+ "type": "module",
3
+ "name": "chiitiler",
4
+ "version": "1.14.1",
5
+ "description": "Tiny map rendering server for MapLibre Style Spec",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "npx esbuild --bundle src/main.ts --minify --outfile=build/main.cjs --platform=node --external:@maplibre/maplibre-gl-native --external:sharp",
13
+ "dev": "tsx watch src/main.ts tile-server -D",
14
+ "test:unit": "vitest src",
15
+ "test:coverage": "vitest src --coverage --coverage.provider=v8",
16
+ "test:integration": "vitest tests/integration.test.ts",
17
+ "test:benchmark": "vitest bench"
18
+ },
19
+ "keywords": [],
20
+ "author": "Kanahiro Iguchi",
21
+ "license": "MIT",
22
+ "devDependencies": {
23
+ "@tsconfig/node20": "^20.1.4",
24
+ "@types/better-sqlite3": "^7.6.10",
25
+ "@types/node": "^20.6.0",
26
+ "@vitest/coverage-v8": "^1.6.0",
27
+ "esbuild": "^0.25.0",
28
+ "image-size": "^1.1.1",
29
+ "maplibre-gl": "^3.3.1",
30
+ "ts-node": "^10.9.1",
31
+ "tsx": "^4.7.1",
32
+ "typescript": "^5.2.2",
33
+ "vitest": "^1.6.0",
34
+ "@aws-sdk/client-s3": "^3.418.0",
35
+ "@hono/node-server": "^1.12.0",
36
+ "@mapbox/sphericalmercator": "^1.2.0",
37
+ "@mapbox/tilebelt": "^1.0.2",
38
+ "@maplibre/maplibre-gl-style-spec": "^20.2.0",
39
+ "better-sqlite3": "^9.6.0",
40
+ "commander": "^11.0.0",
41
+ "file-system-cache": "^2.4.4",
42
+ "higuruma": "^0.1.6",
43
+ "hono": "^4.5.4",
44
+ "lightning-pool": "^4.2.2",
45
+ "lru-cache": "^11.0.0",
46
+ "pmtiles": "^3.0.5"
47
+ },
48
+ "dependencies": {
49
+ "@maplibre/maplibre-gl-native": "^5.4.0",
50
+ "sharp": "^0.32.5"
51
+ }
52
52
  }