Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quadbin

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quadbin - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

.github/workflows/test.yml

6

package.json
{
"name": "quadbin",
"version": "0.1.2",
"version": "0.1.3",
"description": "Utility functions for working with Quadbins",

@@ -43,3 +43,5 @@ "license": "MIT",

},
"dependencies": {}
"dependencies": {
"@mapbox/tile-cover": "^3.0.2"
}
}

@@ -75,1 +75,9 @@ # quadbin-js

Converts quadbin cell into a xyz tile.
## geometryToCells
```javascript
function geometryToCells(geometry: GeoJSONGeometry, resolution: bigint): bigint
```
Returns a list of cells covering a GeoJSON geometry at a given resolution

@@ -0,1 +1,3 @@

import {tiles} from '@mapbox/tile-cover';
const B = [

@@ -12,3 +14,3 @@ 0x5555555555555555n,

type Quadbin = bigint;
type Tile = {x: number, y: number, z: number};
type Tile = {x: number; y: number; z: number};

@@ -83,1 +85,9 @@ export function hexToBigInt(hex: string): bigint {

}
export function geometryToCells(geometry, resolution: bigint): Quadbin[] {
const zoom = Number(resolution);
return tiles(geometry, {
min_zoom: zoom,
max_zoom: zoom
}).map(([x, y, z]) => tileToCell({x, y, z}));
}
import test from 'tape';
import {tileToCell, cellToTile, cellToParent, getResolution} from '../src/index'
import {
tileToCell,
cellToTile,
cellToParent,
geometryToCells,
getResolution,
hexToBigInt
} from '../src/index';
import {tileToQuadkey} from './quadkey-utils';

@@ -41,1 +48,31 @@

});
// Zoom:26 test not agreeing with Python
import PointGeometry from './data/PointGeometry.json';
import MultiPointGeometry from './data/MultiPointGeometry.json';
import LineStringGeometry from './data/LineStringGeometry.json';
import MultiLineStringGeometry from './data/MultiLineStringGeometry.json';
import PolygonGeometry from './data/PolygonGeometry.json';
import MultiPolygonGeometry from './data/MultiPolygonGeometry.json';
const testCases = [
PointGeometry,
MultiPointGeometry,
LineStringGeometry,
PolygonGeometry,
MultiPolygonGeometry
];
test('Quadbin geometryToCells', async t => {
for (const {name, geometry, expected} of testCases) {
for (const resolution of Object.keys(expected)) {
const expectedCells = expected[resolution].map(BigInt).sort();
const cells = geometryToCells(geometry, resolution).sort();
t.deepEquals(
cells,
expectedCells,
`Correct cells generated from ${name} geometry at resolution ${resolution}`
);
}
}
t.end();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc