@tinkatinka/static-map 3.0.6 → 3.1.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/dist/index.js +6 -1
- package/dist/tilecache.d.ts +1 -0
- package/dist/tilecache.js +16 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -330,7 +330,12 @@ export class StaticMap {
|
|
|
330
330
|
.replace('{y}', tileY.toString());
|
|
331
331
|
let src = url;
|
|
332
332
|
if (this.cache !== undefined) {
|
|
333
|
-
const td = {
|
|
333
|
+
const td = {
|
|
334
|
+
z: zoom,
|
|
335
|
+
x: tileX,
|
|
336
|
+
y: tileY,
|
|
337
|
+
url: this.options.tileURL
|
|
338
|
+
};
|
|
334
339
|
try {
|
|
335
340
|
const csrc = await this.cache.pass(td, () => base64img(src, this.options.userAgent, this.options.tileTimeout));
|
|
336
341
|
if (csrc !== undefined) {
|
package/dist/tilecache.d.ts
CHANGED
package/dist/tilecache.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { mkdirSync } from 'fs';
|
|
2
2
|
import { readFile, writeFile } from 'fs/promises';
|
|
3
3
|
import { join as pathJoin } from 'path';
|
|
4
|
+
function cyrb53(str, seed = 0) {
|
|
5
|
+
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
6
|
+
for (let i = 0, ch; i < str.length; i++) {
|
|
7
|
+
ch = str.charCodeAt(i);
|
|
8
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
9
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
10
|
+
}
|
|
11
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
|
|
12
|
+
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
13
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
|
|
14
|
+
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
15
|
+
return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
|
|
16
|
+
}
|
|
17
|
+
;
|
|
4
18
|
export class TileCache {
|
|
5
|
-
static fnTemplate = '{z}_{x}_{y}.png';
|
|
19
|
+
static fnTemplate = '{url}_{z}_{x}_{y}.png';
|
|
6
20
|
path;
|
|
7
21
|
constructor(path) {
|
|
8
22
|
this.path = path;
|
|
@@ -32,6 +46,7 @@ export class TileCache {
|
|
|
32
46
|
}
|
|
33
47
|
tilePath(data) {
|
|
34
48
|
const fn = TileCache.fnTemplate
|
|
49
|
+
.replace('{url}', cyrb53(data.url))
|
|
35
50
|
.replace('{z}', data.z.toString())
|
|
36
51
|
.replace('{x}', data.x.toString())
|
|
37
52
|
.replace('{y}', data.y.toString());
|