@basemaps/lambda-tiler 7.7.0 → 7.10.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/build/__tests__/config.data.js +3 -3
  3. package/build/__tests__/config.data.js.map +1 -1
  4. package/build/__tests__/tile.style.json.test.js +13 -12
  5. package/build/__tests__/tile.style.json.test.js.map +1 -1
  6. package/build/routes/__tests__/health.test.js +40 -20
  7. package/build/routes/__tests__/health.test.js.map +1 -1
  8. package/build/routes/__tests__/tile.style.json.test.js +81 -0
  9. package/build/routes/__tests__/tile.style.json.test.js.map +1 -1
  10. package/build/routes/__tests__/xyz.test.js +13 -0
  11. package/build/routes/__tests__/xyz.test.js.map +1 -1
  12. package/build/routes/health.d.ts +17 -0
  13. package/build/routes/health.js +119 -21
  14. package/build/routes/health.js.map +1 -1
  15. package/build/routes/tile.style.json.d.ts +36 -8
  16. package/build/routes/tile.style.json.js +144 -128
  17. package/build/routes/tile.style.json.js.map +1 -1
  18. package/build/routes/tile.xyz.raster.js.map +1 -1
  19. package/build/routes/tile.xyz.vector.js +9 -9
  20. package/build/routes/tile.xyz.vector.js.map +1 -1
  21. package/build/util/__test__/cache.test.d.ts +1 -0
  22. package/build/util/__test__/cache.test.js +29 -0
  23. package/build/util/__test__/cache.test.js.map +1 -0
  24. package/build/util/__test__/nztm.style.test.d.ts +1 -0
  25. package/build/util/__test__/nztm.style.test.js +87 -0
  26. package/build/util/__test__/nztm.style.test.js.map +1 -0
  27. package/build/util/nztm.style.d.ts +12 -0
  28. package/build/util/nztm.style.js +45 -0
  29. package/build/util/nztm.style.js.map +1 -0
  30. package/build/util/source.cache.d.ts +2 -8
  31. package/build/util/source.cache.js +6 -24
  32. package/build/util/source.cache.js.map +1 -1
  33. package/build/util/swapping.lru.d.ts +1 -0
  34. package/build/util/swapping.lru.js +4 -0
  35. package/build/util/swapping.lru.js.map +1 -1
  36. package/package.json +7 -6
  37. package/src/__tests__/config.data.ts +3 -3
  38. package/src/__tests__/tile.style.json.test.ts +16 -14
  39. package/src/routes/__tests__/health.test.ts +46 -22
  40. package/src/routes/__tests__/tile.style.json.test.ts +91 -0
  41. package/src/routes/__tests__/xyz.test.ts +18 -0
  42. package/src/routes/health.ts +129 -21
  43. package/src/routes/tile.style.json.ts +172 -149
  44. package/src/routes/tile.xyz.raster.ts +0 -1
  45. package/src/routes/tile.xyz.vector.ts +10 -6
  46. package/src/util/__test__/cache.test.ts +36 -0
  47. package/src/util/__test__/nztm.style.test.ts +100 -0
  48. package/src/util/nztm.style.ts +44 -0
  49. package/src/util/source.cache.ts +10 -20
  50. package/src/util/swapping.lru.ts +5 -0
  51. package/tsconfig.tsbuildinfo +1 -1
@@ -7,54 +7,44 @@ export type LruStrut = LruStrutCotar | LruStrutCog;
7
7
  export interface LruStrutCotar {
8
8
  type: 'cotar';
9
9
  value: Promise<Cotar>;
10
- _value?: Cotar;
10
+ size: number;
11
11
  }
12
12
 
13
13
  export interface LruStrutCog {
14
14
  type: 'cog';
15
15
  value: Promise<Tiff>;
16
- _value?: Tiff;
17
- }
18
-
19
- class LruStrutObj<T extends LruStrut> {
20
- ob: T;
21
- constructor(ob: T) {
22
- this.ob = ob;
23
- if (this.ob._value == null) {
24
- void this.ob.value.then((c) => (this.ob._value = c));
25
- }
26
- }
27
-
28
- size = 1;
16
+ size: number;
29
17
  }
30
18
 
31
19
  export class SourceCache {
32
- cache: SwappingLru<LruStrutObj<LruStrutCotar | LruStrutCog>>;
20
+ cache: SwappingLru<LruStrut>;
33
21
  constructor(maxSize: number) {
34
- this.cache = new SwappingLru<LruStrutObj<LruStrut>>(maxSize);
22
+ this.cache = new SwappingLru<LruStrut>(maxSize);
35
23
  }
36
24
 
37
25
  getCog(location: URL): Promise<Tiff> {
38
- const existing = this.cache.get(location.href)?.ob;
26
+ const existing = this.cache.get(location.href);
39
27
 
40
28
  if (existing != null) {
41
29
  if (existing.type === 'cog') return existing.value;
42
30
  throw new Error(`Existing object of type: ${existing.type} made for location: ${location.href}`);
43
31
  }
44
32
  const value = Tiff.create(fsa.source(location));
45
- this.cache.set(location.href, new LruStrutObj({ type: 'cog', value }));
33
+ this.cache.set(location.href, { type: 'cog', value, size: 1 });
34
+ value.catch(() => this.cache.delete(location.href));
46
35
  return value;
47
36
  }
48
37
 
49
38
  getCotar(location: URL): Promise<Cotar> {
50
- const existing = this.cache.get(location.href)?.ob;
39
+ const existing = this.cache.get(location.href);
51
40
 
52
41
  if (existing != null) {
53
42
  if (existing.type === 'cotar') return existing.value;
54
43
  throw new Error(`Existing object of type: ${existing.type} made for location: ${location.href}`);
55
44
  }
56
45
  const value = Cotar.fromTar(fsa.source(location));
57
- this.cache.set(location.href, new LruStrutObj({ type: 'cotar', value }));
46
+ this.cache.set(location.href, { type: 'cotar', value, size: 1 });
47
+ value.catch(() => this.cache.delete(location.href));
58
48
  return value;
59
49
  }
60
50
  }
@@ -41,6 +41,11 @@ export class SwappingLru<T extends { size: number }> {
41
41
  this.clears++;
42
42
  }
43
43
 
44
+ delete(id: string): void {
45
+ this.cacheA.delete(id);
46
+ this.cacheB.delete(id);
47
+ }
48
+
44
49
  set(id: string, tiff: T): void {
45
50
  this.cacheA.set(id, tiff);
46
51
  this.check();