quadbin
Utility functions for working with Quadbins
Last updated 3 years ago by felixpalmer .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install quadbin 
SYNC missed versions from official npm registry.

quadbin-js

The quadbin-js is a TypeScript library for working with the Quadbin spatial index.

Install

npm install quadbin

Usage

import {cellToParent, getResolution, hexToBigInt} from 'quadbin';

cellToParent(5210915457518796799n) // => 5206425052030959615n
getResolution(hexToBigInt('4830ffffffffffff')) // => 3

I/O types

A Quadbin index is a 64-bit integer. This library uses BigInt as a data type to represent quadbin indices, both as parameters and return values for functions.

When working with quadbin indices in other contexts (e.g. passing as a parameter in a URL or serializing as JSON), it is more appropriate to encode the index as a hexidecimal string. The library provides the bigIntToHex() & hexToBigInt() to facilitate this conversion.

API

bigIntToHex

function bigIntToHex(index: bigint): string

Encodes an index into a string, suitable for use in JSON.

hexToBigInt

function hexToBigInt(hex: string): bigint

Decodes an string into an index. Inverse of bigIntToHex().

getResolution

function getResolution(quadbin: bigint): bigint 

Calculates the resolution of a quadbin cell.

function cellToParent

function cellToParent(quadbin: bigint): bigint 

Calculates the parent cell.

tileToCell

function tileToCell(tile: {x: number, y: number, z: number}): bigint

Converts a xyz tile into a quadbin cell.

cellToTile

function cellToTile(quadbin: bigint): Tile 

Converts quadbin cell into a xyz tile.

geometryToCells

function geometryToCells(geometry: GeoJSONGeometry, resolution: bigint): bigint 

Returns a list of cells covering a GeoJSON geometry at a given resolution

Current Tags

  • 0.4.1-alpha.0                                ...           alpha (2 years ago)
  • 0.4.2                                ...           latest (2 years ago)

17 Versions

  • 0.4.2                                ...           2 years ago
  • 0.4.1-alpha.0                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.4.0-alpha.2                                ...           2 years ago
  • 0.4.0-alpha.1                                ...           2 years ago
  • 0.4.0-alpha.0                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.9                                ...           4 years ago
  • 0.1.8                                ...           4 years ago
  • 0.1.7                                ...           4 years ago
  • 0.1.6                                ...           4 years ago
  • 0.1.5                                ...           4 years ago
  • 0.1.4                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
Maintainers (1)
Downloads
Total 59
Today 0
This Week 0
This Month 52
Last Day 0
Last Week 37
Last Month 0
Dependencies (1)
Dev Dependencies (9)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE