@india-boundary-corrector/tilefixer 0.0.1 → 0.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@india-boundary-corrector/tilefixer",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Tile fixer for India boundary corrections using PMTiles",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/index.js CHANGED
@@ -137,7 +137,7 @@ function applyMedianBlurAlongPath(ctx, features, lineWidth, tileSize, maskCanvas
137
137
  if (!maskCanvas || maskCanvas.width !== tileSize || maskCanvas.height !== tileSize) {
138
138
  maskCanvas = new OffscreenCanvas(tileSize, tileSize);
139
139
  }
140
- const maskCtx = maskCanvas.getContext('2d');
140
+ const maskCtx = maskCanvas.getContext('2d', { willReadFrequently: true });
141
141
  maskCtx.fillStyle = 'black';
142
142
  maskCtx.fillRect(0, 0, tileSize, tileSize);
143
143
 
@@ -420,9 +420,12 @@ export class BoundaryCorrector {
420
420
  const addLayerName = useOsm ? 'to-add-osm' : 'to-add-ne';
421
421
  const delLayerName = useOsm ? 'to-del-osm' : 'to-del-ne';
422
422
 
423
- // Create OffscreenCanvas
424
- const canvas = new OffscreenCanvas(tileSize, tileSize);
425
- const ctx = canvas.getContext('2d');
423
+ // Get or create reusable main canvas
424
+ if (!this._canvas || this._canvas.width !== tileSize) {
425
+ this._canvas = new OffscreenCanvas(tileSize, tileSize);
426
+ }
427
+ const canvas = this._canvas;
428
+ const ctx = canvas.getContext('2d', { willReadFrequently: true });
426
429
 
427
430
  // Draw original raster tile
428
431
  const blob = new Blob([rasterTile]);