{"name":"quadbin","version":"0.2.0","description":"Utility functions for working with Quadbins","license":"MIT","type":"module","main":"dist/cjs/index.cjs","module":"dist/esm/index.js","umd:main":"dist/umd/index.js","types":"dist/types/index.d.ts","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.cjs"},"./*":"./*"},"keywords":["quadbin","webgl","visualization"],"repository":{"type":"git","url":"git+https://github.com/CartoDB/quadbin-js.git"},"scripts":{"clean":"rm -rf dist/*","build":"yarn clean && yarn build:cjs && yarn build:esm && yarn build:types && yarn build:umd","build:cjs":"tsc -p tsconfig/tsconfig.cjs.json && mv dist/cjs/index.js dist/cjs/index.cjs","build:esm":"tsc -p tsconfig/tsconfig.esm.json","build:types":"tsc -p tsconfig/tsconfig.types.json","build:umd":"webpack --config tsconfig/webpack.config.cjs","lint":"npx prettier --check src","test":"yarn lint && yarn test-fast","test-fast":"npx ts-node node_modules/tape/bin/tape test/**/*.spec.js"},"browser":{"jsdom":false},"devDependencies":{"@babel/register":"^7.13.0","babel-loader":"^8.0.0","babel-preset-minify":"^0.5.0","prettier":"^2.4.1","tape":"^5.3.0","ts-loader":"^9.2.5","typescript":"^4.4.4","webpack":"^5.52.1","webpack-cli":"^4.8.0"},"engines":{"node":">=14"},"dependencies":{"@mapbox/tile-cover":"3.0.1"},"gitHead":"d38c5e273fbf4170df017d316384d5e08b84654e","bugs":{"url":"https://github.com/CartoDB/quadbin-js/issues"},"homepage":"https://github.com/CartoDB/quadbin-js#readme","_id":"quadbin@0.2.0","_nodeVersion":"16.20.0","_npmVersion":"8.19.4","dist":{"integrity":"sha512-bPgyRreIsFVwKxHRY+GFdaXatNmfQ1LzaQZj7aKEz07/gL893uWREhmRZpG6UuvlGHdTOPw/NGvqLsJica2goA==","shasum":"ee962448bc009967a85c463790269af136d1cccb","tarball":"http://registry-npm.ywwl.com/quadbin/download/quadbin-0.2.0.tgz","fileCount":27,"unpackedSize":26889,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCmvh5q8vCrGrGm765Wm47M1SByNpj7PvzKJiiThYV4RAIgbP2z9dmpW6mqjVBjcIAB1P9sxz1GyCG4oRTLNZyOosM="}],"size":8915,"noattachment":false,"key":"/quadbin/-/quadbin-0.2.0.tgz"},"_npmUser":{"name":"felixpalmer","email":"felixpalmer+npm@gmail.com"},"directories":{},"maintainers":[{"name":"felixpalmer","email":"felixpalmer+npm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/quadbin_0.2.0_1706694493894_0.46150103610647975"},"_hasShrinkwrap":false,"readme":"# quadbin-js\n\nThe `quadbin-js` is a TypeScript library for working with the [Quadbin](https://docs.carto.com/analytics-toolbox-bigquery/overview/spatial-indexes/) spatial index.\n\n# Install\n\n```sh\nnpm install quadbin\n```\n\n# Usage\n\n```javascript\nimport {cellToParent, getResolution, hexToBigInt} from 'quadbin';\n\ncellToParent(5210915457518796799n) // => 5206425052030959615n\ngetResolution(hexToBigInt('4830ffffffffffff')) // => 3\n```\n\n# I/O types\n\nA Quadbin index is a 64-bit integer. This library uses [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) as a data type to represent quadbin indices, both as parameters and return values for functions.\n\nWhen 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.\n\n# API\n\n## bigIntToHex\n\n```javascript\nfunction bigIntToHex(index: bigint): string\n```\n\nEncodes an index into a string, suitable for use in JSON.\n\n## hexToBigInt\n\n```javascript\nfunction hexToBigInt(hex: string): bigint\n```\n\nDecodes an string into an index. Inverse of `bigIntToHex()`.\n\n## getResolution\n\n```javascript\nfunction getResolution(quadbin: bigint): bigint \n```\n\nCalculates the resolution of a quadbin cell.\n\n## function cellToParent\n\n```javascript\nfunction cellToParent(quadbin: bigint): bigint \n```\n\nCalculates the parent cell.\n\n## tileToCell\n\n```javascript\nfunction tileToCell(tile: {x: number, y: number, z: number}): bigint\n```\n\nConverts a xyz tile into a quadbin cell.\n\n## cellToTile\n\n```javascript\nfunction cellToTile(quadbin: bigint): Tile \n```\n\nConverts quadbin cell into a xyz tile.\n\n## geometryToCells\n\n```javascript\nfunction geometryToCells(geometry: GeoJSONGeometry, resolution: bigint): bigint \n```\n\nReturns a list of cells covering a GeoJSON geometry at a given resolution\n","publish_time":1706694494062,"_cnpm_publish_time":1706694494062,"dist-tags":{"alpha":"0.4.1-alpha.0","latest":"0.4.2"}}