How to use the h3-js.hexRing function in h3-js

To help you get started, we’ve selected a few h3-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / geojson2h3 / test / geojson2h3.spec.js View on Github external
test('h3SetToFeature - nested donut', assert => {
    const middle = '89283082877ffff';
    const hexagons = h3.hexRing(middle, 1).concat(h3.hexRing(middle, 3));
    const feature = h3SetToFeature(hexagons);
    const coords = feature.geometry.coordinates;

    assert.strictEqual(coords.length, 2, 'expected polygon count');
    assert.strictEqual(coords[0].length, 2, 'expected loop count for p1');
    assert.strictEqual(coords[1].length, 2, 'expected loop count for p2');
    assert.strictEqual(coords[0][0].length, 6 * 3 + 1, 'expected outer coord count p1');
    assert.strictEqual(coords[0][1].length, 7, 'expected inner coord count p1');
    assert.strictEqual(coords[1][0].length, 6 * 7 + 1, 'expected outer coord count p2');
    assert.strictEqual(coords[1][1].length, 6 * 5 + 1, 'expected inner coord count p2');

    assert.end();
});

h3-js

Pure-Javascript version of the H3 library, a hexagon-based geographic grid system

Apache-2.0
Latest version published 1 year ago

Package Health Score

62 / 100
Full package analysis