chiitiler 1.13.0 → 1.14.0
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 +15 -0
- package/dist/render/pool.js +2 -0
- package/dist/source/cog.d.ts +2 -0
- package/dist/source/cog.js +19 -0
- package/dist/source/index.js +5 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -191,6 +191,13 @@ node dist/main.js tile-server -c s3 -s3b chiitiler -s3r ap-northeast-1
|
|
|
191
191
|
"s3://tiles/{z}/{x}/{y}.pbf"
|
|
192
192
|
],
|
|
193
193
|
"maxzoom": 6
|
|
194
|
+
},
|
|
195
|
+
"cog": {
|
|
196
|
+
"type": "raster",
|
|
197
|
+
"tiles": [
|
|
198
|
+
"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}"
|
|
199
|
+
],
|
|
200
|
+
"tileSize": 256
|
|
194
201
|
}
|
|
195
202
|
},
|
|
196
203
|
"layers": [
|
|
@@ -233,6 +240,14 @@ node dist/main.js tile-server -c s3 -s3b chiitiler -s3r ap-northeast-1
|
|
|
233
240
|
"circle-radius": 3,
|
|
234
241
|
"circle-color": "green"
|
|
235
242
|
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"id": "cog",
|
|
246
|
+
"source": "cog",
|
|
247
|
+
"type": "raster",
|
|
248
|
+
"paint": {
|
|
249
|
+
"raster-opacity": 0.5
|
|
250
|
+
}
|
|
236
251
|
}
|
|
237
252
|
]
|
|
238
253
|
}
|
package/dist/render/pool.js
CHANGED
|
@@ -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();
|
|
@@ -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 };
|
package/dist/source/index.js
CHANGED
|
@@ -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 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "chiitiler",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.14.0",
|
|
5
5
|
"description": "Tiny map rendering server for MapLibre Style Spec",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -43,10 +43,11 @@
|
|
|
43
43
|
"better-sqlite3": "^9.6.0",
|
|
44
44
|
"commander": "^11.0.0",
|
|
45
45
|
"file-system-cache": "^2.4.4",
|
|
46
|
+
"higuruma": "^0.1.6",
|
|
46
47
|
"hono": "^4.5.4",
|
|
47
48
|
"lightning-pool": "^4.2.2",
|
|
48
49
|
"lru-cache": "^11.0.0",
|
|
49
50
|
"pmtiles": "^3.0.5",
|
|
50
51
|
"sharp": "^0.32.5"
|
|
51
52
|
}
|
|
52
|
-
}
|
|
53
|
+
}
|