npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@india-boundary-corrector/tilefixer

v0.2.1

Published

Tile fixer for India boundary corrections using PMTiles

Downloads

1,203

Readme

@india-boundary-corrector/tilefixer

npm version

Core library for fetching and applying India boundary corrections to raster map tiles.

Installation

npm install @india-boundary-corrector/tilefixer

Usage

import { TileFixer } from '@india-boundary-corrector/tilefixer';
import { getPmtilesUrl } from '@india-boundary-corrector/data';
import { layerConfigs } from '@india-boundary-corrector/layer-configs';

// Create a boundary corrector
const corrector = new TileFixer(getPmtilesUrl());

// Get corrections for a tile
const corrections = await corrector.getCorrections(z, x, y);
// Returns: { 'to-add-osm': [...], 'to-del-osm': [...], 'to-add-ne': [...], 'to-del-ne': [...], 
//            'to-add-osm-disp': [...], 'to-del-osm-disp': [...], 'to-add-ne-disp': [...], 'to-del-ne-disp': [...],
//            'to-add-osm-internal': [...], 'to-del-osm-internal': [...] }

// Apply corrections to a raster tile
const layerConfig = layerConfigs.get('osm-carto');
const fixedTileData = await corrector.fixTile(
  corrections,
  originalTileArrayBuffer,
  layerConfig,
  z        // zoom level (tile size is derived from image)
);

API

TileFixer

Static Methods

| Method | Returns | Description | |--------|---------|-------------| | TileFixer.getOrCreate(pmtilesUrl) | TileFixer | Get or create a TileFixer for a URL (reuses existing instances) | | TileFixer.setDefaultCacheMaxFeatures(count) | void | Set default max features to cache for new instances (default: 25000) |

Constructor

new TileFixer(pmtilesUrl, options?)

| Parameter | Type | Description | |-----------|------|-------------| | pmtilesUrl | string | URL to the PMTiles file | | options.cacheMaxFeatures | number | Maximum features to cache |

Methods

| Method | Returns | Description | |--------|---------|-------------| | getCorrections(z, x, y) | Promise<Object> | Get correction features for a tile. Supports overzoom beyond zoom 14. | | fixTile(corrections, rasterTile, layerConfig, zoom) | Promise<ArrayBuffer> | Apply corrections to a raster tile and return corrected PNG. Tile size is derived from the image. | | fetchAndFixTile(tileUrl, z, x, y, layerConfig, options?) | Promise<Object> | Fetch a tile, apply corrections, and return result. See below. | | getSource() | PMTiles | Get the underlying PMTiles source object | | clearCache() | void | Clear the tile cache |

fetchAndFixTile Options and Return Value

const result = await corrector.fetchAndFixTile(tileUrl, z, x, y, layerConfig, {
  signal: abortSignal,  // AbortSignal for cancellation
  mode: 'cors',         // Fetch mode
});

// result: {
//   data: ArrayBuffer,           // The tile image data
//   wasFixed: boolean,           // Whether corrections were applied
//   correctionsFailed: boolean,  // Whether corrections fetch failed
//   correctionsError: Error|null // The error if corrections failed
// }

How It Works

  1. Fetching corrections: The corrector fetches vector tile data from the PMTiles file containing boundary correction geometries.

  2. Overzoom support: For zoom levels > 14 (max data zoom), parent tile data is fetched and transformed to the correct sub-tile quadrant.

  3. Applying corrections:

    • Deletions: Uses median blur along deletion paths to erase incorrect boundary lines
    • Additions: Draws correct boundary lines with configurable colors and dash patterns
  4. Caching: Parsed vector tiles are cached in an LRU cache to avoid repeated fetches.

License

Unlicense