How to use the h3-js.polyfill 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 vasturiano / three-globe / src / layers / hexedPolygons.js View on Github external
const margin = Math.max(0, Math.min(1, +marginAccessor(d)));

        const color = colorAccessor(d);
        const opacity = colorAlpha(color);
        const material = new THREE.MeshLambertMaterial({
          color,
          transparent: opacity < 1,
          opacity,
          side: THREE.DoubleSide,
          depthWrite: true
        });

        const h3Idxs = [];

        if (geoJson.type === 'Polygon') {
          h3Idxs.push(...polyfill(geoJson.coordinates, h3Res, true));
        } else if (geoJson.type === 'MultiPolygon') {
          geoJson.coordinates
            .forEach(coords => h3Idxs.push(...polyfill(coords, h3Res, true)));
        } else {
          console.warn(`Unsupported GeoJson geometry type: ${geoJson.type}. Skipping geometry...`);
        }

        threeDigest(h3Idxs.map(h3Idx => ({ h3Idx })), obj, {
          idAccessor: d => d.h3Idx,
          createObj: ({ h3Idx }) => {
            const obj = new THREE.Mesh();
            obj.__hexCenter = h3ToGeo(h3Idx);
            obj.__hexGeoJson = h3ToGeoBoundary(h3Idx, true);

            // stitch longitudes at the anti-meridian
            const centerLng = obj.__hexCenter[1];
github vasturiano / three-globe / src / layers / hexedPolygons.js View on Github external
            .forEach(coords => h3Idxs.push(...polyfill(coords, h3Res, true)));
        } else {
github uber / geojson2h3 / src / geojson2h3.js View on Github external
    return flatten(polygons.map(polygon => h3.polyfill(polygon, resolution, true)));
}

h3-js

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

Apache-2.0
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis