{"versions":{"0.1.0":{"name":"grid-index","version":"0.1.0","description":"A 2D spatial index for axis-aligned boxes","main":"grid-index.js","scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git+https://github.com/mapbox/grid-index.git"},"license":"ISC","bugs":{"url":"https://github.com/mapbox/grid-index/issues"},"homepage":"https://github.com/mapbox/grid-index#readme","devDependencies":{"tap":"^5.7.0"},"gitHead":"aaa4e8dcf20628fc0a32d364fb5295451d9a9a49","_id":"grid-index@0.1.0","_shasum":"3a585312a969244b4c4d5d99e3a568e65b109543","_from":".","_npmVersion":"2.14.12","_nodeVersion":"4.3.2","_npmUser":{"name":"anonymous","email":"ansis.brammanis@gmail.com"},"maintainers":[{"name":"anonymous","email":"ansis.brammanis@gmail.com"}],"dist":{"shasum":"3a585312a969244b4c4d5d99e3a568e65b109543","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/grid-index/-/grid-index-0.1.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/grid-index-0.1.0.tgz_1458869905514_0.5811388816218823"},"directories":{},"contributors":[]},"1.0.0":{"name":"grid-index","version":"1.0.0","description":"A 2D spatial index for axis-aligned boxes","main":"grid-index.js","scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git+https://github.com/mapbox/grid-index.git"},"license":"ISC","bugs":{"url":"https://github.com/mapbox/grid-index/issues"},"homepage":"https://github.com/mapbox/grid-index#readme","devDependencies":{"tap":"^5.7.0"},"gitHead":"bf809d6ccf27945890f9333335659cf52b3761e9","_id":"grid-index@1.0.0","_shasum":"ad2c5d54ce5b35437faff1d70a9aeb3d1d261110","_from":".","_npmVersion":"2.15.5","_nodeVersion":"4.4.5","_npmUser":{"name":"anonymous","email":"lucas@mapbox.com"},"maintainers":[{"name":"anonymous","email":"ansis.brammanis@gmail.com"},{"name":"anonymous","email":"john.firebaugh@gmail.com"},{"name":"anonymous","email":"lucas@lucaswoj.com"}],"dist":{"shasum":"ad2c5d54ce5b35437faff1d70a9aeb3d1d261110","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/grid-index/-/grid-index-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/grid-index-1.0.0.tgz_1467933356075_0.8242481658235192"},"directories":{},"contributors":[]},"1.1.0":{"name":"grid-index","version":"1.1.0","description":"A 2D spatial index for axis-aligned boxes","main":"grid-index.js","scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git+https://github.com/mapbox/grid-index.git"},"license":"ISC","bugs":{"url":"https://github.com/mapbox/grid-index/issues"},"homepage":"https://github.com/mapbox/grid-index#readme","devDependencies":{"tap":"^5.7.0"},"gitHead":"326d635014ee31eda95a46a294e6bb555b90c8ba","_id":"grid-index@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"8.14.0","_npmUser":{"name":"anonymous","email":"ansis.brammanis@gmail.com"},"dist":{"integrity":"sha512-HZRwumpOGUrHyxO5bqKZL0B0GlUpwtCAzZ42sgxUPniu33R1LSFH5yrIcBCHjkctCAh3mtWKcKd9J4vDDdeVHA==","shasum":"97f8221edec1026c8377b86446a7c71e79522ea7","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/grid-index/-/grid-index-1.1.0.tgz","fileCount":5,"unpackedSize":11957,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcNUMCCRA9TVsSAnZWagAAiT4QAJjJ1CCmlArYvjRIUlXM\nZmi+hcRHdNCtye/rwUSP5U7+CzSXthPkVJ/moMqcc1hOqoEbmpk8YgF+rk++\njxS6myozYvYarQ3kd9cXCREHL2HpEA+8Yh5jMGR1tzWvRjQBrbV+mAVqPbmx\nj8eYIaCS+BmtXtyoOin0oPryPL2mIQ36neHtw/KpTMJuKfN4/6ZZGf5qHduI\nznxAP7qStdZ/x2yR8e2VkbVZ+oTxrsl9T4HyxtPWJObo817c+0ipGlHrWBd5\ng9FSvlb/kM6CZ9hAbH7hKNJXmMr2/V3vtPYqqlQ4jVXzTPvLFybUe8RUdNOA\n0ZWPiBTeZYLH9bj5UzTBAuN3al2FZrufUiVhkADurnLY0BFebpQ7dWd81BsQ\njRWDMYCPNyEyTANUB7vdabxbjMzKVfZbHDD7Uaj0CXjF40IIZrmZLBqQywCl\nlUjUkoXOQKwF/dGIxh6InbzOOmm/EXaLTdYlhFht18RnZGPpX5mAcSSUs7CG\n+GQZyKc0n0Ldht5EDvBHf0xDH+V589z8R4d+pNhx6jQqIfqZ8Ajs83IoRAVu\nwqJWoiDTiOp/PhbsAfaC1bUFkaCST3wDV2UYhORpu/BdVDsapJvE1rIw5L6H\nbCjes/FuZ/UQe9cWd7g0M1Hr01JtJGDuHrp/aT7sgrA8KqsCAkEL2oQtAr6s\nG52a\r\n=ey5j\r\n-----END PGP SIGNATURE-----\r\n"},"maintainers":[{"email":"ansis.brammanis@gmail.com","name":"anonymous"},{"email":"john.firebaugh@gmail.com","name":"anonymous"},{"email":"accounts@mapbox.com","name":"anonymous"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/grid-index_1.1.0_1546994433368_0.17378477411309778"},"_hasShrinkwrap":false,"contributors":[]}},"dist-tags":{"latest":"1.1.0"},"name":"grid-index","time":{"modified":"2023-08-01T03:42:23.870Z","created":"2022-01-26T20:59:51.823Z","0.1.0":"2016-03-25T01:38:27.913Z","1.0.0":"2016-07-07T23:15:58.611Z","1.1.0":"2019-01-09T00:40:33.655Z"},"readme":"# grid-index\n\nGridIndex is a 2D spatial index that is [transferable](https://developer.mozilla.org/en-US/docs/Web/API/Transferable).\n\nPairs of keys and boxes can be inserted into GridIndex. The grid can then be queried to find all the keys that intersect a given box. The grid can be serialized to an ArrayBuffer so that it can be transferred between WebWorkers.\n\n**You should probably use [rbush](https://github.com/mourner/rbush) instead of GridIndex!** It's easier to use and it's as fast or faster in many cases.\n\nGridIndex can be faster in a specific set of cases:\n- the constructed index needs to be transferred between workers\n- the extent of the features is fixed\n- features are somewhat evenly sized and distributed\n- a high number of insertions relative to the number of queries\n\nGridIndex is used by [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js) for label collision detection and feature picking.\n\n## Example\n\n```js\nvar GridIndex = require('grid-index');\n\nvar grid = new GridIndex(100, 5, 0);\nvar key1 = 1;\nvar key2 = 2;\nvar key3 = 3;\ngrid.insert(key1, 30, 10, 35, 15);\ngrid.insert(key2, 60, 20, 65, 25);\ngrid.insert(key3, 40, 10, 45, 15);\n\nvar keys = grid.query(0, 0, 100, 13);\n// `keys` is now [key1, key3]\n\nvar arrayBuffer = grid.toArrayBuffer();\n// transfer the ArrayBuffer to a different worker\n\nvar grid2 = new GridIndex(arrayBuffer);\nvar keys2 = grid2.query(0, 0, 100, 13);\n// `keys2` is now [key1, key3]\n```\n\n## API\n\n### `GridIndex(extent, n, padding)`\nCreate a new GridIndex.\n\n- **extent**: The width and height of the square area that needs to be indexed, for example `4096`.\n- **n**: The rows and columns the grid will be split into. `4` would divide the grid into 16 cells.\n- **padding**: The number of extra rows and columns that should be added on each side of the main grid square.\n\n\n### `GridIndex(arrayBuffer)`\nUnserialize a GridIndex.\n\n- **arrayBuffer**: an ArrayBuffer produced by `gridIndex.toArrayBuffer()`.\n\n\n### `gridIndex.insert(key, x1, y1, x2, y2)`\n\nInsert a new key, box pair into the grid.\n\n- **key**: An unsigned 32bit integer.\n- **x1**: The x coordinate of the left edge of the box.\n- **y1**: The y coordinate of the bottom edge of the box.\n- **x2**: The x coordinate of the right edge of the box.\n- **y2**: The y coordinate of the top edge of the box.\n\n\n### `gridIndex.query(key, x1, y1, x2, y2, intersectionTest?)`\n\nFind the keys that intersect with the given box.\n\n- **x1**: The x coordinate of the left edge of the box.\n- **y1**: The y coordinate of the bottom edge of the box.\n- **x2**: The x coordinate of the right edge of the box.\n- **y2**: The y coordinate of the top edge of the box.\n- **intersectionTest**: An optional function that can be used to filter results by bbox. If provided, this function is called for each possible result with four arguments: x1, y1, x2, y2. Return true to include the result in the returned value.\n\n**returns** an array of keys.\n\n\n### `gridIndex.toArrayBuffer()`\n\nSerialize a GridIndex to an ArrayBuffer so that it can be transferred between WebWorkers efficiently.\n\n**returns** an ArrayBuffer that can later be deserialized with `new GridIndex(arrayBuffer)`.","users":{}}